From 9c9191ca884db26ddb87cfcb5229557b7938d280 Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Fri, 15 Dec 2023 10:37:50 -0700 Subject: [PATCH] Add PostUpgradeArb --- .github/workflows/test.yml | 1 + property_tests/arbitraries/canister_arb.ts | 39 +- .../canister_methods/post_upgrade_arb.ts | 141 +++ .../canister_methods/query_method_arb.ts | 1 + .../canister_methods/update_method_arb.ts | 1 + property_tests/tests/init_method/test/test.ts | 2 +- .../tests/post_upgrade_method/dfx.json | 16 + .../post_upgrade_method/package-lock.json | 996 ++++++++++++++++++ .../tests/post_upgrade_method/package.json | 12 + .../test/generate_callable_method_body.ts | 10 + .../test/generate_init_tests.ts | 34 + .../test/generate_post_deploy_method_body.ts | 23 + .../test/generate_post_upgrade_tests.ts | 35 + .../test/global_var_name.ts | 3 + .../tests/post_upgrade_method/test/test.ts | 133 +++ .../tests/post_upgrade_method/tsconfig.json | 10 + .../stable_b_tree_map/test/contains_key.ts | 6 +- .../tests/stable_b_tree_map/test/get.ts | 6 +- .../tests/stable_b_tree_map/test/insert.ts | 6 +- .../tests/stable_b_tree_map/test/is_empty.ts | 6 +- .../tests/stable_b_tree_map/test/items.ts | 3 +- .../tests/stable_b_tree_map/test/keys.ts | 6 +- .../tests/stable_b_tree_map/test/len.ts | 6 +- .../tests/stable_b_tree_map/test/remove.ts | 6 +- .../tests/stable_b_tree_map/test/values.ts | 6 +- 25 files changed, 1483 insertions(+), 25 deletions(-) create mode 100644 property_tests/arbitraries/canister_methods/post_upgrade_arb.ts create mode 100644 property_tests/tests/post_upgrade_method/dfx.json create mode 100644 property_tests/tests/post_upgrade_method/package-lock.json create mode 100644 property_tests/tests/post_upgrade_method/package.json create mode 100644 property_tests/tests/post_upgrade_method/test/generate_callable_method_body.ts create mode 100644 property_tests/tests/post_upgrade_method/test/generate_init_tests.ts create mode 100644 property_tests/tests/post_upgrade_method/test/generate_post_deploy_method_body.ts create mode 100644 property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts create mode 100644 property_tests/tests/post_upgrade_method/test/global_var_name.ts create mode 100644 property_tests/tests/post_upgrade_method/test/test.ts create mode 100644 property_tests/tests/post_upgrade_method/tsconfig.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d84d135f8b..424dd76dbf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -149,6 +149,7 @@ jobs: "property_tests/tests/nat64", "property_tests/tests/null", "property_tests/tests/opt", + "property_tests/tests/post_upgrade_method", "property_tests/tests/principal", "property_tests/tests/query_methods", "property_tests/tests/record", diff --git a/property_tests/arbitraries/canister_arb.ts b/property_tests/arbitraries/canister_arb.ts index 4a438b984a..719717bd6c 100644 --- a/property_tests/arbitraries/canister_arb.ts +++ b/property_tests/arbitraries/canister_arb.ts @@ -3,6 +3,7 @@ import { QueryMethod } from './canister_methods/query_method_arb'; import { Test } from '../../test'; import { UpdateMethod } from './canister_methods/update_method_arb'; import { InitMethod } from './canister_methods/init_method_arb'; +import { PostUpgradeMethod } from './canister_methods/post_upgrade_arb'; import { CorrespondingJSType } from './candid/corresponding_js_type'; import { TextClass, FloatClass } from '@dfinity/candid/lib/cjs/idl'; @@ -28,12 +29,25 @@ export type Canister = { tests: Test[][]; }; +export type CanisterMethod< + ParamAgentArgumentValue extends CorrespondingJSType, + ParamAgentResponseValue +> = + | QueryMethod + | UpdateMethod + | InitMethod + | PostUpgradeMethod; + export type CanisterConfig< ParamAgentArgumentValue extends CorrespondingJSType = undefined, ParamAgentResponseValue = undefined > = { globalDeclarations?: string[]; initMethod?: InitMethod; + postUpgradeMethod?: PostUpgradeMethod< + ParamAgentArgumentValue, + ParamAgentResponseValue + >; queryMethods?: QueryMethod[]; updateMethods?: UpdateMethod[]; }; @@ -48,12 +62,12 @@ export function CanisterArb< > ) { return configArb.map((config): Canister => { - const canisterMethods: ( - | QueryMethod - | UpdateMethod - | InitMethod - )[] = [ + const canisterMethods: CanisterMethod< + ParamAgentArgumentValue, + ParamAgentResponseValue + >[] = [ ...(config.initMethod ? [config.initMethod] : []), + ...(config.postUpgradeMethod ? [config.postUpgradeMethod] : []), ...(config.queryMethods ?? []), ...(config.updateMethods ?? []) ]; @@ -107,14 +121,10 @@ function generateSourceCode( canisterMethods: (UpdateMethod | QueryMethod)[] ) { const imports = [ - ...new Set( - canisterMethods.reduce( - (acc, method) => { - return [...acc, ...method.imports]; - }, - ['Canister', 'query', 'update'] - ) - ) + ...new Set([ + 'Canister', + ...canisterMethods.flatMap((method) => [...method.imports]) + ]) ] .sort((a, b) => a.localeCompare(b, 'en', { sensitivity: 'base' })) .join(); @@ -124,8 +134,7 @@ function generateSourceCode( ); const declarations = [ - ...globalDeclarations, - ...declarationsFromCanisterMethods + ...new Set([...globalDeclarations, ...declarationsFromCanisterMethods]) ].join('\n'); const sourceCodes = canisterMethods.map((method) => method.sourceCode); diff --git a/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts b/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts new file mode 100644 index 0000000000..e5c7a49efb --- /dev/null +++ b/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts @@ -0,0 +1,141 @@ +import fc from 'fast-check'; + +import { CandidValueAndMeta } from '../candid/candid_value_and_meta_arb'; +import { CorrespondingJSType } from '../candid/corresponding_js_type'; +import { UniqueIdentifierArb } from '../unique_identifier_arb'; +import { Named } from '../..'; +import { + BodyGenerator, + TestsGenerator, + CallbackLocation, + isDefined, + generateCallback +} from '.'; +import { Test } from '../../../test'; +import { VoidArb } from '../candid/primitive/void'; + +export type PostUpgradeMethod< + ParamAgentArgumentValue extends CorrespondingJSType, + ParamAgentResponseValue +> = { + imports: Set; + globalDeclarations: string[]; + params: Named< + CandidValueAndMeta + >[]; + sourceCode: string; + tests: Test[][]; +}; + +export function PostUpgradeMethodArb< + ParamAgentArgumentValue extends CorrespondingJSType, + ParamAgentResponseValue +>( + paramTypeArrayArb: fc.Arbitrary< + CandidValueAndMeta[] + >, + constraints: { + generateBody: BodyGenerator< + ParamAgentArgumentValue, + ParamAgentResponseValue + >; + generateTests: TestsGenerator< + ParamAgentArgumentValue, + ParamAgentResponseValue + >; + callbackLocation?: CallbackLocation; + } +) { + return fc + .tuple( + UniqueIdentifierArb('canisterMethod'), + paramTypeArrayArb, + VoidArb(), + fc.constantFrom( + 'INLINE', + 'STANDALONE' + ) as fc.Arbitrary, + UniqueIdentifierArb('typeDeclaration') + // TODO: This unique id would be better named globalScope or something + // But needs to match the same scope as typeDeclarations so I'm using + // that for now. + ) + .map( + ([ + functionName, + paramTypes, + returnType, + defaultCallbackLocation, + callbackName + ]) => { + // TODO: Add a return type to this map callback of type PostUpgradeMethod + + const callbackLocation = + constraints.callbackLocation ?? defaultCallbackLocation; + + const imports = new Set([ + 'postUpgrade', + ...paramTypes.flatMap((param) => [...param.src.imports]) + ]); + + const namedParams = paramTypes.map( + (param: T, index: number): Named => ({ + name: `param${index}`, + el: param + }) + ); + + const callback = generateCallback( + namedParams, + returnType, + constraints.generateBody, + callbackLocation, + callbackName + ); + + const variableAliasDeclarations = paramTypes + .flatMap((param) => param.src.variableAliasDeclarations) + .filter(isDefined); + + const globalDeclarations = + callbackLocation === 'STANDALONE' + ? [...variableAliasDeclarations, callback] + : variableAliasDeclarations; + + const sourceCode = generateSourceCode( + functionName, + paramTypes, + callbackLocation === 'STANDALONE' ? callbackName : callback + ); + + const tests = constraints.generateTests( + functionName, + namedParams, + returnType + ); + + return { + imports, + globalDeclarations, + params: namedParams, + sourceCode, + tests + }; + } + ); +} + +function generateSourceCode< + ParamType extends CorrespondingJSType, + ParamAgentType +>( + functionName: string, + paramTypes: CandidValueAndMeta[], + callback: string +): string { + const paramCandidTypeObjects = paramTypes + .map((param) => param.src.candidTypeObject) + .join(', '); + + return `${functionName}: postUpgrade([${paramCandidTypeObjects}], ${callback})`; +} diff --git a/property_tests/arbitraries/canister_methods/query_method_arb.ts b/property_tests/arbitraries/canister_methods/query_method_arb.ts index d6e18900af..7f67c6c051 100644 --- a/property_tests/arbitraries/canister_methods/query_method_arb.ts +++ b/property_tests/arbitraries/canister_methods/query_method_arb.ts @@ -78,6 +78,7 @@ export function QueryMethodArb< constraints.callbackLocation ?? defaultCallbackLocation; const imports = new Set([ + 'query', ...paramTypes.flatMap((param) => [...param.src.imports]), ...returnType.src.imports ]); diff --git a/property_tests/arbitraries/canister_methods/update_method_arb.ts b/property_tests/arbitraries/canister_methods/update_method_arb.ts index 633eb4d59f..11fa0244de 100644 --- a/property_tests/arbitraries/canister_methods/update_method_arb.ts +++ b/property_tests/arbitraries/canister_methods/update_method_arb.ts @@ -79,6 +79,7 @@ export function UpdateMethodArb< constraints.callbackLocation ?? defaultCallbackLocation; const imports = new Set([ + 'update', ...paramTypes.flatMap((param) => [...param.src.imports]), ...returnType.src.imports ]); diff --git a/property_tests/tests/init_method/test/test.ts b/property_tests/tests/init_method/test/test.ts index 9ea7fa6a81..719c1b9681 100644 --- a/property_tests/tests/init_method/test/test.ts +++ b/property_tests/tests/init_method/test/test.ts @@ -96,7 +96,7 @@ function generateGetInitValuesCanisterMethod( globalInitVariableNames: string[] ): QueryMethod { return { - imports: new Set(['Tuple', 'bool']), + imports: new Set(['bool', 'query', 'Tuple']), globalDeclarations: [], sourceCode: /*TS*/ `getInitValues: query( [], diff --git a/property_tests/tests/post_upgrade_method/dfx.json b/property_tests/tests/post_upgrade_method/dfx.json new file mode 100644 index 0000000000..6ab9fbd7e4 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/dfx.json @@ -0,0 +1,16 @@ +{ + "canisters": { + "canister": { + "type": "custom", + "main": "src/index.ts", + "candid": "src/index.did", + "build": "npx azle canister", + "wasm": ".azle/canister/canister.wasm", + "gzip": true, + "declarations": { + "output": "test/dfx_generated/canister", + "node_compatibility": true + } + } + } +} diff --git a/property_tests/tests/post_upgrade_method/package-lock.json b/property_tests/tests/post_upgrade_method/package-lock.json new file mode 100644 index 0000000000..708fcab575 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/package-lock.json @@ -0,0 +1,996 @@ +{ + "name": "post_upgrade_method", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "azle": "^0.18.5" + }, + "devDependencies": { + "ts-node": "^10.9.1", + "typescript": "^5.2.2" + } + }, + "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.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@dfinity/principal": { + "version": "0.19.3", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.19.3.tgz", + "integrity": "sha512-+nixVvdGt7ECxRvLXDXsvU9q9sSPssBtDQ4bXa149SK6gcYcmZ6lfWIi3DJNqj3tGROxILVBsguel9tECappsA==", + "dependencies": { + "@noble/hashes": "^1.3.1" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz", + "integrity": "sha512-bhvbzWFF3CwMs5tbjf3ObfGqbl/17ict2/uwOSfr3wmxDE6VdS2GqY/FuzIPe0q0bdhj65zQsvqfArI9MY6+AA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.5.tgz", + "integrity": "sha512-5d1OkoJxnYQfmC+Zd8NBFjkhyCNYwM4n9ODrycTFY6Jk1IGiZ+tjVJDDSwDt77nK+tfpGP4T50iMtVi4dEGzhQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.5.tgz", + "integrity": "sha512-9t+28jHGL7uBdkBjL90QFxe7DVA+KGqWlHCF8ChTKyaKO//VLuoBricQCgwhOjA1/qOczsw843Fy4cbs4H3DVA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.5.tgz", + "integrity": "sha512-mvXGcKqqIqyKoxq26qEDPHJuBYUA5KizJncKOAf9eJQez+L9O+KfvNFu6nl7SCZ/gFb2QPaRqqmG0doSWlgkqw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.5.tgz", + "integrity": "sha512-Ly8cn6fGLNet19s0X4unjcniX24I0RqjPv+kurpXabZYSXGM4Pwpmf85WHJN3lAgB8GSth7s5A0r856S+4DyiA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.5.tgz", + "integrity": "sha512-GGDNnPWTmWE+DMchq1W8Sd0mUkL+APvJg3b11klSGUDvRXh70JqLAO56tubmq1s2cgpVCSKYywEiKBfju8JztQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.5.tgz", + "integrity": "sha512-1CCwDHnSSoA0HNwdfoNY0jLfJpd7ygaLAp5EHFos3VWJCRX9DMwWODf96s9TSse39Br7oOTLryRVmBoFwXbuuQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.5.tgz", + "integrity": "sha512-lrWXLY/vJBzCPC51QN0HM71uWgIEpGSjSZZADQhq7DKhPcI6NH1IdzjfHkDQws2oNpJKpR13kv7/pFHBbDQDwQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.5.tgz", + "integrity": "sha512-o3vYippBmSrjjQUCEEiTZ2l+4yC0pVJD/Dl57WfPwwlvFkrxoSO7rmBZFii6kQB3Wrn/6GwJUPLU5t52eq2meA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.5.tgz", + "integrity": "sha512-MkjHXS03AXAkNp1KKkhSKPOCYztRtK+KXDNkBa6P78F8Bw0ynknCSClO/ztGszILZtyO/lVKpa7MolbBZ6oJtQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.5.tgz", + "integrity": "sha512-42GwZMm5oYOD/JHqHska3Jg0r+XFb/fdZRX+WjADm3nLWLcIsN27YKtqxzQmGNJgu0AyXg4HtcSK9HuOk3v1Dw==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.5.tgz", + "integrity": "sha512-kcjndCSMitUuPJobWCnwQ9lLjiLZUR3QLQmlgaBfMX23UEa7ZOrtufnRds+6WZtIS9HdTXqND4yH8NLoVVIkcg==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.5.tgz", + "integrity": "sha512-yJAxJfHVm0ZbsiljbtFFP1BQKLc8kUF6+17tjQ78QjqjAQDnhULWiTA6u0FCDmYT1oOKS9PzZ2z0aBI+Mcyj7Q==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.5.tgz", + "integrity": "sha512-5u8cIR/t3gaD6ad3wNt1MNRstAZO+aNyBxu2We8X31bA8XUNyamTVQwLDA1SLoPCUehNCymhBhK3Qim1433Zag==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.5.tgz", + "integrity": "sha512-Z6JrMyEw/EmZBD/OFEFpb+gao9xJ59ATsoTNlj39jVBbXqoZm4Xntu6wVmGPB/OATi1uk/DB+yeDPv2E8PqZGw==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.5.tgz", + "integrity": "sha512-psagl+2RlK1z8zWZOmVdImisMtrUxvwereIdyJTmtmHahJTKb64pAcqoPlx6CewPdvGvUKe2Jw+0Z/0qhSbG1A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.5.tgz", + "integrity": "sha512-kL2l+xScnAy/E/3119OggX8SrWyBEcqAh8aOY1gr4gPvw76la2GlD4Ymf832UCVbmuWeTf2adkZDK+h0Z/fB4g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.5.tgz", + "integrity": "sha512-sPOfhtzFufQfTBgRnE1DIJjzsXukKSvZxloZbkJDG383q0awVAq600pc1nfqBcl0ice/WN9p4qLc39WhBShRTA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.5.tgz", + "integrity": "sha512-dGZkBXaafuKLpDSjKcB0ax0FL36YXCvJNnztjKV+6CO82tTYVDSH2lifitJ29jxRMoUhgkg9a+VA/B03WK5lcg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.5.tgz", + "integrity": "sha512-dWVjD9y03ilhdRQ6Xig1NWNgfLtf2o/STKTS+eZuF90fI2BhbwD6WlaiCGKptlqXlURVB5AUOxUj09LuwKGDTg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.5.tgz", + "integrity": "sha512-4liggWIA4oDgUxqpZwrDhmEfAH4d0iljanDOK7AnVU89T6CzHon/ony8C5LeOdfgx60x5cnQJFZwEydVlYx4iw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.5.tgz", + "integrity": "sha512-czTrygUsB/jlM8qEW5MD8bgYU2Xg14lo6kBDXW6HdxKjh8M5PzETGiSHaz9MtbXBYDloHNUAUW2tMiKW4KM9Mw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "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==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@swc/core": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.93.tgz", + "integrity": "sha512-690GRr1wUGmGYZHk7fUduX/JUwViMF2o74mnZYIWEcJaCcd9MQfkhsxPBtjeg6tF+h266/Cf3RPYhsFBzzxXcA==", + "hasInstallScript": true, + "dependencies": { + "@swc/counter": "^0.1.1", + "@swc/types": "^0.1.5" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.3.93", + "@swc/core-darwin-x64": "1.3.93", + "@swc/core-linux-arm-gnueabihf": "1.3.93", + "@swc/core-linux-arm64-gnu": "1.3.93", + "@swc/core-linux-arm64-musl": "1.3.93", + "@swc/core-linux-x64-gnu": "1.3.93", + "@swc/core-linux-x64-musl": "1.3.93", + "@swc/core-win32-arm64-msvc": "1.3.93", + "@swc/core-win32-ia32-msvc": "1.3.93", + "@swc/core-win32-x64-msvc": "1.3.93" + }, + "peerDependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.93.tgz", + "integrity": "sha512-gEKgk7FVIgltnIfDO6GntyuQBBlAYg5imHpRgLxB1zSI27ijVVkksc6QwISzFZAhKYaBWIsFSVeL9AYSziAF7A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.93.tgz", + "integrity": "sha512-ZQPxm/fXdDQtn3yrYSL/gFfA8OfZ5jTi33yFQq6vcg/Y8talpZ+MgdSlYM0FkLrZdMTYYTNFiuBQuuvkA+av+Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.93.tgz", + "integrity": "sha512-OYFMMI2yV+aNe3wMgYhODxHdqUB/jrK0SEMHHS44GZpk8MuBXEF+Mcz4qjkY5Q1EH7KVQqXb/gVWwdgTHpjM2A==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.93.tgz", + "integrity": "sha512-BT4dT78odKnJMNiq5HdjBsv29CiIdcCcImAPxeFqAeFw1LL6gh9nzI8E96oWc+0lVT5lfhoesCk4Qm7J6bty8w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.93.tgz", + "integrity": "sha512-yH5fWEl1bktouC0mhh0Chuxp7HEO4uCtS/ly1Vmf18gs6wZ8DOOkgAEVv2dNKIryy+Na++ljx4Ym7C8tSJTrLw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.93.tgz", + "integrity": "sha512-OFUdx64qvrGJhXKEyxosHxgoUVgba2ztYh7BnMiU5hP8lbI8G13W40J0SN3CmFQwPP30+3oEbW7LWzhKEaYjlg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.93.tgz", + "integrity": "sha512-4B8lSRwEq1XYm6xhxHhvHmKAS7pUp1Q7E33NQ2TlmFhfKvCOh86qvThcjAOo57x8DRwmpvEVrqvpXtYagMN6Ig==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.93.tgz", + "integrity": "sha512-BHShlxtkven8ZjjvZ5QR6sC5fZCJ9bMujEkiha6W4cBUTY7ce7qGFyHmQd+iPC85d9kD/0cCiX/Xez8u0BhO7w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.93.tgz", + "integrity": "sha512-nEwNWnz4JzYAK6asVvb92yeylfxMYih7eMQOnT7ZVlZN5ba9WF29xJ6kcQKs9HRH6MvWhz9+wRgv3FcjlU6HYA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.93.tgz", + "integrity": "sha512-jibQ0zUr4kwJaQVwgmH+svS04bYTPnPw/ZkNInzxS+wFAtzINBYcU8s2PMWbDb2NGYiRSEeoSGyAvS9H+24JFA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz", + "integrity": "sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==" + }, + "node_modules/@swc/types": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.5.tgz", + "integrity": "sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==" + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" + }, + "node_modules/@types/node": { + "version": "20.8.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", + "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", + "peer": true, + "dependencies": { + "undici-types": "~5.25.1" + } + }, + "node_modules/@types/uuid": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", + "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==" + }, + "node_modules/acorn": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "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.18.5", + "resolved": "https://registry.npmjs.org/azle/-/azle-0.18.5.tgz", + "integrity": "sha512-9lLhVKwexVCd8OOYMXgjk06L+Mu0q29Rpchmz07HYV6idwF5kg+8QCxzytpU9GpnUeoADTQNkEkyLABtkd2hCA==", + "dependencies": { + "@dfinity/candid": "github:demergent-labs/candid#minimum_viable", + "@dfinity/principal": "^0.19.0", + "@swc/core": "^1.3.86", + "@types/uuid": "^9.0.4", + "buffer": "^6.0.3", + "esbuild": "^0.19.3", + "fs-extra": "10.0.1", + "js-sha256": "0.9.0", + "text-encoding": "0.7.0", + "ts-node": "10.3.1", + "typescript": "^5.2.2", + "uuid": "^9.0.1" + }, + "bin": { + "azle": "bin.js" + } + }, + "node_modules/azle/node_modules/@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "dependencies": { + "@cspotcode/source-map-consumer": "0.8.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/azle/node_modules/@dfinity/candid": { + "version": "0.19.2", + "resolved": "git+ssh://git@github.com/demergent-labs/candid.git#5797fa906b1a7cc30c161dbb0eb919283ce2f80d", + "license": "Apache-2.0", + "peerDependencies": { + "@dfinity/principal": "^0.19.2" + } + }, + "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/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "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/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "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.2.1" + } + }, + "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/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/esbuild": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz", + "integrity": "sha512-bUxalY7b1g8vNhQKdB24QDmHeY4V4tw/s6Ak5z+jJX9laP5MoQseTOMemAr0gxssjNcH0MCViG8ONI2kksvfFQ==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.19.5", + "@esbuild/android-arm64": "0.19.5", + "@esbuild/android-x64": "0.19.5", + "@esbuild/darwin-arm64": "0.19.5", + "@esbuild/darwin-x64": "0.19.5", + "@esbuild/freebsd-arm64": "0.19.5", + "@esbuild/freebsd-x64": "0.19.5", + "@esbuild/linux-arm": "0.19.5", + "@esbuild/linux-arm64": "0.19.5", + "@esbuild/linux-ia32": "0.19.5", + "@esbuild/linux-loong64": "0.19.5", + "@esbuild/linux-mips64el": "0.19.5", + "@esbuild/linux-ppc64": "0.19.5", + "@esbuild/linux-riscv64": "0.19.5", + "@esbuild/linux-s390x": "0.19.5", + "@esbuild/linux-x64": "0.19.5", + "@esbuild/netbsd-x64": "0.19.5", + "@esbuild/openbsd-x64": "0.19.5", + "@esbuild/sunos-x64": "0.19.5", + "@esbuild/win32-arm64": "0.19.5", + "@esbuild/win32-ia32": "0.19.5", + "@esbuild/win32-x64": "0.19.5" + } + }, + "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.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "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/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/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/text-encoding": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz", + "integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==", + "deprecated": "no longer maintained" + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "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": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.25.3", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", + "peer": true + }, + "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/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "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" + } + } + } +} diff --git a/property_tests/tests/post_upgrade_method/package.json b/property_tests/tests/post_upgrade_method/package.json new file mode 100644 index 0000000000..e5b0aa2544 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/package.json @@ -0,0 +1,12 @@ +{ + "scripts": { + "test": "ts-node --transpile-only --ignore=false test/test.ts" + }, + "dependencies": { + "azle": "^0.18.5" + }, + "devDependencies": { + "ts-node": "^10.9.1", + "typescript": "^5.2.2" + } +} diff --git a/property_tests/tests/post_upgrade_method/test/generate_callable_method_body.ts b/property_tests/tests/post_upgrade_method/test/generate_callable_method_body.ts new file mode 100644 index 0000000000..d1adc9fbb2 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_callable_method_body.ts @@ -0,0 +1,10 @@ +import { Named } from 'azle/property_tests'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; + +export function generateBody( + _namedParams: Named>[], + returnType: CandidValueAndMeta +) { + return `return ${returnType.src.valueLiteral}`; +} diff --git a/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts b/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts new file mode 100644 index 0000000000..5edbaba3ed --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts @@ -0,0 +1,34 @@ +import { deepEqual, Named, getActor } from 'azle/property_tests'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { Test } from 'azle/test'; + +export function generateTests( + _functionName: string, + params: Named>[] +): Test[][] { + const expectedResult = [ + true, + ...params.map((param) => param.el.value.agentResponseValue) + ]; + + return [ + [ + { + name: `init method`, + test: async () => { + const actor = getActor('./tests/post_upgrade_method/test'); + const result = await actor.getPostDeployValues(); + + const valuesAreEqual = deepEqual(result, expectedResult); + + return valuesAreEqual + ? { Ok: true } + : { + Err: `\n Incorrect return value\n expected: ${expectedResult}\n received: ${result}` + }; + } + } + ] + ]; +} diff --git a/property_tests/tests/post_upgrade_method/test/generate_post_deploy_method_body.ts b/property_tests/tests/post_upgrade_method/test/generate_post_deploy_method_body.ts new file mode 100644 index 0000000000..02d9e3d618 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_post_deploy_method_body.ts @@ -0,0 +1,23 @@ +import { Named } from 'azle/property_tests'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { areParamsCorrectlyOrdered } from 'azle/property_tests/are_params_correctly_ordered'; +import { globalVarName } from './global_var_name'; + +export function generateBody( + namedParams: Named>[] +) { + const paramsAreCorrectlyOrdered = areParamsCorrectlyOrdered(namedParams); + + const storeVariablesGlobally = namedParams + .map((param, i) => `${globalVarName(i)} = ${param.name};`) + .join('\n'); + + return ` + postDeployHookExecuted = true; + + ${paramsAreCorrectlyOrdered} + + ${storeVariablesGlobally} + `; +} diff --git a/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts b/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts new file mode 100644 index 0000000000..c03abd46b2 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts @@ -0,0 +1,35 @@ +import { deepEqual, Named, getActor } from 'azle/property_tests'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { Test } from 'azle/test'; + +export function generateTests( + _functionName: string, + params: Named>[] +): Test[][] { + const expectedResult = [ + true, + ...params.map((param) => param.el.value.agentResponseValue) + ]; + + return [ + [], // Don't test on the first deploy, test after a re-deploy + [ + { + name: `post upgrade method`, + test: async () => { + const actor = getActor('./tests/post_upgrade_method/test'); + const result = await actor.getPostDeployValues(); + + const valuesAreEqual = deepEqual(result, expectedResult); + + return valuesAreEqual + ? { Ok: true } + : { + Err: `\n Incorrect return value\n expected: ${expectedResult}\n received: ${result}` + }; + } + } + ] + ]; +} diff --git a/property_tests/tests/post_upgrade_method/test/global_var_name.ts b/property_tests/tests/post_upgrade_method/test/global_var_name.ts new file mode 100644 index 0000000000..b3bfa20f11 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/global_var_name.ts @@ -0,0 +1,3 @@ +export function globalVarName(i: number) { + return `postDeployParam${i}`; +} diff --git a/property_tests/tests/post_upgrade_method/test/test.ts b/property_tests/tests/post_upgrade_method/test/test.ts new file mode 100644 index 0000000000..febaf575ac --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/test.ts @@ -0,0 +1,133 @@ +import fc from 'fast-check'; + +import { runPropTests } from 'azle/property_tests'; +import { CandidValueAndMetaArbWithoutFuncs as CandidValueAndMetaArb } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { CandidReturnTypeArb } from 'azle/property_tests/arbitraries/candid/candid_return_type_arb'; +import { + CanisterArb, + CanisterConfig +} from 'azle/property_tests/arbitraries/canister_arb'; +import { UpdateMethodArb } from 'azle/property_tests/arbitraries/canister_methods/update_method_arb'; +import { + QueryMethod, + QueryMethodArb +} from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; +import { PostUpgradeMethodArb } from 'azle/property_tests/arbitraries/canister_methods/post_upgrade_arb'; + +import { generateBody as callableMethodBodyGenerator } from './generate_callable_method_body'; +import { generateBody as postDeployMethodBodyGenerator } from './generate_post_deploy_method_body'; +import { generateTests as generateInitTests } from './generate_init_tests'; +import { generateTests as generatePostUpgradeTests } from './generate_post_upgrade_tests'; +import { CorrespondingJSType } from '../../../arbitraries/candid/corresponding_js_type'; +import { InitMethodArb } from 'azle/property_tests/arbitraries/canister_methods/init_method_arb'; +import { globalVarName } from './global_var_name'; + +const CanisterConfigArb = fc + .array(CandidValueAndMetaArb()) + .chain((postDeployParams) => { + const postDeployParamsArb = fc.constant(postDeployParams); + + const SimpleInitMethodArb = InitMethodArb(postDeployParamsArb, { + generateBody: postDeployMethodBodyGenerator, + generateTests: generateInitTests + }); + + const SimplePostUpgradeMethodArb = PostUpgradeMethodArb( + postDeployParamsArb, + { + generateBody: postDeployMethodBodyGenerator, + generateTests: generatePostUpgradeTests + } + ); + + const HeterogeneousQueryMethodArb = QueryMethodArb( + fc.array(CandidValueAndMetaArb()), + CandidReturnTypeArb(), + { + generateBody: callableMethodBodyGenerator, + generateTests: () => [] + } + ); + + const HeterogeneousUpdateMethodArb = UpdateMethodArb( + fc.array(CandidValueAndMetaArb()), + CandidReturnTypeArb(), + { + generateBody: callableMethodBodyGenerator, + generateTests: () => [] + } + ); + + const small = { + minLength: 0, + maxLength: 20 + }; + + return fc.tuple( + postDeployParamsArb, + SimpleInitMethodArb, + SimplePostUpgradeMethodArb, + fc.array(HeterogeneousQueryMethodArb, small), + fc.array(HeterogeneousUpdateMethodArb, small) + ); + }) + .map( + ([ + postDeployParams, + initMethod, + postUpgradeMethod, + queryMethods, + updateMethods + ]): CanisterConfig => { + const postDeployParamCandidTypeObjects = postDeployParams.map( + (param) => param.src.candidTypeObject + ); + + const globalPostDeployVariableNames = postDeployParams.map((_, i) => + globalVarName(i) + ); + const globalPostDeployVariableDeclarations = postDeployParams.map( + (param, i) => + `let ${globalVarName(i)}: ${ + param.src.candidTypeAnnotation + };` + ); + + const globalDeclarations = [ + 'let postDeployHookExecuted: boolean = false;', + ...globalPostDeployVariableDeclarations + ]; + + const getPostDeployValues = + generateGetPostDeployValuesCanisterMethod( + postDeployParamCandidTypeObjects, + globalPostDeployVariableNames + ); + + return { + globalDeclarations, + initMethod, + postUpgradeMethod, + queryMethods: [getPostDeployValues, ...queryMethods], + updateMethods + }; + } + ); + +runPropTests(CanisterArb(CanisterConfigArb)); + +function generateGetPostDeployValuesCanisterMethod( + postDeployParamCandidTypeObjects: string[], + globalPostDeployVariableNames: string[] +): QueryMethod { + return { + imports: new Set(['Tuple', 'bool']), + globalDeclarations: [], + sourceCode: /*TS*/ `getPostDeployValues: query( + [], + Tuple(bool, ${postDeployParamCandidTypeObjects.join()}), + () => { return [postDeployHookExecuted, ${globalPostDeployVariableNames.join()}]}) + `, + tests: [] + }; +} diff --git a/property_tests/tests/post_upgrade_method/tsconfig.json b/property_tests/tests/post_upgrade_method/tsconfig.json new file mode 100644 index 0000000000..d20bea88d9 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/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/property_tests/tests/stable_b_tree_map/test/contains_key.ts b/property_tests/tests/stable_b_tree_map/test/contains_key.ts index bcdaaf6491..fe60edb010 100644 --- a/property_tests/tests/stable_b_tree_map/test/contains_key.ts +++ b/property_tests/tests/stable_b_tree_map/test/contains_key.ts @@ -10,7 +10,11 @@ export function ContainsKeyTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'bool']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'bool', + 'query' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject diff --git a/property_tests/tests/stable_b_tree_map/test/get.ts b/property_tests/tests/stable_b_tree_map/test/get.ts index 233aaa7ea6..5839e55c3b 100644 --- a/property_tests/tests/stable_b_tree_map/test/get.ts +++ b/property_tests/tests/stable_b_tree_map/test/get.ts @@ -10,7 +10,11 @@ export function GetTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Opt']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Opt', + 'query' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject diff --git a/property_tests/tests/stable_b_tree_map/test/insert.ts b/property_tests/tests/stable_b_tree_map/test/insert.ts index 2951e43fba..4ca836fb1a 100644 --- a/property_tests/tests/stable_b_tree_map/test/insert.ts +++ b/property_tests/tests/stable_b_tree_map/test/insert.ts @@ -10,7 +10,11 @@ export function InsertTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Opt']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Opt', + 'update' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject, diff --git a/property_tests/tests/stable_b_tree_map/test/is_empty.ts b/property_tests/tests/stable_b_tree_map/test/is_empty.ts index 2029c5ee48..e279549d53 100644 --- a/property_tests/tests/stable_b_tree_map/test/is_empty.ts +++ b/property_tests/tests/stable_b_tree_map/test/is_empty.ts @@ -10,7 +10,11 @@ export function IsEmptyTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'bool']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'bool', + 'query' + ]); const body = generateBody(stableBTreeMap.name); diff --git a/property_tests/tests/stable_b_tree_map/test/items.ts b/property_tests/tests/stable_b_tree_map/test/items.ts index d358ecfb99..17dbfcf5ba 100644 --- a/property_tests/tests/stable_b_tree_map/test/items.ts +++ b/property_tests/tests/stable_b_tree_map/test/items.ts @@ -13,7 +13,8 @@ export function ItemsTestArb(stableBTreeMap: StableBTreeMap) { const imports = new Set([ ...stableBTreeMap.imports, 'Vec', - 'Tuple' + 'Tuple', + 'query' ]); const returnCandidTypeObject = `Vec(Tuple(${stableBTreeMap.keySample.src.candidTypeObject}, ${stableBTreeMap.valueSample.src.candidTypeObject}))`; diff --git a/property_tests/tests/stable_b_tree_map/test/keys.ts b/property_tests/tests/stable_b_tree_map/test/keys.ts index 798a88f780..eaf894c109 100644 --- a/property_tests/tests/stable_b_tree_map/test/keys.ts +++ b/property_tests/tests/stable_b_tree_map/test/keys.ts @@ -11,7 +11,11 @@ export function KeysTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Vec']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Vec', + 'query' + ]); const returnCandidTypeObject = `Vec(${stableBTreeMap.keySample.src.candidTypeObject})`; const body = generateBody( diff --git a/property_tests/tests/stable_b_tree_map/test/len.ts b/property_tests/tests/stable_b_tree_map/test/len.ts index 377639e131..d55b031bc6 100644 --- a/property_tests/tests/stable_b_tree_map/test/len.ts +++ b/property_tests/tests/stable_b_tree_map/test/len.ts @@ -10,7 +10,11 @@ export function LenTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'nat64']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'nat64', + 'query' + ]); const returnCandidTypeObject = `nat64`; const body = generateBody(stableBTreeMap.name); diff --git a/property_tests/tests/stable_b_tree_map/test/remove.ts b/property_tests/tests/stable_b_tree_map/test/remove.ts index 02d0720b9a..a22917ddda 100644 --- a/property_tests/tests/stable_b_tree_map/test/remove.ts +++ b/property_tests/tests/stable_b_tree_map/test/remove.ts @@ -10,7 +10,11 @@ export function RemoveTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Opt']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Opt', + 'update' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject diff --git a/property_tests/tests/stable_b_tree_map/test/values.ts b/property_tests/tests/stable_b_tree_map/test/values.ts index 8b1ae5d1f4..ee71580fac 100644 --- a/property_tests/tests/stable_b_tree_map/test/values.ts +++ b/property_tests/tests/stable_b_tree_map/test/values.ts @@ -11,7 +11,11 @@ export function ValuesTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Vec']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Vec', + 'query' + ]); const returnCandidTypeObject = `Vec(${stableBTreeMap.valueSample.src.candidTypeObject})`; const body = generateBody(