diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e22526cfb8..1d8afefc4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -301,7 +301,10 @@ jobs: - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} shell: bash -l {0} working-directory: ${{ matrix.example_directories }} - run: mv /home/runner/.config/azle/wasmedge-quickjs "/home/runner/.config/azle/wasmedge-quickjs_$(npx azle dockerfile-hash)" + run: | + # TODO remove the echo just for testing + echo "/home/runner/.config/azle/wasmedge-quickjs_$(npx azle dockerfile-hash)" + mv /home/runner/.config/azle/wasmedge-quickjs "/home/runner/.config/azle/wasmedge-quickjs_$(npx azle dockerfile-hash)" - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && !contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} shell: bash -l {0} working-directory: ${{ matrix.example_directories }} diff --git a/examples/ethers_base/dfx.json b/examples/ethers_base/dfx.json index 4a058f96b6..a6c340b133 100644 --- a/examples/ethers_base/dfx.json +++ b/examples/ethers_base/dfx.json @@ -1,7 +1,6 @@ { "canisters": { "server": { - "specified_id": "bd3sg-teaaa-aaaaa-qaaba-cai", "type": "custom", "main": "src/server.ts", "candid": "src/server.did", diff --git a/examples/ethers_base/src/server.did b/examples/ethers_base/src/server.did index 02c019ab7d..7bf084795e 100644 --- a/examples/ethers_base/src/server.did +++ b/examples/ethers_base/src/server.did @@ -1,4 +1,4 @@ service: () -> { - http_request: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:record {}; callback:func (record {}) -> (opt record {token:opt record {}; body:vec nat8}) query}}; status_code:nat16}) query; - http_request_update: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:record {}; callback:func (record {}) -> (opt record {token:opt record {}; body:vec nat8}) query}}; status_code:nat16}); + http_request: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:vec nat8; callback:func (vec nat8) -> (opt record {token:opt vec nat8; body:vec nat8}) query}}; status_code:nat16}) query; + http_request_update: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:vec nat8; callback:func (vec nat8) -> (opt record {token:opt vec nat8; body:vec nat8}) query}}; status_code:nat16}); } diff --git a/examples/ethers_base/test/tests.ts b/examples/ethers_base/test/tests.ts index 3ff4cf928c..d3f2e1cf82 100644 --- a/examples/ethers_base/test/tests.ts +++ b/examples/ethers_base/test/tests.ts @@ -2,7 +2,7 @@ // If 0x9Ac70EE21bE697173b74aF64399d850038697FD3 ever runs out of Base ETH or USDC, // just use a faucet like https://www.ethereum-ecosystem.com/faucets/base-sepolia to get some more -// We should be good for many thousands of tests +// We should be good for a few hundred tests import * as dns from 'node:dns'; dns.setDefaultResultOrder('ipv4first'); diff --git a/examples/http_outcall_fetch/dfx.json b/examples/http_outcall_fetch/dfx.json index aae2c0e2cf..d3d493e38b 100644 --- a/examples/http_outcall_fetch/dfx.json +++ b/examples/http_outcall_fetch/dfx.json @@ -1,7 +1,6 @@ { "canisters": { "server": { - "specified_id": "bd3sg-teaaa-aaaaa-qaaba-cai", "type": "custom", "main": "src/server.ts", "candid": "src/server.did", diff --git a/server.did b/server.did index 02c019ab7d..7bf084795e 100644 --- a/server.did +++ b/server.did @@ -1,4 +1,4 @@ service: () -> { - http_request: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:record {}; callback:func (record {}) -> (opt record {token:opt record {}; body:vec nat8}) query}}; status_code:nat16}) query; - http_request_update: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:record {}; callback:func (record {}) -> (opt record {token:opt record {}; body:vec nat8}) query}}; status_code:nat16}); + http_request: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:vec nat8; callback:func (vec nat8) -> (opt record {token:opt vec nat8; body:vec nat8}) query}}; status_code:nat16}) query; + http_request_update: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:vec nat8; callback:func (vec nat8) -> (opt record {token:opt vec nat8; body:vec nat8}) query}}; status_code:nat16}); } diff --git a/src/lib/fetch/http.ts b/src/lib/fetch/http.ts index 18a68a767e..8ad21f571b 100644 --- a/src/lib/fetch/http.ts +++ b/src/lib/fetch/http.ts @@ -2,6 +2,7 @@ import { inflate } from 'pako'; import { azleFetch, serialize } from '.'; import { ic } from '../'; +import { HttpTransform } from '../../../canisters/management'; import { AzleFetchResponse } from './response'; import { getUrl } from './url'; @@ -93,7 +94,7 @@ export async function fetchHttp( }); } -function getHttpMaxResponseBytes() { +function getHttpMaxResponseBytes(): [] | [bigint] { return globalThis._azleOutgoingHttpOptionsMaxResponseBytes === undefined ? [] : [globalThis._azleOutgoingHttpOptionsMaxResponseBytes]; @@ -127,7 +128,7 @@ function getHttpMethod(init?: RequestInit | undefined) { }; } -function getHttpTransform() { +function getHttpTransform(): [] | [HttpTransform] { if (globalThis._azleOutgoingHttpOptionsTransformMethodName === undefined) { return []; } @@ -172,9 +173,6 @@ function getCycles( const totalFeeEstimate = baseFeeEstimate + requestFeeEstimate + responseFeeEstimate; - // TODO this calculation appears to be very correct according to the documentation - // TODO but it is producing an amount ~20x more than what the system actually asks for - // TODO Hopefully this gets resolved soon: https://forum.dfinity.org/t/a-new-price-function-for-https-outcalls/20838/20 return globalThis._azleOutgoingHttpOptionsCycles ?? totalFeeEstimate; } diff --git a/src/lib/fetch/index.ts b/src/lib/fetch/index.ts index 732dd05a64..36ea2eab05 100644 --- a/src/lib/fetch/index.ts +++ b/src/lib/fetch/index.ts @@ -92,6 +92,6 @@ function logWarnings(init?: RequestInit | undefined) { function logWarning(method: string) { console.warn( - `fetchIc: init.${method} has no effect when using an identity as the Authorization header` + `azleFetch: init.${method} has no effect when using an identity as the Authorization header` ); } diff --git a/src/lib/fetch/response.ts b/src/lib/fetch/response.ts index 7192971066..af433e947f 100644 --- a/src/lib/fetch/response.ts +++ b/src/lib/fetch/response.ts @@ -22,14 +22,16 @@ export class AzleFetchResponse { this.status = init?.status ?? 200; this.statusText = getStatusText(this.status); this.ok = this.status >= 200 && this.status <= 299; - this.type = 'default'; // TODO determine this - this.redirected = false; //TODO determine this - this.bodyUsed = false; // TODO determine this + this.type = '' as any; // TODO we should work to set this appropriately + this.redirected = false; // TODO we are defaulting to false, I believe we would have to implement automatic redirects for this to ever be true + this.bodyUsed = false; this.headers = new AzleFetchHeaders(init?.headers); - this.url = ''; // TODO where are we supposed to get this from? + this.url = ''; // TODO I do not understand how this is supposed to be set, as it is a readon-only property and the Respone constructor does not allow you to pass in the URL } async arrayBuffer(): Promise { + this.bodyUsed = true; + if (this.body === null) { return new ArrayBuffer(0); } @@ -38,8 +40,10 @@ export class AzleFetchResponse { } async json(): Promise { + this.bodyUsed = true; + if (this.body === null) { - return ''; // TODO is this correct? + return JSON.parse(''); } return JSON.parse( @@ -48,6 +52,8 @@ export class AzleFetchResponse { } async text(): Promise { + this.bodyUsed = true; + if (this.body === null) { return ''; } diff --git a/src/lib/globals.ts b/src/lib/globals.ts index f8eb6dcc10..846785509c 100644 --- a/src/lib/globals.ts +++ b/src/lib/globals.ts @@ -55,21 +55,9 @@ if (globalThis._azleInsideCanister) { handler: TimerHandler, timeout?: number ) => { - // if (timeout === undefined || timeout === 0) { - // return originalSetTimeout(handler, 0); - // } - - // console.warn - - // throw new Error() - - // TODO change this to throw once errors throw and show up properly - // TODO should this throw an error or just not do anything? At least a warning would be good right? - // ic.trap(`setTimeout cannot be called with milliseconds above 0`); - if (timeout !== undefined && timeout !== 0) { console.warn( - `Azle Warning: setTimeout should not be called with milliseconds above 0, called with ${timeout} milliseconds`, + `Azle Warning: setTimeout may not behave as expected with milliseconds above 0; called with ${timeout} milliseconds`, new Error().stack ); } diff --git a/src/lib/threshold_wallet/calculate_rsv_for_tecdsa.ts b/src/lib/threshold_wallet/calculate_rsv_for_tecdsa.ts index e74d80e4a4..5c51edc222 100644 --- a/src/lib/threshold_wallet/calculate_rsv_for_tecdsa.ts +++ b/src/lib/threshold_wallet/calculate_rsv_for_tecdsa.ts @@ -39,5 +39,5 @@ export function calculateRsvForTEcdsa( return rsv1; } - throw new Error(`v could not be calculated correctly`); + throw new Error(`ThresholdWallet: v could not be calculated correctly`); }