diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59e87cfd75..492e5d2a37 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,6 +65,7 @@ jobs: "examples/cross_canister_calls", "examples/cycles", "examples/date", + "examples/ethereum_json_rpc", "examples/func_types", "examples/generators", "examples/heartbeat", @@ -93,6 +94,7 @@ jobs: "examples/notify_raw", "examples/null_example", "examples/optional_types", + "examples/outgoing_http_requests", "examples/pre_and_post_upgrade", "examples/primitive_types", "examples/principal", @@ -125,6 +127,8 @@ jobs: basic-integration-tests: needs: release-candidate-deploy runs-on: ubuntu-latest + env: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} strategy: fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest matrix: @@ -174,7 +178,7 @@ jobs: run: npm link - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} working-directory: ${{ matrix.example_directories }} - run: dfx start --clean --background + run: dfx start --clean --background --enable-canister-http - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} shell: bash -l {0} working-directory: ${{ matrix.example_directories }} diff --git a/README.md b/README.md index 155df1e59f..2ec0816428 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Most of Azle's documentation is currently found in this README. The Azle Book, s - [Canister APIs](#canister-apis) - [Call APIs](#call-apis) - [Stable Memory](#stable-memory) +- [Special APIs](#special-apis) - [JS APIs](#js-apis) - [Feature Parity](#feature-parity) - [Benchmarks](#benchmarks) @@ -2293,6 +2294,50 @@ export function stable_write(offset: nat32, buf: blob): Update { } ``` +### Special APIs + +#### Outgoing HTTP Requests + +This feature is available in `dfx 0.11.0` with the `--enable-canister-http` flag but is not yet live on the IC. + +Examples: + +- [ethereum_json_rpc](/examples/ethereum_json_rpc) +- [outgoing_http_requests](/examples/outgoing_http_requests) + +```typescript +import { CanisterResult, ic, ok, Query, Update } from 'azle'; +import { HttpResponse, ManagementCanister } from 'azle/canisters/management'; + +export function* xkcd(): Update { + const max_response_bytes = 1_000n; + + // TODO this is just a hueristic for cost, might change when the feature is officially released: https://forum.dfinity.org/t/enable-canisters-to-make-http-s-requests/9670/130 + const cycle_cost_base = 400_000_000n; + const cycle_cost_per_byte = 300_000n; // TODO not sure on this exact cost + const cycle_cost_total = + cycle_cost_base + cycle_cost_per_byte * max_response_bytes; + + const http_result: CanisterResult = + yield ManagementCanister.http_request({ + url: `https://xkcd.com/642/info.0.json`, + max_response_bytes, + http_method: { + GET: null + }, + headers: [], + body: null, + transform_method_name: 'xkcd_transform' + }).with_cycles(cycle_cost_total); + + if (!ok(http_result)) { + ic.trap(http_result.err ?? 'http_result had an error'); + } + + return http_result.ok; +} +``` + ### JS APIs This section will describe various JS APIs that may need special explanation. diff --git a/canisters/management.ts b/canisters/management.ts index ea1df223a5..2021764869 100644 --- a/canisters/management.ts +++ b/canisters/management.ts @@ -14,8 +14,7 @@ // The original license for the DFINITY code can be found here: https://github.com/dfinity/ic/blob/master/LICENSE // This file contains derivative works licensed as MIT: https://github.com/demergent-labs/azle/blob/main/LICENSE -// TODO created based on this documentation: https://smartcontracts.org/docs/interface-spec/index.html#ic-candid -// TODO I would like to find the canonical did file in the ic repository +// Taken in part from: https://github.com/dfinity/interface-spec/blob/master/spec/ic.did import { blob, @@ -23,6 +22,7 @@ import { CanisterResult, ic, nat, + nat64, Opt, Principal, Variant @@ -124,6 +124,32 @@ export type ProvisionalTopUpCanisterArgs = { amount: nat; }; +export type HttpRequestArgs = { + url: string; + max_response_bytes: Opt; + http_method: HttpMethod; + headers: HttpHeader[]; + body: Opt; + transform_method_name: Opt; +}; + +export type HttpMethod = Variant<{ + GET: null; + HEAD: null; + POST: null; +}>; + +export type HttpHeader = { + name: string; + value: string; +}; + +export type HttpResponse = { + status: nat64; + headers: HttpHeader[]; + body: blob; +}; + export type Management = Canister<{ create_canister( args: CreateCanisterArgs @@ -139,6 +165,7 @@ export type Management = Canister<{ delete_canister(args: DeleteCanisterArgs): CanisterResult; deposit_cycles(args: DepositCyclesArgs): CanisterResult; raw_rand(): CanisterResult; + http_request(args: HttpRequestArgs): CanisterResult; provisional_create_canister_with_cycles( args: ProvisionalCreateCanisterWithCyclesArgs ): CanisterResult; @@ -147,6 +174,6 @@ export type Management = Canister<{ ): CanisterResult; }>; -export const ManagementCanister = ic.canisters.Management( +export const ManagementCanister: Management = ic.canisters.Management( Principal.fromText('aaaaa-aa') ); diff --git a/examples/ethereum_json_rpc/.gitignore b/examples/ethereum_json_rpc/.gitignore new file mode 100644 index 0000000000..9be9f489ef --- /dev/null +++ b/examples/ethereum_json_rpc/.gitignore @@ -0,0 +1,3 @@ +.dfx +node_modules +target diff --git a/examples/ethereum_json_rpc/dfx.json b/examples/ethereum_json_rpc/dfx.json new file mode 100644 index 0000000000..c31a005ee4 --- /dev/null +++ b/examples/ethereum_json_rpc/dfx.json @@ -0,0 +1,15 @@ +{ + "canisters": { + "ethereum_json_rpc": { + "type": "custom", + "build": "npx azle ethereum_json_rpc", + "root": "src", + "ts": "src/index.ts", + "candid": "src/index.did", + "wasm": "target/wasm32-unknown-unknown/release/ethereum_json_rpc.wasm", + "declarations": { + "output": "test/dfx_generated/ethereum_json_rpc" + } + } + } +} diff --git a/examples/ethereum_json_rpc/package-lock.json b/examples/ethereum_json_rpc/package-lock.json new file mode 100644 index 0000000000..da39e29468 --- /dev/null +++ b/examples/ethereum_json_rpc/package-lock.json @@ -0,0 +1,1735 @@ +{ + "name": "ethereum_json_rpc", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "azle": "0.5.0", + "decode-utf8": "^1.0.1", + "encode-utf8": "^2.0.0" + }, + "devDependencies": { + "@dfinity/agent": "0.11.1", + "ts-node": "10.7.0", + "typescript": "4.6.3" + } + }, + "node_modules/@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==", + "engines": { + "node": ">= 12" + } + }, + "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.11.1", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.11.1.tgz", + "integrity": "sha512-Z1zw8l3d+AG3uu7d8G/Rd9Q5MWT9gB+Cori/Rqb6IjSEribRhL36ulCSkDYZJU/dhqSUp1VlvX5u51+wgv+MLg==", + "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" + }, + "peerDependencies": { + "@dfinity/candid": "^0.11.1", + "@dfinity/principal": "^0.11.1" + } + }, + "node_modules/@dfinity/candid": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.11.1.tgz", + "integrity": "sha512-EYZZg+x7OgZxa56D9SWMeTlaMb09HJ7wIfL42+l/e0lgrx+sTXYxKe8bM9FrUW9AWo9/gKkOGV/IxJL/Acncng==", + "dev": true, + "peer": true + }, + "node_modules/@dfinity/principal": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", + "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + }, + "node_modules/@swc/core": { + "version": "1.2.151", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.151.tgz", + "integrity": "sha512-oHgqKwK/Djv765zUHPiGqfMCaKIxXTgQyyCUBKLBQfAJwe/7FVobQ2fghBp4FsZA/NE1LZBmMPpRZNQwlGjeHw==", + "bin": { + "swcx": "run_swcx.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@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" + } + }, + "node_modules/@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==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", + "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==" + }, + "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==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", + "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + }, + "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==" + }, + "node_modules/@types/node": { + "version": "17.0.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", + "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", + "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==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/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==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/azle": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/azle/-/azle-0.5.0.tgz", + "integrity": "sha512-W34rmQr3oUsbYxT/EMdl6qCXhKTk4iJNF031huhqhl3FJShhi+k5q/3pgcPRkIBr5YbyxmzP9pYwDQWembxf5A==", + "dependencies": { + "@dfinity/principal": "0.11.2", + "@swc/core": "1.2.151", + "azle": "^0.3.0", + "azle-syn": "0.0.0", + "esbuild": "0.14.25", + "fs-extra": "10.0.1", + "hash.js": "1.1.7", + "js-sha256": "0.9.0", + "ts-node": "10.3.1", + "typescript": "4.4.4" + }, + "bin": { + "azle": "bin.js" + } + }, + "node_modules/azle-syn": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/azle-syn/-/azle-syn-0.0.0.tgz", + "integrity": "sha512-fWExJb5/hOEJOuBQ8hMMHRs9WryYeLLa9/ydqPWxbwjMEpE8RKdU1dTK6mdZtzNMhbeHdyne2pU1iVKiKmImGw==" + }, + "node_modules/azle/node_modules/azle": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/azle/-/azle-0.3.1.tgz", + "integrity": "sha512-6sO4tYkSetchKuM/JqwFzVwhSI+gpOrKJ8IMorQ/i9DAWsVr0lpTXmuebhXseLcLoz7ZOqkWvn4Hq8E5B46hCQ==", + "dependencies": { + "@swc/core": "1.2.151", + "azle-syn": "0.0.0", + "esbuild": "0.14.25", + "fs-extra": "10.0.1", + "hash.js": "1.1.7", + "ts-node": "10.3.1", + "typescript": "4.4.4" + }, + "bin": { + "azle": "bin.js" + } + }, + "node_modules/azle/node_modules/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==", + "dependencies": { + "@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" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.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 + } + } + }, + "node_modules/azle/node_modules/typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/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, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/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, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bignumber.js": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/borc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/borc/-/borc-2.1.2.tgz", + "integrity": "sha512-Sy9eoUi4OiKzq7VovMn246iTo17kzuyHJKomCfpWMlI6RpfN1gk95w7d7gH264nApVLg0HZfcpz62/g4VH1Y4w==", + "dev": true, + "dependencies": { + "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" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/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 + }, + "node_modules/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==" + }, + "node_modules/decode-utf8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/decode-utf8/-/decode-utf8-1.0.1.tgz", + "integrity": "sha512-iTpp497Pgdg5JdQ3HkHbG0vwSSYRDrtVXKpz/ieFhY+LjLOZ2HjVtdmNKyO4f25lr4Q6O0cYSzlo6h27LgsLDA==" + }, + "node_modules/delimit-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", + "integrity": "sha1-m4MZR3wOX4rrPONXrjBfwl6hzSs=", + "dev": true + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/encode-utf8": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-2.0.0.tgz", + "integrity": "sha512-3EyMFxZj1/7oMotElDQUEQcP7N4TIe1aJ0m1uBDoyQ8I2LBHhBsXx8P3KsPbqNlGzG+NYxFwEauUwMPHZg3YDQ==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, + "node_modules/esbuild": { + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.25.tgz", + "integrity": "sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "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" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/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==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "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==" + }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/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, + "engines": { + "node": ">=10" + } + }, + "node_modules/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==" + }, + "node_modules/json-text-sequence": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz", + "integrity": "sha1-py8hfcSvxGKf/1/rME3BvVGi89I=", + "dev": true, + "dependencies": { + "delimit-stream": "0.1.0" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "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==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/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, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/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 + }, + "node_modules/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, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "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==", + "dev": true, + "dependencies": { + "@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" + }, + "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 + } + } + }, + "node_modules/typescript": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", + "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "node_modules/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 + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "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.11.1", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.11.1.tgz", + "integrity": "sha512-Z1zw8l3d+AG3uu7d8G/Rd9Q5MWT9gB+Cori/Rqb6IjSEribRhL36ulCSkDYZJU/dhqSUp1VlvX5u51+wgv+MLg==", + "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" + } + }, + "@dfinity/candid": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.11.1.tgz", + "integrity": "sha512-EYZZg+x7OgZxa56D9SWMeTlaMb09HJ7wIfL42+l/e0lgrx+sTXYxKe8bM9FrUW9AWo9/gKkOGV/IxJL/Acncng==", + "dev": true, + "peer": true + }, + "@dfinity/principal": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", + "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + }, + "@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.5.0", + "resolved": "https://registry.npmjs.org/azle/-/azle-0.5.0.tgz", + "integrity": "sha512-W34rmQr3oUsbYxT/EMdl6qCXhKTk4iJNF031huhqhl3FJShhi+k5q/3pgcPRkIBr5YbyxmzP9pYwDQWembxf5A==", + "requires": { + "@dfinity/principal": "0.11.2", + "@swc/core": "1.2.151", + "azle": "^0.3.0", + "azle-syn": "0.0.0", + "esbuild": "0.14.25", + "fs-extra": "10.0.1", + "hash.js": "1.1.7", + "js-sha256": "0.9.0", + "ts-node": "10.3.1", + "typescript": "4.4.4" + }, + "dependencies": { + "azle": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/azle/-/azle-0.3.1.tgz", + "integrity": "sha512-6sO4tYkSetchKuM/JqwFzVwhSI+gpOrKJ8IMorQ/i9DAWsVr0lpTXmuebhXseLcLoz7ZOqkWvn4Hq8E5B46hCQ==", + "requires": { + "@swc/core": "1.2.151", + "azle-syn": "0.0.0", + "esbuild": "0.14.25", + "fs-extra": "10.0.1", + "hash.js": "1.1.7", + "ts-node": "10.3.1", + "typescript": "4.4.4" + } + }, + "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.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", + "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==" + }, + "decode-utf8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/decode-utf8/-/decode-utf8-1.0.1.tgz", + "integrity": "sha512-iTpp497Pgdg5JdQ3HkHbG0vwSSYRDrtVXKpz/ieFhY+LjLOZ2HjVtdmNKyO4f25lr4Q6O0cYSzlo6h27LgsLDA==" + }, + "delimit-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", + "integrity": "sha1-m4MZR3wOX4rrPONXrjBfwl6hzSs=", + "dev": true + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" + }, + "encode-utf8": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-2.0.0.tgz", + "integrity": "sha512-3EyMFxZj1/7oMotElDQUEQcP7N4TIe1aJ0m1uBDoyQ8I2LBHhBsXx8P3KsPbqNlGzG+NYxFwEauUwMPHZg3YDQ==" + }, + "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==" + }, + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "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==" + }, + "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": "sha1-py8hfcSvxGKf/1/rME3BvVGi89I=", + "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==" + }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "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": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "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/ethereum_json_rpc/package.json b/examples/ethereum_json_rpc/package.json new file mode 100644 index 0000000000..f24f6b7e21 --- /dev/null +++ b/examples/ethereum_json_rpc/package.json @@ -0,0 +1,15 @@ +{ + "scripts": { + "test": "ETHEREUM_URL=https://rpc.ankr.com/eth ts-node --transpile-only --ignore=false test/test.ts" + }, + "dependencies": { + "azle": "0.5.0", + "decode-utf8": "1.0.1", + "encode-utf8": "2.0.0" + }, + "devDependencies": { + "@dfinity/agent": "0.11.1", + "ts-node": "10.7.0", + "typescript": "4.6.3" + } +} diff --git a/examples/ethereum_json_rpc/src/index.did b/examples/ethereum_json_rpc/src/index.did new file mode 100644 index 0000000000..139622f9e1 --- /dev/null +++ b/examples/ethereum_json_rpc/src/index.did @@ -0,0 +1,111 @@ +type HttpResponse = record { + "status": nat64; + "headers": vec HttpHeader; + "body": blob; +}; + +type CreateCanisterArgs = record { + "settings": opt CanisterSettings; +}; + +type UpdateSettingsArgs = record { + "canister_id": principal; + "settings": CanisterSettings; +}; + +type InstallCodeArgs = record { + "mode": InstallCodeMode; + "canister_id": principal; + "wasm_module": blob; + "arg": blob; +}; + +type UninstallCodeArgs = record { + "canister_id": principal; +}; + +type StartCanisterArgs = record { + "canister_id": principal; +}; + +type StopCanisterArgs = record { + "canister_id": principal; +}; + +type CanisterStatusArgs = record { + "canister_id": principal; +}; + +type DeleteCanisterArgs = record { + "canister_id": principal; +}; + +type DepositCyclesArgs = record { + "canister_id": principal; +}; + +type HttpRequestArgs = record { + "url": text; + "max_response_bytes": opt nat64; + "http_method": HttpMethod; + "headers": vec HttpHeader; + "body": opt blob; + "transform_method_name": opt text; +}; + +type ProvisionalCreateCanisterWithCyclesArgs = record { + "amount": opt nat; + "settings": opt CanisterSettings; +}; + +type ProvisionalTopUpCanisterArgs = record { + "canister_id": principal; + "amount": nat; +}; + +type CreateCanisterResult = record { + "canister_id": principal; +}; + +type CanisterStatusResult = record { + "status": CanisterStatus; + "settings": DefiniteCanisterSettings; + "module_hash": opt blob; + "memory_size": nat; + "cycles": nat; +}; + +type ProvisionalCreateCanisterWithCyclesResult = record { + "canister_id": principal; +}; + +type HttpHeader = record { + "name": text; + "value": text; +}; + +type CanisterSettings = record { + "controllers": opt vec principal; + "compute_allocation": opt nat; + "memory_allocation": opt nat; + "freezing_threshold": opt nat; +}; + +type DefiniteCanisterSettings = record { + "controllers": vec principal; + "compute_allocation": nat; + "memory_allocation": nat; + "freezing_threshold": nat; +}; + +type InstallCodeMode = variant { "install": null; "reinstall": null; "upgrade": null }; + +type HttpMethod = variant { "GET": null; "HEAD": null; "POST": null }; + +type CanisterStatus = variant { "running": null; "stopping": null; "stopped": null }; + +service: (text) -> { + "eth_block_number_transform": (HttpResponse) -> (HttpResponse) query; + "eth_get_balance": (text) -> (text); + "eth_get_block_by_number": (nat32) -> (text); +} diff --git a/examples/ethereum_json_rpc/src/index.ts b/examples/ethereum_json_rpc/src/index.ts new file mode 100644 index 0000000000..680f283d5b --- /dev/null +++ b/examples/ethereum_json_rpc/src/index.ts @@ -0,0 +1,108 @@ +import { + CanisterResult, + ic, + Init, + nat32, + ok, + Query, + Stable, + Update +} from 'azle'; +import { HttpResponse, ManagementCanister } from 'azle/canisters/management'; +import decodeUtf8 from 'decode-utf8'; +import encodeUtf8 from 'encode-utf8'; + +type JSON = string; + +type StableStorage = Stable<{ + ethereum_url: string; +}>; + +let stable_storage: StableStorage = ic.stable_storage(); + +export function init(ethereum_url: string): Init { + stable_storage.ethereum_url = ethereum_url; +} + +export function* eth_get_balance(ethereum_address: string): Update { + const max_response_bytes = 200n; + + // TODO this is just a hueristic for cost, might change when the feature is officially released: https://forum.dfinity.org/t/enable-canisters-to-make-http-s-requests/9670/130 + const cycle_cost_base = 400_000_000n; + const cycle_cost_per_byte = 300_000n; // TODO not sure on this exact cost + const cycle_cost_total = + cycle_cost_base + cycle_cost_per_byte * max_response_bytes; + + const http_result: CanisterResult = + yield ManagementCanister.http_request({ + url: stable_storage.ethereum_url, + max_response_bytes, + http_method: { + POST: null + }, + headers: [], + body: new Uint8Array( + encodeUtf8( + JSON.stringify({ + jsonrpc: '2.0', + method: 'eth_getBalance', + params: [ethereum_address, 'earliest'], + id: 1 + }) + ) + ), + transform_method_name: 'eth_block_number_transform' + }).with_cycles(cycle_cost_total); + + if (!ok(http_result)) { + ic.trap(http_result.err ?? 'http_result had an error'); + } + + return decodeUtf8(Uint8Array.from(http_result.ok.body)); +} + +export function* eth_get_block_by_number(number: nat32): Update { + const max_response_bytes = 2_000n; + + // TODO this is just a hueristic for cost, might change when the feature is officially released: https://forum.dfinity.org/t/enable-canisters-to-make-http-s-requests/9670/130 + const cycle_cost_base = 400_000_000n; + const cycle_cost_per_byte = 300_000n; // TODO not sure on this exact cost + const cycle_cost_total = + cycle_cost_base + cycle_cost_per_byte * max_response_bytes; + + const http_result: CanisterResult = + yield ManagementCanister.http_request({ + url: stable_storage.ethereum_url, + max_response_bytes, + http_method: { + POST: null + }, + headers: [], + body: new Uint8Array( + encodeUtf8( + JSON.stringify({ + jsonrpc: '2.0', + method: 'eth_getBlockByNumber', + params: [`0x${number.toString(16)}`, false], + id: 1 + }) + ) + ), + transform_method_name: 'eth_block_number_transform' + }).with_cycles(cycle_cost_total); + + if (!ok(http_result)) { + ic.trap(http_result.err ?? 'http_result had an error'); + } + + return decodeUtf8(Uint8Array.from(http_result.ok.body)); +} + +export function eth_block_number_transform( + http_response: HttpResponse +): Query { + return { + ...http_response, + headers: [] + }; +} diff --git a/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did new file mode 100644 index 0000000000..139622f9e1 --- /dev/null +++ b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did @@ -0,0 +1,111 @@ +type HttpResponse = record { + "status": nat64; + "headers": vec HttpHeader; + "body": blob; +}; + +type CreateCanisterArgs = record { + "settings": opt CanisterSettings; +}; + +type UpdateSettingsArgs = record { + "canister_id": principal; + "settings": CanisterSettings; +}; + +type InstallCodeArgs = record { + "mode": InstallCodeMode; + "canister_id": principal; + "wasm_module": blob; + "arg": blob; +}; + +type UninstallCodeArgs = record { + "canister_id": principal; +}; + +type StartCanisterArgs = record { + "canister_id": principal; +}; + +type StopCanisterArgs = record { + "canister_id": principal; +}; + +type CanisterStatusArgs = record { + "canister_id": principal; +}; + +type DeleteCanisterArgs = record { + "canister_id": principal; +}; + +type DepositCyclesArgs = record { + "canister_id": principal; +}; + +type HttpRequestArgs = record { + "url": text; + "max_response_bytes": opt nat64; + "http_method": HttpMethod; + "headers": vec HttpHeader; + "body": opt blob; + "transform_method_name": opt text; +}; + +type ProvisionalCreateCanisterWithCyclesArgs = record { + "amount": opt nat; + "settings": opt CanisterSettings; +}; + +type ProvisionalTopUpCanisterArgs = record { + "canister_id": principal; + "amount": nat; +}; + +type CreateCanisterResult = record { + "canister_id": principal; +}; + +type CanisterStatusResult = record { + "status": CanisterStatus; + "settings": DefiniteCanisterSettings; + "module_hash": opt blob; + "memory_size": nat; + "cycles": nat; +}; + +type ProvisionalCreateCanisterWithCyclesResult = record { + "canister_id": principal; +}; + +type HttpHeader = record { + "name": text; + "value": text; +}; + +type CanisterSettings = record { + "controllers": opt vec principal; + "compute_allocation": opt nat; + "memory_allocation": opt nat; + "freezing_threshold": opt nat; +}; + +type DefiniteCanisterSettings = record { + "controllers": vec principal; + "compute_allocation": nat; + "memory_allocation": nat; + "freezing_threshold": nat; +}; + +type InstallCodeMode = variant { "install": null; "reinstall": null; "upgrade": null }; + +type HttpMethod = variant { "GET": null; "HEAD": null; "POST": null }; + +type CanisterStatus = variant { "running": null; "stopping": null; "stopped": null }; + +service: (text) -> { + "eth_block_number_transform": (HttpResponse) -> (HttpResponse) query; + "eth_get_balance": (text) -> (text); + "eth_get_block_by_number": (nat32) -> (text); +} diff --git a/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did.d.ts b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did.d.ts new file mode 100644 index 0000000000..2c08330d76 --- /dev/null +++ b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did.d.ts @@ -0,0 +1,98 @@ +import type { Principal } from '@dfinity/principal'; +import type { ActorMethod } from '@dfinity/agent'; + +export interface CanisterSettings { + freezing_threshold: [] | [bigint]; + controllers: [] | [Array]; + memory_allocation: [] | [bigint]; + compute_allocation: [] | [bigint]; +} +export type CanisterStatus = + | { stopped: null } + | { stopping: null } + | { running: null }; +export interface CanisterStatusArgs { + canister_id: Principal; +} +export interface CanisterStatusResult { + status: CanisterStatus; + memory_size: bigint; + cycles: bigint; + settings: DefiniteCanisterSettings; + module_hash: [] | [Array]; +} +export interface CreateCanisterArgs { + settings: [] | [CanisterSettings]; +} +export interface CreateCanisterResult { + canister_id: Principal; +} +export interface DefiniteCanisterSettings { + freezing_threshold: bigint; + controllers: Array; + memory_allocation: bigint; + compute_allocation: bigint; +} +export interface DeleteCanisterArgs { + canister_id: Principal; +} +export interface DepositCyclesArgs { + canister_id: Principal; +} +export interface HttpHeader { + value: string; + name: string; +} +export type HttpMethod = { GET: null } | { HEAD: null } | { POST: null }; +export interface HttpRequestArgs { + url: string; + transform_method_name: [] | [string]; + max_response_bytes: [] | [bigint]; + body: [] | [Array]; + headers: Array; + http_method: HttpMethod; +} +export interface HttpResponse { + status: bigint; + body: Array; + headers: Array; +} +export interface InstallCodeArgs { + arg: Array; + wasm_module: Array; + mode: InstallCodeMode; + canister_id: Principal; +} +export type InstallCodeMode = + | { reinstall: null } + | { upgrade: null } + | { install: null }; +export interface ProvisionalCreateCanisterWithCyclesArgs { + settings: [] | [CanisterSettings]; + amount: [] | [bigint]; +} +export interface ProvisionalCreateCanisterWithCyclesResult { + canister_id: Principal; +} +export interface ProvisionalTopUpCanisterArgs { + canister_id: Principal; + amount: bigint; +} +export interface StartCanisterArgs { + canister_id: Principal; +} +export interface StopCanisterArgs { + canister_id: Principal; +} +export interface UninstallCodeArgs { + canister_id: Principal; +} +export interface UpdateSettingsArgs { + canister_id: Principal; + settings: CanisterSettings; +} +export interface _SERVICE { + eth_block_number_transform: ActorMethod<[HttpResponse], HttpResponse>; + eth_get_balance: ActorMethod<[string], string>; + eth_get_block_by_number: ActorMethod<[number], string>; +} diff --git a/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did.js b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did.js new file mode 100644 index 0000000000..29dc15ddb0 --- /dev/null +++ b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/ethereum_json_rpc.did.js @@ -0,0 +1,20 @@ +export const idlFactory = ({ IDL }) => { + const HttpHeader = IDL.Record({ value: IDL.Text, name: IDL.Text }); + const HttpResponse = IDL.Record({ + status: IDL.Nat64, + body: IDL.Vec(IDL.Nat8), + headers: IDL.Vec(HttpHeader) + }); + return IDL.Service({ + eth_block_number_transform: IDL.Func( + [HttpResponse], + [HttpResponse], + ['query'] + ), + eth_get_balance: IDL.Func([IDL.Text], [IDL.Text], []), + eth_get_block_by_number: IDL.Func([IDL.Nat32], [IDL.Text], []) + }); +}; +export const init = ({ IDL }) => { + return [IDL.Text]; +}; diff --git a/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/index.js b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/index.js new file mode 100644 index 0000000000..95aee7a78a --- /dev/null +++ b/examples/ethereum_json_rpc/test/dfx_generated/ethereum_json_rpc/index.js @@ -0,0 +1,40 @@ +import { Actor, HttpAgent } from '@dfinity/agent'; + +// Imports and re-exports candid interface +import { idlFactory } from './ethereum_json_rpc.did.js'; +export { idlFactory } from './ethereum_json_rpc.did.js'; +// CANISTER_ID is replaced by webpack based on node environment +export const canisterId = process.env.ETHEREUM_JSON_RPC_CANISTER_ID; + +/** + * + * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent + * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options] + * @return {import("@dfinity/agent").ActorSubclass} + */ +export const createActor = (canisterId, options) => { + const agent = new HttpAgent({ ...options?.agentOptions }); + + // Fetch root key for certificate validation during development + if (process.env.NODE_ENV !== 'production') { + agent.fetchRootKey().catch((err) => { + console.warn( + 'Unable to fetch root key. Check to ensure that your local replica is running' + ); + console.error(err); + }); + } + + // Creates an actor with using the candid interface and the HttpAgent + return Actor.createActor(idlFactory, { + agent, + canisterId, + ...options?.actorOptions + }); +}; + +/** + * A ready-to-use agent for the ethereum_json_rpc canister + * @type {import("@dfinity/agent").ActorSubclass} + */ +// export const ethereum_json_rpc = createActor(canisterId); diff --git a/examples/ethereum_json_rpc/test/test.ts b/examples/ethereum_json_rpc/test/test.ts new file mode 100644 index 0000000000..688ceb31bb --- /dev/null +++ b/examples/ethereum_json_rpc/test/test.ts @@ -0,0 +1,103 @@ +// Ethereum genesis block balances taken from: https://raw.githubusercontent.com/lastmjs/eth-total-supply/master/nethermind-foundation.json + +import { deploy, run_tests, Test } from 'azle/test'; +import { createActor } from './dfx_generated/ethereum_json_rpc'; + +if (process.env.ETHEREUM_URL === undefined) { + throw new Error( + `No Ethereum URL set, did you set the ETHEREUM_URL environment variable?\nExample: ETHEREUM_URL=https://some-ethereum-provider-url.org npm test` + ); +} + +const ethereum_json_rpc_canister = createActor('rrkah-fqaaa-aaaaa-aaaaq-cai', { + agentOptions: { + host: 'http://127.0.0.1:8000' + } +}); + +const tests: Test[] = [ + ...deploy('ethereum_json_rpc', `'("${process.env.ETHEREUM_URL}")'`), + { + name: 'eth_get_balance 0xeac0827eff0c6e3ff28a7d4a54f65cb7689d7b99', + test: async () => { + const result = await ethereum_json_rpc_canister.eth_get_balance( + '0xeac0827eff0c6e3ff28a7d4a54f65cb7689d7b99' + ); + + const result_json = JSON.parse(result); + + return { + ok: result_json.result === '0x9ad9e69f9d47520000' + }; + } + }, + { + name: 'eth_get_balance 0xf4b6cdcfcb24230b337d770df6034dfbd4e1503f', + test: async () => { + const result = await ethereum_json_rpc_canister.eth_get_balance( + '0xf4b6cdcfcb24230b337d770df6034dfbd4e1503f' + ); + + const result_json = JSON.parse(result); + + return { + ok: result_json.result === '0x405fdf7e5af85e00000' + }; + } + }, + { + name: 'eth_get_balance 0x7be2f7680c802da6154c92c0194ae732517a7169', + test: async () => { + const result = await ethereum_json_rpc_canister.eth_get_balance( + '0x7be2f7680c802da6154c92c0194ae732517a7169' + ); + + const result_json = JSON.parse(result); + + return { + ok: result_json.result === '0xfc936392801c0000' + }; + } + }, + { + name: 'eth_get_block_by_number 0', + test: async () => { + const result = + await ethereum_json_rpc_canister.eth_get_block_by_number(0); + + const result_json = JSON.parse(result); + + return { + ok: result_json.result.number === `0x${Number(0).toString(16)}` + }; + } + }, + { + name: 'eth_get_block_by_number 1', + test: async () => { + const result = + await ethereum_json_rpc_canister.eth_get_block_by_number(1); + + const result_json = JSON.parse(result); + + return { + ok: result_json.result.number === `0x${Number(1).toString(16)}` + }; + } + }, + { + name: 'eth_get_block_by_number 2', + test: async () => { + const result = + await ethereum_json_rpc_canister.eth_get_block_by_number(2); + + const result_json = JSON.parse(result); + + return { + ok: result_json.result.number === `0x${Number(2).toString(16)}` + }; + } + } +]; + +run_tests(tests); diff --git a/examples/ethereum_json_rpc/tsconfig.json b/examples/ethereum_json_rpc/tsconfig.json new file mode 100644 index 0000000000..0817cb3fc1 --- /dev/null +++ b/examples/ethereum_json_rpc/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "strict": true, + "target": "ES2020", + "moduleResolution": "node", + "allowJs": true, + "outDir": "HACK_BECAUSE_OF_ALLOW_JS", + "allowSyntheticDefaultImports": true + } +} diff --git a/examples/outgoing_http_requests/.gitignore b/examples/outgoing_http_requests/.gitignore new file mode 100644 index 0000000000..9be9f489ef --- /dev/null +++ b/examples/outgoing_http_requests/.gitignore @@ -0,0 +1,3 @@ +.dfx +node_modules +target diff --git a/examples/outgoing_http_requests/dfx.json b/examples/outgoing_http_requests/dfx.json new file mode 100644 index 0000000000..f0da84f02d --- /dev/null +++ b/examples/outgoing_http_requests/dfx.json @@ -0,0 +1,15 @@ +{ + "canisters": { + "outgoing_http_requests": { + "type": "custom", + "build": "npx azle outgoing_http_requests", + "root": "src", + "ts": "src/index.ts", + "candid": "src/index.did", + "wasm": "target/wasm32-unknown-unknown/release/outgoing_http_requests.wasm", + "declarations": { + "output": "test/dfx_generated/outgoing_http_requests" + } + } + } +} diff --git a/examples/outgoing_http_requests/package-lock.json b/examples/outgoing_http_requests/package-lock.json new file mode 100644 index 0000000000..ac24f31ffe --- /dev/null +++ b/examples/outgoing_http_requests/package-lock.json @@ -0,0 +1,603 @@ +{ + "name": "outgoing_http_requests", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "azle": "0.5.0" + }, + "devDependencies": { + "@dfinity/agent": "0.11.1", + "decode-utf8": "^1.0.1", + "ts-node": "10.7.0", + "typescript": "4.6.3", + "utf8-encoder": "1.0.1" + } + }, + "node_modules/@cspotcode/source-map-consumer": { + "version": "0.8.0", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 12" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.7.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-consumer": "0.8.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@dfinity/agent": { + "version": "0.11.1", + "dev": true, + "license": "Apache-2.0", + "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" + }, + "peerDependencies": { + "@dfinity/candid": "^0.11.1", + "@dfinity/principal": "^0.11.1" + } + }, + "node_modules/@dfinity/candid": { + "version": "0.11.3", + "dev": true, + "license": "Apache-2.0", + "peer": true + }, + "node_modules/@dfinity/principal": { + "version": "0.11.3", + "dev": true, + "license": "Apache-2.0", + "peer": true + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "18.6.3", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/acorn": { + "version": "8.8.0", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "dev": true, + "license": "MIT" + }, + "node_modules/base64-arraybuffer": { + "version": "0.2.0", + "dev": true, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/bignumber.js": { + "version": "9.0.2", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/borc": { + "version": "2.1.2", + "dev": true, + "license": "MIT", + "dependencies": { + "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" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/commander": { + "version": "2.20.3", + "dev": true, + "license": "MIT" + }, + "node_modules/create-require": { + "version": "1.1.1", + "dev": true, + "license": "MIT" + }, + "node_modules/decode-utf8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/decode-utf8/-/decode-utf8-1.0.1.tgz", + "integrity": "sha512-iTpp497Pgdg5JdQ3HkHbG0vwSSYRDrtVXKpz/ieFhY+LjLOZ2HjVtdmNKyO4f25lr4Q6O0cYSzlo6h27LgsLDA==", + "dev": true + }, + "node_modules/delimit-stream": { + "version": "0.1.0", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/diff": { + "version": "4.0.2", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/inherits": { + "version": "2.0.4", + "dev": true, + "license": "ISC" + }, + "node_modules/iso-url": { + "version": "0.4.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/js-sha256": { + "version": "0.9.0", + "dev": true, + "license": "MIT" + }, + "node_modules/json-text-sequence": { + "version": "0.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "delimit-stream": "0.1.0" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "dev": true, + "license": "ISC" + }, + "node_modules/readable-stream": { + "version": "3.6.0", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/simple-cbor": { + "version": "0.4.1", + "dev": true, + "license": "ISC" + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/ts-node": { + "version": "10.7.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@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" + }, + "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 + } + } + }, + "node_modules/typescript": { + "version": "4.6.3", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/utf8-encoder": { + "version": "1.0.1", + "dev": true, + "license": "ISC" + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/yn": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + } + }, + "dependencies": { + "@cspotcode/source-map-consumer": { + "version": "0.8.0", + "dev": true + }, + "@cspotcode/source-map-support": { + "version": "0.7.0", + "dev": true, + "requires": { + "@cspotcode/source-map-consumer": "0.8.0" + } + }, + "@dfinity/agent": { + "version": "0.11.1", + "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" + } + }, + "@dfinity/candid": { + "version": "0.11.3", + "dev": true, + "peer": true + }, + "@dfinity/principal": { + "version": "0.11.3", + "dev": true, + "peer": true + }, + "@tsconfig/node10": { + "version": "1.0.9", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.3", + "dev": true + }, + "@types/node": { + "version": "18.6.3", + "dev": true, + "peer": true + }, + "acorn": { + "version": "8.8.0", + "dev": true + }, + "acorn-walk": { + "version": "8.2.0", + "dev": true + }, + "arg": { + "version": "4.1.3", + "dev": true + }, + "base64-arraybuffer": { + "version": "0.2.0", + "dev": true + }, + "base64-js": { + "version": "1.5.1", + "dev": true + }, + "bignumber.js": { + "version": "9.0.2", + "dev": true + }, + "borc": { + "version": "2.1.2", + "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", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "commander": { + "version": "2.20.3", + "dev": true + }, + "create-require": { + "version": "1.1.1", + "dev": true + }, + "decode-utf8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/decode-utf8/-/decode-utf8-1.0.1.tgz", + "integrity": "sha512-iTpp497Pgdg5JdQ3HkHbG0vwSSYRDrtVXKpz/ieFhY+LjLOZ2HjVtdmNKyO4f25lr4Q6O0cYSzlo6h27LgsLDA==", + "dev": true + }, + "delimit-stream": { + "version": "0.1.0", + "dev": true + }, + "diff": { + "version": "4.0.2", + "dev": true + }, + "ieee754": { + "version": "1.2.1", + "dev": true + }, + "inherits": { + "version": "2.0.4", + "dev": true + }, + "iso-url": { + "version": "0.4.7", + "dev": true + }, + "js-sha256": { + "version": "0.9.0", + "dev": true + }, + "json-text-sequence": { + "version": "0.1.1", + "dev": true, + "requires": { + "delimit-stream": "0.1.0" + } + }, + "make-error": { + "version": "1.3.6", + "dev": true + }, + "readable-stream": { + "version": "3.6.0", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "safe-buffer": { + "version": "5.2.1", + "dev": true + }, + "simple-cbor": { + "version": "0.4.1", + "dev": true + }, + "string_decoder": { + "version": "1.3.0", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } + }, + "ts-node": { + "version": "10.7.0", + "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", + "dev": true + }, + "utf8-encoder": { + "version": "1.0.1", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "dev": true + }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "dev": true + }, + "yn": { + "version": "3.1.1", + "dev": true + } + } +} diff --git a/examples/outgoing_http_requests/package.json b/examples/outgoing_http_requests/package.json new file mode 100644 index 0000000000..6976269abe --- /dev/null +++ b/examples/outgoing_http_requests/package.json @@ -0,0 +1,15 @@ +{ + "scripts": { + "test": "ts-node --transpile-only --ignore=false test/test.ts" + }, + "dependencies": { + "azle": "0.5.0" + }, + "devDependencies": { + "@dfinity/agent": "0.11.1", + "decode-utf8": "1.0.1", + "ts-node": "10.7.0", + "typescript": "4.6.3", + "utf8-encoder": "1.0.1" + } +} diff --git a/examples/outgoing_http_requests/src/index.did b/examples/outgoing_http_requests/src/index.did new file mode 100644 index 0000000000..83077152e5 --- /dev/null +++ b/examples/outgoing_http_requests/src/index.did @@ -0,0 +1,111 @@ +type HttpResponse = record { + "status": nat64; + "headers": vec HttpHeader; + "body": blob; +}; + +type CreateCanisterArgs = record { + "settings": opt CanisterSettings; +}; + +type UpdateSettingsArgs = record { + "canister_id": principal; + "settings": CanisterSettings; +}; + +type InstallCodeArgs = record { + "mode": InstallCodeMode; + "canister_id": principal; + "wasm_module": blob; + "arg": blob; +}; + +type UninstallCodeArgs = record { + "canister_id": principal; +}; + +type StartCanisterArgs = record { + "canister_id": principal; +}; + +type StopCanisterArgs = record { + "canister_id": principal; +}; + +type CanisterStatusArgs = record { + "canister_id": principal; +}; + +type DeleteCanisterArgs = record { + "canister_id": principal; +}; + +type DepositCyclesArgs = record { + "canister_id": principal; +}; + +type HttpRequestArgs = record { + "url": text; + "max_response_bytes": opt nat64; + "http_method": HttpMethod; + "headers": vec HttpHeader; + "body": opt blob; + "transform_method_name": opt text; +}; + +type ProvisionalCreateCanisterWithCyclesArgs = record { + "amount": opt nat; + "settings": opt CanisterSettings; +}; + +type ProvisionalTopUpCanisterArgs = record { + "canister_id": principal; + "amount": nat; +}; + +type CreateCanisterResult = record { + "canister_id": principal; +}; + +type CanisterStatusResult = record { + "status": CanisterStatus; + "settings": DefiniteCanisterSettings; + "module_hash": opt blob; + "memory_size": nat; + "cycles": nat; +}; + +type ProvisionalCreateCanisterWithCyclesResult = record { + "canister_id": principal; +}; + +type HttpHeader = record { + "name": text; + "value": text; +}; + +type CanisterSettings = record { + "controllers": opt vec principal; + "compute_allocation": opt nat; + "memory_allocation": opt nat; + "freezing_threshold": opt nat; +}; + +type DefiniteCanisterSettings = record { + "controllers": vec principal; + "compute_allocation": nat; + "memory_allocation": nat; + "freezing_threshold": nat; +}; + +type InstallCodeMode = variant { "install": null; "reinstall": null; "upgrade": null }; + +type HttpMethod = variant { "GET": null; "HEAD": null; "POST": null }; + +type CanisterStatus = variant { "running": null; "stopping": null; "stopped": null }; + +service: { + "xkcd_transform": (HttpResponse) -> (HttpResponse) query; + "xkcd": () -> (HttpResponse); + "xkcd_raw": () -> (HttpResponse); +} diff --git a/examples/outgoing_http_requests/src/index.ts b/examples/outgoing_http_requests/src/index.ts new file mode 100644 index 0000000000..c3cd8bfd92 --- /dev/null +++ b/examples/outgoing_http_requests/src/index.ts @@ -0,0 +1,82 @@ +import { + blob, + CanisterResult, + ic, + ok, + Principal, + Query, + Update, + UpdateManual +} from 'azle'; +import { HttpResponse, ManagementCanister } from 'azle/canisters/management'; + +export function* xkcd(): Update { + const max_response_bytes = 1_000n; + + // TODO this is just a hueristic for cost, might change when the feature is officially released: https://forum.dfinity.org/t/enable-canisters-to-make-http-s-requests/9670/130 + const cycle_cost_base = 400_000_000n; + const cycle_cost_per_byte = 300_000n; // TODO not sure on this exact cost + const cycle_cost_total = + cycle_cost_base + cycle_cost_per_byte * max_response_bytes; + + const http_result: CanisterResult = + yield ManagementCanister.http_request({ + url: `https://xkcd.com/642/info.0.json`, + max_response_bytes, + http_method: { + GET: null + }, + headers: [], + body: null, + transform_method_name: 'xkcd_transform' + }).with_cycles(cycle_cost_total); + + if (!ok(http_result)) { + ic.trap(http_result.err ?? 'http_result had an error'); + } + + return http_result.ok; +} + +export function* xkcd_raw(): UpdateManual { + const max_response_bytes = 1_000n; + + // TODO this is just a hueristic for cost, might change when the feature is officially released: https://forum.dfinity.org/t/enable-canisters-to-make-http-s-requests/9670/130 + const cycle_cost_base = 400_000_000n; + const cycle_cost_per_byte = 300_000n; // TODO not sure on this exact cost + const cycle_cost_total = + cycle_cost_base + cycle_cost_per_byte * max_response_bytes; + + const http_result: CanisterResult = yield ic.call_raw( + Principal.fromText('aaaaa-aa'), + 'http_request', + ic.candid_encode(` + ( + record { + url = "https://xkcd.com/642/info.0.json"; + max_response_bytes = ${max_response_bytes} : nat64; + http_method = variant { GET }; + headers = vec {}; + body = null; + transform_method_name = "xkcd_transform"; + } + ) + `), + cycle_cost_total + ); + + if (!ok(http_result)) { + ic.trap(http_result.err ?? 'http_result had an error'); + } + + return ic.reply_raw(http_result.ok); +} + +export function xkcd_transform( + http_response: HttpResponse +): Query { + return { + ...http_response, + headers: [] + }; +} diff --git a/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/index.js b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/index.js new file mode 100644 index 0000000000..a88d5df6e4 --- /dev/null +++ b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/index.js @@ -0,0 +1,40 @@ +import { Actor, HttpAgent } from '@dfinity/agent'; + +// Imports and re-exports candid interface +import { idlFactory } from './outgoing_http_requests.did.js'; +export { idlFactory } from './outgoing_http_requests.did.js'; +// CANISTER_ID is replaced by webpack based on node environment +export const canisterId = process.env.OUTGOING_HTTP_REQUESTS_CANISTER_ID; + +/** + * + * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent + * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options] + * @return {import("@dfinity/agent").ActorSubclass} + */ +export const createActor = (canisterId, options) => { + const agent = new HttpAgent({ ...options?.agentOptions }); + + // Fetch root key for certificate validation during development + if (process.env.NODE_ENV !== 'production') { + agent.fetchRootKey().catch((err) => { + console.warn( + 'Unable to fetch root key. Check to ensure that your local replica is running' + ); + console.error(err); + }); + } + + // Creates an actor with using the candid interface and the HttpAgent + return Actor.createActor(idlFactory, { + agent, + canisterId, + ...options?.actorOptions + }); +}; + +/** + * A ready-to-use agent for the outgoing_http_requests canister + * @type {import("@dfinity/agent").ActorSubclass} + */ +// export const outgoing_http_requests = createActor(canisterId); diff --git a/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did new file mode 100644 index 0000000000..83077152e5 --- /dev/null +++ b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did @@ -0,0 +1,111 @@ +type HttpResponse = record { + "status": nat64; + "headers": vec HttpHeader; + "body": blob; +}; + +type CreateCanisterArgs = record { + "settings": opt CanisterSettings; +}; + +type UpdateSettingsArgs = record { + "canister_id": principal; + "settings": CanisterSettings; +}; + +type InstallCodeArgs = record { + "mode": InstallCodeMode; + "canister_id": principal; + "wasm_module": blob; + "arg": blob; +}; + +type UninstallCodeArgs = record { + "canister_id": principal; +}; + +type StartCanisterArgs = record { + "canister_id": principal; +}; + +type StopCanisterArgs = record { + "canister_id": principal; +}; + +type CanisterStatusArgs = record { + "canister_id": principal; +}; + +type DeleteCanisterArgs = record { + "canister_id": principal; +}; + +type DepositCyclesArgs = record { + "canister_id": principal; +}; + +type HttpRequestArgs = record { + "url": text; + "max_response_bytes": opt nat64; + "http_method": HttpMethod; + "headers": vec HttpHeader; + "body": opt blob; + "transform_method_name": opt text; +}; + +type ProvisionalCreateCanisterWithCyclesArgs = record { + "amount": opt nat; + "settings": opt CanisterSettings; +}; + +type ProvisionalTopUpCanisterArgs = record { + "canister_id": principal; + "amount": nat; +}; + +type CreateCanisterResult = record { + "canister_id": principal; +}; + +type CanisterStatusResult = record { + "status": CanisterStatus; + "settings": DefiniteCanisterSettings; + "module_hash": opt blob; + "memory_size": nat; + "cycles": nat; +}; + +type ProvisionalCreateCanisterWithCyclesResult = record { + "canister_id": principal; +}; + +type HttpHeader = record { + "name": text; + "value": text; +}; + +type CanisterSettings = record { + "controllers": opt vec principal; + "compute_allocation": opt nat; + "memory_allocation": opt nat; + "freezing_threshold": opt nat; +}; + +type DefiniteCanisterSettings = record { + "controllers": vec principal; + "compute_allocation": nat; + "memory_allocation": nat; + "freezing_threshold": nat; +}; + +type InstallCodeMode = variant { "install": null; "reinstall": null; "upgrade": null }; + +type HttpMethod = variant { "GET": null; "HEAD": null; "POST": null }; + +type CanisterStatus = variant { "running": null; "stopping": null; "stopped": null }; + +service: { + "xkcd_transform": (HttpResponse) -> (HttpResponse) query; + "xkcd": () -> (HttpResponse); + "xkcd_raw": () -> (HttpResponse); +} diff --git a/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did.d.ts b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did.d.ts new file mode 100644 index 0000000000..fe5fff9771 --- /dev/null +++ b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did.d.ts @@ -0,0 +1,98 @@ +import type { Principal } from '@dfinity/principal'; +import type { ActorMethod } from '@dfinity/agent'; + +export interface CanisterSettings { + freezing_threshold: [] | [bigint]; + controllers: [] | [Array]; + memory_allocation: [] | [bigint]; + compute_allocation: [] | [bigint]; +} +export type CanisterStatus = + | { stopped: null } + | { stopping: null } + | { running: null }; +export interface CanisterStatusArgs { + canister_id: Principal; +} +export interface CanisterStatusResult { + status: CanisterStatus; + memory_size: bigint; + cycles: bigint; + settings: DefiniteCanisterSettings; + module_hash: [] | [Array]; +} +export interface CreateCanisterArgs { + settings: [] | [CanisterSettings]; +} +export interface CreateCanisterResult { + canister_id: Principal; +} +export interface DefiniteCanisterSettings { + freezing_threshold: bigint; + controllers: Array; + memory_allocation: bigint; + compute_allocation: bigint; +} +export interface DeleteCanisterArgs { + canister_id: Principal; +} +export interface DepositCyclesArgs { + canister_id: Principal; +} +export interface HttpHeader { + value: string; + name: string; +} +export type HttpMethod = { GET: null } | { HEAD: null } | { POST: null }; +export interface HttpRequestArgs { + url: string; + transform_method_name: [] | [string]; + max_response_bytes: [] | [bigint]; + body: [] | [Array]; + headers: Array; + http_method: HttpMethod; +} +export interface HttpResponse { + status: bigint; + body: Array; + headers: Array; +} +export interface InstallCodeArgs { + arg: Array; + wasm_module: Array; + mode: InstallCodeMode; + canister_id: Principal; +} +export type InstallCodeMode = + | { reinstall: null } + | { upgrade: null } + | { install: null }; +export interface ProvisionalCreateCanisterWithCyclesArgs { + settings: [] | [CanisterSettings]; + amount: [] | [bigint]; +} +export interface ProvisionalCreateCanisterWithCyclesResult { + canister_id: Principal; +} +export interface ProvisionalTopUpCanisterArgs { + canister_id: Principal; + amount: bigint; +} +export interface StartCanisterArgs { + canister_id: Principal; +} +export interface StopCanisterArgs { + canister_id: Principal; +} +export interface UninstallCodeArgs { + canister_id: Principal; +} +export interface UpdateSettingsArgs { + canister_id: Principal; + settings: CanisterSettings; +} +export interface _SERVICE { + xkcd: ActorMethod<[], HttpResponse>; + xkcd_raw: ActorMethod<[], HttpResponse>; + xkcd_transform: ActorMethod<[HttpResponse], HttpResponse>; +} diff --git a/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did.js b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did.js new file mode 100644 index 0000000000..f264d1d77c --- /dev/null +++ b/examples/outgoing_http_requests/test/dfx_generated/outgoing_http_requests/outgoing_http_requests.did.js @@ -0,0 +1,16 @@ +export const idlFactory = ({ IDL }) => { + const HttpHeader = IDL.Record({ value: IDL.Text, name: IDL.Text }); + const HttpResponse = IDL.Record({ + status: IDL.Nat64, + body: IDL.Vec(IDL.Nat8), + headers: IDL.Vec(HttpHeader) + }); + return IDL.Service({ + xkcd: IDL.Func([], [HttpResponse], []), + xkcd_raw: IDL.Func([], [HttpResponse], []), + xkcd_transform: IDL.Func([HttpResponse], [HttpResponse], ['query']) + }); +}; +export const init = ({ IDL }) => { + return []; +}; diff --git a/examples/outgoing_http_requests/test/test.ts b/examples/outgoing_http_requests/test/test.ts new file mode 100644 index 0000000000..450f22cb68 --- /dev/null +++ b/examples/outgoing_http_requests/test/test.ts @@ -0,0 +1,59 @@ +import { deploy, run_tests, Test } from 'azle/test'; +import { createActor } from './dfx_generated/outgoing_http_requests'; +import { HttpResponse } from './dfx_generated/outgoing_http_requests/outgoing_http_requests.did'; +import decodeUtf8 from 'decode-utf8'; + +const outgoing_http_requests_canister = createActor( + 'rrkah-fqaaa-aaaaa-aaaaq-cai', + { + agentOptions: { + host: 'http://127.0.0.1:8000' + } + } +); + +const tests: Test[] = [ + ...deploy('outgoing_http_requests'), + { + name: 'xkcd', + test: async () => { + const result = await outgoing_http_requests_canister.xkcd(); + + return { + ok: check_xkcd_result(result) + }; + } + }, + { + name: 'xkcd_raw', + test: async () => { + const result = await outgoing_http_requests_canister.xkcd_raw(); + + return { + ok: check_xkcd_result(result) + }; + } + } +]; + +run_tests(tests); + +function check_xkcd_result(result: HttpResponse): boolean { + const result_json = JSON.parse(decodeUtf8(Uint8Array.from(result.body))); + const expected_json = JSON.parse( + `{"month": "9", "num": 642, "link": "", "year": "2009", "news": "", "safe_title": "Creepy", "alt": "And I even got out my adorable new netbook!", "img": "https://imgs.xkcd.com/comics/creepy.png", "title": "Creepy", "day": "28"}` + ); + + return ( + result_json.month === expected_json.month && + result_json.num === expected_json.num && + result_json.link === expected_json.link && + result_json.year === expected_json.year && + result_json.news === expected_json.news && + result_json.safe_title === expected_json.safe_title && + result_json.alt === expected_json.alt && + result_json.img === expected_json.img && + result_json.title === expected_json.title && + result_json.day === expected_json.day + ); +} diff --git a/examples/outgoing_http_requests/tsconfig.json b/examples/outgoing_http_requests/tsconfig.json new file mode 100644 index 0000000000..d20bea88d9 --- /dev/null +++ b/examples/outgoing_http_requests/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "strict": true, + "target": "ES2020", + "moduleResolution": "node", + "allowJs": true, + "outDir": "HACK_BECAUSE_OF_ALLOW_JS", + "esModuleInterop": true + } +} diff --git a/index.ts b/index.ts index 15234407c5..8536596fe9 100644 --- a/index.ts +++ b/index.ts @@ -165,7 +165,7 @@ export type InspectMessage = void; export type Query = T; export type QueryManual = void; export type Update = T | Generator; -export type UpdateManual = void; +export type UpdateManual = void | Generator; export type Oneway = void; // TODO the generator types are not exactly correct...but at least I've given the user the Async type export type Async = Generator; // TODO to be stricter we may want the last parameter to be unknown: https://github.com/demergent-labs/azle/issues/138