diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bdf8786de..9941c907e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,6 @@ # "examples/func_types", # "examples/generics", # "examples/ledger_canister", -# "examples/manual_reply", # "examples/motoko_examples/calc", # "examples/motoko_examples/counter", # "examples/motoko_examples/echo", @@ -113,6 +112,7 @@ jobs: "examples/key_value_store", "examples/list_of_lists", "examples/management_canister", + "examples/manual_reply", "examples/primitive_types", "examples/principal", "examples/query", diff --git a/examples/manual_reply/dfx.json b/examples/manual_reply/dfx.json index baaa659511..4e5a1672ce 100644 --- a/examples/manual_reply/dfx.json +++ b/examples/manual_reply/dfx.json @@ -4,8 +4,8 @@ "type": "custom", "build": "npx azle manual_reply", "root": "src", - "ts": "src/manual_reply.ts", - "candid": "src/manual_reply.did", + "ts": "src/index.ts", + "candid": "src/index.did", "wasm": ".azle/manual_reply/manual_reply.wasm", "gzip": true, "declarations": { diff --git a/examples/manual_reply/package-lock.json b/examples/manual_reply/package-lock.json index 40bb4d516e..7c3e564f14 100644 --- a/examples/manual_reply/package-lock.json +++ b/examples/manual_reply/package-lock.json @@ -8,9 +8,9 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.15.4", - "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": { @@ -33,226 +33,54 @@ } }, "node_modules/@dfinity/agent": { - "version": "0.15.4", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.15.4.tgz", - "integrity": "sha512-JuWaLUUtdGJx2DwHgnGrtTNwF5bC6a+izMbcHeN2M0RSaukeVNkRdYz4Bfxg7yTwdFxQRfQWcXcwvKF8/R2IEg==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.19.2.tgz", + "integrity": "sha512-KLRWEjeU9SyyaS7IBVJ9ZUcufxufr55e/kRIyClK157+0pkTG9a8xKjUIMx3QzKvLsqqzXL238nWwdoP6jAD8g==", "dev": true, "dependencies": { + "@noble/hashes": "^1.3.1", "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.15.4", - "@dfinity/principal": "^0.15.4" - } - }, - "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==", - "dev": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "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==", - "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" + "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.15.4", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.15.4.tgz", - "integrity": "sha512-ImoZ18i95DDstn+EXm/Y1ms7RqF1KVS7+KqZLNvpHFTlcOgfAQc5Bq8W6l1nfkOqeh7wcehDYdjFJwLxBoeTlw==", - "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.15.4", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.15.4.tgz", - "integrity": "sha512-ZH0InIXaIQqXfUDgkSa0S+9VlkAduhu2JJ984KtRs3BSHUyxG32OGnRcvxfJDdm6GHXWndTWoQUraHPoA3RplQ==", - "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==", + "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": { - "@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==", - "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 +93,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", @@ -650,9 +490,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": "*" @@ -1192,12 +1032,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 +1048,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": { @@ -1234,17 +1074,29 @@ } } }, + "node_modules/ts-node/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, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, "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": { @@ -1291,150 +1143,45 @@ } }, "@dfinity/agent": { - "version": "0.15.4", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.15.4.tgz", - "integrity": "sha512-JuWaLUUtdGJx2DwHgnGrtTNwF5bC6a+izMbcHeN2M0RSaukeVNkRdYz4Bfxg7yTwdFxQRfQWcXcwvKF8/R2IEg==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.19.2.tgz", + "integrity": "sha512-KLRWEjeU9SyyaS7IBVJ9ZUcufxufr55e/kRIyClK157+0pkTG9a8xKjUIMx3QzKvLsqqzXL238nWwdoP6jAD8g==", "dev": true, "requires": { + "@noble/hashes": "^1.3.1", "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" - } - } + "simple-cbor": "^0.4.1" } }, "@dfinity/candid": { - "version": "0.15.4", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.15.4.tgz", - "integrity": "sha512-ImoZ18i95DDstn+EXm/Y1ms7RqF1KVS7+KqZLNvpHFTlcOgfAQc5Bq8W6l1nfkOqeh7wcehDYdjFJwLxBoeTlw==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.19.2.tgz", + "integrity": "sha512-X2hCqNMhnnmwtnOc0WnymOZYx3qphjEMuSYbBr7tMIkV7Hwt9BmXXlLnQTxUytTPxf+3he0GcS3KzsSQ9CK8ew==", "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" - } - } - } + "requires": {} }, "@dfinity/principal": { - "version": "0.15.4", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.15.4.tgz", - "integrity": "sha512-ZH0InIXaIQqXfUDgkSa0S+9VlkAduhu2JJ984KtRs3BSHUyxG32OGnRcvxfJDdm6GHXWndTWoQUraHPoA3RplQ==", + "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, "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" - } - } + "@noble/hashes": "^1.3.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==", + "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 }, "@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 }, "@jridgewell/trace-mapping": { @@ -1447,6 +1194,12 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@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 + }, "@swc/core": { "version": "1.2.151", "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.151.tgz", @@ -1650,9 +1403,9 @@ "dev": true }, "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 }, "borc": { @@ -1943,12 +1696,12 @@ } }, "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, "requires": { - "@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", @@ -1959,14 +1712,25 @@ "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" + }, + "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" + } + } } }, "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 }, "universalify": { diff --git a/examples/manual_reply/package.json b/examples/manual_reply/package.json index c66f61ec97..6bc660e4c9 100644 --- a/examples/manual_reply/package.json +++ b/examples/manual_reply/package.json @@ -7,8 +7,8 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.15.4", - "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/manual_reply/src/manual_reply.did b/examples/manual_reply/src/index.did similarity index 100% rename from examples/manual_reply/src/manual_reply.did rename to examples/manual_reply/src/index.did diff --git a/examples/manual_reply/src/index.ts b/examples/manual_reply/src/index.ts new file mode 100644 index 0000000000..c1c2b6bcbc --- /dev/null +++ b/examples/manual_reply/src/index.ts @@ -0,0 +1,306 @@ +import { + blob, + bool, + float32, + ic, + int, + int8, + Manual, + nat, + nat8, + Null, + query, + Record, + reserved, + Service, + text, + Tuple, + update, + Variant, + Vec, + Void +} from 'azle'; + +const Options = Variant({ + Small: Null, + Medium: Null, + Large: Null +}); + +const RawReply = Record({ + int: int, + text: text, + bool: bool, + myBlob: blob, + myVariant: Options +}); + +const Orbital = Record({ + layer: nat8, + electrons: nat8 +}); + +const Solid = Record({ + element: text +}); + +const Gas = Variant({ + Elemental: Null, + Mixed: Null, + Toxic: Null +}); + +const State = Variant({ + Gas: Gas, + Liquid: Null, + Solid: Solid +}); + +const Element = Record({ + id: text, + orbitals: Vec(Orbital), + state: State +}); + +export default Service({ + // Updates + manualUpdate: update( + [text], + Manual(text), + (message) => { + if (message === 'reject') { + ic.reject(message); + return; + } + + ic.reply(message, text); + }, + { manual: true } + ), + updateBlob: update( + [], + Manual(blob), + () => { + ic.reply( + new Uint8Array([83, 117, 114, 112, 114, 105, 115, 101, 33]), + blob + ); + }, + { manual: true } + ), + updateFloat32: update( + [], + Manual(float32), + () => { + ic.reply(1245.678, float32); + }, + { manual: true } + ), + updateInt8: update( + [], + Manual(int8), + () => { + ic.reply(-100, int8); + }, + { manual: true } + ), + updateNat: update( + [], + Manual(nat), + () => { + ic.reply(184467440737095516150n, nat); + }, + { manual: true } + ), + updateNull: update( + [], + Manual(Null), + () => { + ic.reply(null, Null); + }, + { manual: true } + ), + updateVoid: update( + [], + Void, + () => { + ic.reply(undefined, Void); + }, + { manual: true } + ), + updateRecord: update( + [], + Manual(Element), + () => { + const element: typeof Element = { + id: 'b0283eb7-9c0e-41e5-8089-3345e6a8fa6a', + orbitals: [ + { + electrons: 2, + layer: 1 + }, + { + electrons: 8, + layer: 2 + } + ], + state: { + Gas: { Elemental: null } + } + }; + ic.reply(element, Element); + }, + { manual: true } + ), + updateReserved: update( + [], + Manual(reserved), + () => { + ic.reply(undefined, reserved); + }, + { manual: true } + ), + updateString: update( + [], + Manual(text), + () => { + ic.reply('hello', text); + }, + { manual: true } + ), + updateVariant: update( + [], + Manual(Gas), + () => { + const gas = { Toxic: null }; + ic.reply(gas, Gas); + }, + { manual: true } + ), + replyRaw: update( + [], + Manual(RawReply), + () => { + ic.replyRaw( + ic.candidEncode( + '(record { "int" = 42; "text" = "text"; "bool" = true; "myBlob" = blob "Surprise!"; "myVariant" = variant { Medium } })' + ) + ); + }, + { manual: true } + ), + // Queries + manualQuery: query( + [text], + Manual(text), + (message) => { + if (message === 'reject') { + ic.reject(message); + return; + } + + ic.reply(message, text); + }, + { manual: true } + ), + queryBlob: query( + [], + Manual(blob), + () => { + ic.reply( + new Uint8Array([83, 117, 114, 112, 114, 105, 115, 101, 33]), + blob + ); + }, + { manual: true } + ), + queryFloat32: query( + [], + Manual(float32), + () => { + ic.reply(1245.678, float32); + }, + { manual: true } + ), + queryInt8: query( + [], + Manual(int8), + () => { + ic.reply(-100, int8); + }, + { manual: true } + ), + queryNat: query( + [], + Manual(nat), + () => { + ic.reply(184_467_440_737_095_516_150n, nat); + }, + { manual: true } + ), + queryNull: query( + [], + Manual(Null), + () => { + ic.reply(null, Null); + }, + { manual: true } + ), + queryVoid: query( + [], + Manual(Void), + () => { + ic.reply(undefined, Void); + }, + { manual: true } + ), + queryRecord: query( + [], + Manual(Element), + () => { + const element: typeof Element = { + id: 'b0283eb7-9c0e-41e5-8089-3345e6a8fa6a', + orbitals: [ + { + electrons: 2, + layer: 1 + }, + { + electrons: 8, + layer: 2 + } + ], + state: { + Gas: { Elemental: null } + } + }; + ic.reply(element, Element); + }, + { manual: true } + ), + queryReserved: query( + [], + Manual(reserved), + () => { + ic.reply(undefined, reserved); + }, + { manual: true } + ), + queryString: query( + [], + Manual(text), + () => { + ic.reply('hello', text); + }, + { manual: true } + ), + queryVariant: query( + [], + Manual(Gas), + () => { + const gas = { Toxic: null }; + ic.reply(gas, Gas); + }, + { manual: true } + ) +}); diff --git a/examples/manual_reply/src/manual_reply.ts b/examples/manual_reply/src/manual_reply.ts deleted file mode 100644 index 8d5a4268ee..0000000000 --- a/examples/manual_reply/src/manual_reply.ts +++ /dev/null @@ -1,271 +0,0 @@ -import { - blob, - bool, - candid, - float32, - ic, - int, - int8, - Manual, - nat, - nat8, - Null, - query, - Record, - reserved, - Service, - text, - Tuple, - update, - Variant, - Vec, - Void -} from 'azle'; - -class Options extends Variant { - @candid(Null) - Small?: Null; - - @candid(Null) - Medium?: Null; - - @candid(Null) - Large?: Null; -} - -class RawReply extends Record { - @candid(int) - int: int; - - @candid(text) - text: text; - - @candid(bool) - bool: bool; - - @candid(blob) - myBlob: blob; - - @candid(Options) - myVariant: Options; -} - -class Orbital extends Record { - @candid(nat8) - layer: nat8; - - @candid(nat8) - electrons: nat8; -} - -class Solid extends Record { - @candid(text) - element: text; -} - -class Gas extends Variant { - @candid(Null) - Elemental?: Null; - - @candid(Null) - Mixed?: Null; - - @candid(Null) - Toxic?: Null; -} - -class State extends Variant { - @candid(Gas) - Gas?: Gas; - - @candid(Null) - Liquid?: Null; - - @candid(Solid) - Solid?: Solid; -} - -class Element extends Record { - @candid(text) - id: text; - - @candid(Vec(Orbital)) - orbitals: Vec; - - @candid(State) - state: State; -} - -export default class extends Service { - // Updates - @update([text], text, { manual: true }) - manualUpdate(message: text): Manual { - if (message === 'reject') { - ic.reject(message); - return; - } - - ic.reply(message, text); - } - - @update([], blob, { manual: true }) - updateBlob(): Manual { - ic.reply( - new Uint8Array([83, 117, 114, 112, 114, 105, 115, 101, 33]), - blob - ); - } - - @update([], float32, { manual: true }) - updateFloat32(): Manual { - ic.reply(1245.678, float32); - } - - @update([], int8, { manual: true }) - updateInt8(): Manual { - ic.reply(-100, int8); - } - - @update([], nat, { manual: true }) - updateNat(): Manual { - ic.reply(184467440737095516150n, nat); - } - - @update([], Null, { manual: true }) - updateNull(): Manual { - ic.reply(null, Null); - } - - @update([], Void, { manual: true }) - updateVoid(): Manual { - ic.reply(undefined, Void); - } - - @update([], Element, { manual: true }) - updateRecord(): Manual { - const element: Element = { - id: 'b0283eb7-9c0e-41e5-8089-3345e6a8fa6a', - orbitals: [ - { - electrons: 2, - layer: 1 - }, - { - electrons: 8, - layer: 2 - } - ], - state: { - Gas: { Elemental: null } - } - }; - ic.reply(element, Element); - } - - @update([], reserved, { manual: true }) - updateReserved(): Manual { - ic.reply(undefined, reserved); - } - - @update([], text, { manual: true }) - updateString(): Manual { - ic.reply('hello', text); - } - - @update([], Gas, { manual: true }) - updateVariant(): Manual { - const gas = { Toxic: null }; - ic.reply(gas, Gas); - } - - @update([], RawReply, { manual: true }) - replyRaw(): Manual { - ic.replyRaw( - ic.candidEncode( - '(record { "int" = 42; "text" = "text"; "bool" = true; "myBlob" = blob "Surprise!"; "myVariant" = variant { Medium } })' - ) - ); - } - - // Queries - - @query([text], text, { manual: true }) - manualQuery(message: text): Manual { - if (message === 'reject') { - ic.reject(message); - return; - } - - ic.reply(message, text); - } - - @query([], blob, { manual: true }) - queryBlob(): Manual { - ic.reply( - new Uint8Array([83, 117, 114, 112, 114, 105, 115, 101, 33]), - blob - ); - } - - @query([], float32, { manual: true }) - queryFloat32(): Manual { - ic.reply(1245.678, float32); - } - - @query([], int8, { manual: true }) - queryInt8(): Manual { - ic.reply(-100, int8); - } - - @query([], nat, { manual: true }) - queryNat(): Manual { - ic.reply(184_467_440_737_095_516_150n, nat); - } - - @query([], Null, { manual: true }) - queryNull(): Manual { - ic.reply(null, Null); - } - - @query([], Void, { manual: true }) - queryVoid(): Manual { - ic.reply(undefined, Void); - } - - @query([], Element, { manual: true }) - queryRecord(): Manual { - const element: Element = { - id: 'b0283eb7-9c0e-41e5-8089-3345e6a8fa6a', - orbitals: [ - { - electrons: 2, - layer: 1 - }, - { - electrons: 8, - layer: 2 - } - ], - state: { - Gas: { Elemental: null } - } - }; - ic.reply(element, Element); - } - - @query([], reserved, { manual: true }) - queryReserved(): Manual { - ic.reply(undefined, reserved); - } - - @query([], text, { manual: true }) - queryString(): Manual { - ic.reply('hello', text); - } - - @query([], Gas, { manual: true }) - queryVariant(): Manual { - const gas = { Toxic: null }; - ic.reply(gas, Gas); - } -} diff --git a/src/lib_functional/canister_methods/index.ts b/src/lib_functional/canister_methods/index.ts index faf00f9591..22c52b9591 100644 --- a/src/lib_functional/canister_methods/index.ts +++ b/src/lib_functional/canister_methods/index.ts @@ -100,15 +100,15 @@ export function executeMethod( ic.trap(error.toString()); }); } else { - // const encodeReadyResult = result === undefined ? [] : [result]; - const encodeReadyResult = returnCandid[0].map((idl: any) => { - return idl.accept(new EncodeVisitor(), { - js_class: returnIdl, - js_data: result + if (!manual) { + // const encodeReadyResult = result === undefined ? [] : [result]; + const encodeReadyResult = returnCandid[0].map((idl: any) => { + return idl.accept(new EncodeVisitor(), { + js_class: returnIdl, + js_data: result + }); }); - }); - if (!manual) { const encoded = IDL.encode( returnCandid[0] as any, encodeReadyResult diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index 07094b5b13..6fb7779b5f 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -5,6 +5,7 @@ import { blob, nat, nat32, nat64, AzleNat64, Void, Opt } from './primitives'; import { RejectionCode } from './system_types'; import { v4 } from 'uuid'; import { CandidClass, toIDLType } from './utils'; +import { EncodeVisitor } from './visitors/encode_decode'; // declare var globalThis: { // ic: Ic; @@ -727,15 +728,22 @@ export const ic: Ic = globalThis._azleIc ); } }, - reply: (reply: any, type: CandidClass): void => { + reply: (data: any, type: CandidClass): void => { if (Array.isArray(type) && type.length === 0) { // return type is void const bytes = new Uint8Array(IDL.encode([], [])).buffer; return globalThis._azleIc.replyRaw(bytes); } const idlType = toIDLType(type, []); - const bytes = new Uint8Array(IDL.encode([idlType], [reply])) - .buffer; + + const encodeReadyResult = idlType.accept(new EncodeVisitor(), { + js_class: type, + js_data: data + }); + + const bytes = new Uint8Array( + IDL.encode([idlType], [encodeReadyResult]) + ).buffer; return globalThis._azleIc.replyRaw(bytes); }, replyRaw: (replyBuffer: blob) => {