From b32ac5dfff0114346f239d388b50c900b6e97ad4 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 6 Sep 2023 16:07:44 -0600 Subject: [PATCH 01/23] Update canister syntax --- examples/ic_api/src/ic_api.ts | 303 ++++++++++++++++++---------------- 1 file changed, 158 insertions(+), 145 deletions(-) diff --git a/examples/ic_api/src/ic_api.ts b/examples/ic_api/src/ic_api.ts index 1de9bc6db8..84870c9f06 100644 --- a/examples/ic_api/src/ic_api.ts +++ b/examples/ic_api/src/ic_api.ts @@ -3,162 +3,175 @@ import { empty, ic, int8, - Manual, nat, nat32, nat64, Opt, Principal, - $query, - $update + query, + update, + Service, + bool, + text, + principal, + Void } from 'azle'; +// TODO: Actually implement manual. See https://github.com/demergent-labs/azle/issues/1200 +type Manual = Void; + +function manual( + _target: Service, + _name: string, + descriptor: PropertyDescriptor +): any { + return descriptor; +} + // TODO: See https://github.com/demergent-labs/azle/issues/496 // type ArgDataMultipleParamsResult = { // blob: blob; // int: int8; -// boolean: boolean; -// string: string; +// boolean: bool; +// string: text; // }; -// // returns the argument data as an array. -// export function argDataZeroParams(): Vec { -// return ic.argData(); -// } -// -// // returns the argument data as an array. -// export function argDataOneParam(arg: boolean): boolean { -// const argData = ic.argData(); -// return argData[0]; -// } -// -// // returns the argument data as an array. -// export function argDataMultipleParams( -// arg1: blob, -// arg2: int8, -// arg3: boolean, -// arg4: string -// ): ArgDataMultipleParamsResult { -// const argData = ic.argData(); -// return { -// blob: Uint8Array.from(argData[0]), -// int: argData[1], -// boolean: argData[2], -// string: argData[3] -// }; -// } - -// returns the argument data as bytes. -$query; -export function argDataRaw( - arg1: blob, - arg2: int8, - arg3: boolean, - arg4: string -): blob { - return ic.argDataRaw(); -} - -// returns the length of the argument data in bytes -$query; -export function argDataRawSize( - arg1: blob, - arg2: int8, - arg3: boolean, - arg4: string -): nat32 { - return ic.argDataRawSize(); -} - -// returns the principal of the identity that called this function -$query; -export function caller(): Principal { - return ic.caller(); -} - -// returns the amount of cycles available in the canister -$query; -export function canisterBalance(): nat64 { - return ic.canisterBalance(); -} - -// returns the amount of cycles available in the canister -$query; -export function canisterBalance128(): nat { - return ic.canisterBalance128(); -} - -// returns the canister's version number -$query; -export function canisterVersion(): nat64 { - return ic.canisterVersion(); -} - -// When called from a query call, returns the data certificate authenticating certified data set by this canister. Returns None if not called from a query call. -$query; -export function dataCertificate(): Opt { - return ic.dataCertificate(); -} - -// When called from a query call, returns the data certificate authenticating certified data set by this canister. Returns None if called not from a query call. -$update; -export function dataCertificateNull(): Opt { - return ic.dataCertificate(); -} - -// returns this canister's id -$query; -export function id(): Principal { - return ic.id(); -} - -// Returns the number of instructions that the canister executed since the last -// entry point. -$query; -export function instructionCounter(): nat64 { - return ic.instructionCounter(); -} - -// determines whether the given principal is a controller of the canister -$query; -export function isController(principal: Principal): boolean { - return ic.isController(principal); -} - -$query; -export function performanceCounter(): nat64 { - return ic.performanceCounter(0); -} - -// prints a message through the local replica's output -$query; -export function print(message: string): boolean { - ic.print(message); - - return true; -} - -$query; -export function reject(message: string): Manual { - ic.reject(message); -} - -// sets up to 32 bytes of certified data -$update; -export function setCertifiedData(data: blob): void { - ic.setCertifiedData(data); -} - -// returns the current timestamp -$query; -export function time(): nat64 { - return ic.time(); -} - -// traps with a message, stopping execution and discarding all state within the call -$query; -export function trap(message: string): boolean { - ic.trap(message); - - return true; +export default class extends Service { + // // returns the argument data as an array. + // argDataZeroParams(): Vec { + // return ic.argData(); + // } + // + // // returns the argument data as an array. + // argDataOneParam(arg: bool): bool { + // const argData = ic.argData(); + // return argData[0]; + // } + // + // // returns the argument data as an array. + // argDataMultipleParams( + // arg1: blob, + // arg2: int8, + // arg3: bool, + // arg4: text + // ): ArgDataMultipleParamsResult { + // const argData = ic.argData(); + // return { + // blob: Uint8Array.from(argData[0]), + // int: argData[1], + // boolean: argData[2], + // string: argData[3] + // }; + // } + + // returns the argument data as bytes. + @query([blob, int8, bool, text], blob) + argDataRaw(arg1: blob, arg2: int8, arg3: bool, arg4: text): blob { + return ic.argDataRaw(); + } + + // returns the length of the argument data in bytes + @query([blob, int8, bool, text], nat32) + argDataRawSize(arg1: blob, arg2: int8, arg3: bool, arg4: text): nat32 { + return ic.argDataRawSize(); + } + + // returns the principal of the identity that called this function + @query([], principal) + caller(): Principal { + return ic.caller(); + } + + // returns the amount of cycles available in the canister + @query([], nat64) + canisterBalance(): nat64 { + return ic.canisterBalance(); + } + + // returns the amount of cycles available in the canister + @query([], nat) + canisterBalance128(): nat { + return ic.canisterBalance128(); + } + + // returns the canister's version number + @query([], nat64) + canisterVersion(): nat64 { + return ic.canisterVersion(); + } + + // // When called from a query call, returns the data certificate + // // authenticating certified data set by this canister. Returns None if not + // // called from a query call. + // @query([], Opt(blob)) + // dataCertificate(): Opt { + // return ic.dataCertificate(); + // } + + // // When called from a query call, returns the data certificate + // // authenticating certified data set by this canister. Returns None if + // // called not from a query call. + // @update([], Opt(blob)) + // dataCertificateNull(): Opt { + // return ic.dataCertificate(); + // } + + // returns this canister's id + @query([], principal) + id(): Principal { + return ic.id(); + } + + // Returns the number of instructions that the canister executed since the last + // entry point. + @query([], nat64) + instructionCounter(): nat64 { + return ic.instructionCounter(); + } + + // determines whether the given principal is a controller of the canister + @query([principal], bool) + isController(principal: Principal): bool { + return ic.isController(principal); + } + + @query([], nat64) + performanceCounter(): nat64 { + return ic.performanceCounter(0); + } + + // prints a message through the local replica's output + @query([text], bool) + print(message: text): bool { + ic.print(message); + + return true; + } + + // TODO: See https://github.com/demergent-labs/azle/issues/1200 + @manual + @query([text], empty) + reject(message: text): Manual { + ic.reject(message); + } + + // sets up to 32 bytes of certified data + @update([blob], Void) + setCertifiedData(data: blob): Void { + ic.setCertifiedData(data); + } + + // returns the current timestamp + @query([], nat64) + time(): nat64 { + return ic.time(); + } + + // traps with a message, stopping execution and discarding all state within the call + @query([], bool) + trap(message: text): bool { + ic.trap(message); + + return true; + } } From 153232dfe23612b5cf22ee0450f3f9fb83eb335b Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 6 Sep 2023 16:09:48 -0600 Subject: [PATCH 02/23] Rename entrypoint --- examples/ic_api/dfx.json | 4 ++-- examples/ic_api/src/{ic_api.did => index.did} | 0 examples/ic_api/src/{ic_api.ts => index.ts} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename examples/ic_api/src/{ic_api.did => index.did} (100%) rename examples/ic_api/src/{ic_api.ts => index.ts} (100%) diff --git a/examples/ic_api/dfx.json b/examples/ic_api/dfx.json index 3488571e32..b881b1966c 100644 --- a/examples/ic_api/dfx.json +++ b/examples/ic_api/dfx.json @@ -4,8 +4,8 @@ "type": "custom", "build": "npx azle ic_api", "root": "src", - "ts": "src/ic_api.ts", - "candid": "src/ic_api.did", + "ts": "src/index.ts", + "candid": "src/index.did", "wasm": ".azle/ic_api/ic_api.wasm.gz", "declarations": { "output": "test/dfx_generated/ic_api", diff --git a/examples/ic_api/src/ic_api.did b/examples/ic_api/src/index.did similarity index 100% rename from examples/ic_api/src/ic_api.did rename to examples/ic_api/src/index.did diff --git a/examples/ic_api/src/ic_api.ts b/examples/ic_api/src/index.ts similarity index 100% rename from examples/ic_api/src/ic_api.ts rename to examples/ic_api/src/index.ts From 50caa70b749476a1b1e171a895cccd514ad86946 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 6 Sep 2023 16:09:54 -0600 Subject: [PATCH 03/23] Update dependencies --- examples/ic_api/package-lock.json | 1038 +++-------------------------- examples/ic_api/package.json | 6 +- 2 files changed, 90 insertions(+), 954 deletions(-) diff --git a/examples/ic_api/package-lock.json b/examples/ic_api/package-lock.json index b1d6f133c3..7f5f80bff9 100644 --- a/examples/ic_api/package-lock.json +++ b/examples/ic_api/package-lock.json @@ -1,6 +1,6 @@ { "name": "ic_api", - "lockfileVersion": 2, + "lockfileVersion": 3, "requires": true, "packages": { "": { @@ -8,9 +8,9 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.14.1", - "ts-node": "10.7.0", - "typescript": "4.6.3" + "@dfinity/agent": "^0.19.2", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" } }, "node_modules/@cspotcode/source-map-consumer": { @@ -22,35 +22,6 @@ } }, "node_modules/@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", - "dependencies": { - "@cspotcode/source-map-consumer": "0.8.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@dfinity/agent": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.14.1.tgz", - "integrity": "sha512-qLAQrhkxshcsxECnMSa1zY7mI8ua0vItrdA9JJI9WBRz4rDDXtrXyOYnh3u6pUPpdfF/i6bjx+NgrjYZucLe1Q==", - "dev": true, - "dependencies": { - "base64-arraybuffer": "^0.2.0", - "bignumber.js": "^9.0.0", - "borc": "^2.1.1", - "js-sha256": "0.9.0", - "simple-cbor": "^0.4.1", - "ts-node": "^10.8.2" - }, - "peerDependencies": { - "@dfinity/candid": "^0.14.1", - "@dfinity/principal": "^0.14.1" - } - }, - "node_modules/@dfinity/agent/node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", @@ -62,197 +33,55 @@ "node": ">=12" } }, - "node_modules/@dfinity/agent/node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "node_modules/@dfinity/agent": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.19.2.tgz", + "integrity": "sha512-KLRWEjeU9SyyaS7IBVJ9ZUcufxufr55e/kRIyClK157+0pkTG9a8xKjUIMx3QzKvLsqqzXL238nWwdoP6jAD8g==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" + "@noble/hashes": "^1.3.1", + "base64-arraybuffer": "^0.2.0", + "borc": "^2.1.1", + "simple-cbor": "^0.4.1" }, "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } + "@dfinity/candid": "^0.19.2", + "@dfinity/principal": "^0.19.2" } }, "node_modules/@dfinity/candid": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.14.1.tgz", - "integrity": "sha512-yRIRnVrJ4LjB0jFKUqZ2NeUzCCR6m8pm/n+0+IoVzY94ZkFATUkBSvdNxDZd1CCtNDNApi+YDe61DSQ51cDkrg==", - "dev": true, - "peer": true, - "dependencies": { - "ts-node": "^10.8.2" - } - }, - "node_modules/@dfinity/candid/node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@dfinity/candid/node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.19.2.tgz", + "integrity": "sha512-X2hCqNMhnnmwtnOc0WnymOZYx3qphjEMuSYbBr7tMIkV7Hwt9BmXXlLnQTxUytTPxf+3he0GcS3KzsSQ9CK8ew==", "dev": true, "peer": true, - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } + "@dfinity/principal": "^0.19.2" } }, "node_modules/@dfinity/principal": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.14.1.tgz", - "integrity": "sha512-a5TDU0iWLeuNjI+L1Ukx5nRhQHMCN2GRQkQg1Z0AzP3dX7FkBOiaLwMCLhCRUk/sK/SeR6/hCA0YKiwRqzjhqA==", - "dev": true, - "peer": true, - "dependencies": { - "js-sha256": "^0.9.0", - "ts-node": "^10.8.2" - } - }, - "node_modules/@dfinity/principal/node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@dfinity/principal/node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.19.2.tgz", + "integrity": "sha512-vsKN6BKya70bQUsjgKRDlR2lOpv/XpUkCMIiji6rjMtKHIuWEB5Eu3JqZsOuBmWo3A3TT/K/osT9VPm0k4qdYQ==", "dev": true, "peer": true, "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } + "@noble/hashes": "^1.3.1" } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", "dev": true, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, "node_modules/@jridgewell/trace-mapping": { @@ -265,6 +94,18 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "dev": true, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@swc/core": { "version": "1.2.151", "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.151.tgz", @@ -491,35 +332,35 @@ } }, "node_modules/@tsconfig/node10": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", - "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==" + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" }, "node_modules/@tsconfig/node12": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", - "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==" + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" }, "node_modules/@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" }, "node_modules/@tsconfig/node16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", - "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" }, "node_modules/@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "peer": true }, "node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "bin": { "acorn": "bin/acorn" }, @@ -563,6 +404,17 @@ "resolved": "https://registry.npmjs.org/azle-syn/-/azle-syn-0.0.0.tgz", "integrity": "sha512-fWExJb5/hOEJOuBQ8hMMHRs9WryYeLLa9/ydqPWxbwjMEpE8RKdU1dTK6mdZtzNMhbeHdyne2pU1iVKiKmImGw==" }, + "node_modules/azle/node_modules/@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "dependencies": { + "@cspotcode/source-map-consumer": "0.8.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/azle/node_modules/@dfinity/principal": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", @@ -650,9 +502,9 @@ ] }, "node_modules/bignumber.js": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz", - "integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", "dev": true, "engines": { "node": "*" @@ -1073,9 +925,9 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, "node_modules/ieee754": { "version": "1.2.1", @@ -1143,9 +995,9 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, "node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dev": true, "dependencies": { "inherits": "^2.0.3", @@ -1192,12 +1044,12 @@ } }, "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -1208,7 +1060,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "bin": { @@ -1235,16 +1087,16 @@ } }, "node_modules/typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/universalify": { @@ -1275,721 +1127,5 @@ "node": ">=6" } } - }, - "dependencies": { - "@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" - }, - "@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", - "requires": { - "@cspotcode/source-map-consumer": "0.8.0" - } - }, - "@dfinity/agent": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.14.1.tgz", - "integrity": "sha512-qLAQrhkxshcsxECnMSa1zY7mI8ua0vItrdA9JJI9WBRz4rDDXtrXyOYnh3u6pUPpdfF/i6bjx+NgrjYZucLe1Q==", - "dev": true, - "requires": { - "base64-arraybuffer": "^0.2.0", - "bignumber.js": "^9.0.0", - "borc": "^2.1.1", - "js-sha256": "0.9.0", - "simple-cbor": "^0.4.1", - "ts-node": "^10.8.2" - }, - "dependencies": { - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - } - } - }, - "@dfinity/candid": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.14.1.tgz", - "integrity": "sha512-yRIRnVrJ4LjB0jFKUqZ2NeUzCCR6m8pm/n+0+IoVzY94ZkFATUkBSvdNxDZd1CCtNDNApi+YDe61DSQ51cDkrg==", - "dev": true, - "peer": true, - "requires": { - "ts-node": "^10.8.2" - }, - "dependencies": { - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, - "peer": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - } - } - }, - "@dfinity/principal": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.14.1.tgz", - "integrity": "sha512-a5TDU0iWLeuNjI+L1Ukx5nRhQHMCN2GRQkQg1Z0AzP3dX7FkBOiaLwMCLhCRUk/sK/SeR6/hCA0YKiwRqzjhqA==", - "dev": true, - "peer": true, - "requires": { - "js-sha256": "^0.9.0", - "ts-node": "^10.8.2" - }, - "dependencies": { - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, - "peer": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - } - } - }, - "@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true - }, - "@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, - "@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "@swc/core": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.151.tgz", - "integrity": "sha512-oHgqKwK/Djv765zUHPiGqfMCaKIxXTgQyyCUBKLBQfAJwe/7FVobQ2fghBp4FsZA/NE1LZBmMPpRZNQwlGjeHw==", - "requires": { - "@swc/core-android-arm-eabi": "1.2.151", - "@swc/core-android-arm64": "1.2.151", - "@swc/core-darwin-arm64": "1.2.151", - "@swc/core-darwin-x64": "1.2.151", - "@swc/core-freebsd-x64": "1.2.151", - "@swc/core-linux-arm-gnueabihf": "1.2.151", - "@swc/core-linux-arm64-gnu": "1.2.151", - "@swc/core-linux-arm64-musl": "1.2.151", - "@swc/core-linux-x64-gnu": "1.2.151", - "@swc/core-linux-x64-musl": "1.2.151", - "@swc/core-win32-arm64-msvc": "1.2.151", - "@swc/core-win32-ia32-msvc": "1.2.151", - "@swc/core-win32-x64-msvc": "1.2.151" - } - }, - "@swc/core-android-arm-eabi": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.151.tgz", - "integrity": "sha512-Suk3IcHdha33K4hq9tfBCwkXJsENh7kjXCseLqL8Yvy8QobqkXjf1fcoJxX9BdCmPwsKmIw0ZgCBYR+Hl83M2w==", - "optional": true - }, - "@swc/core-android-arm64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.151.tgz", - "integrity": "sha512-HZVy69dVWT5RgrMJMRK5aiicPmhzkyCHAexApYAHYLgAIhsxL7uoAIPmuRKRkrKNJjrwsWL7H27bBH5bddRDvg==", - "optional": true - }, - "@swc/core-darwin-arm64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.151.tgz", - "integrity": "sha512-Ql7rXMu+IC76TemRtkt+opl5iSpX2ApAXVSfvf6afNVTrfTKLpDwiR3ySRRlG0FnNIv6TfOCJpHf655xp01S/g==", - "optional": true - }, - "@swc/core-darwin-x64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.151.tgz", - "integrity": "sha512-N1OBIB7xatR5eybLo91ZhvMJMxT0zxRQURV/a9I8o5CyP4iLd1k8gmrYvBbtj08ohS8F9z7k/dFjxk/9ve5Drw==", - "optional": true - }, - "@swc/core-freebsd-x64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.151.tgz", - "integrity": "sha512-WVIRiDzuz+/W7BMjVtg1Cmk1+zmDT18Qq+Ygr9J6aFQ1JQUkLEE1pvtkGD3JIEa6Jhz/VwM6AFHtY5o1CrZ21w==", - "optional": true - }, - "@swc/core-linux-arm-gnueabihf": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.151.tgz", - "integrity": "sha512-pfBrIUwu3cR/M7DzDCUJAw9jFKXvJ/Ge8auFk07lRb+JcDnPm0XxLyrLqGvNQWdcHgXeXfmnS4fMQxdb9GUN1w==", - "optional": true - }, - "@swc/core-linux-arm64-gnu": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.151.tgz", - "integrity": "sha512-M+BTkTdPY7gteM+0dYz9wrU/j9taL4ccqPEHkDEKP21lS24y99UtuKsvdBLzDm/6ShBVLFAkgIBPu5cEb7y6ig==", - "optional": true - }, - "@swc/core-linux-arm64-musl": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.151.tgz", - "integrity": "sha512-7A+yTtSvPJVwO8X1cxUbD/PVCx8G9MKn83G9pH/r+9sQMBXqxyw6/NR0DG6nMMiyOmJkmYWgh5mO47BN7WC4dQ==", - "optional": true - }, - "@swc/core-linux-x64-gnu": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.151.tgz", - "integrity": "sha512-ORlbN3wf1w0IQGjGToYYC/hV/Vwfcs88Ohfxc4X+IQaw/VxKG6/XT65c0btK640F2TVhvhH1MbYFJJlsycsW7g==", - "optional": true - }, - "@swc/core-linux-x64-musl": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.151.tgz", - "integrity": "sha512-r6odKE3+9+ReVdnNTZnICt5tscyFFtP4GFcmPQzBSlVoD9LZX6O4WeOlFXn77rVK/+205n2ag/KkKgZH+vdPuQ==", - "optional": true - }, - "@swc/core-win32-arm64-msvc": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.151.tgz", - "integrity": "sha512-jnjJTNHpLhBaPwRgiKv1TdrMljL88ePqMCdVMantyd7yl4lP0D2e5/xR9ysR9S4EGcUnOyo9w8WUYhx/TioMZw==", - "optional": true - }, - "@swc/core-win32-ia32-msvc": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.151.tgz", - "integrity": "sha512-hSCxAiyDDXKvdUExj4jSIhzWFePqoqak1qdNUjlhEhEinDG8T8PTRCLalyW6fqZDcLf6Tqde7H79AqbfhRlYGQ==", - "optional": true - }, - "@swc/core-win32-x64-msvc": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.151.tgz", - "integrity": "sha512-HOkqcJWCChps83Maj0M5kifPDuZ2sGPqpLM67poawspTFkBh0QJ9TMmxW1doQw+74cqsTpRi1ewr/KhsN18i5g==", - "optional": true - }, - "@tsconfig/node10": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", - "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==" - }, - "@tsconfig/node12": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", - "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==" - }, - "@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" - }, - "@tsconfig/node16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", - "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" - }, - "@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", - "peer": true - }, - "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==" - }, - "acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" - }, - "arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" - }, - "azle": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/azle/-/azle-0.17.1.tgz", - "integrity": "sha512-wU0gzPMCDzvvurdZQ5NUaHlW9RvR0CVLyiTSxt+e61kA8aq5W/0k8KyzPIvOYdk7+WVZLCzs++yahlnmkHcaOg==", - "requires": { - "@dfinity/principal": "0.11.2", - "@swc/core": "1.2.151", - "azle-syn": "0.0.0", - "esbuild": "0.14.25", - "fs-extra": "10.0.1", - "js-sha256": "0.9.0", - "ts-node": "10.3.1", - "typescript": "4.4.4" - }, - "dependencies": { - "@dfinity/principal": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", - "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" - }, - "ts-node": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", - "integrity": "sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==", - "requires": { - "@cspotcode/source-map-support": "0.7.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "yn": "3.1.1" - } - }, - "typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==" - } - } - }, - "azle-syn": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/azle-syn/-/azle-syn-0.0.0.tgz", - "integrity": "sha512-fWExJb5/hOEJOuBQ8hMMHRs9WryYeLLa9/ydqPWxbwjMEpE8RKdU1dTK6mdZtzNMhbeHdyne2pU1iVKiKmImGw==" - }, - "base64-arraybuffer": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.2.0.tgz", - "integrity": "sha512-7emyCsu1/xiBXgQZrscw/8KPRT44I4Yq9Pe6EGs3aPRTsWuggML1/1DTuZUuIaJPIm1FTDUVXl4x/yW8s0kQDQ==", - "dev": true - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true - }, - "bignumber.js": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz", - "integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==", - "dev": true - }, - "borc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/borc/-/borc-2.1.2.tgz", - "integrity": "sha512-Sy9eoUi4OiKzq7VovMn246iTo17kzuyHJKomCfpWMlI6RpfN1gk95w7d7gH264nApVLg0HZfcpz62/g4VH1Y4w==", - "dev": true, - "requires": { - "bignumber.js": "^9.0.0", - "buffer": "^5.5.0", - "commander": "^2.15.0", - "ieee754": "^1.1.13", - "iso-url": "~0.4.7", - "json-text-sequence": "~0.1.0", - "readable-stream": "^3.6.0" - } - }, - "buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" - }, - "delimit-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", - "integrity": "sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ==", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" - }, - "esbuild": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.25.tgz", - "integrity": "sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==", - "requires": { - "esbuild-android-64": "0.14.25", - "esbuild-android-arm64": "0.14.25", - "esbuild-darwin-64": "0.14.25", - "esbuild-darwin-arm64": "0.14.25", - "esbuild-freebsd-64": "0.14.25", - "esbuild-freebsd-arm64": "0.14.25", - "esbuild-linux-32": "0.14.25", - "esbuild-linux-64": "0.14.25", - "esbuild-linux-arm": "0.14.25", - "esbuild-linux-arm64": "0.14.25", - "esbuild-linux-mips64le": "0.14.25", - "esbuild-linux-ppc64le": "0.14.25", - "esbuild-linux-riscv64": "0.14.25", - "esbuild-linux-s390x": "0.14.25", - "esbuild-netbsd-64": "0.14.25", - "esbuild-openbsd-64": "0.14.25", - "esbuild-sunos-64": "0.14.25", - "esbuild-windows-32": "0.14.25", - "esbuild-windows-64": "0.14.25", - "esbuild-windows-arm64": "0.14.25" - } - }, - "esbuild-android-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.25.tgz", - "integrity": "sha512-L5vCUk7TzFbBnoESNoXjU3x9+/+7TDIE/1mTfy/erAfvZAqC+S3sp/Qa9wkypFMcFvN9FzvESkTlpeQDolREtQ==", - "optional": true - }, - "esbuild-android-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.25.tgz", - "integrity": "sha512-4jv5xPjM/qNm27T5j3ZEck0PvjgQtoMHnz4FzwF5zNP56PvY2CT0WStcAIl6jNlsuDdN63rk2HRBIsO6xFbcFw==", - "optional": true - }, - "esbuild-darwin-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.25.tgz", - "integrity": "sha512-TGp8tuudIxOyWd1+8aYPxQmC1ZQyvij/AfNBa35RubixD0zJ1vkKHVAzo0Zao1zcG6pNqiSyzfPto8vmg0s7oA==", - "optional": true - }, - "esbuild-darwin-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.25.tgz", - "integrity": "sha512-oTcDgdm0MDVEmw2DWu8BV68pYuImpFgvWREPErBZmNA4MYKGuBRaCiJqq6jZmBR1x+3y1DWCjez+5uLtuAm6mw==", - "optional": true - }, - "esbuild-freebsd-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.25.tgz", - "integrity": "sha512-ueAqbnMZ8arnuLH8tHwTCQYeptnHOUV7vA6px6j4zjjQwDx7TdP7kACPf3TLZLdJQ3CAD1XCvQ2sPhX+8tacvQ==", - "optional": true - }, - "esbuild-freebsd-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.25.tgz", - "integrity": "sha512-+ZVWud2HKh+Ob6k/qiJWjBtUg4KmJGGmbvEXXW1SNKS7hW7HU+Zq2ZCcE1akFxOPkVB+EhOty/sSek30tkCYug==", - "optional": true - }, - "esbuild-linux-32": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.25.tgz", - "integrity": "sha512-3OP/lwV3kCzEz45tobH9nj+uE4ubhGsfx+tn0L26WAGtUbmmcRpqy7XRG/qK7h1mClZ+eguIANcQntYMdYklfw==", - "optional": true - }, - "esbuild-linux-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.25.tgz", - "integrity": "sha512-+aKHdHZmX9qwVlQmu5xYXh7GsBFf4TWrePgeJTalhXHOG7NNuUwoHmketGiZEoNsWyyqwH9rE5BC+iwcLY30Ug==", - "optional": true - }, - "esbuild-linux-arm": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.25.tgz", - "integrity": "sha512-aTLcE2VBoLydL943REcAcgnDi3bHtmULSXWLbjtBdtykRatJVSxKMjK9YlBXUZC4/YcNQfH7AxwVeQr9fNxPhw==", - "optional": true - }, - "esbuild-linux-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.25.tgz", - "integrity": "sha512-UxfenPx/wSZx55gScCImPtXekvZQLI2GW3qe5dtlmU7luiqhp5GWPzGeQEbD3yN3xg/pHc671m5bma5Ns7lBHw==", - "optional": true - }, - "esbuild-linux-mips64le": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.25.tgz", - "integrity": "sha512-wLWYyqVfYx9Ur6eU5RT92yJVsaBGi5RdkoWqRHOqcJ38Kn60QMlcghsKeWfe9jcYut8LangYZ98xO1LxIoSXrQ==", - "optional": true - }, - "esbuild-linux-ppc64le": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.25.tgz", - "integrity": "sha512-0dR6Csl6Zas3g4p9ULckEl8Mo8IInJh33VCJ3eaV1hj9+MHGdmDOakYMN8MZP9/5nl+NU/0ygpd14cWgy8uqRw==", - "optional": true - }, - "esbuild-linux-riscv64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.25.tgz", - "integrity": "sha512-J4d20HDmTrgvhR0bdkDhvvJGaikH3LzXQnNaseo8rcw9Yqby9A90gKUmWpfwqLVNRILvNnAmKLfBjCKU9ajg8w==", - "optional": true - }, - "esbuild-linux-s390x": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.25.tgz", - "integrity": "sha512-YI2d5V6nTE73ZnhEKQD7MtsPs1EtUZJ3obS21oxQxGbbRw1G+PtJKjNyur+3t6nzHP9oTg6GHQ3S3hOLLmbDIQ==", - "optional": true - }, - "esbuild-netbsd-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.25.tgz", - "integrity": "sha512-TKIVgNWLUOkr+Exrye70XTEE1lJjdQXdM4tAXRzfHE9iBA7LXWcNtVIuSnphTqpanPzTDFarF0yqq4kpbC6miA==", - "optional": true - }, - "esbuild-openbsd-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.25.tgz", - "integrity": "sha512-QgFJ37A15D7NIXBTYEqz29+uw3nNBOIyog+3kFidANn6kjw0GHZ0lEYQn+cwjyzu94WobR+fes7cTl/ZYlHb1A==", - "optional": true - }, - "esbuild-sunos-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.25.tgz", - "integrity": "sha512-rmWfjUItYIVlqr5EnTH1+GCxXiBOC42WBZ3w++qh7n2cS9Xo0lO5pGSG2N+huOU2fX5L+6YUuJ78/vOYvefeFw==", - "optional": true - }, - "esbuild-windows-32": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.25.tgz", - "integrity": "sha512-HGAxVUofl3iUIz9W10Y9XKtD0bNsK9fBXv1D55N/ljNvkrAYcGB8YCm0v7DjlwtyS6ws3dkdQyXadbxkbzaKOA==", - "optional": true - }, - "esbuild-windows-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.25.tgz", - "integrity": "sha512-TirEohRkfWU9hXLgoDxzhMQD1g8I2mOqvdQF2RS9E/wbkORTAqJHyh7wqGRCQAwNzdNXdg3JAyhQ9/177AadWA==", - "optional": true - }, - "esbuild-windows-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.25.tgz", - "integrity": "sha512-4ype9ERiI45rSh+R8qUoBtaj6kJvUOI7oVLhKqPEpcF4Pa5PpT3hm/mXAyotJHREkHpM87PAJcA442mLnbtlNA==", - "optional": true - }, - "fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" - }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "iso-url": { - "version": "0.4.7", - "resolved": "https://registry.npmjs.org/iso-url/-/iso-url-0.4.7.tgz", - "integrity": "sha512-27fFRDnPAMnHGLq36bWTpKET+eiXct3ENlCcdcMdk+mjXrb2kw3mhBUg1B7ewAC0kVzlOPhADzQgz1SE6Tglog==", - "dev": true - }, - "js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, - "json-text-sequence": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz", - "integrity": "sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w==", - "dev": true, - "requires": { - "delimit-stream": "0.1.0" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - }, - "simple-cbor": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/simple-cbor/-/simple-cbor-0.4.1.tgz", - "integrity": "sha512-rijcxtwx2b4Bje3sqeIqw5EeW7UlOIC4YfOdwqIKacpvRQ/D78bWg/4/0m5e0U91oKvlGh7LlJuZCu07ISCC7w==", - "dev": true - }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - } - }, - "ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", - "dev": true, - "requires": { - "@cspotcode/source-map-support": "0.7.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", - "yn": "3.1.1" - } - }, - "typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", - "dev": true - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true - }, - "v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true - }, - "yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" - } } } diff --git a/examples/ic_api/package.json b/examples/ic_api/package.json index 1891ce1c82..6bc660e4c9 100644 --- a/examples/ic_api/package.json +++ b/examples/ic_api/package.json @@ -7,8 +7,8 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.14.1", - "ts-node": "10.7.0", - "typescript": "4.6.3" + "@dfinity/agent": "^0.19.2", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" } } From 53e0d535440cc4ea05d0298b19833b67224e8446 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 6 Sep 2023 21:36:54 -0600 Subject: [PATCH 04/23] Fix argDataRaw --- src/lib_new/ic.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index baf75c0e17..35d2745143 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -393,6 +393,9 @@ type ReturnTypeOfPromise = T extends (...args: any[]) => infer R export const ic: Ic = globalThis._azleIc ? { ...globalThis._azleIc, + argDataRaw: () => { + return new Uint8Array(globalThis._azleIc.argDataRaw()); + }, call: (method, config) => { return method( '_AZLE_CROSS_CANISTER_CALL', From c4ca45a92bc2d1be2b6e616931cdebba8d5e7ab9 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 6 Sep 2023 21:37:38 -0600 Subject: [PATCH 05/23] Add data_certificate API --- examples/ic_api/src/index.ts | 28 +++++++++---------- .../src/ic/data_certificate.rs | 22 +++++++++++++++ .../src/ic/mod.rs | 4 +++ src/lib_new/ic.ts | 18 +++++++++++- 4 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/data_certificate.rs diff --git a/examples/ic_api/src/index.ts b/examples/ic_api/src/index.ts index 84870c9f06..ae45fae658 100644 --- a/examples/ic_api/src/index.ts +++ b/examples/ic_api/src/index.ts @@ -100,21 +100,21 @@ export default class extends Service { return ic.canisterVersion(); } - // // When called from a query call, returns the data certificate - // // authenticating certified data set by this canister. Returns None if not - // // called from a query call. - // @query([], Opt(blob)) - // dataCertificate(): Opt { - // return ic.dataCertificate(); - // } + // When called from a query call, returns the data certificate + // authenticating certified data set by this canister. Otherwise returns + // None. + @query([], Opt(blob)) + dataCertificate(): Opt { + return ic.dataCertificate(); + } - // // When called from a query call, returns the data certificate - // // authenticating certified data set by this canister. Returns None if - // // called not from a query call. - // @update([], Opt(blob)) - // dataCertificateNull(): Opt { - // return ic.dataCertificate(); - // } + // When called from a query call, returns the data certificate + // authenticating certified data set by this canister. Otherwise returns + // None. + @update([], Opt(blob)) + dataCertificateNull(): Opt { + return ic.dataCertificate(); + } // returns this canister's id @query([], principal) diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/data_certificate.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/data_certificate.rs new file mode 100644 index 0000000000..323b9c1809 --- /dev/null +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/data_certificate.rs @@ -0,0 +1,22 @@ +use proc_macro2::TokenStream; +use quote::quote; + +pub fn generate() -> TokenStream { + quote! { + fn data_certificate<'a>( + context: &'a JSContextRef, + _this: &CallbackArg, + _args: &[CallbackArg], + ) -> Result, anyhow::Error> { + match ic_cdk::api::data_certificate() { + Some(data_certificate_vec_u8) => { + let data_certificate_js_value: JSValue = data_certificate_vec_u8.into(); + to_qjs_value(&context, &data_certificate_js_value) + }, + None => { + context.undefined_value() + } + } + } + } +} diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs index 7b0dc91393..7a0a06da4e 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs @@ -13,6 +13,7 @@ mod canister_balance; mod canister_balance128; mod canister_version; mod clear_timer; +mod data_certificate; mod id; mod instruction_counter; mod is_controller; @@ -55,6 +56,7 @@ pub fn generate() -> TokenStream { let canister_balance128 = canister_balance128::generate(); let canister_version = canister_version::generate(); let clear_timer = clear_timer::generate(); + let data_certificate = data_certificate::generate(); let id = id::generate(); let instruction_counter = instruction_counter::generate(); let is_controller = is_controller::generate(); @@ -97,6 +99,7 @@ pub fn generate() -> TokenStream { #canister_balance128 #canister_version #clear_timer + #data_certificate #id #instruction_counter #is_controller @@ -140,6 +143,7 @@ pub fn generate() -> TokenStream { ic.set_property("canisterBalance128", context.wrap_callback2(canister_balance128).unwrap()).unwrap(); ic.set_property("canisterVersion", context.wrap_callback2(canister_version).unwrap()).unwrap(); ic.set_property("clearTimer", context.wrap_callback2(clear_timer).unwrap()).unwrap(); + ic.set_property("dataCertificate", context.wrap_callback2(data_certificate).unwrap()).unwrap(); ic.set_property("id", context.wrap_callback2(id).unwrap()).unwrap(); ic.set_property("instructionCounter", context.wrap_callback2(instruction_counter).unwrap()).unwrap(); ic.set_property("isController", context.wrap_callback2(is_controller).unwrap()).unwrap(); diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 35d2745143..27e35762b3 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -1,6 +1,6 @@ import { IDL } from './index'; import { Principal } from '@dfinity/principal'; -import { blob, nat, nat32, nat64, Void } from './primitives'; +import { blob, nat, nat32, nat64, Void, Opt } from './primitives'; import { v4 } from 'uuid'; import { CandidClass, toCandidClass, toReturnCandidClass } from './utils'; @@ -124,6 +124,14 @@ type Ic = { */ clearTimer: (id: bigint) => void; + /** + * When called from a query call, returns the data certificate + * authenticating `certifiedData` set by this canister. Otherwise returns + * `None`. + * @returns the data certificate or None + */ + dataCertificate: () => Opt; + /** * Gets the id of this canister * @returns the canister id @@ -538,6 +546,14 @@ export const ic: Ic = globalThis._azleIc return globalThis._azleIc.clearTimer(timerIdCandidBytes); }, + dataCertificate: () => { + const rawRustValue: ArrayBuffer | undefined = + globalThis._azleIc.dataCertificate(); + + return rawRustValue === undefined + ? [] + : [new Uint8Array(rawRustValue)]; + }, id: () => { // TODO consider bytes instead of string, just like with caller const idString = globalThis._azleIc.id(); From 2db5d005670adeb01c9917eceaf684a041cb8871 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 6 Sep 2023 21:45:22 -0600 Subject: [PATCH 06/23] Fix is controller The changes to is_controller.rs are purely formatting changes. The fix is passing the inner buffer down, rather than the whole Uint8Array --- .../azle_generate_rearchitecture/src/ic/is_controller.rs | 8 ++++++-- src/lib_new/ic.ts | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/is_controller.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/is_controller.rs index d83ed07a03..6e9ee07e98 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/is_controller.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/is_controller.rs @@ -6,9 +6,13 @@ pub fn generate() -> TokenStream { fn is_controller<'a>( context: &'a JSContextRef, _this: &CallbackArg, - _args: &[CallbackArg], + args: &[CallbackArg], ) -> Result, anyhow::Error> { - let principal_bytes: Vec = _args.get(0).expect("isController must have at least one argument").to_js_value()?.try_into()?; + let principal_bytes: Vec = args + .get(0) + .expect("isController must have at least one argument") + .to_js_value()? + .try_into()?; let principal = candid::Principal::from_slice(&principal_bytes); diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 27e35762b3..d2b0c4f216 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -565,7 +565,9 @@ export const ic: Ic = globalThis._azleIc return IDL.decode([IDL.Nat64], instructionCounterCandidBytes)[0]; }, isController: (principal) => { - return globalThis._azleIc.isController(principal.toUint8Array()); + return globalThis._azleIc.isController( + principal.toUint8Array().buffer + ); }, msgCyclesAccept: (maxAmount: nat64) => { const maxAmountCandidBytes = new Uint8Array( From bf38d1eb531954b82cf779beddfcc0880cc655db Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 6 Sep 2023 22:01:55 -0600 Subject: [PATCH 07/23] Get all tests except reject passing Reject requires the work for manual replies to be done. --- examples/ic_api/src/index.did | 38 +++++++++++++++++------------------ examples/ic_api/src/index.ts | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/ic_api/src/index.did b/examples/ic_api/src/index.did index 183f26418e..083bbc4846 100644 --- a/examples/ic_api/src/index.did +++ b/examples/ic_api/src/index.did @@ -1,19 +1,19 @@ -service : () -> { - argDataRaw : (vec nat8, int8, bool, text) -> (vec nat8) query; - argDataRawSize : (vec nat8, int8, bool, text) -> (nat32) query; - caller : () -> (principal) query; - canisterBalance : () -> (nat64) query; - canisterBalance128 : () -> (nat) query; - canisterVersion : () -> (nat) query; - dataCertificate : () -> (opt vec nat8) query; - dataCertificateNull : () -> (opt vec nat8); - id : () -> (principal) query; - instructionCounter : () -> (nat64) query; - isController : (principal) -> (bool) query; - performanceCounter : () -> (nat64) query; - print : (text) -> (bool) query; - reject : (text) -> (empty) query; - setCertifiedData : (vec nat8) -> (); - time : () -> (nat64) query; - trap : (text) -> (bool) query; -} \ No newline at end of file +service: () -> { + argDataRaw: (vec nat8, int8, bool, text) -> (vec nat8) query; + argDataRawSize: (vec nat8, int8, bool, text) -> (nat32) query; + caller: () -> (principal) query; + canisterBalance: () -> (nat64) query; + canisterBalance128: () -> (nat) query; + canisterVersion: () -> (nat64) query; + dataCertificate: () -> (opt vec nat8) query; + dataCertificateNull: () -> (opt vec nat8); + id: () -> (principal) query; + instructionCounter: () -> (nat64) query; + isController: (principal) -> (bool) query; + performanceCounter: () -> (nat64) query; + print: (text) -> (bool) query; + reject: (text) -> (empty) query; + setCertifiedData: (vec nat8) -> (); + time: () -> (nat64) query; + trap: (text) -> (bool) query; +} diff --git a/examples/ic_api/src/index.ts b/examples/ic_api/src/index.ts index ae45fae658..357e892714 100644 --- a/examples/ic_api/src/index.ts +++ b/examples/ic_api/src/index.ts @@ -149,7 +149,7 @@ export default class extends Service { } // TODO: See https://github.com/demergent-labs/azle/issues/1200 - @manual + // @manual @query([text], empty) reject(message: text): Manual { ic.reject(message); @@ -168,7 +168,7 @@ export default class extends Service { } // traps with a message, stopping execution and discarding all state within the call - @query([], bool) + @query([text], bool) trap(message: text): bool { ic.trap(message); From a33ca467bcadb419cb0caea18b613f85bd775c7b Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 12:24:58 -0600 Subject: [PATCH 08/23] Remove extraneous decorators --- .../motoko_examples/http_counter/src/index.ts | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/examples/motoko_examples/http_counter/src/index.ts b/examples/motoko_examples/http_counter/src/index.ts index fbc746b55c..0824a3e05a 100644 --- a/examples/motoko_examples/http_counter/src/index.ts +++ b/examples/motoko_examples/http_counter/src/index.ts @@ -11,11 +11,9 @@ import { Variant, Vec, update, - record, text, candid, func, - variant, Some, None, bool, @@ -23,7 +21,12 @@ import { } from 'azle'; import encodeUtf8 from 'encode-utf8'; -@record +class Token extends Record { + // add whatever fields you'd like + @candid(text) + arbitrary_data: text; +} + class StreamingCallbackHttpResponse extends Record { @candid(blob) body: blob; @@ -32,14 +35,9 @@ class StreamingCallbackHttpResponse extends Record { token: Opt; } -@record -class Token extends Record { - // add whatever fields you'd like - @candid(text) - arbitrary_data: text; -} +@func([text], StreamingCallbackHttpResponse, 'query') +class Callback {} -@record class CallbackStrategy extends Record { @candid(Callback) callback: Callback; @@ -48,10 +46,6 @@ class CallbackStrategy extends Record { token: Token; } -@func([text], StreamingCallbackHttpResponse, 'query') -class Callback {} - -@variant class StreamingStrategy extends Variant { @candid(CallbackStrategy) Callback?: CallbackStrategy; @@ -60,7 +54,6 @@ class StreamingStrategy extends Variant { type HeaderField = [text, text]; const HeaderField = Tuple(text, text); -@record class HttpResponse extends Record { @candid(nat16) status_code: nat16; @@ -78,7 +71,6 @@ class HttpResponse extends Record { upgrade: Opt; } -@record class HttpRequest extends Record { @candid(text) method: text; From be59485a6427c10908fc30db1b824add965c2b4b Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 12:51:45 -0600 Subject: [PATCH 09/23] Remove extraneous decorators from some examples --- .../phone-book/src/phone_book/index.ts | 2 -- .../motoko_examples/simple-to-do/src/index.ts | 2 -- .../superheroes/src/superheroes/index.ts | 2 -- .../threshold_ecdsa/src/index.ts | 21 +++++++++++-------- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/examples/motoko_examples/phone-book/src/phone_book/index.ts b/examples/motoko_examples/phone-book/src/phone_book/index.ts index 857b19f7ad..4c190a4b16 100644 --- a/examples/motoko_examples/phone-book/src/phone_book/index.ts +++ b/examples/motoko_examples/phone-book/src/phone_book/index.ts @@ -3,7 +3,6 @@ import { None, Opt, query, - record, Record, Service, Some, @@ -12,7 +11,6 @@ import { Void } from 'azle'; -@record export class Entry extends Record { @candid(text) desc: text; diff --git a/examples/motoko_examples/simple-to-do/src/index.ts b/examples/motoko_examples/simple-to-do/src/index.ts index 1130cd64b9..e9bdf92491 100644 --- a/examples/motoko_examples/simple-to-do/src/index.ts +++ b/examples/motoko_examples/simple-to-do/src/index.ts @@ -3,7 +3,6 @@ import { candid, nat, query, - record, Record, Service, text, @@ -12,7 +11,6 @@ import { Void } from 'azle'; -@record export class ToDo extends Record { @candid(text) description: text; diff --git a/examples/motoko_examples/superheroes/src/superheroes/index.ts b/examples/motoko_examples/superheroes/src/superheroes/index.ts index 006de3d3ea..1495dcfada 100644 --- a/examples/motoko_examples/superheroes/src/superheroes/index.ts +++ b/examples/motoko_examples/superheroes/src/superheroes/index.ts @@ -5,7 +5,6 @@ import { None, Opt, query, - record, Record, Service, Some, @@ -22,7 +21,6 @@ export type List = [text, Opt]; const List: List = Tuple(text, Opt(List)); // The type of a superhero. -@record class Superhero extends Record { @candid(text) name: text; diff --git a/examples/motoko_examples/threshold_ecdsa/src/index.ts b/examples/motoko_examples/threshold_ecdsa/src/index.ts index df793bceb7..41d0e6aa66 100644 --- a/examples/motoko_examples/threshold_ecdsa/src/index.ts +++ b/examples/motoko_examples/threshold_ecdsa/src/index.ts @@ -1,13 +1,16 @@ -import { blob, candid, ic, None, record, Record, Service, update } from 'azle'; -import { managementCanister } from 'azle/canisters/management'; +import { blob, candid, ic, None, Record, Service, update } from 'azle'; +import { + EcdsaCurve, + EcdsaPublicKeyArgs, + KeyId, + managementCanister +} from 'azle/canisters/management'; -@record class PublicKey extends Record { @candid(blob) publicKey: blob; } -@record class Signature extends Record { @candid(blob) signature: blob; @@ -22,14 +25,14 @@ export default class extends Service { managementCanister.ecdsa_public_key, { args: [ - { + EcdsaPublicKeyArgs.create({ canister_id: None, derivation_path: [caller], - key_id: { - curve: { secp256k1: null }, + key_id: KeyId.create({ + curve: EcdsaCurve.create({ secp256k1: null }), name: 'dfx_test_key' - } - } + }) + }) ] } ); From 0fa71c22f7d5d1e9c32501a34f269d4ec8dd7e3e Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 12:52:31 -0600 Subject: [PATCH 10/23] Re-add simple-to-do & phone-book examples to CI/CD --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7f8fdbbdb..a0483ba2c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,8 +102,6 @@ # "examples/inline_types", # "examples/motoko_examples/http_counter", # "examples/motoko_examples/persistent-storage", -# "examples/motoko_examples/phone-book", -# "examples/motoko_examples/simple-to-do", # "examples/motoko_examples/superheroes", # "examples/motoko_examples/threshold_ecdsa", # "examples/motoko_examples/whoami", @@ -179,6 +177,8 @@ jobs: "examples/motoko_examples/hello", "examples/motoko_examples/hello-world", "examples/motoko_examples/minimal-counter-dapp", + "examples/motoko_examples/phone-book", + "examples/motoko_examples/simple-to-do", "examples/motoko_examples/quicksort", "examples/notify_raw", "examples/null_example", From b22c8e24b9398643508b77b287064cc6aa9d5eed Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 13:39:06 -0600 Subject: [PATCH 11/23] Update whoami example --- .github/workflows/test.yml | 4 +- examples/motoko_examples/whoami/dfx.json | 2 +- examples/motoko_examples/whoami/src/index.did | 16 ++--- examples/motoko_examples/whoami/src/index.ts | 71 ++++++++----------- examples/motoko_examples/whoami/test/test.ts | 4 +- examples/motoko_examples/whoami/test/tests.ts | 2 +- 6 files changed, 44 insertions(+), 55 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0483ba2c1..640549a884 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,7 +104,6 @@ # "examples/motoko_examples/persistent-storage", # "examples/motoko_examples/superheroes", # "examples/motoko_examples/threshold_ecdsa", -# "examples/motoko_examples/whoami", name: Azle Tests on: @@ -178,8 +177,9 @@ jobs: "examples/motoko_examples/hello-world", "examples/motoko_examples/minimal-counter-dapp", "examples/motoko_examples/phone-book", - "examples/motoko_examples/simple-to-do", "examples/motoko_examples/quicksort", + "examples/motoko_examples/simple-to-do", + "examples/motoko_examples/whoami", "examples/notify_raw", "examples/null_example", "examples/optional_types", diff --git a/examples/motoko_examples/whoami/dfx.json b/examples/motoko_examples/whoami/dfx.json index 22b2127b40..3a298d6c6c 100644 --- a/examples/motoko_examples/whoami/dfx.json +++ b/examples/motoko_examples/whoami/dfx.json @@ -8,7 +8,7 @@ "candid": "src/index.did", "wasm": ".azle/whoami/whoami.wasm.gz", "declarations": { - "output": "./dfx_generated/whoami", + "output": "test/dfx_generated/whoami", "node_compatibility": true } } diff --git a/examples/motoko_examples/whoami/src/index.did b/examples/motoko_examples/whoami/src/index.did index ccd95385ff..e1800ff5cf 100644 --- a/examples/motoko_examples/whoami/src/index.did +++ b/examples/motoko_examples/whoami/src/index.did @@ -1,9 +1,7 @@ -type PerfResult = record { wasmBodyOnly : nat64; wasmIncludingPrelude : nat64 }; -service : (principal) -> { - argument : () -> (principal) query; - getPerfResult : () -> (opt PerfResult) query; - id : () -> (principal); - idQuick : () -> (principal) query; - installer : () -> (principal) query; - whoami : () -> (principal); -} \ No newline at end of file +service: (principal) -> { + installer: () -> (principal) query; + argument: () -> (principal) query; + whoami: () -> (principal); + id: () -> (principal); + idQuick: () -> (principal) query; +} diff --git a/examples/motoko_examples/whoami/src/index.ts b/examples/motoko_examples/whoami/src/index.ts index d4f75b3329..ed6d8c56ab 100644 --- a/examples/motoko_examples/whoami/src/index.ts +++ b/examples/motoko_examples/whoami/src/index.ts @@ -1,21 +1,14 @@ -import { ic, Principal, query, Service, update, principal } from 'azle'; - -class WhoAmICanister extends Service { - @query([], principal) - installer: () => Promise; - - @query([], principal) - argument: () => Promise; - - @update([], principal) - whoami: () => Promise; - - @update([], principal) - id: () => Promise; - - @query([], principal) - idQuick: () => Promise; -} +import { + ic, + init, + postUpgrade, + principal, + Principal, + query, + Service, + update, + Void +} from 'azle'; export default class extends Service { // Initialize the variables to ensure that they aren't `undefined`. @@ -23,55 +16,53 @@ export default class extends Service { install: Principal = Principal.fromText('aaaaa-aa'); someone: Principal = Principal.fromText('aaaaa-aa'); - // TODO: Implement this - // // Manually save the calling principal and argument for later access. - // @init([Principal], Void) - // init(somebody: Principal): void { - // this.install = ic.caller(); - // someone = somebody; - // } + // Manually save the calling principal and argument for later access. + @init([principal], Void) + init(somebody: Principal): Void { + this.install = ic.caller(); + this.someone = somebody; + } - // TODO: Implement this - // // Manually re-save these variables after new deploys. - // @postUpgrade([Principal], Void) - // postUpgrade(somebody: Principal): void { - // this.install = ic.caller(); - // someone = somebody; - // } + // Manually re-save these variables after new deploys. + @postUpgrade([principal], Void) + postUpgrade(somebody: Principal): Void { + this.install = ic.caller(); + this.someone = somebody; + } // Return the principal identifier of the wallet canister that installed this // canister. - @query([], Principal) + @query([], principal) installer(): Principal { return this.install; } // Return the principal identifier that was provided as an installation // argument to this canister. - @query([], Principal) + @query([], principal) argument(): Principal { return this.someone; } // Return the principal identifier of the caller of this method. - @update([], Principal) + @update([], principal) whoami(): Principal { return ic.caller(); } // Return the principal identifier of this canister. - @update([], Principal) + @update([], principal) async id(): Promise { - const thisCanister = new WhoAmICanister(ic.id()); - - return await thisCanister.whoami(); + return await ic.call(this.whoami, { + args: [] + }); } // Return the principal identifier of this canister via the global `ic` object. // This is much quicker than `id()` above because it isn't making a cross- // canister call to itself. Additionally, it can now be a `Query` which means it // doesn't have to go through consensus. - @query([], Principal) + @query([], principal) idQuick(): Principal { return ic.id(); } diff --git a/examples/motoko_examples/whoami/test/test.ts b/examples/motoko_examples/whoami/test/test.ts index 9daf614fc7..e5fd015c94 100644 --- a/examples/motoko_examples/whoami/test/test.ts +++ b/examples/motoko_examples/whoami/test/test.ts @@ -2,11 +2,11 @@ import { runTests } from 'azle/test'; import { createActor } from './dfx_generated/whoami'; import { callingIdentity, canisterId, getTests } from './tests'; -const whoami_canister = createActor(canisterId, { +const whoamiCanister = createActor(canisterId, { agentOptions: { host: 'http://127.0.0.1:8000', identity: callingIdentity } }); -runTests(getTests(whoami_canister, 'azle')); +runTests(getTests(whoamiCanister, 'whoami')); diff --git a/examples/motoko_examples/whoami/test/tests.ts b/examples/motoko_examples/whoami/test/tests.ts index 7a20978a22..5dfc550c3e 100644 --- a/examples/motoko_examples/whoami/test/tests.ts +++ b/examples/motoko_examples/whoami/test/tests.ts @@ -10,7 +10,7 @@ function createIdentity(seed: number): SignIdentity { return Ed25519KeyIdentity.generate(Uint8Array.from(seed1)); } -export const canisterId = getCanisterId('azle'); +export const canisterId = getCanisterId('whoami'); const installationPrincipal = execSync(`dfx identity get-principal`) .toString() From ae0ee99bf29ec498bd5f222ce980c9cfbe41cca4 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 16:03:10 -0600 Subject: [PATCH 12/23] Rewrite timers example Note: Does not yet work. The underlying API calls haven't been hooked up --- examples/timers/package-lock.json | 1020 ++--------------- examples/timers/package.json | 6 +- examples/timers/src/timers.did | 28 +- examples/timers/src/timers.ts | 215 ++-- .../src/ic/mod.rs | 8 + .../src/ic/set_timer.rs | 15 + .../src/ic/set_timer_interval.rs | 15 + src/lib_new/ic.ts | 56 +- 8 files changed, 296 insertions(+), 1067 deletions(-) create mode 100644 src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs create mode 100644 src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs diff --git a/examples/timers/package-lock.json b/examples/timers/package-lock.json index a96e7cd771..5baa0cb4f9 100644 --- a/examples/timers/package-lock.json +++ b/examples/timers/package-lock.json @@ -1,6 +1,6 @@ { "name": "timers", - "lockfileVersion": 2, + "lockfileVersion": 3, "requires": true, "packages": { "": { @@ -8,9 +8,9 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.14.1", - "ts-node": "10.7.0", - "typescript": "4.6.3" + "@dfinity/agent": "^0.19.2", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" } }, "node_modules/@cspotcode/source-map-consumer": { @@ -22,35 +22,6 @@ } }, "node_modules/@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", - "dependencies": { - "@cspotcode/source-map-consumer": "0.8.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@dfinity/agent": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.14.1.tgz", - "integrity": "sha512-qLAQrhkxshcsxECnMSa1zY7mI8ua0vItrdA9JJI9WBRz4rDDXtrXyOYnh3u6pUPpdfF/i6bjx+NgrjYZucLe1Q==", - "dev": true, - "dependencies": { - "base64-arraybuffer": "^0.2.0", - "bignumber.js": "^9.0.0", - "borc": "^2.1.1", - "js-sha256": "0.9.0", - "simple-cbor": "^0.4.1", - "ts-node": "^10.8.2" - }, - "peerDependencies": { - "@dfinity/candid": "^0.14.1", - "@dfinity/principal": "^0.14.1" - } - }, - "node_modules/@dfinity/agent/node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", @@ -62,197 +33,55 @@ "node": ">=12" } }, - "node_modules/@dfinity/agent/node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "node_modules/@dfinity/agent": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.19.2.tgz", + "integrity": "sha512-KLRWEjeU9SyyaS7IBVJ9ZUcufxufr55e/kRIyClK157+0pkTG9a8xKjUIMx3QzKvLsqqzXL238nWwdoP6jAD8g==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" + "@noble/hashes": "^1.3.1", + "base64-arraybuffer": "^0.2.0", + "borc": "^2.1.1", + "simple-cbor": "^0.4.1" }, "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } + "@dfinity/candid": "^0.19.2", + "@dfinity/principal": "^0.19.2" } }, "node_modules/@dfinity/candid": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.14.1.tgz", - "integrity": "sha512-yRIRnVrJ4LjB0jFKUqZ2NeUzCCR6m8pm/n+0+IoVzY94ZkFATUkBSvdNxDZd1CCtNDNApi+YDe61DSQ51cDkrg==", - "dev": true, - "peer": true, - "dependencies": { - "ts-node": "^10.8.2" - } - }, - "node_modules/@dfinity/candid/node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@dfinity/candid/node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.19.2.tgz", + "integrity": "sha512-X2hCqNMhnnmwtnOc0WnymOZYx3qphjEMuSYbBr7tMIkV7Hwt9BmXXlLnQTxUytTPxf+3he0GcS3KzsSQ9CK8ew==", "dev": true, "peer": true, - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } + "@dfinity/principal": "^0.19.2" } }, "node_modules/@dfinity/principal": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.14.1.tgz", - "integrity": "sha512-a5TDU0iWLeuNjI+L1Ukx5nRhQHMCN2GRQkQg1Z0AzP3dX7FkBOiaLwMCLhCRUk/sK/SeR6/hCA0YKiwRqzjhqA==", - "dev": true, - "peer": true, - "dependencies": { - "js-sha256": "^0.9.0", - "ts-node": "^10.8.2" - } - }, - "node_modules/@dfinity/principal/node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@dfinity/principal/node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.19.2.tgz", + "integrity": "sha512-vsKN6BKya70bQUsjgKRDlR2lOpv/XpUkCMIiji6rjMtKHIuWEB5Eu3JqZsOuBmWo3A3TT/K/osT9VPm0k4qdYQ==", "dev": true, "peer": true, "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } + "@noble/hashes": "^1.3.1" } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", "dev": true, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, "node_modules/@jridgewell/trace-mapping": { @@ -265,6 +94,18 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "dev": true, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@swc/core": { "version": "1.2.151", "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.151.tgz", @@ -506,20 +347,20 @@ "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" }, "node_modules/@tsconfig/node16": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", - "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" }, "node_modules/@types/node": { - "version": "18.11.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz", - "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "peer": true }, "node_modules/acorn": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", - "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "bin": { "acorn": "bin/acorn" }, @@ -563,6 +404,17 @@ "resolved": "https://registry.npmjs.org/azle-syn/-/azle-syn-0.0.0.tgz", "integrity": "sha512-fWExJb5/hOEJOuBQ8hMMHRs9WryYeLLa9/ydqPWxbwjMEpE8RKdU1dTK6mdZtzNMhbeHdyne2pU1iVKiKmImGw==" }, + "node_modules/azle/node_modules/@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "dependencies": { + "@cspotcode/source-map-consumer": "0.8.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/azle/node_modules/@dfinity/principal": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", @@ -650,9 +502,9 @@ ] }, "node_modules/bignumber.js": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", - "integrity": "sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", "dev": true, "engines": { "node": "*" @@ -1073,9 +925,9 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, "node_modules/ieee754": { "version": "1.2.1", @@ -1143,9 +995,9 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, "node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dev": true, "dependencies": { "inherits": "^2.0.3", @@ -1192,12 +1044,12 @@ } }, "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -1208,7 +1060,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "bin": { @@ -1235,16 +1087,16 @@ } }, "node_modules/typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/universalify": { @@ -1275,721 +1127,5 @@ "node": ">=6" } } - }, - "dependencies": { - "@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" - }, - "@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", - "requires": { - "@cspotcode/source-map-consumer": "0.8.0" - } - }, - "@dfinity/agent": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.14.1.tgz", - "integrity": "sha512-qLAQrhkxshcsxECnMSa1zY7mI8ua0vItrdA9JJI9WBRz4rDDXtrXyOYnh3u6pUPpdfF/i6bjx+NgrjYZucLe1Q==", - "dev": true, - "requires": { - "base64-arraybuffer": "^0.2.0", - "bignumber.js": "^9.0.0", - "borc": "^2.1.1", - "js-sha256": "0.9.0", - "simple-cbor": "^0.4.1", - "ts-node": "^10.8.2" - }, - "dependencies": { - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - } - } - }, - "@dfinity/candid": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.14.1.tgz", - "integrity": "sha512-yRIRnVrJ4LjB0jFKUqZ2NeUzCCR6m8pm/n+0+IoVzY94ZkFATUkBSvdNxDZd1CCtNDNApi+YDe61DSQ51cDkrg==", - "dev": true, - "peer": true, - "requires": { - "ts-node": "^10.8.2" - }, - "dependencies": { - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, - "peer": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - } - } - }, - "@dfinity/principal": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.14.1.tgz", - "integrity": "sha512-a5TDU0iWLeuNjI+L1Ukx5nRhQHMCN2GRQkQg1Z0AzP3dX7FkBOiaLwMCLhCRUk/sK/SeR6/hCA0YKiwRqzjhqA==", - "dev": true, - "peer": true, - "requires": { - "js-sha256": "^0.9.0", - "ts-node": "^10.8.2" - }, - "dependencies": { - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "peer": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, - "peer": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - } - } - }, - "@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true - }, - "@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, - "@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "@swc/core": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.151.tgz", - "integrity": "sha512-oHgqKwK/Djv765zUHPiGqfMCaKIxXTgQyyCUBKLBQfAJwe/7FVobQ2fghBp4FsZA/NE1LZBmMPpRZNQwlGjeHw==", - "requires": { - "@swc/core-android-arm-eabi": "1.2.151", - "@swc/core-android-arm64": "1.2.151", - "@swc/core-darwin-arm64": "1.2.151", - "@swc/core-darwin-x64": "1.2.151", - "@swc/core-freebsd-x64": "1.2.151", - "@swc/core-linux-arm-gnueabihf": "1.2.151", - "@swc/core-linux-arm64-gnu": "1.2.151", - "@swc/core-linux-arm64-musl": "1.2.151", - "@swc/core-linux-x64-gnu": "1.2.151", - "@swc/core-linux-x64-musl": "1.2.151", - "@swc/core-win32-arm64-msvc": "1.2.151", - "@swc/core-win32-ia32-msvc": "1.2.151", - "@swc/core-win32-x64-msvc": "1.2.151" - } - }, - "@swc/core-android-arm-eabi": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.151.tgz", - "integrity": "sha512-Suk3IcHdha33K4hq9tfBCwkXJsENh7kjXCseLqL8Yvy8QobqkXjf1fcoJxX9BdCmPwsKmIw0ZgCBYR+Hl83M2w==", - "optional": true - }, - "@swc/core-android-arm64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.151.tgz", - "integrity": "sha512-HZVy69dVWT5RgrMJMRK5aiicPmhzkyCHAexApYAHYLgAIhsxL7uoAIPmuRKRkrKNJjrwsWL7H27bBH5bddRDvg==", - "optional": true - }, - "@swc/core-darwin-arm64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.151.tgz", - "integrity": "sha512-Ql7rXMu+IC76TemRtkt+opl5iSpX2ApAXVSfvf6afNVTrfTKLpDwiR3ySRRlG0FnNIv6TfOCJpHf655xp01S/g==", - "optional": true - }, - "@swc/core-darwin-x64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.151.tgz", - "integrity": "sha512-N1OBIB7xatR5eybLo91ZhvMJMxT0zxRQURV/a9I8o5CyP4iLd1k8gmrYvBbtj08ohS8F9z7k/dFjxk/9ve5Drw==", - "optional": true - }, - "@swc/core-freebsd-x64": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.151.tgz", - "integrity": "sha512-WVIRiDzuz+/W7BMjVtg1Cmk1+zmDT18Qq+Ygr9J6aFQ1JQUkLEE1pvtkGD3JIEa6Jhz/VwM6AFHtY5o1CrZ21w==", - "optional": true - }, - "@swc/core-linux-arm-gnueabihf": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.151.tgz", - "integrity": "sha512-pfBrIUwu3cR/M7DzDCUJAw9jFKXvJ/Ge8auFk07lRb+JcDnPm0XxLyrLqGvNQWdcHgXeXfmnS4fMQxdb9GUN1w==", - "optional": true - }, - "@swc/core-linux-arm64-gnu": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.151.tgz", - "integrity": "sha512-M+BTkTdPY7gteM+0dYz9wrU/j9taL4ccqPEHkDEKP21lS24y99UtuKsvdBLzDm/6ShBVLFAkgIBPu5cEb7y6ig==", - "optional": true - }, - "@swc/core-linux-arm64-musl": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.151.tgz", - "integrity": "sha512-7A+yTtSvPJVwO8X1cxUbD/PVCx8G9MKn83G9pH/r+9sQMBXqxyw6/NR0DG6nMMiyOmJkmYWgh5mO47BN7WC4dQ==", - "optional": true - }, - "@swc/core-linux-x64-gnu": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.151.tgz", - "integrity": "sha512-ORlbN3wf1w0IQGjGToYYC/hV/Vwfcs88Ohfxc4X+IQaw/VxKG6/XT65c0btK640F2TVhvhH1MbYFJJlsycsW7g==", - "optional": true - }, - "@swc/core-linux-x64-musl": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.151.tgz", - "integrity": "sha512-r6odKE3+9+ReVdnNTZnICt5tscyFFtP4GFcmPQzBSlVoD9LZX6O4WeOlFXn77rVK/+205n2ag/KkKgZH+vdPuQ==", - "optional": true - }, - "@swc/core-win32-arm64-msvc": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.151.tgz", - "integrity": "sha512-jnjJTNHpLhBaPwRgiKv1TdrMljL88ePqMCdVMantyd7yl4lP0D2e5/xR9ysR9S4EGcUnOyo9w8WUYhx/TioMZw==", - "optional": true - }, - "@swc/core-win32-ia32-msvc": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.151.tgz", - "integrity": "sha512-hSCxAiyDDXKvdUExj4jSIhzWFePqoqak1qdNUjlhEhEinDG8T8PTRCLalyW6fqZDcLf6Tqde7H79AqbfhRlYGQ==", - "optional": true - }, - "@swc/core-win32-x64-msvc": { - "version": "1.2.151", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.151.tgz", - "integrity": "sha512-HOkqcJWCChps83Maj0M5kifPDuZ2sGPqpLM67poawspTFkBh0QJ9TMmxW1doQw+74cqsTpRi1ewr/KhsN18i5g==", - "optional": true - }, - "@tsconfig/node10": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", - "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" - }, - "@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" - }, - "@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" - }, - "@tsconfig/node16": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", - "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" - }, - "@types/node": { - "version": "18.11.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz", - "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g==", - "peer": true - }, - "acorn": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", - "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==" - }, - "acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" - }, - "arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" - }, - "azle": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/azle/-/azle-0.17.1.tgz", - "integrity": "sha512-wU0gzPMCDzvvurdZQ5NUaHlW9RvR0CVLyiTSxt+e61kA8aq5W/0k8KyzPIvOYdk7+WVZLCzs++yahlnmkHcaOg==", - "requires": { - "@dfinity/principal": "0.11.2", - "@swc/core": "1.2.151", - "azle-syn": "0.0.0", - "esbuild": "0.14.25", - "fs-extra": "10.0.1", - "js-sha256": "0.9.0", - "ts-node": "10.3.1", - "typescript": "4.4.4" - }, - "dependencies": { - "@dfinity/principal": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", - "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" - }, - "ts-node": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", - "integrity": "sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==", - "requires": { - "@cspotcode/source-map-support": "0.7.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "yn": "3.1.1" - } - }, - "typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==" - } - } - }, - "azle-syn": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/azle-syn/-/azle-syn-0.0.0.tgz", - "integrity": "sha512-fWExJb5/hOEJOuBQ8hMMHRs9WryYeLLa9/ydqPWxbwjMEpE8RKdU1dTK6mdZtzNMhbeHdyne2pU1iVKiKmImGw==" - }, - "base64-arraybuffer": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.2.0.tgz", - "integrity": "sha512-7emyCsu1/xiBXgQZrscw/8KPRT44I4Yq9Pe6EGs3aPRTsWuggML1/1DTuZUuIaJPIm1FTDUVXl4x/yW8s0kQDQ==", - "dev": true - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true - }, - "bignumber.js": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", - "integrity": "sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==", - "dev": true - }, - "borc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/borc/-/borc-2.1.2.tgz", - "integrity": "sha512-Sy9eoUi4OiKzq7VovMn246iTo17kzuyHJKomCfpWMlI6RpfN1gk95w7d7gH264nApVLg0HZfcpz62/g4VH1Y4w==", - "dev": true, - "requires": { - "bignumber.js": "^9.0.0", - "buffer": "^5.5.0", - "commander": "^2.15.0", - "ieee754": "^1.1.13", - "iso-url": "~0.4.7", - "json-text-sequence": "~0.1.0", - "readable-stream": "^3.6.0" - } - }, - "buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" - }, - "delimit-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", - "integrity": "sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ==", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" - }, - "esbuild": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.25.tgz", - "integrity": "sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==", - "requires": { - "esbuild-android-64": "0.14.25", - "esbuild-android-arm64": "0.14.25", - "esbuild-darwin-64": "0.14.25", - "esbuild-darwin-arm64": "0.14.25", - "esbuild-freebsd-64": "0.14.25", - "esbuild-freebsd-arm64": "0.14.25", - "esbuild-linux-32": "0.14.25", - "esbuild-linux-64": "0.14.25", - "esbuild-linux-arm": "0.14.25", - "esbuild-linux-arm64": "0.14.25", - "esbuild-linux-mips64le": "0.14.25", - "esbuild-linux-ppc64le": "0.14.25", - "esbuild-linux-riscv64": "0.14.25", - "esbuild-linux-s390x": "0.14.25", - "esbuild-netbsd-64": "0.14.25", - "esbuild-openbsd-64": "0.14.25", - "esbuild-sunos-64": "0.14.25", - "esbuild-windows-32": "0.14.25", - "esbuild-windows-64": "0.14.25", - "esbuild-windows-arm64": "0.14.25" - } - }, - "esbuild-android-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.25.tgz", - "integrity": "sha512-L5vCUk7TzFbBnoESNoXjU3x9+/+7TDIE/1mTfy/erAfvZAqC+S3sp/Qa9wkypFMcFvN9FzvESkTlpeQDolREtQ==", - "optional": true - }, - "esbuild-android-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.25.tgz", - "integrity": "sha512-4jv5xPjM/qNm27T5j3ZEck0PvjgQtoMHnz4FzwF5zNP56PvY2CT0WStcAIl6jNlsuDdN63rk2HRBIsO6xFbcFw==", - "optional": true - }, - "esbuild-darwin-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.25.tgz", - "integrity": "sha512-TGp8tuudIxOyWd1+8aYPxQmC1ZQyvij/AfNBa35RubixD0zJ1vkKHVAzo0Zao1zcG6pNqiSyzfPto8vmg0s7oA==", - "optional": true - }, - "esbuild-darwin-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.25.tgz", - "integrity": "sha512-oTcDgdm0MDVEmw2DWu8BV68pYuImpFgvWREPErBZmNA4MYKGuBRaCiJqq6jZmBR1x+3y1DWCjez+5uLtuAm6mw==", - "optional": true - }, - "esbuild-freebsd-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.25.tgz", - "integrity": "sha512-ueAqbnMZ8arnuLH8tHwTCQYeptnHOUV7vA6px6j4zjjQwDx7TdP7kACPf3TLZLdJQ3CAD1XCvQ2sPhX+8tacvQ==", - "optional": true - }, - "esbuild-freebsd-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.25.tgz", - "integrity": "sha512-+ZVWud2HKh+Ob6k/qiJWjBtUg4KmJGGmbvEXXW1SNKS7hW7HU+Zq2ZCcE1akFxOPkVB+EhOty/sSek30tkCYug==", - "optional": true - }, - "esbuild-linux-32": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.25.tgz", - "integrity": "sha512-3OP/lwV3kCzEz45tobH9nj+uE4ubhGsfx+tn0L26WAGtUbmmcRpqy7XRG/qK7h1mClZ+eguIANcQntYMdYklfw==", - "optional": true - }, - "esbuild-linux-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.25.tgz", - "integrity": "sha512-+aKHdHZmX9qwVlQmu5xYXh7GsBFf4TWrePgeJTalhXHOG7NNuUwoHmketGiZEoNsWyyqwH9rE5BC+iwcLY30Ug==", - "optional": true - }, - "esbuild-linux-arm": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.25.tgz", - "integrity": "sha512-aTLcE2VBoLydL943REcAcgnDi3bHtmULSXWLbjtBdtykRatJVSxKMjK9YlBXUZC4/YcNQfH7AxwVeQr9fNxPhw==", - "optional": true - }, - "esbuild-linux-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.25.tgz", - "integrity": "sha512-UxfenPx/wSZx55gScCImPtXekvZQLI2GW3qe5dtlmU7luiqhp5GWPzGeQEbD3yN3xg/pHc671m5bma5Ns7lBHw==", - "optional": true - }, - "esbuild-linux-mips64le": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.25.tgz", - "integrity": "sha512-wLWYyqVfYx9Ur6eU5RT92yJVsaBGi5RdkoWqRHOqcJ38Kn60QMlcghsKeWfe9jcYut8LangYZ98xO1LxIoSXrQ==", - "optional": true - }, - "esbuild-linux-ppc64le": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.25.tgz", - "integrity": "sha512-0dR6Csl6Zas3g4p9ULckEl8Mo8IInJh33VCJ3eaV1hj9+MHGdmDOakYMN8MZP9/5nl+NU/0ygpd14cWgy8uqRw==", - "optional": true - }, - "esbuild-linux-riscv64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.25.tgz", - "integrity": "sha512-J4d20HDmTrgvhR0bdkDhvvJGaikH3LzXQnNaseo8rcw9Yqby9A90gKUmWpfwqLVNRILvNnAmKLfBjCKU9ajg8w==", - "optional": true - }, - "esbuild-linux-s390x": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.25.tgz", - "integrity": "sha512-YI2d5V6nTE73ZnhEKQD7MtsPs1EtUZJ3obS21oxQxGbbRw1G+PtJKjNyur+3t6nzHP9oTg6GHQ3S3hOLLmbDIQ==", - "optional": true - }, - "esbuild-netbsd-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.25.tgz", - "integrity": "sha512-TKIVgNWLUOkr+Exrye70XTEE1lJjdQXdM4tAXRzfHE9iBA7LXWcNtVIuSnphTqpanPzTDFarF0yqq4kpbC6miA==", - "optional": true - }, - "esbuild-openbsd-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.25.tgz", - "integrity": "sha512-QgFJ37A15D7NIXBTYEqz29+uw3nNBOIyog+3kFidANn6kjw0GHZ0lEYQn+cwjyzu94WobR+fes7cTl/ZYlHb1A==", - "optional": true - }, - "esbuild-sunos-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.25.tgz", - "integrity": "sha512-rmWfjUItYIVlqr5EnTH1+GCxXiBOC42WBZ3w++qh7n2cS9Xo0lO5pGSG2N+huOU2fX5L+6YUuJ78/vOYvefeFw==", - "optional": true - }, - "esbuild-windows-32": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.25.tgz", - "integrity": "sha512-HGAxVUofl3iUIz9W10Y9XKtD0bNsK9fBXv1D55N/ljNvkrAYcGB8YCm0v7DjlwtyS6ws3dkdQyXadbxkbzaKOA==", - "optional": true - }, - "esbuild-windows-64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.25.tgz", - "integrity": "sha512-TirEohRkfWU9hXLgoDxzhMQD1g8I2mOqvdQF2RS9E/wbkORTAqJHyh7wqGRCQAwNzdNXdg3JAyhQ9/177AadWA==", - "optional": true - }, - "esbuild-windows-arm64": { - "version": "0.14.25", - "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.25.tgz", - "integrity": "sha512-4ype9ERiI45rSh+R8qUoBtaj6kJvUOI7oVLhKqPEpcF4Pa5PpT3hm/mXAyotJHREkHpM87PAJcA442mLnbtlNA==", - "optional": true - }, - "fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" - }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "iso-url": { - "version": "0.4.7", - "resolved": "https://registry.npmjs.org/iso-url/-/iso-url-0.4.7.tgz", - "integrity": "sha512-27fFRDnPAMnHGLq36bWTpKET+eiXct3ENlCcdcMdk+mjXrb2kw3mhBUg1B7ewAC0kVzlOPhADzQgz1SE6Tglog==", - "dev": true - }, - "js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, - "json-text-sequence": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz", - "integrity": "sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w==", - "dev": true, - "requires": { - "delimit-stream": "0.1.0" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - }, - "simple-cbor": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/simple-cbor/-/simple-cbor-0.4.1.tgz", - "integrity": "sha512-rijcxtwx2b4Bje3sqeIqw5EeW7UlOIC4YfOdwqIKacpvRQ/D78bWg/4/0m5e0U91oKvlGh7LlJuZCu07ISCC7w==", - "dev": true - }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - } - }, - "ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", - "dev": true, - "requires": { - "@cspotcode/source-map-support": "0.7.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", - "yn": "3.1.1" - } - }, - "typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", - "dev": true - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true - }, - "v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true - }, - "yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" - } } } diff --git a/examples/timers/package.json b/examples/timers/package.json index 1891ce1c82..6bc660e4c9 100644 --- a/examples/timers/package.json +++ b/examples/timers/package.json @@ -7,8 +7,8 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.14.1", - "ts-node": "10.7.0", - "typescript": "4.6.3" + "@dfinity/agent": "^0.19.2", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" } } diff --git a/examples/timers/src/timers.did b/examples/timers/src/timers.did index 368c6accb4..3767a93413 100644 --- a/examples/timers/src/timers.did +++ b/examples/timers/src/timers.did @@ -1,21 +1,7 @@ -type StatusReport = record { - repeat : int8; - repeatCrossCanister : vec nat8; - inline : int8; - capture : text; - single : bool; - singleCrossCanister : vec nat8; -}; -type TimerIds = record { - repeat : nat64; - repeatCrossCanister : nat64; - inline : nat64; - capture : nat64; - single : nat64; - singleCrossCanister : nat64; -}; -service : () -> { - clearTimer : (nat64) -> (); - setTimers : (nat64, nat64) -> (TimerIds); - statusReport : () -> (StatusReport) query; -} \ No newline at end of file +type rec_0 = record {repeat:nat64; repeatCrossCanister:nat64; inline:nat64; capture:nat64; single:nat64; singleCrossCanister:nat64}; +type rec_1 = record {repeat:int8; repeatCrossCanister:vec nat8; inline:int8; capture:text; single:bool; singleCrossCanister:vec nat8}; +service: () -> { + clearTimer: (nat64) -> (); + setTimers: (nat64, nat64) -> (rec_0); + statusReport: () -> (rec_1) query; +} diff --git a/examples/timers/src/timers.ts b/examples/timers/src/timers.ts index 7d0ba41109..00415f8002 100644 --- a/examples/timers/src/timers.ts +++ b/examples/timers/src/timers.ts @@ -1,125 +1,142 @@ import { blob, + bool, + candid, Duration, ic, int8, - match, - $query, + nat64, + query, Record, + Service, + text, TimerId, - $update + update, + Void } from 'azle'; import { managementCanister } from 'azle/canisters/management'; -type StatusReport = Record<{ - single: boolean; +class StatusReport extends Record { + @candid(bool) + single: bool; + + @candid(int8) inline: int8; - capture: string; + + @candid(text) + capture: text; + + @candid(int8) repeat: int8; + + @candid(blob) singleCrossCanister: blob; + + @candid(blob) repeatCrossCanister: blob; -}>; +} -type TimerIds = Record<{ +class TimerIds extends Record { + @candid(nat64) single: TimerId; + + @candid(nat64) inline: TimerId; + + @candid(nat64) capture: TimerId; + + @candid(nat64) repeat: TimerId; + + @candid(nat64) singleCrossCanister: TimerId; + + @candid(nat64) repeatCrossCanister: TimerId; -}>; - -let status: StatusReport = { - single: false, - inline: 0, - capture: '', - repeat: 0, - singleCrossCanister: Uint8Array.from([]), - repeatCrossCanister: Uint8Array.from([]) -}; - -$update; -export function clearTimer(timerId: TimerId): void { - ic.clearTimer(timerId); - console.log(`timer ${timerId} cancelled`); } -$update; -export function setTimers(delay: Duration, interval: Duration): TimerIds { - const capturedValue = '🚩'; - - const singleId = ic.setTimer(delay, oneTimeTimerCallback); - - const inlineId = ic.setTimer(delay, () => { - status.inline = 1; - console.log('Inline timer called'); - }); - - const captureId = ic.setTimer(delay, () => { - status.capture = capturedValue; - console.log(`Timer captured value ${capturedValue}`); - }); - - const repeatId = ic.setTimerInterval(interval, () => { - status.repeat++; - console.log(`Repeating timer. Call ${status.repeat}`); - }); - - const singleCrossCanisterId = ic.setTimer( - delay, - singleCrossCanisterTimerCallback - ); - - const repeatCrossCanisterId = ic.setTimerInterval( - interval, - repeatCrossCanisterTimerCallback - ); - - return { - single: singleId, - inline: inlineId, - capture: captureId, - repeat: repeatId, - singleCrossCanister: singleCrossCanisterId, - repeatCrossCanister: repeatCrossCanisterId +export default class extends Service { + status: StatusReport = { + single: false, + inline: 0, + capture: '', + repeat: 0, + singleCrossCanister: Uint8Array.from([]), + repeatCrossCanister: Uint8Array.from([]) }; -} - -$query; -export function statusReport(): StatusReport { - return status; -} - -function oneTimeTimerCallback(): void { - status.single = true; - console.log('oneTimeTimerCallback called'); -} - -async function singleCrossCanisterTimerCallback(): Promise { - console.log('singleCrossCanisterTimerCallback'); - - const result = await managementCanister.raw_rand().call(); - - match(result, { - Ok: (ok) => { - status.singleCrossCanister = ok; - }, - Err: (err) => ic.trap(err) - }); -} - -async function repeatCrossCanisterTimerCallback(): Promise { - console.log('repeatCrossCanisterTimerCallback'); - - const result = await managementCanister.raw_rand().call(); - match(result, { - Ok: (ok) => { - status.repeatCrossCanister = Uint8Array.from([ - ...status.repeatCrossCanister, - ...ok - ]); - }, - Err: (err) => ic.trap(err) - }); + @update([nat64], Void) + clearTimer(timerId: TimerId): Void { + ic.clearTimer(timerId); + console.log(`timer ${timerId} cancelled`); + } + + @update([nat64, nat64], TimerIds) + setTimers(delay: Duration, interval: Duration): TimerIds { + const capturedValue = '🚩'; + + const singleId = ic.setTimer(delay, this.oneTimeTimerCallback); + + const inlineId = ic.setTimer(delay, () => { + this.status.inline = 1; + console.log('Inline timer called'); + }); + + const captureId = ic.setTimer(delay, () => { + this.status.capture = capturedValue; + console.log(`Timer captured value ${capturedValue}`); + }); + + const repeatId = ic.setTimerInterval(interval, () => { + this.status.repeat++; + console.log(`Repeating timer. Call ${this.status.repeat}`); + }); + + const singleCrossCanisterId = ic.setTimer( + delay, + this.singleCrossCanisterTimerCallback + ); + + const repeatCrossCanisterId = ic.setTimerInterval( + interval, + this.repeatCrossCanisterTimerCallback + ); + + return { + single: singleId, + inline: inlineId, + capture: captureId, + repeat: repeatId, + singleCrossCanister: singleCrossCanisterId, + repeatCrossCanister: repeatCrossCanisterId + }; + } + + @query([], StatusReport) + statusReport(): StatusReport { + return this.status; + } + + oneTimeTimerCallback(): Void { + this.status.single = true; + console.log('oneTimeTimerCallback called'); + } + + async singleCrossCanisterTimerCallback(): Promise { + console.log('singleCrossCanisterTimerCallback'); + + this.status.singleCrossCanister = await ic.call( + managementCanister.raw_rand + ); + } + + async repeatCrossCanisterTimerCallback(): Promise { + console.log('repeatCrossCanisterTimerCallback'); + + this.status.repeatCrossCanister = Uint8Array.from([ + ...this.status.repeatCrossCanister, + ...(await ic.call(managementCanister.raw_rand)) + ]); + } } diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs index 7a0a06da4e..09b5764672 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs @@ -31,6 +31,8 @@ mod reject; mod reject_message; mod reply_raw; mod set_certified_data; +mod set_timer; +mod set_timer_interval; mod stable64_grow; mod stable64_read; mod stable64_size; @@ -74,6 +76,8 @@ pub fn generate() -> TokenStream { let reject_message = reject_message::generate(); let reply_raw = reply_raw::generate(); let set_certified_data = set_certified_data::generate(); + let set_timer = set_timer::generate(); + let set_timer_interval = set_timer_interval::generate(); let stable_bytes = stable_bytes::generate(); let stable_grow = stable_grow::generate(); let stable_read = stable_read::generate(); @@ -117,6 +121,8 @@ pub fn generate() -> TokenStream { #reject_message #reply_raw #set_certified_data + #set_timer + #set_timer_interval #stable_bytes #stable_grow #stable_read @@ -161,6 +167,8 @@ pub fn generate() -> TokenStream { ic.set_property("rejectMessage", context.wrap_callback2(reject_message).unwrap()).unwrap(); ic.set_property("replyRaw", context.wrap_callback2(reply_raw).unwrap()).unwrap(); ic.set_property("setCertifiedData", context.wrap_callback2(set_certified_data).unwrap()).unwrap(); + ic.set_property("setTimer", context.wrap_callback2(set_timer).unwrap()).unwrap(); + ic.set_property("setTimerInterval", context.wrap_callback2(set_timer_interval).unwrap()).unwrap(); ic.set_property("stable64Grow", context.wrap_callback2(stable64_grow).unwrap()).unwrap(); ic.set_property("stable64Read", context.wrap_callback2(stable64_read).unwrap()).unwrap(); ic.set_property("stable64Size", context.wrap_callback2(stable64_size).unwrap()).unwrap(); diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs new file mode 100644 index 0000000000..93cf904687 --- /dev/null +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs @@ -0,0 +1,15 @@ +use proc_macro2::TokenStream; +use quote::quote; + +pub fn generate() -> TokenStream { + quote! { + fn set_timer<'a>( + context: &'a JSContextRef, + _this: &CallbackArg, + _args: &[CallbackArg], + ) -> Result, anyhow::Error> { + // TODO: Implement set_timer + context.undefined_value() + } + } +} diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs new file mode 100644 index 0000000000..9be86bb28c --- /dev/null +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs @@ -0,0 +1,15 @@ +use proc_macro2::TokenStream; +use quote::quote; + +pub fn generate() -> TokenStream { + quote! { + fn set_timer_interval<'a>( + context: &'a JSContextRef, + _this: &CallbackArg, + _args: &[CallbackArg], + ) -> Result, anyhow::Error> { + // TODO: Implement set_timer_interval + context.undefined_value() + } + } +} diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index d2b0c4f216..477a684abc 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -1,8 +1,9 @@ -import { IDL } from './index'; +import { Nat64 } from '@dfinity/candid/lib/esm/idl'; // Note: Importing IDL from './index' instead causes the build to fail import { Principal } from '@dfinity/principal'; +import { IDL } from './index'; import { blob, nat, nat32, nat64, Void, Opt } from './primitives'; import { v4 } from 'uuid'; -import { CandidClass, toCandidClass, toReturnCandidClass } from './utils'; +import { CandidClass, toCandidClass } from './utils'; // declare var globalThis: { // ic: Ic; @@ -10,6 +11,19 @@ import { CandidClass, toCandidClass, toReturnCandidClass } from './utils'; declare var globalThis: any; +/** + * Represents a duration of time in seconds. + */ +export type Duration = nat64; // TODO: Consider modeling this after the corresponding struct in Rust +export const Duration = Nat64; // Note: using IDL.Nat64 from './index' causes the build to fail + +/** + * Type returned by the {@link ic.setTimer} and {@link ic.setTimerInterval} + * functions. Pass to {@link ic.clearTimer} to remove the timer. + */ +export type TimerId = nat64; // TODO: Consider modeling this after the corresponding struct in Rust +export const TimerId = Nat64; // Note: using IDL.Nat64 from './index' causes the build to fail + type Ic = { /** * Accepts the ingress message. Calling from outside the @@ -300,6 +314,34 @@ type Ic = { */ setCertifiedData: (data: Uint8Array) => void; + /** + * Sets callback to be executed later, after delay. Panics if `delay` + time() is more than 2^64 - 1. + * To cancel the timer before it executes, pass the returned `TimerId` to `clearTimer`. + * Note that timers are not persisted across canister upgrades. + * + * @param delay The time (in seconds) to wait before executing the provided callback. + * @param callback the function to invoke after the specified delay has passed. + * @returns the ID of the created timer. Used to cancel the timer. + */ + setTimer: ( + delay: Duration, + callback: () => void | Promise + ) => TimerId; + + /** + * Sets callback to be executed every interval. Panics if `interval` + time() is more than 2^64 - 1. + * To cancel the interval timer, pass the returned `TimerId` to `clearTimer`. + * Note that timers are not persisted across canister upgrades. + * + * @param interval The interval (in seconds) between each callback execution. + * @param callback the function to invoke after the specified delay has passed. + * @returns the ID of the created timer. Used to cancel the timer. + */ + setTimerInterval: ( + interval: Duration, + callback: () => void | Promise + ) => TimerId; + /** * Gets a copy of stable memory * @@ -667,6 +709,16 @@ export const ic: Ic = globalThis._azleIc return globalThis._azleIc.setCertifiedData(dataBytes); }, + setTimer: (delay: nat64, callback: () => void | Promise) => { + const delayCandidBytes = new Uint8Array( + IDL.encode([IDL.Nat64], [delay]) + ).buffer; + + const setTimerCandidBytes = + globalThis._azleIc.setTimer(delayCandidBytes); + + return IDL.decode([IDL.Nat64], setTimerCandidBytes)[0]; + }, stableBytes: () => { return new Uint8Array(globalThis._azleIc.stableBytes()); }, From 2a19663ad7e2cc6ab4f2167fc8954cbb19276de4 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 17:28:36 -0600 Subject: [PATCH 13/23] Get set timer hooked up to call a rust closure --- .../src/ic/set_timer.rs | 32 +++++++++++++++++-- .../azle_generate_rearchitecture/src/main.rs | 4 +-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs index 93cf904687..41c26c95eb 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs @@ -6,10 +6,36 @@ pub fn generate() -> TokenStream { fn set_timer<'a>( context: &'a JSContextRef, _this: &CallbackArg, - _args: &[CallbackArg], + args: &[CallbackArg], ) -> Result, anyhow::Error> { - // TODO: Implement set_timer - context.undefined_value() + let candid_encoded_array_buffer: Vec = args + .get(0) + .expect("performanceCounter must have one argument") + .to_js_value()? + .try_into()?; + + let delay_as_u64: u64 = candid::decode_one(&candid_encoded_array_buffer)?; + + let delay = core::time::Duration::new(delay_as_u64, 0); + + // TODO: Get the callback they passed in somehow + + // let callback: u64 args + // .get(1) + // .expect("An argument for 'callback' was not provided") + // .to_js_value()? + // .try_into()?; + + let closure = move || { + // TODO: Hook this up to the callback they passed + ic_cdk::println!("The timer was called!!!"); + }; + + let timer_id: ic_cdk_timers::TimerId = ic_cdk_timers::set_timer(delay, closure); + let timer_id_as_u64: u64 = timer_id.data().as_ffi(); + let timer_id_candid_encoded_bytes: JSValue = + candid::encode_one(timer_id_as_u64)?.into(); + to_qjs_value(&context, &timer_id_candid_encoded_bytes) } } } diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/main.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/main.rs index a8492c29d3..738f634124 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/main.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/main.rs @@ -147,7 +147,7 @@ fn main() -> Result<(), String> { let lib_file = quote! { #![allow(non_snake_case)] use quickjs_wasm_rs::{JSContextRef, JSValueRef, JSValue, from_qjs_value, to_qjs_value, CallbackArg}; - + use slotmap::Key; use std::cell::RefCell; use std::convert::TryInto; @@ -173,7 +173,7 @@ fn main() -> Result<(), String> { let _azle_init_name_js_value: JSValue = from_qjs_value(&_azle_init_name).unwrap(); _azle_init_name_js_value.try_into().unwrap() } else { "".to_string() }; - + CONTEXT.with(|ctx| { let mut ctx = ctx.borrow_mut(); *ctx = Some(context); From 58b261e150c782775e1f5d1cd87b843b1d8ffc43 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 17:36:37 -0600 Subject: [PATCH 14/23] Add rough setTimerInterval boilerplate Still needs to actually call the callback they passed in. --- .../src/ic/set_timer_interval.rs | 32 +++++++++++++++++-- src/lib_new/ic.ts | 23 +++++++++++-- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs index 9be86bb28c..f120af1458 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs @@ -6,10 +6,36 @@ pub fn generate() -> TokenStream { fn set_timer_interval<'a>( context: &'a JSContextRef, _this: &CallbackArg, - _args: &[CallbackArg], + args: &[CallbackArg], ) -> Result, anyhow::Error> { - // TODO: Implement set_timer_interval - context.undefined_value() + let candid_encoded_array_buffer: Vec = args + .get(0) + .expect("performanceCounter must have one argument") + .to_js_value()? + .try_into()?; + + let interval_as_u64: u64 = candid::decode_one(&candid_encoded_array_buffer)?; + + let interval = core::time::Duration::new(interval_as_u64, 0); + + // TODO: Get the callback they passed in somehow + + // let callback: u64 args + // .get(1) + // .expect("An argument for 'callback' was not provided") + // .to_js_value()? + // .try_into()?; + + let closure = move || { + // TODO: Hook this up to the callback they passed + ic_cdk::println!("Callback was called on an interval"); + }; + + let timer_id: ic_cdk_timers::TimerId = ic_cdk_timers::set_timer_interval(interval, closure); + let timer_id_as_u64: u64 = timer_id.data().as_ffi(); + let timer_id_candid_encoded_bytes: JSValue = + candid::encode_one(timer_id_as_u64)?.into(); + to_qjs_value(&context, &timer_id_candid_encoded_bytes) } } } diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 477a684abc..88be6c8725 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -714,10 +714,27 @@ export const ic: Ic = globalThis._azleIc IDL.encode([IDL.Nat64], [delay]) ).buffer; - const setTimerCandidBytes = - globalThis._azleIc.setTimer(delayCandidBytes); + const timerIdCandidBytes = globalThis._azleIc.setTimer( + delayCandidBytes, + callback + ); + + return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; + }, + setTimerInterval: ( + interval: nat64, + callback: () => void | Promise + ) => { + const intervalCandidBytes = new Uint8Array( + IDL.encode([IDL.Nat64], [interval]) + ).buffer; + + const timerIdCandidBytes = globalThis._azleIc.setTimerInterval( + intervalCandidBytes, + callback + ); - return IDL.decode([IDL.Nat64], setTimerCandidBytes)[0]; + return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; }, stableBytes: () => { return new Uint8Array(globalThis._azleIc.stableBytes()); From 6a6744d4b20b480a9c23bcfdc6ce4dc742f7ded0 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Thu, 7 Sep 2023 18:28:45 -0600 Subject: [PATCH 15/23] Attempt to hookup callback But it's an object not a function... ;( --- .../src/ic/set_timer.rs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs index 41c26c95eb..361e706479 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs @@ -20,15 +20,32 @@ pub fn generate() -> TokenStream { // TODO: Get the callback they passed in somehow - // let callback: u64 args - // .get(1) - // .expect("An argument for 'callback' was not provided") - // .to_js_value()? - // .try_into()?; + let callback: JSValue = args + .get(1) + .expect("An argument for 'callback' was not provided") + .to_js_value()?; let closure = move || { - // TODO: Hook this up to the callback they passed ic_cdk::println!("The timer was called!!!"); + + CONTEXT.with(|context| { + let mut context = context.borrow_mut(); + let context = context.as_mut().unwrap(); + + let callback_js_value_ref = to_qjs_value(&context, &callback).unwrap(); + + if callback_js_value_ref.is_function() { + ic_cdk::println!("and the callback seems to be a function..."); + } else { + ic_cdk::println!("BUT THE CALLBACK ISN'T A FUNCTION!!!"); + if callback_js_value_ref.is_object() { + ic_cdk::println!("Callback is an object"); + } + } + + // TODO I am not sure what the first parameter to call is supposed to be + callback_js_value_ref.call(&callback_js_value_ref, &[]).unwrap(); + }); }; let timer_id: ic_cdk_timers::TimerId = ic_cdk_timers::set_timer(delay, closure); From af316540c64f16f52bbd4b4813f2e03d42658193 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Fri, 8 Sep 2023 12:18:23 -0600 Subject: [PATCH 16/23] Get timers tests passing! --- .../src/ic/set_timer.rs | 26 ++++------ .../src/ic/set_timer_interval.rs | 29 +++++++---- src/lib_new/ic.ts | 49 +++++++++++++++---- 3 files changed, 69 insertions(+), 35 deletions(-) diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs index 361e706479..29ef3e885c 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs @@ -18,33 +18,27 @@ pub fn generate() -> TokenStream { let delay = core::time::Duration::new(delay_as_u64, 0); - // TODO: Get the callback they passed in somehow - - let callback: JSValue = args + let callback_id: String = args .get(1) .expect("An argument for 'callback' was not provided") - .to_js_value()?; + .to_js_value()? + .try_into()?; let closure = move || { - ic_cdk::println!("The timer was called!!!"); - CONTEXT.with(|context| { let mut context = context.borrow_mut(); let context = context.as_mut().unwrap(); - let callback_js_value_ref = to_qjs_value(&context, &callback).unwrap(); + let global = context.global_object().unwrap(); - if callback_js_value_ref.is_function() { - ic_cdk::println!("and the callback seems to be a function..."); - } else { - ic_cdk::println!("BUT THE CALLBACK ISN'T A FUNCTION!!!"); - if callback_js_value_ref.is_object() { - ic_cdk::println!("Callback is an object"); - } - } + let timer_callback = global.get_property(callback_id.as_str()).unwrap(); // TODO I am not sure what the first parameter to call is supposed to be - callback_js_value_ref.call(&callback_js_value_ref, &[]).unwrap(); + let callback_result = timer_callback.call(&timer_callback, &[]); + + if let Err(e) = callback_result { + ic_cdk::api::trap(e.to_string().as_str()) + } }); }; diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs index f120af1458..6e0c72dbaa 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs @@ -18,17 +18,28 @@ pub fn generate() -> TokenStream { let interval = core::time::Duration::new(interval_as_u64, 0); - // TODO: Get the callback they passed in somehow - - // let callback: u64 args - // .get(1) - // .expect("An argument for 'callback' was not provided") - // .to_js_value()? - // .try_into()?; + let callback_id: String = args + .get(1) + .expect("An argument for 'callback' was not provided") + .to_js_value()? + .try_into()?; let closure = move || { - // TODO: Hook this up to the callback they passed - ic_cdk::println!("Callback was called on an interval"); + CONTEXT.with(|context| { + let mut context = context.borrow_mut(); + let context = context.as_mut().unwrap(); + + let global = context.global_object().unwrap(); + + let timer_callback = global.get_property(callback_id.as_str()).unwrap(); + + // TODO I am not sure what the first parameter to call is supposed to be + let callback_result = timer_callback.call(&timer_callback, &[]); + + if let Err(e) = callback_result { + ic_cdk::api::trap(e.to_string().as_str()) + } + }); }; let timer_id: ic_cdk_timers::TimerId = ic_cdk_timers::set_timer_interval(interval, closure); diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 88be6c8725..514c80ba46 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -582,6 +582,7 @@ export const ic: Ic = globalThis._azleIc return IDL.decode([IDL.Nat64], canisterVersionCandidBytes)[0]; }, clearTimer: (timerId: nat64) => { + // TODO: We need to delete the callback from the global scope as well const timerIdCandidBytes = new Uint8Array( IDL.encode([IDL.Nat64], [timerId]) ).buffer; @@ -710,31 +711,59 @@ export const ic: Ic = globalThis._azleIc return globalThis._azleIc.setCertifiedData(dataBytes); }, setTimer: (delay: nat64, callback: () => void | Promise) => { + const timerCallbackId = `_timer_${v4()}`; + + globalThis[timerCallbackId] = () => { + try { + callback(); + } finally { + delete globalThis[timerCallbackId]; + } + }; + const delayCandidBytes = new Uint8Array( IDL.encode([IDL.Nat64], [delay]) ).buffer; - const timerIdCandidBytes = globalThis._azleIc.setTimer( - delayCandidBytes, - callback - ); + try { + const timerIdCandidBytes = globalThis._azleIc.setTimer( + delayCandidBytes, + timerCallbackId + ); - return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; + return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; + } catch (error) { + delete globalThis[timerCallbackId]; + } }, setTimerInterval: ( interval: nat64, callback: () => void | Promise ) => { + const timerCallbackId = `_interval_timer_${v4()}`; + + // We don't delete this even if the callback throws because + // it still needs to be here for the next tick + globalThis[timerCallbackId] = callback; + const intervalCandidBytes = new Uint8Array( IDL.encode([IDL.Nat64], [interval]) ).buffer; - const timerIdCandidBytes = globalThis._azleIc.setTimerInterval( - intervalCandidBytes, - callback - ); + try { + const timerIdCandidBytes = + globalThis._azleIc.setTimerInterval( + intervalCandidBytes, + timerCallbackId + ); - return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; + return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; + } catch (error) { + // TODO: If the rust code returns an error after registering + // the timer then we will be deleting the timer callback, + // which means the rust closure will error out. + delete globalThis[timerCallbackId]; + } }, stableBytes: () => { return new Uint8Array(globalThis._azleIc.stableBytes()); From 0cd809ceabb8e406d5fbf4464a91df30356b6a03 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Fri, 8 Sep 2023 13:08:29 -0600 Subject: [PATCH 17/23] Improve timers in non-happy-path cases --- .../src/ic/set_timer.rs | 15 ++++++++++++--- .../src/ic/set_timer_interval.rs | 18 ++++++++++++++---- src/lib_new/ic.ts | 5 ++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs index 29ef3e885c..91b033a3e7 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer.rs @@ -31,7 +31,9 @@ pub fn generate() -> TokenStream { let global = context.global_object().unwrap(); - let timer_callback = global.get_property(callback_id.as_str()).unwrap(); + let timer_callback = global + .get_property(callback_id.as_str()) + .unwrap_or_else(|e| ic_cdk::api::trap(e.to_string().as_str())); // TODO I am not sure what the first parameter to call is supposed to be let callback_result = timer_callback.call(&timer_callback, &[]); @@ -44,8 +46,15 @@ pub fn generate() -> TokenStream { let timer_id: ic_cdk_timers::TimerId = ic_cdk_timers::set_timer(delay, closure); let timer_id_as_u64: u64 = timer_id.data().as_ffi(); - let timer_id_candid_encoded_bytes: JSValue = - candid::encode_one(timer_id_as_u64)?.into(); + let timer_id_candid_encoded_bytes: JSValue = candid::encode_one(timer_id_as_u64) + .unwrap_or_else(|e| { + // If something goes wrong we need to clear the timer before + // throwing to the JS above. + ic_cdk_timers::clear_timer(timer_id); + ic_cdk::api::trap(e.to_string().as_str()); + }) + .into(); + to_qjs_value(&context, &timer_id_candid_encoded_bytes) } } diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs index 6e0c72dbaa..d9e4d06e9d 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/set_timer_interval.rs @@ -31,7 +31,9 @@ pub fn generate() -> TokenStream { let global = context.global_object().unwrap(); - let timer_callback = global.get_property(callback_id.as_str()).unwrap(); + let timer_callback = global + .get_property(callback_id.as_str()) + .unwrap_or_else(|e| ic_cdk::api::trap(e.to_string().as_str())); // TODO I am not sure what the first parameter to call is supposed to be let callback_result = timer_callback.call(&timer_callback, &[]); @@ -42,10 +44,18 @@ pub fn generate() -> TokenStream { }); }; - let timer_id: ic_cdk_timers::TimerId = ic_cdk_timers::set_timer_interval(interval, closure); + let timer_id: ic_cdk_timers::TimerId = + ic_cdk_timers::set_timer_interval(interval, closure); let timer_id_as_u64: u64 = timer_id.data().as_ffi(); - let timer_id_candid_encoded_bytes: JSValue = - candid::encode_one(timer_id_as_u64)?.into(); + let timer_id_candid_encoded_bytes: JSValue = candid::encode_one(timer_id_as_u64) + .unwrap_or_else(|e| { + // If something goes wrong we need to clear the timer before + // throwing to the JS above. + ic_cdk_timers::clear_timer(timer_id); + ic_cdk::api::trap(e.to_string().as_str()); + }) + .into(); + to_qjs_value(&context, &timer_id_candid_encoded_bytes) } } diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 514c80ba46..52336f14dd 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -734,6 +734,7 @@ export const ic: Ic = globalThis._azleIc return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; } catch (error) { delete globalThis[timerCallbackId]; + throw error; } }, setTimerInterval: ( @@ -759,10 +760,8 @@ export const ic: Ic = globalThis._azleIc return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; } catch (error) { - // TODO: If the rust code returns an error after registering - // the timer then we will be deleting the timer callback, - // which means the rust closure will error out. delete globalThis[timerCallbackId]; + throw error; } }, stableBytes: () => { From a6fb236702bf02c4e6669f10aade1e18613e2012 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Fri, 8 Sep 2023 13:24:27 -0600 Subject: [PATCH 18/23] Re-enable timers in CI/CD --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 640549a884..1a485ce6b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,7 +81,6 @@ # "examples/update" # These are the ones that don't work -# "examples/timers", # "examples/tuple_types", # "examples/stable_structures", # "examples/service", @@ -190,6 +189,7 @@ jobs: "examples/simple_erc20", "examples/simple_user_accounts", "examples/stable_memory", + "examples/timers", "examples/update" ] END From 0690ef3580b61a5d5c21ab444a2fe22cc4992973 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Fri, 8 Sep 2023 14:53:45 -0600 Subject: [PATCH 19/23] Fix memory leaks in clear_timer --- src/lib_new/globals.ts | 14 ++++++-- src/lib_new/ic.ts | 82 +++++++++++++++++++++++------------------- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/src/lib_new/globals.ts b/src/lib_new/globals.ts index fbedb5f58b..9c19760a0a 100644 --- a/src/lib_new/globals.ts +++ b/src/lib_new/globals.ts @@ -1,17 +1,25 @@ import { ic } from './ic'; import { Buffer } from 'buffer'; -declare var globalThis: { - TextDecoder: any; - TextEncoder: any; +export declare var globalThis: { _azleCandidInitParams: any[]; _azleCandidMethods: any[]; _azleCandidTypes: any[]; + Buffer: BufferConstructor; console: any; + crypto: { + getRandomValues: () => Uint8Array; + }; + icTimers: { + [key: string]: string; + }; + TextDecoder: any; + TextEncoder: any; }; globalThis.TextDecoder = require('text-encoding').TextDecoder; globalThis.TextEncoder = require('text-encoding').TextEncoder; +globalThis.icTimers ||= {}; globalThis.console = { ...globalThis.console, diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 52336f14dd..8cc1aad354 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -582,12 +582,17 @@ export const ic: Ic = globalThis._azleIc return IDL.decode([IDL.Nat64], canisterVersionCandidBytes)[0]; }, clearTimer: (timerId: nat64) => { - // TODO: We need to delete the callback from the global scope as well - const timerIdCandidBytes = new Uint8Array( - IDL.encode([IDL.Nat64], [timerId]) - ).buffer; + const encode = (value: nat64) => { + return new Uint8Array(IDL.encode([IDL.Nat64], [value])) + .buffer; + }; + + globalThis._azleIc.clearTimer(encode(timerId)); + + const timerCallbackId = globalThis.icTimers[timerId.toString()]; - return globalThis._azleIc.clearTimer(timerIdCandidBytes); + delete globalThis.icTimers[timerId.toString()]; + delete globalThis[timerCallbackId]; }, dataCertificate: () => { const rawRustValue: ArrayBuffer | undefined = @@ -711,58 +716,63 @@ export const ic: Ic = globalThis._azleIc return globalThis._azleIc.setCertifiedData(dataBytes); }, setTimer: (delay: nat64, callback: () => void | Promise) => { + const encode = (value: nat64) => { + return new Uint8Array(IDL.encode([IDL.Nat64], [value])) + .buffer; + }; + + const decode = (value: ArrayBufferLike) => { + return BigInt(IDL.decode([IDL.Nat64], value)[0] as number); + }; + const timerCallbackId = `_timer_${v4()}`; + const timerId = decode( + globalThis._azleIc.setTimer(encode(delay), timerCallbackId) + ); + + globalThis.icTimers[timerId.toString()] = timerCallbackId; + globalThis[timerCallbackId] = () => { try { callback(); } finally { + delete globalThis.icTimers[timerId.toString()]; delete globalThis[timerCallbackId]; } }; - const delayCandidBytes = new Uint8Array( - IDL.encode([IDL.Nat64], [delay]) - ).buffer; - - try { - const timerIdCandidBytes = globalThis._azleIc.setTimer( - delayCandidBytes, - timerCallbackId - ); - - return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; - } catch (error) { - delete globalThis[timerCallbackId]; - throw error; - } + return timerId; }, setTimerInterval: ( interval: nat64, callback: () => void | Promise ) => { + const encode = (value: nat64) => { + return new Uint8Array(IDL.encode([IDL.Nat64], [value])) + .buffer; + }; + + const decode = (value: ArrayBufferLike) => { + return BigInt(IDL.decode([IDL.Nat64], value)[0] as number); + }; + const timerCallbackId = `_interval_timer_${v4()}`; + const timerId = decode( + globalThis._azleIc.setTimerInterval( + encode(interval), + timerCallbackId + ) + ); + + globalThis.icTimers[timerId.toString()] = timerCallbackId; + // We don't delete this even if the callback throws because // it still needs to be here for the next tick globalThis[timerCallbackId] = callback; - const intervalCandidBytes = new Uint8Array( - IDL.encode([IDL.Nat64], [interval]) - ).buffer; - - try { - const timerIdCandidBytes = - globalThis._azleIc.setTimerInterval( - intervalCandidBytes, - timerCallbackId - ); - - return IDL.decode([IDL.Nat64], timerIdCandidBytes)[0]; - } catch (error) { - delete globalThis[timerCallbackId]; - throw error; - } + return timerId; }, stableBytes: () => { return new Uint8Array(globalThis._azleIc.stableBytes()); From 2ed552fb51121e40ceb8c1828d0b326175645943 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Fri, 8 Sep 2023 17:30:05 -0600 Subject: [PATCH 20/23] Rename entry points --- .../rejections/{rejections.did => index.did} | 0 .../rejections/{rejections.ts => index.ts} | 0 .../some_service/{some_service.did => index.did} | 0 .../canisters/some_service/some_service.ts | 16 ---------------- examples/rejections/dfx.json | 8 ++++---- 5 files changed, 4 insertions(+), 20 deletions(-) rename examples/rejections/canisters/rejections/{rejections.did => index.did} (100%) rename examples/rejections/canisters/rejections/{rejections.ts => index.ts} (100%) rename examples/rejections/canisters/some_service/{some_service.did => index.did} (100%) delete mode 100644 examples/rejections/canisters/some_service/some_service.ts diff --git a/examples/rejections/canisters/rejections/rejections.did b/examples/rejections/canisters/rejections/index.did similarity index 100% rename from examples/rejections/canisters/rejections/rejections.did rename to examples/rejections/canisters/rejections/index.did diff --git a/examples/rejections/canisters/rejections/rejections.ts b/examples/rejections/canisters/rejections/index.ts similarity index 100% rename from examples/rejections/canisters/rejections/rejections.ts rename to examples/rejections/canisters/rejections/index.ts diff --git a/examples/rejections/canisters/some_service/some_service.did b/examples/rejections/canisters/some_service/index.did similarity index 100% rename from examples/rejections/canisters/some_service/some_service.did rename to examples/rejections/canisters/some_service/index.did diff --git a/examples/rejections/canisters/some_service/some_service.ts b/examples/rejections/canisters/some_service/some_service.ts deleted file mode 100644 index 0ad6a9c9e9..0000000000 --- a/examples/rejections/canisters/some_service/some_service.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { empty, ic, Manual, $query } from 'azle'; - -$query; -export function accept(): boolean { - return true; -} - -$query; -export function error(): Manual { - // This errors because neither ic.reject nor ic.reply were called -} - -$query; -export function reject(message: string): Manual { - ic.reject(message); -} diff --git a/examples/rejections/dfx.json b/examples/rejections/dfx.json index 84c5ae6573..0326e4c996 100644 --- a/examples/rejections/dfx.json +++ b/examples/rejections/dfx.json @@ -4,8 +4,8 @@ "type": "custom", "build": "npx azle rejections", "root": "canisters/rejections", - "ts": "canisters/rejections/rejections.ts", - "candid": "canisters/rejections/rejections.did", + "ts": "canisters/rejections/index.ts", + "candid": "canisters/rejections/index.did", "wasm": ".azle/rejections/rejections.wasm.gz", "declarations": { "output": "test/dfx_generated/rejections", @@ -17,8 +17,8 @@ "type": "custom", "build": "npx azle some_service", "root": "canisters/some_service", - "ts": "canisters/some_service/some_service.ts", - "candid": "canisters/some_service/some_service.did", + "ts": "canisters/some_service/index.ts", + "candid": "canisters/some_service/index.did", "wasm": ".azle/some_service/some_service.wasm.gz", "declarations": { "output": "test/dfx_generated/some_service", From dbea089781a956d46d2fd07d16fe4b6bd47dfc28 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Fri, 8 Sep 2023 17:30:43 -0600 Subject: [PATCH 21/23] Update syntax --- .../rejections/canisters/rejections/index.ts | 80 +++++++++++-------- .../canisters/some_service/index.ts | 31 +++---- 2 files changed, 63 insertions(+), 48 deletions(-) diff --git a/examples/rejections/canisters/rejections/index.ts b/examples/rejections/canisters/rejections/index.ts index f271ba09c5..2f836634f9 100644 --- a/examples/rejections/canisters/rejections/index.ts +++ b/examples/rejections/canisters/rejections/index.ts @@ -1,49 +1,63 @@ import { - CallResult, ic, Principal, RejectionCode, Service, - serviceUpdate, - $update + text, + update, + Void } from 'azle'; -import { someService } from '../some_service'; +import { default as SomeService } from '../some_service'; class Nonexistent extends Service { - @serviceUpdate - method: () => CallResult; + @update([], Void) + method: () => Void; } -export const nonexistentCanister = new Nonexistent( - Principal.fromText('rkp4c-7iaaa-aaaaa-aaaca-cai') -); +export default class extends Service { + nonexistentCanister = new Nonexistent( + Principal.fromText('rkp4c-7iaaa-aaaaa-aaaca-cai') + ); -$update; -export async function getRejectionCodeNoError(): Promise { - await someService.accept().call(); - return ic.rejectCode(); -} + someService = new SomeService( + Principal.fromText( + process.env.SOME_SERVICE_PRINCIPAL ?? + ic.trap('process.env.SOME_SERVICE_PRINCIPAL is undefined') + ) + ); -$update; -export async function getRejectionCodeDestinationInvalid(): Promise { - await nonexistentCanister.method().call(); - return ic.rejectCode(); -} + @update([], RejectionCode) + async getRejectionCodeNoError(): Promise { + await ic.call(this.someService.accept); -$update; -export async function getRejectionCodeCanisterReject(): Promise { - await someService.reject('reject').call(); - return ic.rejectCode(); -} + return ic.rejectCode(); + } -$update; -export async function getRejectionCodeCanisterError(): Promise { - await someService.error().call(); - return ic.rejectCode(); -} + @update([], RejectionCode) + async getRejectionCodeDestinationInvalid(): Promise { + await ic.call(this.nonexistentCanister.method); + + return ic.rejectCode(); + } + + @update([], RejectionCode) + async getRejectionCodeCanisterReject(): Promise { + await ic.call(this.someService.reject, { args: ['reject'] }); + + return ic.rejectCode(); + } + + @update([], RejectionCode) + async getRejectionCodeCanisterError(): Promise { + await ic.call(this.someService.error); + + return ic.rejectCode(); + } + + @update([text], text) + async getRejectionMessage(message: text): Promise { + await ic.call(this.someService.reject, { args: [message] }); -$update; -export async function getRejectionMessage(message: string): Promise { - await someService.reject(message).call(); - return ic.rejectMessage(); + return ic.rejectMessage(); + } } diff --git a/examples/rejections/canisters/some_service/index.ts b/examples/rejections/canisters/some_service/index.ts index 6260886690..03b309adfa 100644 --- a/examples/rejections/canisters/some_service/index.ts +++ b/examples/rejections/canisters/some_service/index.ts @@ -1,19 +1,20 @@ -import { CallResult, empty, ic, Principal, Service, serviceQuery } from 'azle'; +import { bool, empty, ic, query, Service, text } from 'azle'; -export class SomeService extends Service { - @serviceQuery - reject: (message: string) => CallResult; +type Manual = void; - @serviceQuery - accept: () => CallResult; +export default class extends Service { + @query([text], empty, { manual: true }) + reject(message: text): Manual { + ic.reject(message); + } - @serviceQuery - error: () => CallResult; -} + @query([], bool) + accept(): bool { + return true; + } -export const someService = new SomeService( - Principal.fromText( - process.env.SOME_SERVICE_PRINCIPAL ?? - ic.trap('process.env.SOME_SERVICE_PRINCIPAL is undefined') - ) -); + @query([], empty, { manual: true }) + error(): Manual { + // This errors because neither ic.reject nor ic.reply were called + } +} From cc78f4530358f002466c24e27af7eebe3ba3c006 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Mon, 11 Sep 2023 12:34:21 -0600 Subject: [PATCH 22/23] Implement reject_code --- .github/workflows/test.yml | 2 +- .../rejections/canisters/rejections/index.did | 27 +++++++-------- .../rejections/canisters/rejections/index.ts | 16 ++++++--- .../canisters/some_service/index.did | 10 +++--- .../src/ic/mod.rs | 4 +++ .../src/ic/reject_code.rs | 28 ++++++++++++++++ src/lib_new/ic.ts | 33 +++++++++++++++++++ 7 files changed, 94 insertions(+), 26 deletions(-) create mode 100644 src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/reject_code.rs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a485ce6b0..5736c1c27d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -86,7 +86,6 @@ # "examples/service", # "examples/outgoing_http_requests", # "examples/pre_and_post_upgrade", -# "examples/rejections", # "examples/robust_imports", # "examples/run_time_errors", # "examples/rust_type_conversions", @@ -186,6 +185,7 @@ jobs: "examples/principal", "examples/query", "examples/randomness", + "examples/rejections", "examples/simple_erc20", "examples/simple_user_accounts", "examples/stable_memory", diff --git a/examples/rejections/canisters/rejections/index.did b/examples/rejections/canisters/rejections/index.did index dfb1473040..e988a2ebb0 100644 --- a/examples/rejections/canisters/rejections/index.did +++ b/examples/rejections/canisters/rejections/index.did @@ -1,16 +1,11 @@ -type ManualReply = variant { - NoError; - CanisterError; - SysTransient; - DestinationInvalid; - Unknown; - SysFatal; - CanisterReject; -}; -service : () -> { - getRejectionCodeCanisterError : () -> (ManualReply); - getRejectionCodeCanisterReject : () -> (ManualReply); - getRejectionCodeDestinationInvalid : () -> (ManualReply); - getRejectionCodeNoError : () -> (ManualReply); - getRejectionMessage : (text) -> (text); -} \ No newline at end of file +type rec_0 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; +type rec_1 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; +type rec_2 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; +type rec_3 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; +service: () -> { + getRejectionCodeNoError: () -> (rec_0); + getRejectionCodeDestinationInvalid: () -> (rec_1); + getRejectionCodeCanisterReject: () -> (rec_2); + getRejectionCodeCanisterError: () -> (rec_3); + getRejectionMessage: (text) -> (text); +} diff --git a/examples/rejections/canisters/rejections/index.ts b/examples/rejections/canisters/rejections/index.ts index 2f836634f9..d6812446da 100644 --- a/examples/rejections/canisters/rejections/index.ts +++ b/examples/rejections/canisters/rejections/index.ts @@ -35,28 +35,36 @@ export default class extends Service { @update([], RejectionCode) async getRejectionCodeDestinationInvalid(): Promise { - await ic.call(this.nonexistentCanister.method); + try { + await ic.call(this.nonexistentCanister.method); + } catch (error) {} return ic.rejectCode(); } @update([], RejectionCode) async getRejectionCodeCanisterReject(): Promise { - await ic.call(this.someService.reject, { args: ['reject'] }); + try { + await ic.call(this.someService.reject, { args: ['reject'] }); + } catch (error) {} return ic.rejectCode(); } @update([], RejectionCode) async getRejectionCodeCanisterError(): Promise { - await ic.call(this.someService.error); + try { + await ic.call(this.someService.error); + } catch (error) {} return ic.rejectCode(); } @update([text], text) async getRejectionMessage(message: text): Promise { - await ic.call(this.someService.reject, { args: [message] }); + try { + await ic.call(this.someService.reject, { args: [message] }); + } catch (error) {} return ic.rejectMessage(); } diff --git a/examples/rejections/canisters/some_service/index.did b/examples/rejections/canisters/some_service/index.did index 19b538a628..c6fa73bb53 100644 --- a/examples/rejections/canisters/some_service/index.did +++ b/examples/rejections/canisters/some_service/index.did @@ -1,5 +1,5 @@ -service : () -> { - accept : () -> (bool) query; - error : () -> (empty) query; - reject : (text) -> (empty) query; -} \ No newline at end of file +service: () -> { + reject: (text) -> (empty) query; + accept: () -> (bool) query; + error: () -> (empty) query; +} diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs index 09b5764672..3a1e17d789 100644 --- a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/mod.rs @@ -28,6 +28,7 @@ mod notify_raw; mod performance_counter; mod print; mod reject; +mod reject_code; mod reject_message; mod reply_raw; mod set_certified_data; @@ -73,6 +74,7 @@ pub fn generate() -> TokenStream { let performance_counter = performance_counter::generate(); let print = print::generate(); let reject = reject::generate(); + let reject_code = reject_code::generate(); let reject_message = reject_message::generate(); let reply_raw = reply_raw::generate(); let set_certified_data = set_certified_data::generate(); @@ -118,6 +120,7 @@ pub fn generate() -> TokenStream { #performance_counter #print #reject + #reject_code #reject_message #reply_raw #set_certified_data @@ -164,6 +167,7 @@ pub fn generate() -> TokenStream { ic.set_property("performanceCounter", context.wrap_callback2(performance_counter).unwrap()).unwrap(); ic.set_property("print", context.wrap_callback2(print).unwrap()).unwrap(); ic.set_property("reject", context.wrap_callback2(reject).unwrap()).unwrap(); + ic.set_property("rejectCode", context.wrap_callback2(reject_code).unwrap()).unwrap(); ic.set_property("rejectMessage", context.wrap_callback2(reject_message).unwrap()).unwrap(); ic.set_property("replyRaw", context.wrap_callback2(reply_raw).unwrap()).unwrap(); ic.set_property("setCertifiedData", context.wrap_callback2(set_certified_data).unwrap()).unwrap(); diff --git a/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/reject_code.rs b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/reject_code.rs new file mode 100644 index 0000000000..f439dd8b1c --- /dev/null +++ b/src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/reject_code.rs @@ -0,0 +1,28 @@ +use proc_macro2::TokenStream; +use quote::quote; + +pub fn generate() -> TokenStream { + quote! { + fn reject_code<'a>( + context: &'a JSContextRef, + _this: &CallbackArg, + _args: &[CallbackArg], + ) -> Result, anyhow::Error> { + let reject_code = ic_cdk::api::call::reject_code(); + + let reject_code_as_u8 = match reject_code { + ic_cdk::api::call::RejectionCode::NoError => 0, + ic_cdk::api::call::RejectionCode::SysFatal => 1, + ic_cdk::api::call::RejectionCode::SysTransient => 2, + ic_cdk::api::call::RejectionCode::DestinationInvalid => 3, + ic_cdk::api::call::RejectionCode::CanisterReject => 4, + ic_cdk::api::call::RejectionCode::CanisterError => 5, + ic_cdk::api::call::RejectionCode::Unknown => 6, + }; + + let reject_code_as_js_value: JSValue = reject_code_as_u8.into(); + + to_qjs_value(&context, &reject_code_as_js_value) + } + } +} diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 8cc1aad354..e9d5048241 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -2,6 +2,7 @@ import { Nat64 } from '@dfinity/candid/lib/esm/idl'; // Note: Importing IDL from import { Principal } from '@dfinity/principal'; import { IDL } from './index'; import { blob, nat, nat32, nat64, Void, Opt } from './primitives'; +import { RejectionCode } from './system_types'; import { v4 } from 'uuid'; import { CandidClass, toCandidClass } from './utils'; @@ -251,6 +252,13 @@ type Ic = { */ reject: (message: string) => void; + /** + * Returns the rejection code from the most recently executed cross-canister + * call + * @returns the rejection code + */ + rejectCode: () => RejectionCode; + /** * Returns the rejection message from the most recently executed * cross-canister call @@ -694,6 +702,30 @@ export const ic: Ic = globalThis._azleIc return IDL.decode([IDL.Nat64], performanceCounterCandidBytes)[0]; }, + rejectCode: () => { + const rejectCodeNumber = globalThis._azleIc.rejectCode(); + + switch (rejectCodeNumber) { + case 0: + return { NoError: null }; + case 1: + return { SysFatal: null }; + case 2: + return { SysTransient: null }; + case 3: + return { DestinationInvalid: null }; + case 4: + return { CanisterReject: null }; + case 5: + return { CanisterError: null }; + case 6: + return { Unknown: null }; + default: + throw Error( + `Unknown rejection code: ${rejectCodeNumber}` + ); + } + }, reply: (reply: any, type: CandidClass): void => { if (Array.isArray(type) && type.length === 0) { // return type is void @@ -871,6 +903,7 @@ export const ic: Ic = globalThis._azleIc performanceCounter: () => {}, print: () => {}, reject: () => {}, + rejectCode: () => {}, rejectMessage: () => {}, reply: () => {}, replyRaw: () => {}, From 3bfdc21072cbec3e6573adf3dd4bf716a9b5f21f Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Mon, 11 Sep 2023 13:40:42 -0600 Subject: [PATCH 23/23] Fix ic_api example --- .github/workflows/test.yml | 2 +- examples/ic_api/src/index.ts | 16 ++-------------- examples/ic_api/test/tests.ts | 2 +- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5736c1c27d..592b26d581 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,7 +96,6 @@ # "examples/func_types", # "examples/generics", # "examples/guard_functions", -# "examples/ic_api", # "examples/inline_types", # "examples/motoko_examples/http_counter", # "examples/motoko_examples/persistent-storage", @@ -159,6 +158,7 @@ jobs: "examples/cycles", "examples/date", "examples/heartbeat", + "examples/ic_api", "examples/imports", "examples/init", "examples/inspect_message", diff --git a/examples/ic_api/src/index.ts b/examples/ic_api/src/index.ts index 357e892714..31cf2bc361 100644 --- a/examples/ic_api/src/index.ts +++ b/examples/ic_api/src/index.ts @@ -3,6 +3,7 @@ import { empty, ic, int8, + Manual, nat, nat32, nat64, @@ -17,17 +18,6 @@ import { Void } from 'azle'; -// TODO: Actually implement manual. See https://github.com/demergent-labs/azle/issues/1200 -type Manual = Void; - -function manual( - _target: Service, - _name: string, - descriptor: PropertyDescriptor -): any { - return descriptor; -} - // TODO: See https://github.com/demergent-labs/azle/issues/496 // type ArgDataMultipleParamsResult = { // blob: blob; @@ -148,9 +138,7 @@ export default class extends Service { return true; } - // TODO: See https://github.com/demergent-labs/azle/issues/1200 - // @manual - @query([text], empty) + @query([text], empty, { manual: true }) reject(message: text): Manual { ic.reject(message); } diff --git a/examples/ic_api/test/tests.ts b/examples/ic_api/test/tests.ts index 57995c71ae..f7aab58c1c 100644 --- a/examples/ic_api/test/tests.ts +++ b/examples/ic_api/test/tests.ts @@ -156,7 +156,7 @@ export function getTests(icApiCanister: ActorSubclass<_SERVICE>): Test[] { const result = await icApiCanister.canisterVersion(); return { - Ok: result > 0n + Ok: result >= 0n }; } },