quantumcoin 7.0.15 → 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 +44 -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 -123
- 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 -18
- package/src/providers/json-rpc-provider.d.ts +1 -0
- package/src/providers/provider.d.ts +233 -222
- package/src/providers/provider.js +1 -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 -29
- package/src/wallet/wallet.js +3 -3
- 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 -1689
- 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 -100
- 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 -115
- package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +0 -69
- package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +0 -960
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +0 -34
- 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 -56
- 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 -1047
- package/examples/node_modules/quantum-coin-js-sdk/index.js +0 -3182
- 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/get-gas-price.test.js +0 -59
- 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 -945
- package/test/unit/address-wallet.test.ts +0 -899
- 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 -305
- package/test/unit/providers.test.ts +0 -304
- 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,304 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Provider helpers, wrappers, defaults, and extra providers
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
|
|
11
|
-
import qc from "../../index";
|
|
12
|
-
import { Initialize } from "../../config";
|
|
13
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
14
|
-
|
|
15
|
-
describe("JsonRpcProvider", () => {
|
|
16
|
-
logSuite("JsonRpcProvider");
|
|
17
|
-
it("defaults url/chainId when omitted vs null (no Initialize required)", () => {
|
|
18
|
-
logTest("defaults url/chainId when omitted vs null (no Initialize required)", {});
|
|
19
|
-
const p1 = new qc.JsonRpcProvider();
|
|
20
|
-
const p2 = new qc.JsonRpcProvider(null, null);
|
|
21
|
-
|
|
22
|
-
assert.equal(typeof p1.url, "string");
|
|
23
|
-
assert.ok(p1.url.length > 0);
|
|
24
|
-
assert.equal(p1.chainId, 123123);
|
|
25
|
-
|
|
26
|
-
assert.equal(p2.url, p1.url);
|
|
27
|
-
assert.equal(p2.chainId, 123123);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("_perform defaults params when omitted vs null", async (t: { skip: (msg: string) => void }) => {
|
|
31
|
-
logTest("_perform defaults params when omitted vs null", {});
|
|
32
|
-
if (typeof (globalThis as unknown as { fetch?: unknown }).fetch !== "function") {
|
|
33
|
-
t.skip("global fetch not available");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const originalFetch = (globalThis as unknown as { fetch: typeof fetch }).fetch;
|
|
38
|
-
const seen: unknown[][] = [];
|
|
39
|
-
|
|
40
|
-
(globalThis as unknown as { fetch: typeof fetch }).fetch = async (_url: string, init: RequestInit) => {
|
|
41
|
-
const body = JSON.parse(init.body as string);
|
|
42
|
-
seen.push(body.params);
|
|
43
|
-
const responseBody = JSON.stringify({ jsonrpc: "2.0", id: body.id, result: "0x1" });
|
|
44
|
-
return {
|
|
45
|
-
ok: true,
|
|
46
|
-
text: async () => responseBody,
|
|
47
|
-
json: async () => JSON.parse(responseBody),
|
|
48
|
-
} as Response;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const p = new qc.JsonRpcProvider("http://example.invalid", 123123);
|
|
53
|
-
const a = await p._perform("eth_blockNumber");
|
|
54
|
-
const b = await p._perform("eth_blockNumber", null);
|
|
55
|
-
assert.equal(a, "0x1");
|
|
56
|
-
assert.equal(b, "0x1");
|
|
57
|
-
assert.deepEqual(seen, [[], []]);
|
|
58
|
-
} finally {
|
|
59
|
-
(globalThis as unknown as { fetch: typeof fetch }).fetch = originalFetch;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe("AbstractProvider defaults", () => {
|
|
65
|
-
logSuite("AbstractProvider defaults");
|
|
66
|
-
it("getTransactionCount/call/getCode default blockTag when omitted vs null", async () => {
|
|
67
|
-
logTest("getTransactionCount/call/getCode default blockTag when omitted vs null", {});
|
|
68
|
-
class P extends qc.AbstractProvider {
|
|
69
|
-
calls: { method: string; params: unknown[] }[] = [];
|
|
70
|
-
constructor() {
|
|
71
|
-
super();
|
|
72
|
-
}
|
|
73
|
-
async _perform(method: string, params: unknown[]) {
|
|
74
|
-
this.calls.push({ method, params });
|
|
75
|
-
if (method === "eth_getTransactionCount") return "0x2";
|
|
76
|
-
if (method === "eth_call") return "0x";
|
|
77
|
-
if (method === "eth_getCode") return "0x";
|
|
78
|
-
throw new Error("unexpected");
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const p = new P();
|
|
83
|
-
await p.getTransactionCount("0x" + "11".repeat(32));
|
|
84
|
-
await p.getTransactionCount("0x" + "11".repeat(32), null);
|
|
85
|
-
await p.call({ to: "0x" + "11".repeat(32), data: "0x" });
|
|
86
|
-
await p.call({ to: "0x" + "11".repeat(32), data: "0x" }, null);
|
|
87
|
-
await p.getCode("0x" + "11".repeat(32));
|
|
88
|
-
await p.getCode("0x" + "11".repeat(32), null);
|
|
89
|
-
|
|
90
|
-
const tags = p.calls.map((c) => c.params[c.params.length - 1]);
|
|
91
|
-
assert.deepEqual(tags, ["latest", "latest", "latest", "latest", "latest", "latest"]);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe("AbstractProvider block-tag QUANTITY formatting", () => {
|
|
96
|
-
logSuite("AbstractProvider block-tag QUANTITY formatting");
|
|
97
|
-
|
|
98
|
-
it("getBlock encodes block numbers as spec-compliant quantities (no leading zeros)", async () => {
|
|
99
|
-
logTest("getBlock encodes block numbers as spec-compliant quantities", {});
|
|
100
|
-
class BlockStub extends qc.AbstractProvider {
|
|
101
|
-
calls: { method: string; params: any[] }[] = [];
|
|
102
|
-
async _perform(method: string, params: any[]) {
|
|
103
|
-
this.calls.push({ method, params });
|
|
104
|
-
return { number: "0x5", timestamp: "0x64" };
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const p = new BlockStub();
|
|
108
|
-
await p.getBlock(0); assert.equal(p.calls.at(-1)!.params[0], "0x0");
|
|
109
|
-
await p.getBlock(5); assert.equal(p.calls.at(-1)!.params[0], "0x5");
|
|
110
|
-
await p.getBlock(15); assert.equal(p.calls.at(-1)!.params[0], "0xf");
|
|
111
|
-
await p.getBlock(16); assert.equal(p.calls.at(-1)!.params[0], "0x10");
|
|
112
|
-
await p.getBlock(256); assert.equal(p.calls.at(-1)!.params[0], "0x100");
|
|
113
|
-
await p.getBlock(4095); assert.equal(p.calls.at(-1)!.params[0], "0xfff");
|
|
114
|
-
await p.getBlock(4096); assert.equal(p.calls.at(-1)!.params[0], "0x1000");
|
|
115
|
-
await p.getBlock("latest"); assert.equal(p.calls.at(-1)!.params[0], "latest");
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("getLogs encodes fromBlock/toBlock as spec-compliant quantities (no leading zeros)", async () => {
|
|
119
|
-
logTest("getLogs encodes fromBlock/toBlock as spec-compliant quantities", {});
|
|
120
|
-
class LogStub extends qc.AbstractProvider {
|
|
121
|
-
calls: { method: string; params: any[] }[] = [];
|
|
122
|
-
async _perform(method: string, params: any[]) {
|
|
123
|
-
this.calls.push({ method, params });
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const lp = new LogStub();
|
|
128
|
-
await lp.getLogs({ fromBlock: 5, toBlock: 256 });
|
|
129
|
-
assert.equal(lp.calls[0].params[0].fromBlock, "0x5");
|
|
130
|
-
assert.equal(lp.calls[0].params[0].toBlock, "0x100");
|
|
131
|
-
await lp.getLogs({ fromBlock: "latest", toBlock: "pending" });
|
|
132
|
-
assert.equal(lp.calls[1].params[0].fromBlock, "latest");
|
|
133
|
-
assert.equal(lp.calls[1].params[0].toBlock, "pending");
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("getBlock rejects invalid block numbers with a clear typed error", async () => {
|
|
137
|
-
logTest("getBlock rejects invalid block numbers", {});
|
|
138
|
-
class StubP extends qc.AbstractProvider {
|
|
139
|
-
async _perform() { return { number: "0x0" }; }
|
|
140
|
-
}
|
|
141
|
-
const p = new StubP();
|
|
142
|
-
await assert.rejects(() => p.getBlock(-1 as unknown as number), (e) => e instanceof RangeError);
|
|
143
|
-
await assert.rejects(() => p.getBlock(1.5 as unknown as number), (e) => e instanceof TypeError);
|
|
144
|
-
await assert.rejects(() => p.getBlock(NaN as unknown as number), (e) => e instanceof TypeError);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe("TransactionResponse.wait", () => {
|
|
149
|
-
logSuite("TransactionResponse.wait");
|
|
150
|
-
it("uses default confirmations when omitted vs null", async () => {
|
|
151
|
-
logTest("uses default confirmations when omitted vs null", {});
|
|
152
|
-
const fakeProvider = {
|
|
153
|
-
getTransactionReceipt: async () => ({ blockNumber: 1 }),
|
|
154
|
-
getBlockNumber: async () => 1,
|
|
155
|
-
};
|
|
156
|
-
const tx = new qc.TransactionResponse({ hash: "0x" + "11".repeat(32) }, fakeProvider as unknown as qc.Provider);
|
|
157
|
-
const r1 = await tx.wait();
|
|
158
|
-
const r2 = await tx.wait(null, null);
|
|
159
|
-
assert.deepEqual(r1, { blockNumber: 1 });
|
|
160
|
-
assert.deepEqual(r2, { blockNumber: 1 });
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("throws if provider missing", async () => {
|
|
164
|
-
logTest("throws if provider missing", {});
|
|
165
|
-
const tx = new qc.TransactionResponse({ hash: "0x" + "11".repeat(32) }, null);
|
|
166
|
-
await assert.rejects(() => tx.wait(), (e: Error & { code?: string; message?: string }) => e && e.code === "UNKNOWN_ERROR" && /missing provider/i.test(e.message ?? ""));
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
describe("getProvider", () => {
|
|
171
|
-
logSuite("getProvider");
|
|
172
|
-
it("returns JsonRpcProvider for http/https URLs", () => {
|
|
173
|
-
logTest("returns JsonRpcProvider for http/https URLs", {});
|
|
174
|
-
const p1 = qc.getProvider("https://public.rpc.quantumcoinapi.com", 123123);
|
|
175
|
-
const p2 = qc.getProvider("http://localhost:8545");
|
|
176
|
-
assert.ok(p1 instanceof qc.JsonRpcProvider);
|
|
177
|
-
assert.ok(p2 instanceof qc.JsonRpcProvider);
|
|
178
|
-
assert.equal(p1.url, "https://public.rpc.quantumcoinapi.com");
|
|
179
|
-
assert.equal(p1.chainId, 123123);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("returns WebSocketProvider for ws/wss URLs", () => {
|
|
183
|
-
logTest("returns WebSocketProvider for ws/wss URLs", {});
|
|
184
|
-
const p1 = qc.getProvider("ws://127.0.0.1:8546");
|
|
185
|
-
const p2 = qc.getProvider("wss://example.com/ws", 1);
|
|
186
|
-
assert.ok(p1 instanceof qc.WebSocketProvider);
|
|
187
|
-
assert.ok(p2 instanceof qc.WebSocketProvider);
|
|
188
|
-
assert.equal(p1.url, "ws://127.0.0.1:8546");
|
|
189
|
-
assert.equal(p2.chainId, 1);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("returns IpcSocketProvider for IPC paths", () => {
|
|
193
|
-
logTest("returns IpcSocketProvider for IPC paths", {});
|
|
194
|
-
const p = qc.getProvider("\\\\.\\pipe\\geth.ipc");
|
|
195
|
-
assert.ok(p instanceof qc.IpcSocketProvider);
|
|
196
|
-
assert.equal(p.path, "\\\\.\\pipe\\geth.ipc");
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("returns JsonRpcProvider with default url/chainId when endpoint omitted or empty", () => {
|
|
200
|
-
logTest("returns JsonRpcProvider with default url/chainId when endpoint omitted or empty", {});
|
|
201
|
-
const p1 = qc.getProvider();
|
|
202
|
-
const p2 = qc.getProvider("");
|
|
203
|
-
assert.ok(p1 instanceof qc.JsonRpcProvider);
|
|
204
|
-
assert.ok(p2 instanceof qc.JsonRpcProvider);
|
|
205
|
-
assert.ok(p1.url.length > 0);
|
|
206
|
-
assert.equal(p1.chainId, 123123);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
describe("Extra providers", () => {
|
|
211
|
-
logSuite("Extra providers");
|
|
212
|
-
it("BrowserProvider requires an EIP-1193 provider with request()", () => {
|
|
213
|
-
logTest("BrowserProvider requires an EIP-1193 provider with request()", {});
|
|
214
|
-
assert.throws(() => new qc.BrowserProvider(null), (e: Error & { code?: string }) => e && e.code === "INVALID_ARGUMENT");
|
|
215
|
-
assert.throws(() => new qc.BrowserProvider({}), (e: Error & { code?: string }) => e && e.code === "INVALID_ARGUMENT");
|
|
216
|
-
const p = new qc.BrowserProvider({ request: async () => null });
|
|
217
|
-
assert.ok(p);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("WebSocketProvider requires a url and stores it", () => {
|
|
221
|
-
logTest("WebSocketProvider requires a url and stores it", {});
|
|
222
|
-
assert.throws(() => new qc.WebSocketProvider(), (e: Error & { code?: string }) => e && e.code === "INVALID_ARGUMENT");
|
|
223
|
-
const p = new qc.WebSocketProvider("ws://127.0.0.1:8546 ");
|
|
224
|
-
assert.equal(p.url, "ws://127.0.0.1:8546");
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it("IpcSocketProvider requires a path and stores it", () => {
|
|
228
|
-
logTest("IpcSocketProvider requires a path and stores it", {});
|
|
229
|
-
assert.throws(() => new qc.IpcSocketProvider(), (e: Error & { code?: string }) => e && e.code === "INVALID_ARGUMENT");
|
|
230
|
-
const p = new qc.IpcSocketProvider("\\\\.\\pipe\\geth.ipc");
|
|
231
|
-
assert.equal(p.path, "\\\\.\\pipe\\geth.ipc");
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it("FallbackProvider accepts single vs array and tries providers in order", async () => {
|
|
235
|
-
logTest("FallbackProvider accepts single vs array and tries providers in order", {});
|
|
236
|
-
const p1 = { _perform: async () => "0x10" };
|
|
237
|
-
const fp1 = new qc.FallbackProvider(p1 as unknown as qc.Provider);
|
|
238
|
-
const bn1 = await fp1.getBlockNumber();
|
|
239
|
-
assert.equal(bn1, 16);
|
|
240
|
-
|
|
241
|
-
const pFail = { _perform: async () => { throw new Error("fail"); } };
|
|
242
|
-
const pOk = { _perform: async () => "0x02" };
|
|
243
|
-
const fp2 = new qc.FallbackProvider([pFail, pOk] as unknown as qc.Provider[]);
|
|
244
|
-
const bn2 = await fp2.getBlockNumber();
|
|
245
|
-
assert.equal(bn2, 2);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it("FallbackProvider throws when no providers provided", () => {
|
|
249
|
-
logTest("FallbackProvider throws when no providers provided", {});
|
|
250
|
-
assert.throws(() => new qc.FallbackProvider([]));
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
describe("Provider.getFeeData", () => {
|
|
255
|
-
logSuite("Provider.getFeeData");
|
|
256
|
-
|
|
257
|
-
// Expected per-gas-unit prices (wei). BASE is keyType 3 (compact / context 0);
|
|
258
|
-
// keyType 3 full-sign is BASE x 30; keyType 5 is BASE x 20.
|
|
259
|
-
const FEE_BASE = 4761904761904760n;
|
|
260
|
-
const FEE_KT3_FULL = 142857142857142800n;
|
|
261
|
-
const FEE_KT5 = 95238095238095200n;
|
|
262
|
-
|
|
263
|
-
it("prices by keyType number", async () => {
|
|
264
|
-
logTest("prices by keyType number", {});
|
|
265
|
-
const p = new qc.JsonRpcProvider();
|
|
266
|
-
assert.strictEqual((await p.getFeeData(3)).gasPrice, FEE_BASE);
|
|
267
|
-
assert.strictEqual((await p.getFeeData(3, true)).gasPrice, FEE_KT3_FULL);
|
|
268
|
-
assert.strictEqual((await p.getFeeData(5)).gasPrice, FEE_KT5);
|
|
269
|
-
assert.strictEqual((await p.getFeeData(5, true)).gasPrice, FEE_KT5);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it("prices by wallet (reads keyType from wallet)", async () => {
|
|
273
|
-
logTest("prices by wallet", {});
|
|
274
|
-
await Initialize(null);
|
|
275
|
-
const p = new qc.JsonRpcProvider();
|
|
276
|
-
|
|
277
|
-
const w3 = qc.Wallet.createRandom(undefined, 3);
|
|
278
|
-
assert.strictEqual((await p.getFeeData(w3)).gasPrice, FEE_BASE);
|
|
279
|
-
assert.strictEqual((await p.getFeeData(w3, false)).gasPrice, FEE_BASE);
|
|
280
|
-
assert.strictEqual((await p.getFeeData(w3, null)).gasPrice, FEE_BASE);
|
|
281
|
-
assert.strictEqual((await p.getFeeData(w3, true)).gasPrice, FEE_KT3_FULL);
|
|
282
|
-
|
|
283
|
-
const w5 = qc.Wallet.createRandom(undefined, 5);
|
|
284
|
-
assert.strictEqual((await p.getFeeData(w5)).gasPrice, FEE_KT5);
|
|
285
|
-
assert.strictEqual((await p.getFeeData(w5, true)).gasPrice, FEE_KT5);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("FeeData exposes only gasPrice (maxFeePerGas / maxPriorityFeePerGas unsupported)", async () => {
|
|
289
|
-
logTest("FeeData exposes only gasPrice", {});
|
|
290
|
-
const p = new qc.JsonRpcProvider();
|
|
291
|
-
const fd = await p.getFeeData(3);
|
|
292
|
-
assert.ok(fd instanceof qc.FeeData);
|
|
293
|
-
assert.strictEqual((fd as any).maxFeePerGas, undefined);
|
|
294
|
-
assert.strictEqual((fd as any).maxPriorityFeePerGas, undefined);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it("rejects invalid keyType and invalid first argument", async () => {
|
|
298
|
-
logTest("rejects invalid inputs", {});
|
|
299
|
-
const p = new qc.JsonRpcProvider();
|
|
300
|
-
await assert.rejects(() => p.getFeeData(99), /getGasPrice failed/);
|
|
301
|
-
await assert.rejects(() => p.getFeeData({} as any), /expected a Wallet or a keyType number/);
|
|
302
|
-
await assert.rejects(() => p.getFeeData(null as any), /expected a Wallet or a keyType number/);
|
|
303
|
-
});
|
|
304
|
-
});
|
package/test/unit/result.test.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Result utility (optional params, deep conversions)
|
|
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("Result", () => {
|
|
15
|
-
logSuite("Result");
|
|
16
|
-
it("constructor supports items omitted vs provided and keys omitted vs null", () => {
|
|
17
|
-
logTest("constructor supports items omitted vs provided and keys omitted vs null", {});
|
|
18
|
-
const r1 = new qc.Result();
|
|
19
|
-
const r2 = new qc.Result(undefined, undefined);
|
|
20
|
-
const r3 = new qc.Result([], null);
|
|
21
|
-
|
|
22
|
-
assert.deepEqual(r1.toArray(), []);
|
|
23
|
-
assert.deepEqual(r2.toArray(), []);
|
|
24
|
-
assert.deepEqual(r3.toArray(), []);
|
|
25
|
-
assert.deepEqual(r1.toObject(), {});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("maps named keys onto indices and supports getValue()", () => {
|
|
29
|
-
const r = new qc.Result([1, 2], ["a", "b"]);
|
|
30
|
-
assert.equal(r.a, 1);
|
|
31
|
-
assert.equal(r.b, 2);
|
|
32
|
-
assert.equal(r.getValue("a"), 1);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("toArray/toObject support deep=true (optional param omitted vs null)", () => {
|
|
36
|
-
const inner = new qc.Result([1], ["x"]);
|
|
37
|
-
const outer = new qc.Result([inner], ["inner"]);
|
|
38
|
-
|
|
39
|
-
assert.deepEqual(outer.toArray(), [inner]);
|
|
40
|
-
assert.deepEqual(outer.toArray(null), [inner]); // deep omitted behavior
|
|
41
|
-
assert.deepEqual(outer.toArray(true), [[1]]);
|
|
42
|
-
|
|
43
|
-
assert.deepEqual(outer.toObject(), { inner });
|
|
44
|
-
assert.deepEqual(outer.toObject(null), { inner }); // deep omitted behavior
|
|
45
|
-
assert.deepEqual(outer.toObject(true), { inner: { x: 1 } });
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("fromItems creates a Result and checkResultErrors returns []", () => {
|
|
49
|
-
const r = qc.Result.fromItems([1, 2], ["a", "b"]);
|
|
50
|
-
assert.ok(r instanceof qc.Result);
|
|
51
|
-
assert.deepEqual(qc.checkResultErrors(r), []);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("checkResultErrors finds Error instances and returns paths (nested Result)", () => {
|
|
55
|
-
const e1 = new Error("outer");
|
|
56
|
-
const e2 = new Error("inner");
|
|
57
|
-
|
|
58
|
-
const inner = new qc.Result([e2], ["x"]);
|
|
59
|
-
const outer = new qc.Result([e1, inner], ["a", "b"]);
|
|
60
|
-
|
|
61
|
-
const errs = qc.checkResultErrors(outer);
|
|
62
|
-
assert.equal(errs.length, 2);
|
|
63
|
-
assert.equal(errs[0].error, e1);
|
|
64
|
-
assert.deepEqual(errs[0].path, ["a"]);
|
|
65
|
-
assert.equal(errs[1].error, e2);
|
|
66
|
-
assert.deepEqual(errs[1].path, ["b", "x"]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("checkResultErrors walks plain objects (struct-like) and is cycle-safe", () => {
|
|
70
|
-
const e = new Error("boom");
|
|
71
|
-
const obj = { foo: { bar: e } };
|
|
72
|
-
obj.self = obj;
|
|
73
|
-
|
|
74
|
-
const errs = qc.checkResultErrors(obj);
|
|
75
|
-
assert.equal(errs.length, 1);
|
|
76
|
-
assert.equal(errs[0].error, e);
|
|
77
|
-
assert.deepEqual(errs[0].path, ["foo", "bar"]);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
package/test/unit/result.test.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Result utility (optional params, deep conversions)
|
|
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("Result", () => {
|
|
15
|
-
logSuite("Result");
|
|
16
|
-
it("constructor supports items omitted vs provided and keys omitted vs null", () => {
|
|
17
|
-
logTest("constructor supports items omitted vs provided and keys omitted vs null", {});
|
|
18
|
-
const r1 = new qc.Result();
|
|
19
|
-
const r2 = new qc.Result(undefined, undefined);
|
|
20
|
-
const r3 = new qc.Result([], null);
|
|
21
|
-
|
|
22
|
-
assert.deepEqual(r1.toArray(), []);
|
|
23
|
-
assert.deepEqual(r2.toArray(), []);
|
|
24
|
-
assert.deepEqual(r3.toArray(), []);
|
|
25
|
-
assert.deepEqual(r1.toObject(), {});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("maps named keys onto indices and supports getValue()", () => {
|
|
29
|
-
const r = new qc.Result([1, 2], ["a", "b"]);
|
|
30
|
-
assert.equal(r.a, 1);
|
|
31
|
-
assert.equal(r.b, 2);
|
|
32
|
-
assert.equal(r.getValue("a"), 1);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("toArray/toObject support deep=true (optional param omitted vs null)", () => {
|
|
36
|
-
const inner = new qc.Result([1], ["x"]);
|
|
37
|
-
const outer = new qc.Result([inner], ["inner"]);
|
|
38
|
-
|
|
39
|
-
assert.deepEqual(outer.toArray(), [inner]);
|
|
40
|
-
assert.deepEqual(outer.toArray(null), [inner]);
|
|
41
|
-
assert.deepEqual(outer.toArray(true), [[1]]);
|
|
42
|
-
|
|
43
|
-
assert.deepEqual(outer.toObject(), { inner });
|
|
44
|
-
assert.deepEqual(outer.toObject(null), { inner });
|
|
45
|
-
assert.deepEqual(outer.toObject(true), { inner: { x: 1 } });
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("fromItems creates a Result and checkResultErrors returns []", () => {
|
|
49
|
-
const r = qc.Result.fromItems([1, 2], ["a", "b"]);
|
|
50
|
-
assert.ok(r instanceof qc.Result);
|
|
51
|
-
assert.deepEqual(qc.checkResultErrors(r), []);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("checkResultErrors finds Error instances and returns paths (nested Result)", () => {
|
|
55
|
-
const e1 = new Error("outer");
|
|
56
|
-
const e2 = new Error("inner");
|
|
57
|
-
|
|
58
|
-
const inner = new qc.Result([e2], ["x"]);
|
|
59
|
-
const outer = new qc.Result([e1, inner], ["a", "b"]);
|
|
60
|
-
|
|
61
|
-
const errs = qc.checkResultErrors(outer);
|
|
62
|
-
assert.equal(errs.length, 2);
|
|
63
|
-
assert.equal(errs[0].error, e1);
|
|
64
|
-
assert.deepEqual(errs[0].path, ["a"]);
|
|
65
|
-
assert.equal(errs[1].error, e2);
|
|
66
|
-
assert.deepEqual(errs[1].path, ["b", "x"]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("checkResultErrors walks plain objects (struct-like) and is cycle-safe", () => {
|
|
70
|
-
const e = new Error("boom");
|
|
71
|
-
const obj: { foo: { bar: Error }; self?: unknown } = { foo: { bar: e } };
|
|
72
|
-
obj.self = obj;
|
|
73
|
-
|
|
74
|
-
const errs = qc.checkResultErrors(obj);
|
|
75
|
-
assert.equal(errs.length, 1);
|
|
76
|
-
assert.equal(errs[0].error, e);
|
|
77
|
-
assert.deepEqual(errs[0].path, ["foo", "bar"]);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Core Solidity type exports exist and are wired via package exports.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
const fs = require("node:fs");
|
|
11
|
-
const path = require("node:path");
|
|
12
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
|
-
|
|
14
|
-
describe("core solidity types", () => {
|
|
15
|
-
logSuite("core solidity types");
|
|
16
|
-
it("has src/types/index.d.ts with expected exports", () => {
|
|
17
|
-
logTest("has src/types/index.d.ts with expected exports", {});
|
|
18
|
-
const repoRoot = path.resolve(__dirname, "..", "..");
|
|
19
|
-
const dts = path.join(repoRoot, "src", "types", "index.d.ts");
|
|
20
|
-
assert.ok(fs.existsSync(dts), "missing src/types/index.d.ts");
|
|
21
|
-
const src = fs.readFileSync(dts, "utf8");
|
|
22
|
-
|
|
23
|
-
for (const needle of [
|
|
24
|
-
"export type AddressLike",
|
|
25
|
-
"export type BytesLike",
|
|
26
|
-
"export type BigNumberish",
|
|
27
|
-
"export type SolidityTypeName",
|
|
28
|
-
"export type SolidityInputValue",
|
|
29
|
-
"export type SolidityOutputValue",
|
|
30
|
-
]) {
|
|
31
|
-
assert.ok(src.includes(needle), `expected types module to include: ${needle}`);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("exports ./types via package.json exports map", () => {
|
|
36
|
-
const repoRoot = path.resolve(__dirname, "..", "..");
|
|
37
|
-
const pkgPath = path.join(repoRoot, "package.json");
|
|
38
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
39
|
-
|
|
40
|
-
assert.equal(pkg.types, "src/index.d.ts");
|
|
41
|
-
assert.ok(pkg.typesVersions && pkg.typesVersions["*"], "package.json missing typesVersions");
|
|
42
|
-
|
|
43
|
-
assert.ok(pkg.exports, "package.json missing exports");
|
|
44
|
-
assert.ok(pkg.exports["./types"], "package.json exports missing ./types");
|
|
45
|
-
assert.equal(pkg.exports["./types"].types, "./src/types/index.d.ts");
|
|
46
|
-
assert.equal(pkg.exports["./types"].default, "./src/types/index.js");
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Core Solidity type exports exist and are wired via package exports.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
import fs from "node:fs";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
13
|
-
|
|
14
|
-
describe("core solidity types", () => {
|
|
15
|
-
logSuite("core solidity types");
|
|
16
|
-
it("has src/types/index.d.ts with expected exports", () => {
|
|
17
|
-
logTest("has src/types/index.d.ts with expected exports", {});
|
|
18
|
-
const repoRoot = path.resolve(__dirname, "..", "..");
|
|
19
|
-
const dts = path.join(repoRoot, "src", "types", "index.d.ts");
|
|
20
|
-
assert.ok(fs.existsSync(dts), "missing src/types/index.d.ts");
|
|
21
|
-
const src = fs.readFileSync(dts, "utf8");
|
|
22
|
-
// Types may be defined here or re-exported; at minimum the module exists and exports something.
|
|
23
|
-
assert.ok(src.includes("export"), "expected types module to have an export");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("exports ./types via package.json exports map", () => {
|
|
27
|
-
const repoRoot = path.resolve(__dirname, "..", "..");
|
|
28
|
-
const pkgPath = path.join(repoRoot, "package.json");
|
|
29
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
30
|
-
|
|
31
|
-
assert.equal(pkg.types, "src/index.d.ts");
|
|
32
|
-
assert.ok(pkg.typesVersions && pkg.typesVersions["*"], "package.json missing typesVersions");
|
|
33
|
-
|
|
34
|
-
assert.ok(pkg.exports, "package.json missing exports");
|
|
35
|
-
assert.ok(pkg.exports["./types"], "package.json exports missing ./types");
|
|
36
|
-
assert.equal(pkg.exports["./types"].types, "./src/types/index.d.ts");
|
|
37
|
-
assert.equal(pkg.exports["./types"].default, "./src/types/index.js");
|
|
38
|
-
});
|
|
39
|
-
});
|
package/test/unit/utils.test.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Utility helpers (units, encoding, hashing, rlp, abi coder)
|
|
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("Utils", () => {
|
|
16
|
-
logSuite("Utils");
|
|
17
|
-
it("parseEther/formatEther roundtrip", () => {
|
|
18
|
-
logTest("parseEther/formatEther roundtrip", {});
|
|
19
|
-
const wei = qc.parseEther("1.5");
|
|
20
|
-
assert.equal(wei, 1500000000000000000n);
|
|
21
|
-
assert.equal(qc.formatEther(wei), "1.5");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("encodeBytes32String/decodeBytes32String roundtrip", () => {
|
|
25
|
-
const hex = qc.encodeBytes32String("hello");
|
|
26
|
-
assert.equal(hex.length, 66);
|
|
27
|
-
assert.equal(qc.decodeBytes32String(hex), "hello");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("base58 encode/decode roundtrip", () => {
|
|
31
|
-
const bytes = qc.toUtf8Bytes("hello world");
|
|
32
|
-
const b58 = qc.encodeBase58(bytes);
|
|
33
|
-
const out = qc.decodeBase58(b58);
|
|
34
|
-
assert.equal(qc.toUtf8String(out), "hello world");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("RLP encode/decode roundtrip (hex bytes)", () => {
|
|
38
|
-
const value = ["0x68656c6c6f", "0x7b", "0x01"];
|
|
39
|
-
const encoded = qc.encodeRlp(value);
|
|
40
|
-
assert.ok(typeof encoded === "string" && encoded.startsWith("0x"));
|
|
41
|
-
const decoded = qc.decodeRlp(encoded);
|
|
42
|
-
assert.deepEqual(decoded, value);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("AbiCoder encode/decode roundtrip", async () => {
|
|
46
|
-
await Initialize(null);
|
|
47
|
-
const coder = new qc.AbiCoder();
|
|
48
|
-
const data = coder.encode(["uint256", "bool", "string"], [123n, true, "hello"]);
|
|
49
|
-
assert.ok(typeof data === "string" && data.startsWith("0x"));
|
|
50
|
-
const decoded = coder.decode(["uint256", "bool", "string"], data);
|
|
51
|
-
// qcsdk returns JSON array, so we accept array-like output
|
|
52
|
-
assert.equal(decoded[0].toString(), "123");
|
|
53
|
-
assert.equal(Boolean(decoded[1]), true);
|
|
54
|
-
assert.equal(decoded[2], "hello");
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
package/test/unit/utils.test.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Utility helpers (units, encoding, hashing, rlp, abi coder)
|
|
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("Utils", () => {
|
|
16
|
-
logSuite("Utils");
|
|
17
|
-
it("parseEther/formatEther roundtrip", () => {
|
|
18
|
-
logTest("parseEther/formatEther roundtrip", {});
|
|
19
|
-
const wei = qc.parseEther("1.5");
|
|
20
|
-
assert.equal(wei, 1500000000000000000n);
|
|
21
|
-
assert.equal(qc.formatEther(wei), "1.5");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("encodeBytes32String/decodeBytes32String roundtrip", () => {
|
|
25
|
-
const hex = qc.encodeBytes32String("hello");
|
|
26
|
-
assert.equal(hex.length, 66);
|
|
27
|
-
assert.equal(qc.decodeBytes32String(hex), "hello");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("base58 encode/decode roundtrip", () => {
|
|
31
|
-
const bytes = qc.toUtf8Bytes("hello world");
|
|
32
|
-
const b58 = qc.encodeBase58(bytes);
|
|
33
|
-
const out = qc.decodeBase58(b58);
|
|
34
|
-
assert.equal(qc.toUtf8String(out), "hello world");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("RLP encode/decode roundtrip (hex bytes)", () => {
|
|
38
|
-
const value = ["0x68656c6c6f", "0x7b", "0x01"];
|
|
39
|
-
const encoded = qc.encodeRlp(value);
|
|
40
|
-
assert.ok(typeof encoded === "string" && encoded.startsWith("0x"));
|
|
41
|
-
const decoded = qc.decodeRlp(encoded);
|
|
42
|
-
assert.deepEqual(decoded, value);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("AbiCoder encode/decode roundtrip", async () => {
|
|
46
|
-
await Initialize(null);
|
|
47
|
-
const coder = new qc.AbiCoder();
|
|
48
|
-
const data = coder.encode(["uint256", "bool", "string"], [123n, true, "hello"]);
|
|
49
|
-
assert.ok(typeof data === "string" && data.startsWith("0x"));
|
|
50
|
-
const decoded = coder.decode(["uint256", "bool", "string"], data);
|
|
51
|
-
// qcsdk returns JSON array, so we accept array-like output
|
|
52
|
-
assert.equal(decoded[0].toString(), "123");
|
|
53
|
-
assert.equal(Boolean(decoded[1]), true);
|
|
54
|
-
assert.equal(decoded[2], "hello");
|
|
55
|
-
});
|
|
56
|
-
});
|