quantumcoin 7.0.14 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-SDK.md +46 -0
- package/README.md +1 -1
- package/generate-sdk.js +8 -6
- package/package.json +22 -4
- package/src/abi/interface.d.ts +133 -128
- package/src/abi/js-abi-coder.d.ts +8 -8
- package/src/constants.d.ts +61 -61
- package/src/contract/contract-factory.d.ts +28 -28
- package/src/contract/contract.d.ts +121 -113
- package/src/contract/index.d.ts +1 -0
- package/src/errors/index.d.ts +10 -2
- package/src/errors/index.js +1 -1
- package/src/generator/index.d.ts +109 -81
- package/src/index.d.ts +126 -122
- package/src/internal/event-emitter.d.ts +76 -0
- package/src/internal/event-emitter.js +144 -0
- package/src/internal/hex.d.ts +27 -4
- package/src/internal/hex.js +7 -3
- package/src/providers/extra-providers.d.ts +141 -139
- package/src/providers/extra-providers.js +15 -1
- package/src/providers/index.d.ts +18 -17
- package/src/providers/json-rpc-provider.d.ts +1 -0
- package/src/providers/provider.d.ts +233 -206
- package/src/providers/provider.js +41 -1
- package/src/utils/encoding.js +16 -4
- package/src/utils/fixednumber.d.ts +57 -57
- package/src/utils/hashing.d.ts +79 -76
- package/src/utils/hashing.js +68 -177
- package/src/utils/index.d.ts +1 -1
- package/src/utils/rlp.js +1 -1
- package/src/wallet/wallet.d.ts +54 -19
- package/src/wallet/wallet.js +48 -10
- package/.github/workflows/publish-npmjs.yaml +0 -22
- package/.gitignore +0 -15
- package/examples/AllSolidityTypes.sol +0 -184
- package/examples/SimpleIERC20.sol +0 -74
- package/examples/events.js +0 -41
- package/examples/events.ts +0 -35
- package/examples/example-generated-sdk-js/README.md +0 -65
- package/examples/example-generated-sdk-js/examples/_test-wallet.js +0 -17
- package/examples/example-generated-sdk-js/examples/deploy.js +0 -41
- package/examples/example-generated-sdk-js/examples/events.js +0 -36
- package/examples/example-generated-sdk-js/examples/read-operations.js +0 -46
- package/examples/example-generated-sdk-js/examples/write-operations.js +0 -44
- package/examples/example-generated-sdk-js/index.d.ts +0 -1
- package/examples/example-generated-sdk-js/index.js +0 -15
- package/examples/example-generated-sdk-js/package-lock.json +0 -59
- package/examples/example-generated-sdk-js/package.json +0 -22
- package/examples/example-generated-sdk-js/src/SimpleERC20.d.ts +0 -19
- package/examples/example-generated-sdk-js/src/SimpleERC20.js +0 -353
- package/examples/example-generated-sdk-js/src/SimpleERC20__factory.d.ts +0 -10
- package/examples/example-generated-sdk-js/src/SimpleERC20__factory.js +0 -29
- package/examples/example-generated-sdk-js/src/index.d.ts +0 -4
- package/examples/example-generated-sdk-js/src/index.js +0 -5
- package/examples/example-generated-sdk-js/src/quantumcoin-shims.d.ts +0 -23
- package/examples/example-generated-sdk-js/src/types.d.ts +0 -3
- package/examples/example-generated-sdk-js/src/types.js +0 -3
- package/examples/example-generated-sdk-js/test/e2e/SimpleERC20.e2e.test.js +0 -78
- package/examples/example-generated-sdk-ts/README.md +0 -65
- package/examples/example-generated-sdk-ts/examples/_test-wallet.js +0 -17
- package/examples/example-generated-sdk-ts/examples/deploy.js +0 -41
- package/examples/example-generated-sdk-ts/examples/events.js +0 -36
- package/examples/example-generated-sdk-ts/examples/read-operations.js +0 -46
- package/examples/example-generated-sdk-ts/examples/write-operations.js +0 -44
- package/examples/example-generated-sdk-ts/index.d.ts +0 -1
- package/examples/example-generated-sdk-ts/index.js +0 -15
- package/examples/example-generated-sdk-ts/package-lock.json +0 -59
- package/examples/example-generated-sdk-ts/package.json +0 -23
- package/examples/example-generated-sdk-ts/src/SimpleERC20.ts +0 -334
- package/examples/example-generated-sdk-ts/src/SimpleERC20__factory.ts +0 -28
- package/examples/example-generated-sdk-ts/src/index.ts +0 -4
- package/examples/example-generated-sdk-ts/src/quantumcoin-shims.d.ts +0 -23
- package/examples/example-generated-sdk-ts/src/types.ts +0 -4
- package/examples/example-generated-sdk-ts/test/e2e/SimpleERC20.e2e.test.js +0 -78
- package/examples/example-generated-sdk-ts/tsconfig.json +0 -14
- package/examples/example-generator-sdk-js.js +0 -100
- package/examples/example-generator-sdk-js.ts +0 -77
- package/examples/example-generator-sdk-ts.js +0 -100
- package/examples/example-generator-sdk-ts.ts +0 -77
- package/examples/example.js +0 -67
- package/examples/example.ts +0 -56
- package/examples/node_modules/.bin/esbuild +0 -16
- package/examples/node_modules/.bin/esbuild.cmd +0 -17
- package/examples/node_modules/.bin/esbuild.ps1 +0 -28
- package/examples/node_modules/.bin/sdkgen +0 -16
- package/examples/node_modules/.bin/sdkgen.cmd +0 -17
- package/examples/node_modules/.bin/sdkgen.ps1 +0 -28
- package/examples/node_modules/.bin/tsx +0 -16
- package/examples/node_modules/.bin/tsx.cmd +0 -17
- package/examples/node_modules/.bin/tsx.ps1 +0 -28
- package/examples/node_modules/.package-lock.json +0 -144
- package/examples/node_modules/@esbuild/win32-x64/README.md +0 -3
- package/examples/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
- package/examples/node_modules/@esbuild/win32-x64/package.json +0 -20
- package/examples/node_modules/esbuild/LICENSE.md +0 -21
- package/examples/node_modules/esbuild/README.md +0 -3
- package/examples/node_modules/esbuild/bin/esbuild +0 -223
- package/examples/node_modules/esbuild/install.js +0 -289
- package/examples/node_modules/esbuild/lib/main.d.ts +0 -716
- package/examples/node_modules/esbuild/lib/main.js +0 -2532
- package/examples/node_modules/esbuild/package.json +0 -49
- package/examples/node_modules/get-tsconfig/LICENSE +0 -21
- package/examples/node_modules/get-tsconfig/README.md +0 -235
- package/examples/node_modules/get-tsconfig/dist/index.cjs +0 -7
- package/examples/node_modules/get-tsconfig/dist/index.d.cts +0 -2088
- package/examples/node_modules/get-tsconfig/dist/index.d.mts +0 -2088
- package/examples/node_modules/get-tsconfig/dist/index.mjs +0 -7
- package/examples/node_modules/get-tsconfig/package.json +0 -46
- package/examples/node_modules/quantum-coin-js-sdk/LICENSE +0 -21
- package/examples/node_modules/quantum-coin-js-sdk/LICENSE-wasm_exec.js.txt +0 -30
- package/examples/node_modules/quantum-coin-js-sdk/README.md +0 -1675
- package/examples/node_modules/quantum-coin-js-sdk/example/README.md +0 -14
- package/examples/node_modules/quantum-coin-js-sdk/example/conversion-example.js +0 -19
- package/examples/node_modules/quantum-coin-js-sdk/example/example-create-contract.js +0 -396
- package/examples/node_modules/quantum-coin-js-sdk/example/example-encode-decode-rlp.js +0 -225
- package/examples/node_modules/quantum-coin-js-sdk/example/example-event-pack-unpack.js +0 -391
- package/examples/node_modules/quantum-coin-js-sdk/example/example-misc.js +0 -101
- package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send-signRawTransaction.js +0 -318
- package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send.js +0 -116
- package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +0 -70
- package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +0 -961
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +0 -35
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet.js +0 -43
- package/examples/node_modules/quantum-coin-js-sdk/example/example.js +0 -405
- package/examples/node_modules/quantum-coin-js-sdk/example/package-lock.json +0 -134
- package/examples/node_modules/quantum-coin-js-sdk/example/package.json +0 -15
- package/examples/node_modules/quantum-coin-js-sdk/index.d.ts +0 -1031
- package/examples/node_modules/quantum-coin-js-sdk/index.js +0 -3144
- package/examples/node_modules/quantum-coin-js-sdk/package.json +0 -34
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-32.json +0 -1
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-36.json +0 -1
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-48.json +0 -1
- package/examples/node_modules/quantum-coin-js-sdk/tests/generate-verify-vectors.js +0 -91
- package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.preinit.test.js +0 -41
- package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.test.js +0 -1389
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-keytype5-context-null.test.js +0 -107
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-transaction.test.js +0 -196
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-verify.test.js +0 -311
- package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.relay.test.js +0 -131
- package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.rpc.test.js +0 -103
- package/examples/node_modules/quantum-coin-js-sdk/tests/verify-vectors.json +0 -95035
- package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.d.ts +0 -9
- package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.js +0 -16
- package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.d.ts +0 -0
- package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.js +0 -587
- package/examples/node_modules/resolve-pkg-maps/LICENSE +0 -21
- package/examples/node_modules/resolve-pkg-maps/README.md +0 -216
- package/examples/node_modules/resolve-pkg-maps/dist/index.cjs +0 -1
- package/examples/node_modules/resolve-pkg-maps/dist/index.d.cts +0 -11
- package/examples/node_modules/resolve-pkg-maps/dist/index.d.mts +0 -11
- package/examples/node_modules/resolve-pkg-maps/dist/index.mjs +0 -1
- package/examples/node_modules/resolve-pkg-maps/package.json +0 -42
- package/examples/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
- package/examples/node_modules/seed-words/BUILD.md +0 -7
- package/examples/node_modules/seed-words/LICENSE +0 -121
- package/examples/node_modules/seed-words/README.md +0 -67
- package/examples/node_modules/seed-words/dist/seedwords.d.ts +0 -39
- package/examples/node_modules/seed-words/package.json +0 -27
- package/examples/node_modules/seed-words/seedwords.js +0 -315
- package/examples/node_modules/seed-words/seedwords.txt +0 -65536
- package/examples/node_modules/seed-words/tsconfig.json +0 -21
- package/examples/node_modules/tsx/LICENSE +0 -21
- package/examples/node_modules/tsx/README.md +0 -32
- package/examples/node_modules/tsx/dist/cjs/api/index.cjs +0 -1
- package/examples/node_modules/tsx/dist/cjs/api/index.d.cts +0 -35
- package/examples/node_modules/tsx/dist/cjs/api/index.d.mts +0 -35
- package/examples/node_modules/tsx/dist/cjs/api/index.mjs +0 -1
- package/examples/node_modules/tsx/dist/cjs/index.cjs +0 -1
- package/examples/node_modules/tsx/dist/cjs/index.mjs +0 -1
- package/examples/node_modules/tsx/dist/cli.cjs +0 -54
- package/examples/node_modules/tsx/dist/cli.mjs +0 -55
- package/examples/node_modules/tsx/dist/client-BQVF1NaW.mjs +0 -1
- package/examples/node_modules/tsx/dist/client-D6NvIMSC.cjs +0 -1
- package/examples/node_modules/tsx/dist/esm/api/index.cjs +0 -1
- package/examples/node_modules/tsx/dist/esm/api/index.d.cts +0 -35
- package/examples/node_modules/tsx/dist/esm/api/index.d.mts +0 -35
- package/examples/node_modules/tsx/dist/esm/api/index.mjs +0 -1
- package/examples/node_modules/tsx/dist/esm/index.cjs +0 -2
- package/examples/node_modules/tsx/dist/esm/index.mjs +0 -2
- package/examples/node_modules/tsx/dist/get-pipe-path-BHW2eJdv.mjs +0 -1
- package/examples/node_modules/tsx/dist/get-pipe-path-BoR10qr8.cjs +0 -1
- package/examples/node_modules/tsx/dist/index-7AaEi15b.mjs +0 -14
- package/examples/node_modules/tsx/dist/index-BWFBUo6r.cjs +0 -1
- package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +0 -1
- package/examples/node_modules/tsx/dist/index-gckBtVBf.cjs +0 -14
- package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +0 -3
- package/examples/node_modules/tsx/dist/lexer-DgIbo0BU.cjs +0 -3
- package/examples/node_modules/tsx/dist/loader.cjs +0 -1
- package/examples/node_modules/tsx/dist/loader.mjs +0 -1
- package/examples/node_modules/tsx/dist/node-features-_8ZFwP_x.mjs +0 -1
- package/examples/node_modules/tsx/dist/node-features-roYmp9jK.cjs +0 -1
- package/examples/node_modules/tsx/dist/package-CeBgXWuR.mjs +0 -1
- package/examples/node_modules/tsx/dist/package-Dxt5kIHw.cjs +0 -1
- package/examples/node_modules/tsx/dist/patch-repl.cjs +0 -1
- package/examples/node_modules/tsx/dist/patch-repl.mjs +0 -1
- package/examples/node_modules/tsx/dist/preflight.cjs +0 -1
- package/examples/node_modules/tsx/dist/preflight.mjs +0 -1
- package/examples/node_modules/tsx/dist/register-2sWVXuRQ.cjs +0 -1
- package/examples/node_modules/tsx/dist/register-B7jrtLTO.mjs +0 -1
- package/examples/node_modules/tsx/dist/register-CFH5oNdT.mjs +0 -4
- package/examples/node_modules/tsx/dist/register-D46fvsV_.cjs +0 -4
- package/examples/node_modules/tsx/dist/repl.cjs +0 -3
- package/examples/node_modules/tsx/dist/repl.mjs +0 -3
- package/examples/node_modules/tsx/dist/require-D4F1Lv60.cjs +0 -1
- package/examples/node_modules/tsx/dist/require-DQxpCAr4.mjs +0 -1
- package/examples/node_modules/tsx/dist/suppress-warnings.cjs +0 -1
- package/examples/node_modules/tsx/dist/suppress-warnings.mjs +0 -1
- package/examples/node_modules/tsx/dist/temporary-directory-B83uKxJF.cjs +0 -1
- package/examples/node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs +0 -1
- package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +0 -5
- package/examples/node_modules/tsx/package.json +0 -68
- package/examples/offline-signing.js +0 -77
- package/examples/offline-signing.ts +0 -65
- package/examples/package-lock.json +0 -596
- package/examples/package.json +0 -32
- package/examples/read-operations.js +0 -32
- package/examples/read-operations.ts +0 -31
- package/examples/sdk-generator-erc20.inline.json +0 -251
- package/examples/solidity-types.ts +0 -43
- package/examples/wallet-offline.js +0 -36
- package/examples/wallet-offline.ts +0 -26
- package/scripts/copy-declarations.js +0 -31
- package/scripts/run-all-one-by-one.js +0 -151
- package/test/e2e/all-solidity-types.dynamic.test.js +0 -207
- package/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
- package/test/e2e/all-solidity-types.fixtures.js +0 -231
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/README.md +0 -83
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.abi.json +0 -12544
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.bin +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.js +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.d.ts +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.js +0 -21
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package-lock.json +0 -597
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package.json +0 -25
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.d.ts +0 -1280
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.js +0 -14021
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.d.ts +0 -11
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.js +0 -31
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.d.ts +0 -4
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.js +0 -5
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.d.ts +0 -3
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.js +0 -3
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.e2e.test.js +0 -77
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.extra.test.js +0 -195
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/README.md +0 -83
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.abi.json +0 -12544
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.bin +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.js +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.d.ts +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.js +0 -21
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package-lock.json +0 -597
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package.json +0 -26
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes.ts +0 -13940
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes__factory.ts +0 -31
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/index.ts +0 -4
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/types.ts +0 -4
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.e2e.test.js +0 -77
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.extra.test.js +0 -195
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/tsconfig.json +0 -18
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/README.md +0 -74
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.abi.json +0 -245
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.bin +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.js +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.d.ts +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.js +0 -16
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package-lock.json +0 -597
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package.json +0 -25
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.d.ts +0 -24
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.js +0 -378
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.d.ts +0 -10
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.js +0 -31
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.d.ts +0 -4
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.js +0 -5
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.d.ts +0 -3
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.js +0 -3
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/test/e2e/SimpleERC20.e2e.test.js +0 -90
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/README.md +0 -74
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.abi.json +0 -245
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.bin +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.js +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.d.ts +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.js +0 -16
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package-lock.json +0 -597
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package.json +0 -26
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20.ts +0 -361
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20__factory.ts +0 -30
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/index.ts +0 -4
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/types.ts +0 -4
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/test/e2e/SimpleERC20.e2e.test.js +0 -90
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/tsconfig.json +0 -18
- package/test/e2e/generator-interface.e2e.test.js +0 -165
- package/test/e2e/generator-interface.e2e.test.ts +0 -160
- package/test/e2e/helpers.js +0 -59
- package/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
- package/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
- package/test/e2e/transactional.test.js +0 -245
- package/test/e2e/transactional.test.ts +0 -208
- package/test/e2e/typed-generator.e2e.test.js +0 -407
- package/test/e2e/typed-generator.e2e.test.ts +0 -337
- package/test/fixtures/ConstructorParam.sol +0 -23
- package/test/fixtures/MultiContracts.sol +0 -37
- package/test/fixtures/SimpleStorage.sol +0 -18
- package/test/fixtures/StakingContract.abi.json +0 -1
- package/test/integration/ipc-provider.test.js +0 -49
- package/test/integration/ipc-provider.test.ts +0 -44
- package/test/integration/provider.test.js +0 -88
- package/test/integration/provider.test.ts +0 -85
- package/test/integration/ws-provider.test.js +0 -41
- package/test/integration/ws-provider.test.ts +0 -38
- package/test/security/abi-decoder-bounds.test.js +0 -122
- package/test/security/contract-overrides.test.js +0 -112
- package/test/security/generator-injection.test.js +0 -195
- package/test/security/malformed-input.test.js +0 -330
- package/test/security/malformed-input.test.ts +0 -35
- package/test/security/rpc-numeric-bounds.test.js +0 -81
- package/test/security/rpc-trust.test.js +0 -202
- package/test/unit/_encrypted-output.txt +0 -6
- package/test/unit/_log-encrypted-jsons.js +0 -45
- package/test/unit/_write-keystore-fixture.js +0 -16
- package/test/unit/abi-interface.test.js +0 -110
- package/test/unit/abi-interface.test.ts +0 -109
- package/test/unit/address-wallet.test.js +0 -923
- package/test/unit/address-wallet.test.ts +0 -877
- package/test/unit/browser-provider.test.js +0 -85
- package/test/unit/browser-provider.test.ts +0 -79
- package/test/unit/contract.test.js +0 -85
- package/test/unit/contract.test.ts +0 -83
- package/test/unit/encoding-units-rlp.test.js +0 -127
- package/test/unit/encoding-units-rlp.test.ts +0 -91
- package/test/unit/errors.test.js +0 -77
- package/test/unit/errors.test.ts +0 -76
- package/test/unit/filter-by-blockhash.test.js +0 -55
- package/test/unit/filter-by-blockhash.test.ts +0 -54
- package/test/unit/fixednumber.test.js +0 -656
- package/test/unit/fixednumber.test.ts +0 -660
- package/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
- package/test/unit/generate-contract-cli.test.js +0 -42
- package/test/unit/generate-contract-cli.test.ts +0 -41
- package/test/unit/generate-sdk-artifacts-json.test.js +0 -113
- package/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
- package/test/unit/generator.test.js +0 -149
- package/test/unit/generator.test.ts +0 -148
- package/test/unit/hashing.test.js +0 -64
- package/test/unit/hashing.test.ts +0 -63
- package/test/unit/init.test.js +0 -39
- package/test/unit/init.test.ts +0 -38
- package/test/unit/interface.test.js +0 -56
- package/test/unit/interface.test.ts +0 -54
- package/test/unit/internal-hex.test.js +0 -81
- package/test/unit/internal-hex.test.ts +0 -80
- package/test/unit/populate-transaction.test.js +0 -98
- package/test/unit/populate-transaction.test.ts +0 -64
- package/test/unit/providers.test.js +0 -252
- package/test/unit/providers.test.ts +0 -251
- package/test/unit/result.test.js +0 -80
- package/test/unit/result.test.ts +0 -79
- package/test/unit/solidity-types.test.js +0 -49
- package/test/unit/solidity-types.test.ts +0 -39
- package/test/unit/utils.test.js +0 -57
- package/test/unit/utils.test.ts +0 -56
- package/test/verbose-logger.js +0 -74
- package/tsconfig.build.json +0 -14
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description BrowserProvider (EIP-1193 wrapper) + debug event sink validation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
|
|
11
|
-
const qc = require("../../index");
|
|
12
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
|
-
|
|
14
|
-
describe("BrowserProvider", () => {
|
|
15
|
-
logSuite("BrowserProvider");
|
|
16
|
-
it("wraps an EIP-1193 provider and emits debug events", async () => {
|
|
17
|
-
logTest("wraps an EIP-1193 provider and emits debug events", {});
|
|
18
|
-
/** @type {any[]} */
|
|
19
|
-
const calls = [];
|
|
20
|
-
|
|
21
|
-
const fakeEip1193 = {
|
|
22
|
-
request: async ({ method, params }) => {
|
|
23
|
-
calls.push({ method, params });
|
|
24
|
-
if (method === "eth_accounts") {
|
|
25
|
-
return ["0x" + "11".repeat(32)];
|
|
26
|
-
}
|
|
27
|
-
if (method === "eth_blockNumber") {
|
|
28
|
-
return "0x10";
|
|
29
|
-
}
|
|
30
|
-
if (method === "eth_getBlockByNumber") {
|
|
31
|
-
// params: [ "latest", false ]
|
|
32
|
-
return {
|
|
33
|
-
number: "0x10",
|
|
34
|
-
hash: "0x" + "aa".repeat(32),
|
|
35
|
-
parentHash: "0x" + "bb".repeat(32),
|
|
36
|
-
timestamp: "0x1",
|
|
37
|
-
transactions: [],
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`unsupported method: ${method}`);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const provider = new qc.BrowserProvider(fakeEip1193);
|
|
45
|
-
|
|
46
|
-
/** @type {any[]} */
|
|
47
|
-
const debug = [];
|
|
48
|
-
provider.on("debug", (ev) => debug.push(ev));
|
|
49
|
-
|
|
50
|
-
const bn = await provider.getBlockNumber();
|
|
51
|
-
assert.equal(bn, 16);
|
|
52
|
-
|
|
53
|
-
const latest = await provider.getBlock("latest");
|
|
54
|
-
assert.equal(latest.number, 16);
|
|
55
|
-
assert.ok(typeof latest.hash === "string");
|
|
56
|
-
|
|
57
|
-
const signer = await provider.getSigner();
|
|
58
|
-
const addr = await signer.getAddress();
|
|
59
|
-
assert.equal(addr.toLowerCase(), ("0x" + "11".repeat(32)).toLowerCase());
|
|
60
|
-
assert.equal(await provider.hasSigner(addr), true);
|
|
61
|
-
|
|
62
|
-
// Validate calls shape
|
|
63
|
-
assert.deepEqual(
|
|
64
|
-
calls.map((c) => c.method),
|
|
65
|
-
["eth_blockNumber", "eth_getBlockByNumber", "eth_accounts", "eth_accounts"],
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// Validate debug event sink: send+receive per request in order
|
|
69
|
-
const actions = debug.map((d) => d && d.action);
|
|
70
|
-
assert.deepEqual(actions, [
|
|
71
|
-
"sendEip1193Payload",
|
|
72
|
-
"receiveEip1193Result",
|
|
73
|
-
"sendEip1193Payload",
|
|
74
|
-
"receiveEip1193Result",
|
|
75
|
-
"sendEip1193Payload",
|
|
76
|
-
"receiveEip1193Result",
|
|
77
|
-
"sendEip1193Payload",
|
|
78
|
-
"receiveEip1193Result",
|
|
79
|
-
]);
|
|
80
|
-
|
|
81
|
-
assert.equal(debug[0].payload.method, "eth_blockNumber");
|
|
82
|
-
assert.equal(debug[2].payload.method, "eth_getBlockByNumber");
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description BrowserProvider (EIP-1193 wrapper) + debug event sink validation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
|
|
11
|
-
import qc from "../../index";
|
|
12
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
13
|
-
|
|
14
|
-
describe("BrowserProvider", () => {
|
|
15
|
-
logSuite("BrowserProvider");
|
|
16
|
-
it("wraps an EIP-1193 provider and emits debug events", async () => {
|
|
17
|
-
logTest("wraps an EIP-1193 provider and emits debug events", {});
|
|
18
|
-
const calls: { method: string; params?: unknown }[] = [];
|
|
19
|
-
|
|
20
|
-
const fakeEip1193 = {
|
|
21
|
-
request: async ({ method, params }: { method: string; params?: unknown }) => {
|
|
22
|
-
calls.push({ method, params });
|
|
23
|
-
if (method === "eth_accounts") {
|
|
24
|
-
return ["0x" + "11".repeat(32)];
|
|
25
|
-
}
|
|
26
|
-
if (method === "eth_blockNumber") {
|
|
27
|
-
return "0x10";
|
|
28
|
-
}
|
|
29
|
-
if (method === "eth_getBlockByNumber") {
|
|
30
|
-
return {
|
|
31
|
-
number: "0x10",
|
|
32
|
-
hash: "0x" + "aa".repeat(32),
|
|
33
|
-
parentHash: "0x" + "bb".repeat(32),
|
|
34
|
-
timestamp: "0x1",
|
|
35
|
-
transactions: [],
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
throw new Error(`unsupported method: ${method}`);
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const provider = new qc.BrowserProvider(fakeEip1193);
|
|
43
|
-
|
|
44
|
-
const debug: { action?: string; payload?: { method: string } }[] = [];
|
|
45
|
-
provider.on("debug", (ev) => debug.push(ev));
|
|
46
|
-
|
|
47
|
-
const bn = await provider.getBlockNumber();
|
|
48
|
-
assert.equal(bn, 16);
|
|
49
|
-
|
|
50
|
-
const latest = await provider.getBlock("latest");
|
|
51
|
-
assert.equal(latest.number, 16);
|
|
52
|
-
assert.ok(typeof latest.hash === "string");
|
|
53
|
-
|
|
54
|
-
const signer = await provider.getSigner();
|
|
55
|
-
const addr = await signer.getAddress();
|
|
56
|
-
assert.equal(addr.toLowerCase(), ("0x" + "11".repeat(32)).toLowerCase());
|
|
57
|
-
assert.equal(await provider.hasSigner(addr), true);
|
|
58
|
-
|
|
59
|
-
assert.deepEqual(
|
|
60
|
-
calls.map((c) => c.method),
|
|
61
|
-
["eth_blockNumber", "eth_getBlockByNumber", "eth_accounts", "eth_accounts"],
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const actions = debug.map((d) => d && d.action);
|
|
65
|
-
assert.deepEqual(actions, [
|
|
66
|
-
"sendEip1193Payload",
|
|
67
|
-
"receiveEip1193Result",
|
|
68
|
-
"sendEip1193Payload",
|
|
69
|
-
"receiveEip1193Result",
|
|
70
|
-
"sendEip1193Payload",
|
|
71
|
-
"receiveEip1193Result",
|
|
72
|
-
"sendEip1193Payload",
|
|
73
|
-
"receiveEip1193Result",
|
|
74
|
-
]);
|
|
75
|
-
|
|
76
|
-
assert.equal(debug[0].payload!.method, "eth_blockNumber");
|
|
77
|
-
assert.equal(debug[2].payload!.method, "eth_getBlockByNumber");
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Contract behavior that can be tested offline (overrides, listeners)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
|
|
11
|
-
const { Initialize } = require("../../config");
|
|
12
|
-
const qc = require("../../index");
|
|
13
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
14
|
-
|
|
15
|
-
describe("Contract", () => {
|
|
16
|
-
logSuite("Contract");
|
|
17
|
-
it("_invoke treats last arg as overrides only when object-like (null is NOT overrides)", async () => {
|
|
18
|
-
logTest("_invoke treats last arg as overrides only when object-like (null is NOT overrides)", {});
|
|
19
|
-
await Initialize(null);
|
|
20
|
-
const addr = qc.Wallet.createRandom().address;
|
|
21
|
-
const abi = [
|
|
22
|
-
{ type: "function", name: "viewFn", stateMutability: "view", inputs: [{ name: "x", type: "uint256" }], outputs: [] },
|
|
23
|
-
{ type: "function", name: "writeFn", stateMutability: "nonpayable", inputs: [{ name: "x", type: "uint256" }], outputs: [] },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const c = new qc.Contract(addr, abi, null);
|
|
27
|
-
|
|
28
|
-
/** @type {any[]} */
|
|
29
|
-
const seen = [];
|
|
30
|
-
c.call = async (methodName, args, overrides) => {
|
|
31
|
-
seen.push({ kind: "call", methodName, args, overrides });
|
|
32
|
-
return "ok";
|
|
33
|
-
};
|
|
34
|
-
c.send = async (methodName, args, overrides) => {
|
|
35
|
-
seen.push({ kind: "send", methodName, args, overrides });
|
|
36
|
-
return { hash: "0x" + "22".repeat(32) };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Overrides object extracted
|
|
40
|
-
await c._invoke("viewFn", [1n, { gasLimit: 123 }]);
|
|
41
|
-
// Passing null is NOT treated as overrides (it becomes a second argument)
|
|
42
|
-
await c._invoke("viewFn", [1n, null]);
|
|
43
|
-
// State-changing path chooses send()
|
|
44
|
-
await c._invoke("writeFn", [1n, { gasLimit: 456 }]);
|
|
45
|
-
|
|
46
|
-
assert.deepEqual(seen[0], { kind: "call", methodName: "viewFn", args: [1n], overrides: { gasLimit: 123 } });
|
|
47
|
-
assert.deepEqual(seen[1], { kind: "call", methodName: "viewFn", args: [1n, null], overrides: undefined });
|
|
48
|
-
assert.deepEqual(seen[2], { kind: "send", methodName: "writeFn", args: [1n], overrides: { gasLimit: 456 } });
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("removeAllListeners clears all when event omitted vs null, and clears one event when provided", async () => {
|
|
52
|
-
await Initialize(null);
|
|
53
|
-
const addr = qc.Wallet.createRandom().address;
|
|
54
|
-
const c = new qc.Contract(addr, [], null);
|
|
55
|
-
|
|
56
|
-
const cb1 = () => {};
|
|
57
|
-
const cb2 = () => {};
|
|
58
|
-
c.on("A", cb1);
|
|
59
|
-
c.on("B", cb2);
|
|
60
|
-
|
|
61
|
-
c.removeAllListeners("A");
|
|
62
|
-
// B remains
|
|
63
|
-
assert.equal(c._listeners.get("A")?.length || 0, 0);
|
|
64
|
-
assert.equal(c._listeners.get("B")?.length || 0, 1);
|
|
65
|
-
|
|
66
|
-
c.removeAllListeners(null); // treated as "no event"
|
|
67
|
-
assert.equal(c._listeners.size, 0);
|
|
68
|
-
|
|
69
|
-
c.on("C", cb1);
|
|
70
|
-
c.removeAllListeners(); // omitted => clear all
|
|
71
|
-
assert.equal(c._listeners.size, 0);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe("ContractTransactionReceipt", () => {
|
|
76
|
-
it("getEvent/getEvents filter logs by eventName", () => {
|
|
77
|
-
const receipt = new qc.ContractTransactionReceipt({
|
|
78
|
-
logs: [{ eventName: "A", data: 1 }, { eventName: "B", data: 2 }, { eventName: "A", data: 3 }],
|
|
79
|
-
});
|
|
80
|
-
assert.deepEqual(receipt.getEvents("A").map((l) => l.data), [1, 3]);
|
|
81
|
-
assert.equal(receipt.getEvent("B").data, 2);
|
|
82
|
-
assert.equal(receipt.getEvent("Missing"), null);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Contract behavior that can be tested offline (overrides, listeners)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
|
|
11
|
-
import { Initialize } from "../../config";
|
|
12
|
-
import qc from "../../index";
|
|
13
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
14
|
-
|
|
15
|
-
describe("Contract", () => {
|
|
16
|
-
logSuite("Contract");
|
|
17
|
-
it("_invoke treats last arg as overrides only when object-like (null is NOT overrides)", async () => {
|
|
18
|
-
logTest("_invoke treats last arg as overrides only when object-like (null is NOT overrides)", {});
|
|
19
|
-
await Initialize(null);
|
|
20
|
-
const addr = qc.Wallet.createRandom().address;
|
|
21
|
-
const abi = [
|
|
22
|
-
{ type: "function", name: "viewFn", stateMutability: "view", inputs: [{ name: "x", type: "uint256" }], outputs: [] },
|
|
23
|
-
{ type: "function", name: "writeFn", stateMutability: "nonpayable", inputs: [{ name: "x", type: "uint256" }], outputs: [] },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const c = new qc.Contract(addr, abi, null);
|
|
27
|
-
|
|
28
|
-
const seen: { kind: string; methodName: string; args: unknown[]; overrides?: unknown }[] = [];
|
|
29
|
-
c.call = async (methodName: string, args: unknown[], overrides?: unknown) => {
|
|
30
|
-
seen.push({ kind: "call", methodName, args, overrides });
|
|
31
|
-
return "ok";
|
|
32
|
-
};
|
|
33
|
-
c.send = async (methodName: string, args: unknown[], overrides?: unknown) => {
|
|
34
|
-
seen.push({ kind: "send", methodName, args, overrides });
|
|
35
|
-
return { hash: "0x" + "22".repeat(32) };
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
await c._invoke("viewFn", [1n, { gasLimit: 123 }]);
|
|
39
|
-
await c._invoke("viewFn", [1n, null]);
|
|
40
|
-
await c._invoke("writeFn", [1n, { gasLimit: 456 }]);
|
|
41
|
-
|
|
42
|
-
assert.deepEqual(seen[0], { kind: "call", methodName: "viewFn", args: [1n], overrides: { gasLimit: 123 } });
|
|
43
|
-
assert.deepEqual(seen[1], { kind: "call", methodName: "viewFn", args: [1n, null], overrides: undefined });
|
|
44
|
-
assert.deepEqual(seen[2], { kind: "send", methodName: "writeFn", args: [1n], overrides: { gasLimit: 456 } });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("removeAllListeners clears all when event omitted vs null, and clears one event when provided", async () => {
|
|
48
|
-
await Initialize(null);
|
|
49
|
-
const addr = qc.Wallet.createRandom().address;
|
|
50
|
-
const c = new qc.Contract(addr, [], null);
|
|
51
|
-
|
|
52
|
-
const cb1 = () => {};
|
|
53
|
-
const cb2 = () => {};
|
|
54
|
-
c.on("A", cb1);
|
|
55
|
-
c.on("B", cb2);
|
|
56
|
-
|
|
57
|
-
c.removeAllListeners("A");
|
|
58
|
-
assert.equal(c._listeners.get("A")?.length || 0, 0);
|
|
59
|
-
assert.equal(c._listeners.get("B")?.length || 0, 1);
|
|
60
|
-
|
|
61
|
-
c.removeAllListeners(null);
|
|
62
|
-
assert.equal(c._listeners.size, 0);
|
|
63
|
-
|
|
64
|
-
c.on("C", cb1);
|
|
65
|
-
c.removeAllListeners();
|
|
66
|
-
assert.equal(c._listeners.size, 0);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe("ContractTransactionReceipt", () => {
|
|
71
|
-
it("getEvent/getEvents filter logs by eventName", () => {
|
|
72
|
-
const receipt = new qc.ContractTransactionReceipt({
|
|
73
|
-
logs: [
|
|
74
|
-
{ eventName: "A", data: 1 },
|
|
75
|
-
{ eventName: "B", data: 2 },
|
|
76
|
-
{ eventName: "A", data: 3 },
|
|
77
|
-
],
|
|
78
|
-
});
|
|
79
|
-
assert.deepEqual(receipt.getEvents("A").map((l) => l.data), [1, 3]);
|
|
80
|
-
assert.equal(receipt.getEvent("B").data, 2);
|
|
81
|
-
assert.equal(receipt.getEvent("Missing"), null);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Encoding + units + RLP edge cases (optional params, negative paths)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
|
|
11
|
-
const qc = require("../../index");
|
|
12
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
|
-
|
|
14
|
-
describe("Encoding", () => {
|
|
15
|
-
logSuite("Encoding");
|
|
16
|
-
it("toHex/hexlify normalize strings and bytes", () => {
|
|
17
|
-
logTest("toHex/hexlify normalize strings and bytes", {});
|
|
18
|
-
assert.equal(qc.toHex("0x0A"), "0x0a");
|
|
19
|
-
assert.equal(qc.hexlify(new Uint8Array([0x0a])), "0x0a");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("concat concatenates and rejects non-array", () => {
|
|
23
|
-
const out = qc.concat([new Uint8Array([1, 2]), "0x03"]);
|
|
24
|
-
assert.equal(out, "0x010203");
|
|
25
|
-
assert.throws(() => qc.concat("nope"));
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("stripZerosLeft removes leading zeros", () => {
|
|
29
|
-
assert.equal(qc.stripZerosLeft("0x0000"), "0x");
|
|
30
|
-
assert.equal(qc.stripZerosLeft("0x000001"), "0x01");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("zeroPad throws when value exceeds length", () => {
|
|
34
|
-
assert.throws(() => qc.zeroPad("0x1234", 1));
|
|
35
|
-
assert.equal(qc.zeroPad("0x12", 2), "0x0012");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("base64 encode/decode roundtrip", () => {
|
|
39
|
-
const b = qc.toUtf8Bytes("hello");
|
|
40
|
-
const b64 = qc.encodeBase64(b);
|
|
41
|
-
const out = qc.decodeBase64(b64);
|
|
42
|
-
assert.equal(qc.toUtf8String(out), "hello");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("isBytesLike returns true for hex and Uint8Array", () => {
|
|
46
|
-
assert.equal(qc.isBytesLike("0x1234"), true);
|
|
47
|
-
assert.equal(qc.isBytesLike(new Uint8Array([1, 2, 3])), true);
|
|
48
|
-
assert.equal(qc.isBytesLike("not-hex"), false);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("solidityPacked helpers throw (not implemented)", () => {
|
|
52
|
-
assert.throws(() => qc.solidityPacked(), /not implemented/i);
|
|
53
|
-
assert.throws(() => qc.solidityPackedKeccak256(), /not implemented/i);
|
|
54
|
-
assert.throws(() => qc.solidityPackedSha256(), /not implemented/i);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe("Units", () => {
|
|
59
|
-
it("parseUnits defaults decimals when omitted vs null", () => {
|
|
60
|
-
const a = qc.parseUnits("1.5");
|
|
61
|
-
const b = qc.parseUnits("1.5", null);
|
|
62
|
-
assert.equal(a, 1500000000000000000n);
|
|
63
|
-
assert.equal(a, b);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("formatUnits defaults decimals when omitted vs null", () => {
|
|
67
|
-
const a = qc.formatUnits(1500000000000000000n);
|
|
68
|
-
const b = qc.formatUnits(1500000000000000000n, null);
|
|
69
|
-
assert.equal(a, "1.5");
|
|
70
|
-
assert.equal(a, b);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("RLP", () => {
|
|
75
|
-
it("decodeRlp rejects non-string input", () => {
|
|
76
|
-
assert.throws(() => qc.decodeRlp(123));
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("decodeRlp rejects trailing data", () => {
|
|
80
|
-
const encoded = qc.encodeRlp("0x01");
|
|
81
|
-
const withTrailing = "0x" + encoded.slice(2) + "00";
|
|
82
|
-
assert.throws(() => qc.decodeRlp(withTrailing), /trailing data/i);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("encodeRlp supports null as empty bytes", () => {
|
|
86
|
-
const encoded = qc.encodeRlp(null);
|
|
87
|
-
assert.ok(typeof encoded === "string" && encoded.startsWith("0x"));
|
|
88
|
-
const decoded = qc.decodeRlp(encoded);
|
|
89
|
-
assert.equal(decoded, "0x");
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe("Security: RLP canonical encoding & length overflow", () => {
|
|
94
|
-
it("rejects a single byte < 0x80 encoded as a 1-byte string (negative)", () => {
|
|
95
|
-
// 0x81 0x00 = "short string of length 1 containing 0x00" — must be 0x00.
|
|
96
|
-
assert.throws(() => qc.decodeRlp("0x8100"), /non-canonical single byte/i);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("rejects a long-string form whose length fits the short form (negative)", () => {
|
|
100
|
-
// 0xb8 (long string, lenOfLen=1) 0x01 0xff -> declared length 1 (<= 55).
|
|
101
|
-
assert.throws(() => qc.decodeRlp("0xb801ff"), /non-canonical long string/i);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("rejects a length field with a leading zero byte (negative)", () => {
|
|
105
|
-
// 0xb9 (long string, lenOfLen=2) 0x00 0x38 -> leading zero in the length.
|
|
106
|
-
assert.throws(() => qc.decodeRlp("0xb9003800"), /leading zero/i);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("rejects a length that overflows MAX_SAFE_INTEGER (negative)", () => {
|
|
110
|
-
// 0xbf (long string, lenOfLen=8) followed by an 8-byte length starting at 0x20.
|
|
111
|
-
assert.throws(() => qc.decodeRlp("0xbf2000000000000000"), /maximum safe integer/i);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("round-trips a canonical long string (> 55 bytes) (positive)", () => {
|
|
115
|
-
const big = "0x" + "ab".repeat(60); // 60-byte string -> long-string form
|
|
116
|
-
const encoded = qc.encodeRlp(big);
|
|
117
|
-
const decoded = qc.decodeRlp(encoded);
|
|
118
|
-
assert.equal(decoded, big);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("round-trips a canonical nested list (positive)", () => {
|
|
122
|
-
const encoded = qc.encodeRlp([["0x01", "0x02"], "0x03"]);
|
|
123
|
-
const decoded = qc.decodeRlp(encoded);
|
|
124
|
-
assert.deepEqual(decoded, [["0x01", "0x02"], "0x03"]);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Encoding + units + RLP edge cases (optional params, negative paths)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
|
|
11
|
-
import qc from "../../index";
|
|
12
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
13
|
-
|
|
14
|
-
describe("Encoding", () => {
|
|
15
|
-
logSuite("Encoding");
|
|
16
|
-
it("toHex/hexlify normalize strings and bytes", () => {
|
|
17
|
-
logTest("toHex/hexlify normalize strings and bytes", {});
|
|
18
|
-
assert.equal(qc.toHex("0x0A"), "0x0a");
|
|
19
|
-
assert.equal(qc.hexlify(new Uint8Array([0x0a])), "0x0a");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("concat concatenates and rejects non-array", () => {
|
|
23
|
-
const out = qc.concat([new Uint8Array([1, 2]), "0x03"]);
|
|
24
|
-
assert.equal(out, "0x010203");
|
|
25
|
-
assert.throws(() => qc.concat("nope" as unknown as (string | Uint8Array)[]));
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("stripZerosLeft removes leading zeros", () => {
|
|
29
|
-
assert.equal(qc.stripZerosLeft("0x0000"), "0x");
|
|
30
|
-
assert.equal(qc.stripZerosLeft("0x000001"), "0x01");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("zeroPad throws when value exceeds length", () => {
|
|
34
|
-
assert.throws(() => qc.zeroPad("0x1234", 1));
|
|
35
|
-
assert.equal(qc.zeroPad("0x12", 2), "0x0012");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("base64 encode/decode roundtrip", () => {
|
|
39
|
-
const b = qc.toUtf8Bytes("hello");
|
|
40
|
-
const b64 = qc.encodeBase64(b);
|
|
41
|
-
const out = qc.decodeBase64(b64);
|
|
42
|
-
assert.equal(qc.toUtf8String(out), "hello");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("isBytesLike returns true for hex and Uint8Array", () => {
|
|
46
|
-
assert.equal(qc.isBytesLike("0x1234"), true);
|
|
47
|
-
assert.equal(qc.isBytesLike(new Uint8Array([1, 2, 3])), true);
|
|
48
|
-
assert.equal(qc.isBytesLike("not-hex"), false);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("solidityPacked helpers throw (not implemented)", () => {
|
|
52
|
-
assert.throws(() => qc.solidityPacked(), /not implemented/i);
|
|
53
|
-
assert.throws(() => qc.solidityPackedKeccak256(), /not implemented/i);
|
|
54
|
-
assert.throws(() => qc.solidityPackedSha256(), /not implemented/i);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe("Units", () => {
|
|
59
|
-
it("parseUnits defaults decimals when omitted vs null", () => {
|
|
60
|
-
const a = qc.parseUnits("1.5");
|
|
61
|
-
const b = qc.parseUnits("1.5", null);
|
|
62
|
-
assert.equal(a, 1500000000000000000n);
|
|
63
|
-
assert.equal(a, b);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("formatUnits defaults decimals when omitted vs null", () => {
|
|
67
|
-
const a = qc.formatUnits(1500000000000000000n);
|
|
68
|
-
const b = qc.formatUnits(1500000000000000000n, null);
|
|
69
|
-
assert.equal(a, "1.5");
|
|
70
|
-
assert.equal(a, b);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("RLP", () => {
|
|
75
|
-
it("decodeRlp rejects non-string input", () => {
|
|
76
|
-
assert.throws(() => qc.decodeRlp(123 as unknown as string));
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("decodeRlp rejects trailing data", () => {
|
|
80
|
-
const encoded = qc.encodeRlp("0x01");
|
|
81
|
-
const withTrailing = "0x" + encoded.slice(2) + "00";
|
|
82
|
-
assert.throws(() => qc.decodeRlp(withTrailing), /trailing data/i);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("encodeRlp supports null as empty bytes", () => {
|
|
86
|
-
const encoded = qc.encodeRlp(null);
|
|
87
|
-
assert.ok(typeof encoded === "string" && encoded.startsWith("0x"));
|
|
88
|
-
const decoded = qc.decodeRlp(encoded);
|
|
89
|
-
assert.equal(decoded, "0x");
|
|
90
|
-
});
|
|
91
|
-
});
|
package/test/unit/errors.test.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Error helpers and error classes (direct coverage)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
|
|
11
|
-
const qc = require("../../index");
|
|
12
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
|
-
|
|
14
|
-
describe("Errors", () => {
|
|
15
|
-
logSuite("Errors");
|
|
16
|
-
it("makeError sets code and shortMessage (info omitted vs null)", () => {
|
|
17
|
-
logTest("makeError sets code and shortMessage (info omitted vs null)", {});
|
|
18
|
-
const e1 = qc.makeError("boom", "UNKNOWN_ERROR");
|
|
19
|
-
const e2 = qc.makeError("boom", "UNKNOWN_ERROR", null);
|
|
20
|
-
|
|
21
|
-
assert.equal(e1.code, "UNKNOWN_ERROR");
|
|
22
|
-
assert.equal(e1.shortMessage, "boom");
|
|
23
|
-
assert.equal(e2.code, "UNKNOWN_ERROR");
|
|
24
|
-
assert.equal(e2.shortMessage, "boom");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("makeError attaches info and protects message/code/name", () => {
|
|
28
|
-
const e = qc.makeError("boom", "UNKNOWN_ERROR", { operation: "x" });
|
|
29
|
-
assert.equal(e.code, "UNKNOWN_ERROR");
|
|
30
|
-
assert.equal(e.shortMessage, "boom");
|
|
31
|
-
assert.equal(e.operation, "x");
|
|
32
|
-
|
|
33
|
-
assert.throws(() => qc.makeError("boom", "UNKNOWN_ERROR", { message: "nope" }));
|
|
34
|
-
assert.throws(() => qc.makeError("boom", "UNKNOWN_ERROR", { code: "NOPE" }));
|
|
35
|
-
assert.throws(() => qc.makeError("boom", "UNKNOWN_ERROR", { name: "Nope" }));
|
|
36
|
-
// shortMessage is defined read-only by makeError; passing it via info causes a TypeError
|
|
37
|
-
assert.throws(() => qc.makeError("boom", "UNKNOWN_ERROR", { shortMessage: "nope" }));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("assert and assertArgument throw INVALID_ARGUMENT with metadata", () => {
|
|
41
|
-
assert.throws(
|
|
42
|
-
() => qc.assert(false, "bad", "INVALID_ARGUMENT", { operation: "test" }),
|
|
43
|
-
(err) => err && err.code === "INVALID_ARGUMENT" && String(err.message).includes("operation"),
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
assert.throws(
|
|
47
|
-
() => qc.assertArgument(false, "bad arg", "foo", 123),
|
|
48
|
-
(err) => err && err.code === "INVALID_ARGUMENT" && err.argument === "foo" && err.value === 123,
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("isError and isCallException match code", () => {
|
|
53
|
-
const err = qc.makeError("x", "CALL_EXCEPTION");
|
|
54
|
-
assert.equal(qc.isError(err, "CALL_EXCEPTION"), true);
|
|
55
|
-
assert.equal(qc.isCallException(err), true);
|
|
56
|
-
assert.equal(qc.isCallException(qc.makeError("x", "UNKNOWN_ERROR")), false);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("ProviderError/TransactionError/ContractError set code and include info (info omitted vs null)", () => {
|
|
60
|
-
const p1 = new qc.ProviderError("p");
|
|
61
|
-
const p2 = new qc.ProviderError("p", null);
|
|
62
|
-
const p3 = new qc.ProviderError("p", { operation: "op" });
|
|
63
|
-
assert.equal(p1.code, "UNKNOWN_ERROR");
|
|
64
|
-
assert.equal(p1.shortMessage, "p");
|
|
65
|
-
assert.equal(p2.code, "UNKNOWN_ERROR");
|
|
66
|
-
assert.equal(p3.operation, "op");
|
|
67
|
-
|
|
68
|
-
const t1 = new qc.TransactionError("t", { reason: "r" });
|
|
69
|
-
assert.equal(t1.code, "UNKNOWN_ERROR");
|
|
70
|
-
assert.equal(t1.reason, "r");
|
|
71
|
-
|
|
72
|
-
const c1 = new qc.ContractError("c", { contract: "X" });
|
|
73
|
-
assert.equal(c1.code, "UNKNOWN_ERROR");
|
|
74
|
-
assert.equal(c1.contract, "X");
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|