From 1b76f8480186ad9b60a7bdf4f4e24df732fc5db7 Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Mon, 25 Sep 2023 07:41:41 -0500 Subject: [PATCH] date example refactored --- .github/workflows/test.yml | 2 +- examples/date/dfx.json | 3 +- examples/date/package-lock.json | 238 +++++++++++++++++++-------- examples/date/package.json | 6 +- examples/date/src/index.ts | 283 ++++++++++++-------------------- examples/date/test/test.ts | 4 +- 6 files changed, 286 insertions(+), 250 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ee2808bd7..89b271fcf5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,6 @@ # All Examples TODO restore when https://github.com/demergent-labs/azle/issues/1192 is resolved # "examples/complex_types", -# "examples/date", # "examples/ethereum_json_rpc", # "examples/func_types", # "examples/generics", @@ -114,6 +113,7 @@ jobs: "examples/counter", "examples/cross_canister_calls", "examples/cycles", + "examples/date", "examples/primitive_types", "examples/principal", "examples/query", diff --git a/examples/date/dfx.json b/examples/date/dfx.json index 63e9d28117..717c735c2f 100644 --- a/examples/date/dfx.json +++ b/examples/date/dfx.json @@ -6,7 +6,8 @@ "root": "src", "ts": "src/index.ts", "candid": "src/index.did", - "wasm": ".azle/date/date.wasm.gz", + "wasm": ".azle/date/date.wasm", + "gzip": true, "declarations": { "output": "test/dfx_generated/date", "node_compatibility": true diff --git a/examples/date/package-lock.json b/examples/date/package-lock.json index ecca145ab9..b051bce1b7 100644 --- a/examples/date/package-lock.json +++ b/examples/date/package-lock.json @@ -8,9 +8,9 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.11.1", - "ts-node": "10.7.0", - "typescript": "4.6.3" + "@dfinity/agent": "^0.19.2", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" } }, "node_modules/@cspotcode/source-map-consumer": { @@ -33,33 +33,77 @@ } }, "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==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.19.2.tgz", + "integrity": "sha512-KLRWEjeU9SyyaS7IBVJ9ZUcufxufr55e/kRIyClK157+0pkTG9a8xKjUIMx3QzKvLsqqzXL238nWwdoP6jAD8g==", "dev": true, "dependencies": { + "@noble/hashes": "^1.3.1", "base64-arraybuffer": "^0.2.0", - "bignumber.js": "^9.0.0", "borc": "^2.1.1", - "js-sha256": "0.9.0", "simple-cbor": "^0.4.1" }, "peerDependencies": { - "@dfinity/candid": "^0.11.1", - "@dfinity/principal": "^0.11.1" + "@dfinity/candid": "^0.19.2", + "@dfinity/principal": "^0.19.2" } }, "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==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.19.2.tgz", + "integrity": "sha512-X2hCqNMhnnmwtnOc0WnymOZYx3qphjEMuSYbBr7tMIkV7Hwt9BmXXlLnQTxUytTPxf+3he0GcS3KzsSQ9CK8ew==", "dev": true, - "peer": true + "peer": true, + "peerDependencies": { + "@dfinity/principal": "^0.19.2" + } }, "node_modules/@dfinity/principal": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", - "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.19.2.tgz", + "integrity": "sha512-vsKN6BKya70bQUsjgKRDlR2lOpv/XpUkCMIiji6rjMtKHIuWEB5Eu3JqZsOuBmWo3A3TT/K/osT9VPm0k4qdYQ==", + "dev": true, + "peer": true, + "dependencies": { + "@noble/hashes": "^1.3.1" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "dev": true, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } }, "node_modules/@swc/core": { "version": "1.2.151", @@ -359,6 +403,11 @@ "resolved": "https://registry.npmjs.org/azle-syn/-/azle-syn-0.0.0.tgz", "integrity": "sha512-fWExJb5/hOEJOuBQ8hMMHRs9WryYeLLa9/ydqPWxbwjMEpE8RKdU1dTK6mdZtzNMhbeHdyne2pU1iVKiKmImGw==" }, + "node_modules/azle/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/azle/node_modules/ts-node": { "version": "10.3.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", @@ -441,9 +490,9 @@ ] }, "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==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", "dev": true, "engines": { "node": "*" @@ -505,7 +554,7 @@ "node_modules/delimit-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", - "integrity": "sha1-m4MZR3wOX4rrPONXrjBfwl6hzSs=", + "integrity": "sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ==", "dev": true }, "node_modules/diff": { @@ -911,7 +960,7 @@ "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=", + "integrity": "sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w==", "dev": true, "dependencies": { "delimit-stream": "0.1.0" @@ -934,9 +983,9 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, "node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dev": true, "dependencies": { "inherits": "^2.0.3", @@ -983,12 +1032,12 @@ } }, "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -999,7 +1048,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "bin": { @@ -1025,17 +1074,29 @@ } } }, + "node_modules/ts-node/node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/universalify": { @@ -1049,7 +1110,7 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "node_modules/v8-compile-cache-lib": { @@ -1082,29 +1143,62 @@ } }, "@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==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.19.2.tgz", + "integrity": "sha512-KLRWEjeU9SyyaS7IBVJ9ZUcufxufr55e/kRIyClK157+0pkTG9a8xKjUIMx3QzKvLsqqzXL238nWwdoP6jAD8g==", "dev": true, "requires": { + "@noble/hashes": "^1.3.1", "base64-arraybuffer": "^0.2.0", - "bignumber.js": "^9.0.0", "borc": "^2.1.1", - "js-sha256": "0.9.0", "simple-cbor": "^0.4.1" } }, "@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==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.19.2.tgz", + "integrity": "sha512-X2hCqNMhnnmwtnOc0WnymOZYx3qphjEMuSYbBr7tMIkV7Hwt9BmXXlLnQTxUytTPxf+3he0GcS3KzsSQ9CK8ew==", "dev": true, - "peer": true + "peer": true, + "requires": {} }, "@dfinity/principal": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", - "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.19.2.tgz", + "integrity": "sha512-vsKN6BKya70bQUsjgKRDlR2lOpv/XpUkCMIiji6rjMtKHIuWEB5Eu3JqZsOuBmWo3A3TT/K/osT9VPm0k4qdYQ==", + "dev": true, + "peer": true, + "requires": { + "@noble/hashes": "^1.3.1" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "dev": true }, "@swc/core": { "version": "1.2.151", @@ -1260,6 +1354,11 @@ "typescript": "4.4.4" }, "dependencies": { + "@dfinity/principal": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", + "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + }, "ts-node": { "version": "10.3.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", @@ -1304,9 +1403,9 @@ "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==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", "dev": true }, "borc": { @@ -1348,7 +1447,7 @@ "delimit-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", - "integrity": "sha1-m4MZR3wOX4rrPONXrjBfwl6hzSs=", + "integrity": "sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ==", "dev": true }, "diff": { @@ -1544,7 +1643,7 @@ "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=", + "integrity": "sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w==", "dev": true, "requires": { "delimit-stream": "0.1.0" @@ -1565,9 +1664,9 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dev": true, "requires": { "inherits": "^2.0.3", @@ -1597,12 +1696,12 @@ } }, "ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "requires": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -1613,14 +1712,25 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" + }, + "dependencies": { + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + } + } } }, "typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true }, "universalify": { @@ -1631,7 +1741,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "v8-compile-cache-lib": { diff --git a/examples/date/package.json b/examples/date/package.json index c07d970dd5..6bc660e4c9 100644 --- a/examples/date/package.json +++ b/examples/date/package.json @@ -7,8 +7,8 @@ "azle": "0.17.1" }, "devDependencies": { - "@dfinity/agent": "0.11.1", - "ts-node": "10.7.0", - "typescript": "4.6.3" + "@dfinity/agent": "^0.19.2", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" } } diff --git a/examples/date/src/index.ts b/examples/date/src/index.ts index 8d5fe43e48..ecb930d0ad 100644 --- a/examples/date/src/index.ts +++ b/examples/date/src/index.ts @@ -1,273 +1,198 @@ import { nat32, nat64, query, Service, text } from 'azle'; -export default class extends Service { - @query([text], nat32) - getDate(isoString: text): nat32 { +export default Service({ + getDate: query([text], nat32, (isoString) => { return new Date(isoString).getDate(); - } - - @query([text], nat32) - getDay(isoString: text): nat32 { + }), + getDay: query([text], nat32, (isoString) => { return new Date(isoString).getDay(); - } - - @query([text], nat32) - getFullYear(isoString: text): nat32 { + }), + getFullYear: query([text], nat32, (isoString) => { return new Date(isoString).getFullYear(); - } - - @query([text], nat32) - getHours(isoString: text): nat32 { + }), + getHours: query([text], nat32, (isoString) => { return new Date(isoString).getHours(); - } - - @query([text], nat32) - getMilliseconds(isoString: text): nat32 { + }), + getMilliseconds: query([text], nat32, (isoString) => { return new Date(isoString).getMilliseconds(); - } - - @query([text], nat32) - getMinutes(isoString: text): nat32 { + }), + getMinutes: query([text], nat32, (isoString) => { return new Date(isoString).getMinutes(); - } - - @query([text], nat32) - getMonth(isoString: text): nat32 { + }), + getMonth: query([text], nat32, (isoString) => { return new Date(isoString).getMonth(); - } - - @query([text], nat32) - getSeconds(isoString: text): nat32 { + }), + getSeconds: query([text], nat32, (isoString) => { return new Date(isoString).getSeconds(); - } - - @query([text], nat64) - getTime(isoString: text): nat64 { + }), + getTime: query([text], nat64, (isoString) => { return BigInt(new Date(isoString).getTime()); - } - - @query([text], nat32) - getTimezoneOffset(isoString: text): nat32 { + }), + getTimezoneOffset: query([text], nat32, (isoString) => { return new Date(isoString).getTimezoneOffset(); - } - - @query([text], nat32) - getUtcDate(isoString: text): nat32 { + }), + getUtcDate: query([text], nat32, (isoString) => { return new Date(isoString).getUTCDate(); - } - - @query([text], nat32) - getUtcDay(isoString: text): nat32 { + }), + getUtcDay: query([text], nat32, (isoString) => { return new Date(isoString).getUTCDay(); - } - - @query([text], nat32) - getUtcFullYear(isoString: text): nat32 { + }), + getUtcFullYear: query([text], nat32, (isoString) => { return new Date(isoString).getUTCFullYear(); - } - - @query([text], nat32) - getUtcHours(isoString: text): nat32 { + }), + getUtcHours: query([text], nat32, (isoString) => { return new Date(isoString).getUTCHours(); - } - - @query([text], nat32) - getUtcMilliseconds(isoString: text): nat32 { + }), + getUtcMilliseconds: query([text], nat32, (isoString) => { return new Date(isoString).getUTCMilliseconds(); - } - - @query([text], nat32) - getUtcMinutes(isoString: text): nat32 { + }), + getUtcMinutes: query([text], nat32, (isoString) => { return new Date(isoString).getUTCMinutes(); - } - - @query([text], nat32) - getUtcMonth(isoString: text): nat32 { + }), + getUtcMonth: query([text], nat32, (isoString) => { return new Date(isoString).getUTCMonth(); - } - - @query([text], nat32) - getUtcSeconds(isoString: text): nat32 { + }), + getUtcSeconds: query([text], nat32, (isoString) => { return new Date(isoString).getUTCSeconds(); - } - - @query([text, nat32], nat32) - setDate(isoString: text, newDate: nat32): nat32 { + }), + setDate: query([text, nat32], nat32, (isoString, newDate) => { let date = new Date(isoString); date.setDate(newDate); return date.getDate(); - } - - @query([text, nat32], nat32) - setFullYear(isoString: text, newFullYear: nat32): nat32 { + }), + setFullYear: query([text, nat32], nat32, (isoString, newFullYear) => { let date = new Date(isoString); date.setFullYear(newFullYear); return date.getFullYear(); - } - - @query([text, nat32], nat32) - setHours(isoString: text, newHours: nat32): nat32 { + }), + setHours: query([text, nat32], nat32, (isoString, newHours) => { let date = new Date(isoString); date.setHours(newHours); return date.getHours(); - } - - @query([text, nat32], nat32) - setMilliseconds(isoString: text, newMilliseconds: nat32): nat32 { - let date = new Date(isoString); - - date.setMilliseconds(newMilliseconds); - - return date.getMilliseconds(); - } - - @query([text, nat32], nat32) - setMinutes(isoString: text, newMinutes: nat32): nat32 { + }), + setMilliseconds: query( + [text, nat32], + nat32, + (isoString, newMilliseconds) => { + let date = new Date(isoString); + + date.setMilliseconds(newMilliseconds); + + return date.getMilliseconds(); + } + ), + setMinutes: query([text, nat32], nat32, (isoString, newMinutes) => { let date = new Date(isoString); date.setMinutes(newMinutes); return date.getMinutes(); - } - - @query([text, nat32], nat32) - setMonth(isoString: text, newMonth: nat32): nat32 { + }), + setMonth: query([text, nat32], nat32, (isoString, newMonth) => { let date = new Date(isoString); date.setMonth(newMonth); return date.getMonth(); - } - - @query([text, nat32], nat32) - setSeconds(isoString: text, newSeconds: nat32): nat32 { + }), + setSeconds: query([text, nat32], nat32, (isoString, newSeconds) => { let date = new Date(isoString); date.setSeconds(newSeconds); return date.getSeconds(); - } - - @query([text, nat64], nat64) - setTime(isoString: text, newTime: nat64): nat64 { + }), + setTime: query([text, nat64], nat64, (isoString, newTime) => { let date = new Date(isoString); date.setTime(Number(newTime)); return BigInt(date.getTime()); - } - - @query([text, nat32], nat32) - setUtcDate(isoString: text, newUtcDate: nat32): nat32 { + }), + setUtcDate: query([text, nat32], nat32, (isoString, newUtcDate) => { let date = new Date(isoString); date.setUTCDate(newUtcDate); return date.getUTCDate(); - } - - @query([text, nat32], nat32) - setUtcFullYear(isoString: text, newUtcFullYear: nat32): nat32 { + }), + setUtcFullYear: query([text, nat32], nat32, (isoString, newUtcFullYear) => { let date = new Date(isoString); date.setUTCFullYear(newUtcFullYear); return date.getUTCFullYear(); - } - - @query([text, nat32], nat32) - setUtcHours(isoString: text, newUtcHours: nat32): nat32 { + }), + setUtcHours: query([text, nat32], nat32, (isoString, newUtcHours) => { let date = new Date(isoString); date.setUTCHours(newUtcHours); return date.getUTCHours(); - } - - @query([text, nat32], nat32) - setUtcMilliseconds(isoString: text, newUtcMilliseconds: nat32): nat32 { - let date = new Date(isoString); - - date.setUTCMilliseconds(newUtcMilliseconds); - - return date.getUTCMilliseconds(); - } - - @query([text, nat32], nat32) - setUtcMinutes(isoString: text, newUtcMinutes: nat32): nat32 { + }), + setUtcMilliseconds: query( + [text, nat32], + nat32, + (isoString, newUtcMilliseconds) => { + let date = new Date(isoString); + + date.setUTCMilliseconds(newUtcMilliseconds); + + return date.getUTCMilliseconds(); + } + ), + setUtcMinutes: query([text, nat32], nat32, (isoString, newUtcMinutes) => { let date = new Date(isoString); date.setUTCMinutes(newUtcMinutes); return date.getUTCMinutes(); - } - - @query([text, nat32], nat32) - setUtcMonth(isoString: text, newUtcMonth: nat32): nat32 { + }), + setUtcMonth: query([text, nat32], nat32, (isoString, newUtcMonth) => { let date = new Date(isoString); date.setUTCMonth(newUtcMonth); return date.getUTCMonth(); - } - - @query([text, nat32], nat32) - setUtcSeconds(isoString: text, newUtcSeconds: nat32): nat32 { + }), + setUtcSeconds: query([text, nat32], nat32, (isoString, newUtcSeconds) => { let date = new Date(isoString); date.setUTCSeconds(newUtcSeconds); return date.getUTCSeconds(); - } - - @query([text], text) - toDateString(isoString: text): text { + }), + toDateString: query([text], text, (isoString) => { return new Date(isoString).toDateString(); - } - - @query([text], text) - toISOString(isoString: text): text { + }), + toISOString: query([text], text, (isoString) => { return new Date(isoString).toISOString(); - } - - @query([text], text) - toJSON(isoString: text): text { + }), + toJSON: query([text], text, (isoString) => { return new Date(isoString).toJSON(); - } - - @query([text], text) - toString(isoString: text): text { + }), + toString: query([text], text, (isoString) => { return new Date(isoString).toString(); - } - - @query([text], text) - toTimeString(isoString: text): text { + }), + toTimeString: query([text], text, (isoString) => { return new Date(isoString).toTimeString(); - } - - @query([text], text) - toUtcString(isoString: text): text { + }), + toUtcString: query([text], text, (isoString) => { return new Date(isoString).toUTCString(); - } - - @query([], nat64) - now(): nat64 { + }), + now: query([], nat64, () => { return BigInt(Date.now()); - } - - @query([text], nat64) - parse(isoString: text): nat64 { + }), + parse: query([text], nat64, (isoString) => { return BigInt(Date.parse(isoString)); - } - - @query([nat32, nat32], nat64) - utc(year: nat32, month: nat32): nat64 { + }), + utc: query([nat32, nat32], nat64, (year, month) => { return BigInt(Date.UTC(year, month)); - } -} + }) +}); diff --git a/examples/date/test/test.ts b/examples/date/test/test.ts index 39569139ce..faaf1b30cb 100644 --- a/examples/date/test/test.ts +++ b/examples/date/test/test.ts @@ -2,10 +2,10 @@ import { getCanisterId, runTests } from 'azle/test'; import { createActor } from './dfx_generated/date'; import { getTests } from './tests'; -const date_canister = createActor(getCanisterId('date'), { +const dateCanister = createActor(getCanisterId('date'), { agentOptions: { host: 'http://127.0.0.1:8000' } }); -runTests(getTests(date_canister)); +runTests(getTests(dateCanister));