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,330 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory security
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Security tests for malformed input, edge cases, and invalid values.
|
|
6
|
-
* Run with VERBOSE=1 for test names.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const { describe, it } = require("node:test");
|
|
10
|
-
const assert = require("node:assert/strict");
|
|
11
|
-
|
|
12
|
-
const { Initialize } = require("../../config");
|
|
13
|
-
const qc = require("../../index");
|
|
14
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
15
|
-
|
|
16
|
-
describe("Security: Malformed Input", () => {
|
|
17
|
-
logSuite("Security: Malformed Input");
|
|
18
|
-
it("rejects invalid address length and characters", async () => {
|
|
19
|
-
logTest("rejects invalid address length and characters", {});
|
|
20
|
-
await Initialize(null);
|
|
21
|
-
assert.equal(qc.isAddress("0x1234"), false);
|
|
22
|
-
assert.equal(qc.isAddress("not-an-address"), false);
|
|
23
|
-
assert.throws(() => qc.getAddress("0x1234"), /invalid address/i);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("rejects too-long bytes32 strings", () => {
|
|
27
|
-
logTest("rejects too-long bytes32 strings", {});
|
|
28
|
-
assert.throws(() => qc.encodeBytes32String("x".repeat(33)), /max 32/i);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("rejects invalid parseUnits inputs", () => {
|
|
32
|
-
logTest("rejects invalid parseUnits inputs", {});
|
|
33
|
-
assert.throws(() => qc.parseUnits("", 18), /invalid/i);
|
|
34
|
-
assert.throws(() => qc.parseUnits("1.234", 2), /exceeds decimals/i);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("Security: Private key enumeration protection", () => {
|
|
39
|
-
logSuite("Security: Private key enumeration protection");
|
|
40
|
-
|
|
41
|
-
it("JSON.stringify(wallet) must NOT contain privateKey or seed", async () => {
|
|
42
|
-
logTest("JSON.stringify(wallet) must NOT contain privateKey or seed", {});
|
|
43
|
-
await Initialize(null);
|
|
44
|
-
const w = qc.Wallet.createRandom();
|
|
45
|
-
const json = JSON.stringify(w);
|
|
46
|
-
const parsed = JSON.parse(json);
|
|
47
|
-
|
|
48
|
-
assert.ok(!("privateKey" in parsed), "privateKey must not appear in JSON");
|
|
49
|
-
assert.ok(!("seed" in parsed), "seed must not appear in JSON");
|
|
50
|
-
assert.ok(!("signingKey" in parsed), "signingKey must not appear in JSON");
|
|
51
|
-
assert.ok(!("_qcWallet" in parsed), "_qcWallet must not appear in JSON");
|
|
52
|
-
assert.ok(!("_seed" in parsed), "_seed must not appear in JSON");
|
|
53
|
-
assert.ok(!("privateKeyBytes" in parsed), "privateKeyBytes must not appear in JSON");
|
|
54
|
-
|
|
55
|
-
assert.ok("address" in parsed, "address should be in JSON");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("Object.keys(wallet) must not include secret properties", async () => {
|
|
59
|
-
logTest("Object.keys(wallet) must not include secret properties", {});
|
|
60
|
-
await Initialize(null);
|
|
61
|
-
const w = qc.Wallet.createRandom();
|
|
62
|
-
const keys = Object.keys(w);
|
|
63
|
-
|
|
64
|
-
assert.ok(!keys.includes("privateKey"), "privateKey must not be enumerable");
|
|
65
|
-
assert.ok(!keys.includes("seed"), "seed must not be enumerable");
|
|
66
|
-
assert.ok(!keys.includes("signingKey"), "signingKey must not be enumerable");
|
|
67
|
-
assert.ok(!keys.includes("_qcWallet"), "_qcWallet must not be enumerable");
|
|
68
|
-
assert.ok(!keys.includes("_seed"), "_seed must not be enumerable");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("privateKey and seed are still accessible directly", async () => {
|
|
72
|
-
logTest("privateKey and seed are still accessible directly", {});
|
|
73
|
-
await Initialize(null);
|
|
74
|
-
const w = qc.Wallet.createRandom();
|
|
75
|
-
assert.equal(typeof w.privateKey, "string");
|
|
76
|
-
assert.ok(w.privateKey.startsWith("0x"));
|
|
77
|
-
assert.equal(typeof w.seed, "string");
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe("Security: Wallet.connect() preserves state", () => {
|
|
82
|
-
logSuite("Security: Wallet.connect() preserves state");
|
|
83
|
-
|
|
84
|
-
it("connect() preserves seed", async () => {
|
|
85
|
-
logTest("connect() preserves seed", {});
|
|
86
|
-
await Initialize(null);
|
|
87
|
-
const w = qc.Wallet.createRandom();
|
|
88
|
-
const seedBefore = w.seed;
|
|
89
|
-
|
|
90
|
-
const provider = new qc.JsonRpcProvider("http://127.0.0.1:9999", 123123);
|
|
91
|
-
const connected = w.connect(provider);
|
|
92
|
-
|
|
93
|
-
assert.equal(connected.seed, seedBefore, "seed must survive connect()");
|
|
94
|
-
assert.equal(connected.address, w.address, "address must survive connect()");
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe("Security: KDF string password handling", () => {
|
|
99
|
-
logSuite("Security: KDF string password handling");
|
|
100
|
-
|
|
101
|
-
it("pbkdf2 with plain string password does not crash", async () => {
|
|
102
|
-
logTest("pbkdf2 with plain string password does not crash", {});
|
|
103
|
-
const result = qc.pbkdf2("password123", "salt123", 1000, 32, "sha256");
|
|
104
|
-
assert.equal(typeof result, "string");
|
|
105
|
-
assert.ok(result.startsWith("0x"));
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("computeHmac with plain string key/data does not crash", async () => {
|
|
109
|
-
logTest("computeHmac with plain string key/data does not crash", {});
|
|
110
|
-
const result = qc.computeHmac("sha256", "mykey", "mydata");
|
|
111
|
-
assert.equal(typeof result, "string");
|
|
112
|
-
assert.ok(result.startsWith("0x"));
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("scryptSync with plain string password does not crash", async () => {
|
|
116
|
-
logTest("scryptSync with plain string password does not crash", {});
|
|
117
|
-
const result = qc.scryptSync("password123", "salt123", 1024, 8, 1, 32);
|
|
118
|
-
assert.equal(typeof result, "string");
|
|
119
|
-
assert.ok(result.startsWith("0x"));
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe("Security: Numeric precision in signTransaction", () => {
|
|
124
|
-
logSuite("Security: Numeric precision in signTransaction");
|
|
125
|
-
|
|
126
|
-
it("rejects number value above MAX_SAFE_INTEGER", async () => {
|
|
127
|
-
logTest("rejects number value above MAX_SAFE_INTEGER", {});
|
|
128
|
-
await Initialize(null);
|
|
129
|
-
const w = qc.Wallet.createRandom();
|
|
130
|
-
await assert.rejects(
|
|
131
|
-
() => w.signTransaction({ to: w.address, value: Number.MAX_SAFE_INTEGER + 1, nonce: 0, chainId: 123123 }),
|
|
132
|
-
/overflow/i,
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("accepts bigint value for large amounts", async () => {
|
|
137
|
-
logTest("accepts bigint value for large amounts", {});
|
|
138
|
-
await Initialize(null);
|
|
139
|
-
const w = qc.Wallet.createRandom();
|
|
140
|
-
const raw = await w.signTransaction({
|
|
141
|
-
to: w.address,
|
|
142
|
-
value: 999999999999999999999n,
|
|
143
|
-
nonce: 0,
|
|
144
|
-
chainId: 123123,
|
|
145
|
-
});
|
|
146
|
-
assert.equal(typeof raw, "string");
|
|
147
|
-
assert.ok(raw.startsWith("0x"));
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("accepts string value '0x' as zero", async () => {
|
|
151
|
-
logTest("accepts string value '0x' as zero", {});
|
|
152
|
-
await Initialize(null);
|
|
153
|
-
const w = qc.Wallet.createRandom();
|
|
154
|
-
const raw = await w.signTransaction({ to: w.address, value: "0x", nonce: 0, chainId: 123123 });
|
|
155
|
-
assert.equal(typeof raw, "string");
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe("Security: Password strength enforcement", () => {
|
|
160
|
-
logSuite("Security: Password strength enforcement");
|
|
161
|
-
|
|
162
|
-
it("encryptSync rejects password shorter than 12 characters", async () => {
|
|
163
|
-
logTest("encryptSync rejects password shorter than 12 characters", {});
|
|
164
|
-
await Initialize(null);
|
|
165
|
-
const w = qc.Wallet.createRandom();
|
|
166
|
-
assert.throws(() => w.encryptSync("short"), /password must be at least 12 characters/);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("encryptSync accepts password of 12+ characters", async () => {
|
|
170
|
-
logTest("encryptSync accepts password of 12+ characters", {});
|
|
171
|
-
await Initialize(null);
|
|
172
|
-
const w = qc.Wallet.createRandom();
|
|
173
|
-
const json = w.encryptSync("abcdefghijkl");
|
|
174
|
-
assert.equal(typeof json, "string");
|
|
175
|
-
assert.ok(json.length > 0);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe("Security: Message signing removed", () => {
|
|
180
|
-
logSuite("Security: Message signing removed");
|
|
181
|
-
|
|
182
|
-
it("hashMessage is not exported", () => {
|
|
183
|
-
logTest("hashMessage is not exported", {});
|
|
184
|
-
assert.equal(qc.hashMessage, undefined, "hashMessage should not be exported");
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("verifyMessage is not exported", () => {
|
|
188
|
-
logTest("verifyMessage is not exported", {});
|
|
189
|
-
assert.equal(qc.verifyMessage, undefined, "verifyMessage should not be exported");
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("recoverAddress is not exported", () => {
|
|
193
|
-
logTest("recoverAddress is not exported", {});
|
|
194
|
-
assert.equal(qc.recoverAddress, undefined, "recoverAddress should not be exported");
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it("MessagePrefix is not exported", () => {
|
|
198
|
-
logTest("MessagePrefix is not exported", {});
|
|
199
|
-
assert.equal(qc.MessagePrefix, undefined, "MessagePrefix should not be exported");
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
describe("Security: Error messages do not leak secrets", () => {
|
|
204
|
-
logSuite("Security: Error messages do not leak secrets");
|
|
205
|
-
|
|
206
|
-
it("fromKeys error does not contain actual key bytes", async () => {
|
|
207
|
-
logTest("fromKeys error does not contain actual key bytes", {});
|
|
208
|
-
await Initialize(null);
|
|
209
|
-
const fakeKey = "0xdeadbeef";
|
|
210
|
-
try {
|
|
211
|
-
qc.Wallet.fromKeys(fakeKey, fakeKey);
|
|
212
|
-
assert.fail("should have thrown");
|
|
213
|
-
} catch (e) {
|
|
214
|
-
assert.ok(!e.message.includes("deadbeef"), "error must not contain key material");
|
|
215
|
-
assert.ok(e.message.includes("[REDACTED]") || !e.message.includes("0x"), "value should be redacted");
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
describe("Security: _hexToBigInt handles '0x'", () => {
|
|
221
|
-
logSuite("Security: _hexToBigInt handles '0x'");
|
|
222
|
-
|
|
223
|
-
it("getBalance does not crash on '0x' response", async () => {
|
|
224
|
-
logTest("getBalance does not crash on '0x' response", {});
|
|
225
|
-
assert.equal(typeof qc.JsonRpcProvider, "function");
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
describe("Security: RLP depth limit", () => {
|
|
230
|
-
logSuite("Security: RLP depth limit");
|
|
231
|
-
|
|
232
|
-
it("rejects deeply nested RLP (depth > 64)", () => {
|
|
233
|
-
logTest("rejects deeply nested RLP (depth > 64)", {});
|
|
234
|
-
let inner = [];
|
|
235
|
-
for (let i = 0; i < 70; i++) {
|
|
236
|
-
inner = [inner];
|
|
237
|
-
}
|
|
238
|
-
const encoded = qc.encodeRlp(inner);
|
|
239
|
-
assert.throws(() => qc.decodeRlp(encoded), /maximum nesting depth exceeded/);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it("accepts RLP within depth limit", () => {
|
|
243
|
-
logTest("accepts RLP within depth limit", {});
|
|
244
|
-
const encoded = qc.encodeRlp([["hello", "world"], "test"]);
|
|
245
|
-
const decoded = qc.decodeRlp(encoded);
|
|
246
|
-
assert.ok(Array.isArray(decoded));
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
describe("Security: Seed phrase with invalid words", () => {
|
|
251
|
-
logSuite("Security: Seed phrase with invalid words");
|
|
252
|
-
|
|
253
|
-
it("rejects gibberish words of correct count", async () => {
|
|
254
|
-
logTest("rejects gibberish words of correct count", {});
|
|
255
|
-
await Initialize(null);
|
|
256
|
-
const gibberish = new Array(32).fill("xyzzyplugh");
|
|
257
|
-
assert.throws(
|
|
258
|
-
() => qc.Wallet.fromPhrase(gibberish),
|
|
259
|
-
{ message: /failed/i },
|
|
260
|
-
);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("rejects empty string words of correct count", async () => {
|
|
264
|
-
logTest("rejects empty string words of correct count", {});
|
|
265
|
-
await Initialize(null);
|
|
266
|
-
const empty = new Array(32).fill("");
|
|
267
|
-
assert.throws(() => qc.Wallet.fromPhrase(empty));
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
describe("Security: Keccak-256 test vectors", () => {
|
|
272
|
-
logSuite("Security: Keccak-256 test vectors");
|
|
273
|
-
|
|
274
|
-
it("keccak256 of empty bytes matches known digest", async () => {
|
|
275
|
-
logTest("keccak256 of empty bytes matches known digest", {});
|
|
276
|
-
const result = qc.keccak256(new Uint8Array(0));
|
|
277
|
-
assert.equal(result, "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it("keccak256 of 'hello' matches known digest", async () => {
|
|
281
|
-
logTest("keccak256 of 'hello' matches known digest", {});
|
|
282
|
-
const bytes = new TextEncoder().encode("hello");
|
|
283
|
-
const result = qc.keccak256(bytes);
|
|
284
|
-
assert.equal(result, "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8");
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("sha256 produces correct length output", () => {
|
|
288
|
-
logTest("sha256 produces correct length output", {});
|
|
289
|
-
const result = qc.sha256(new Uint8Array([1, 2, 3]));
|
|
290
|
-
assert.equal(typeof result, "string");
|
|
291
|
-
assert.equal(result.length, 66);
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
describe("Security: BigInt in provider params", () => {
|
|
296
|
-
logSuite("Security: BigInt in provider params");
|
|
297
|
-
|
|
298
|
-
it("JsonRpcProvider serializes BigInt params without crashing", async (t) => {
|
|
299
|
-
logTest("JsonRpcProvider serializes BigInt params without crashing", {});
|
|
300
|
-
if (typeof fetch !== "function") {
|
|
301
|
-
t.skip("global fetch not available");
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
const originalFetch = fetch;
|
|
305
|
-
global.fetch = async (_url, init) => {
|
|
306
|
-
const body = JSON.parse(init.body);
|
|
307
|
-
assert.equal(body.params[0].value, "0x3e8");
|
|
308
|
-
const responseBody = JSON.stringify({ jsonrpc: "2.0", id: body.id, result: "0x1" });
|
|
309
|
-
return { ok: true, text: async () => responseBody, json: async () => JSON.parse(responseBody) };
|
|
310
|
-
};
|
|
311
|
-
try {
|
|
312
|
-
const p = new qc.JsonRpcProvider("http://example.invalid", 123123);
|
|
313
|
-
await p._perform("eth_call", [{ to: "0x" + "00".repeat(32), value: 1000n }]);
|
|
314
|
-
} finally {
|
|
315
|
-
global.fetch = originalFetch;
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
describe("Security: Per-instance RPC IDs", () => {
|
|
321
|
-
logSuite("Security: Per-instance RPC IDs");
|
|
322
|
-
|
|
323
|
-
it("different provider instances have independent ID counters", () => {
|
|
324
|
-
logTest("different provider instances have independent ID counters", {});
|
|
325
|
-
const p1 = new qc.JsonRpcProvider("http://a.invalid", 1);
|
|
326
|
-
const p2 = new qc.JsonRpcProvider("http://b.invalid", 1);
|
|
327
|
-
assert.equal(p1._rpcId, 1);
|
|
328
|
-
assert.equal(p2._rpcId, 1);
|
|
329
|
-
});
|
|
330
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory security
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Security tests for malformed input, edge cases, and invalid values
|
|
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("Security: Malformed Input", () => {
|
|
16
|
-
logSuite("Security: Malformed Input");
|
|
17
|
-
it("rejects invalid address length and characters", async () => {
|
|
18
|
-
logTest("rejects invalid address length and characters", {});
|
|
19
|
-
await Initialize(null);
|
|
20
|
-
assert.equal(qc.isAddress("0x1234"), false);
|
|
21
|
-
assert.equal(qc.isAddress("not-an-address"), false);
|
|
22
|
-
assert.throws(() => qc.getAddress("0x1234"), /invalid address/i);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("rejects too-long bytes32 strings", () => {
|
|
26
|
-
logTest("rejects too-long bytes32 strings", {});
|
|
27
|
-
assert.throws(() => qc.encodeBytes32String("x".repeat(33)), /max 32/i);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("rejects invalid parseUnits inputs", () => {
|
|
31
|
-
logTest("rejects invalid parseUnits inputs", {});
|
|
32
|
-
assert.throws(() => qc.parseUnits("", 18), /invalid/i);
|
|
33
|
-
assert.throws(() => qc.parseUnits("1.234", 2), /exceeds decimals/i);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory security
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description RPC quantities are untrusted. A value above
|
|
6
|
-
* Number.MAX_SAFE_INTEGER must fail loudly instead of being silently
|
|
7
|
-
* truncated by Number(BigInt(...)). The decoder keeps returning a
|
|
8
|
-
* `number` (no signature change); only out-of-range values throw.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const { describe, it } = require("node:test");
|
|
12
|
-
const assert = require("node:assert/strict");
|
|
13
|
-
|
|
14
|
-
const { Initialize } = require("../../config");
|
|
15
|
-
const qc = require("../../index");
|
|
16
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
17
|
-
|
|
18
|
-
// 2^53 = 9007199254740992 = one past Number.MAX_SAFE_INTEGER.
|
|
19
|
-
const UNSAFE_HEX = "0x20000000000000";
|
|
20
|
-
const TX_HASH = "0x" + "aa".repeat(32);
|
|
21
|
-
|
|
22
|
-
class NumProvider extends qc.AbstractProvider {
|
|
23
|
-
constructor(map) {
|
|
24
|
-
super();
|
|
25
|
-
this._map = map;
|
|
26
|
-
}
|
|
27
|
-
async _perform(method) {
|
|
28
|
-
return Object.prototype.hasOwnProperty.call(this._map, method) ? this._map[method] : null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
describe("Security: untrusted RPC quantity bounds", () => {
|
|
33
|
-
logSuite("Security: untrusted RPC quantity bounds");
|
|
34
|
-
|
|
35
|
-
it("getBlockNumber throws for a value above MAX_SAFE_INTEGER (negative)", async () => {
|
|
36
|
-
logTest("getBlockNumber rejects an out-of-range quantity", {});
|
|
37
|
-
await Initialize(null);
|
|
38
|
-
const p = new NumProvider({ eth_blockNumber: UNSAFE_HEX });
|
|
39
|
-
await assert.rejects(() => p.getBlockNumber(), /safe integer range/i);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("getBlock throws when block.number exceeds MAX_SAFE_INTEGER (negative)", async () => {
|
|
43
|
-
logTest("getBlock rejects an out-of-range block number", {});
|
|
44
|
-
await Initialize(null);
|
|
45
|
-
const p = new NumProvider({
|
|
46
|
-
eth_getBlockByNumber: { hash: "0x" + "11".repeat(32), number: UNSAFE_HEX, timestamp: "0x1", transactions: [] },
|
|
47
|
-
});
|
|
48
|
-
await assert.rejects(() => p.getBlock("latest"), /safe integer range/i);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("getTransactionReceipt throws when a quantity exceeds MAX_SAFE_INTEGER (negative)", async () => {
|
|
52
|
-
logTest("getTransactionReceipt rejects an out-of-range quantity", {});
|
|
53
|
-
await Initialize(null);
|
|
54
|
-
const p = new NumProvider({
|
|
55
|
-
eth_getTransactionReceipt: { transactionHash: TX_HASH, blockNumber: UNSAFE_HEX, status: "0x1" },
|
|
56
|
-
});
|
|
57
|
-
await assert.rejects(() => p.getTransactionReceipt(TX_HASH), /safe integer range/i);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("decodes normal in-range quantities to the correct number (positive)", async () => {
|
|
61
|
-
logTest("decodes in-range quantities correctly", {});
|
|
62
|
-
await Initialize(null);
|
|
63
|
-
const p = new NumProvider({
|
|
64
|
-
eth_blockNumber: "0x10",
|
|
65
|
-
eth_getTransactionReceipt: {
|
|
66
|
-
transactionHash: TX_HASH,
|
|
67
|
-
blockNumber: "0x5",
|
|
68
|
-
transactionIndex: "0x0",
|
|
69
|
-
status: "0x1",
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
const bn = await p.getBlockNumber();
|
|
73
|
-
assert.equal(bn, 16);
|
|
74
|
-
assert.equal(typeof bn, "number");
|
|
75
|
-
|
|
76
|
-
const receipt = await p.getTransactionReceipt(TX_HASH);
|
|
77
|
-
assert.equal(receipt.blockNumber, 5);
|
|
78
|
-
assert.equal(typeof receipt.blockNumber, "number");
|
|
79
|
-
assert.equal(receipt.status, 1);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory security
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Do not trust the RPC node. A broadcast must be rejected if
|
|
6
|
-
* the node returns a transaction hash different from the one we
|
|
7
|
-
* signed, and event logs from foreign contract addresses must be
|
|
8
|
-
* dropped from getLogs results.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const { describe, it } = require("node:test");
|
|
12
|
-
const assert = require("node:assert/strict");
|
|
13
|
-
|
|
14
|
-
const { Initialize } = require("../../config");
|
|
15
|
-
const qc = require("../../index");
|
|
16
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
17
|
-
|
|
18
|
-
const SIGNED_HASH = "0x" + "aa".repeat(32);
|
|
19
|
-
|
|
20
|
-
class SendProvider extends qc.AbstractProvider {
|
|
21
|
-
constructor(returnedHash) {
|
|
22
|
-
super();
|
|
23
|
-
this._returnedHash = returnedHash;
|
|
24
|
-
}
|
|
25
|
-
async _perform(method) {
|
|
26
|
-
if (method === "eth_sendRawTransaction") return this._returnedHash;
|
|
27
|
-
if (method === "eth_getTransactionByHash") return { hash: this._returnedHash };
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
describe("Security: RPC broadcast hash verification", () => {
|
|
33
|
-
logSuite("Security: RPC broadcast hash verification");
|
|
34
|
-
|
|
35
|
-
it("throws when the node returns a different hash than the signed tx (negative)", async () => {
|
|
36
|
-
logTest("throws when the node returns a different hash than the signed tx", {});
|
|
37
|
-
await Initialize(null);
|
|
38
|
-
const p = new SendProvider("0x" + "bb".repeat(32));
|
|
39
|
-
await assert.rejects(
|
|
40
|
-
() => p.sendTransaction("0xrawsigned", { expectedHash: SIGNED_HASH }),
|
|
41
|
-
/does not match the signed transaction/i,
|
|
42
|
-
);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("returns the response when the node hash matches (positive, case-insensitive)", async () => {
|
|
46
|
-
logTest("returns the response when the node hash matches", {});
|
|
47
|
-
await Initialize(null);
|
|
48
|
-
const p = new SendProvider(SIGNED_HASH);
|
|
49
|
-
const resp = await p.sendTransaction("0xrawsigned", { expectedHash: SIGNED_HASH.toUpperCase() });
|
|
50
|
-
assert.ok(resp && typeof resp.hash === "string");
|
|
51
|
-
assert.equal(resp.hash.toLowerCase(), SIGNED_HASH);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("without expectedHash, sendTransaction stays backward compatible", async () => {
|
|
55
|
-
logTest("without expectedHash, sendTransaction stays backward compatible", {});
|
|
56
|
-
await Initialize(null);
|
|
57
|
-
const p = new SendProvider(SIGNED_HASH);
|
|
58
|
-
const resp = await p.sendTransaction("0xrawsigned");
|
|
59
|
-
assert.equal(resp.hash, SIGNED_HASH);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
class LogProvider extends qc.AbstractProvider {
|
|
64
|
-
constructor(logs) {
|
|
65
|
-
super();
|
|
66
|
-
this._logs = logs;
|
|
67
|
-
}
|
|
68
|
-
async _perform(method) {
|
|
69
|
-
if (method === "eth_getLogs") return this._logs;
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
describe("Security: event-log provenance", () => {
|
|
75
|
-
logSuite("Security: event-log provenance");
|
|
76
|
-
|
|
77
|
-
it("drops logs whose address does not match the filter (negative) and keeps matching ones (positive)", async () => {
|
|
78
|
-
logTest("drops foreign-address logs and keeps matching ones", {});
|
|
79
|
-
await Initialize(null);
|
|
80
|
-
const target = "0x" + "11".repeat(32);
|
|
81
|
-
const foreign = "0x" + "99".repeat(32);
|
|
82
|
-
const p = new LogProvider([
|
|
83
|
-
{ address: target, topics: [], data: "0x", blockNumber: "0x1" },
|
|
84
|
-
{ address: foreign, topics: [], data: "0x", blockNumber: "0x1" },
|
|
85
|
-
{ address: target.toUpperCase(), topics: [], data: "0x", blockNumber: "0x1" },
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
const logs = await p.getLogs({ address: target });
|
|
89
|
-
assert.equal(logs.length, 2, "only logs from the requested address survive");
|
|
90
|
-
for (const l of logs) {
|
|
91
|
-
assert.equal(l.address.toLowerCase(), target.toLowerCase());
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("returns all logs when no address filter is given (positive)", async () => {
|
|
96
|
-
logTest("returns all logs when no address filter is given", {});
|
|
97
|
-
await Initialize(null);
|
|
98
|
-
const p = new LogProvider([
|
|
99
|
-
{ address: "0x" + "11".repeat(32), topics: [], data: "0x" },
|
|
100
|
-
{ address: "0x" + "99".repeat(32), topics: [], data: "0x" },
|
|
101
|
-
]);
|
|
102
|
-
const logs = await p.getLogs({ fromBlock: 0 });
|
|
103
|
-
assert.equal(logs.length, 2);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
const AA = "0x" + "aa".repeat(32);
|
|
108
|
-
const BB = "0x" + "bb".repeat(32);
|
|
109
|
-
|
|
110
|
-
class HashProvider extends qc.AbstractProvider {
|
|
111
|
-
constructor(obj) {
|
|
112
|
-
super();
|
|
113
|
-
this._obj = obj;
|
|
114
|
-
}
|
|
115
|
-
async _perform(method) {
|
|
116
|
-
if (method === "eth_getTransactionByHash") return this._obj;
|
|
117
|
-
if (method === "eth_getTransactionReceipt") return this._obj;
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
describe("Security: read-back / confirmation hash verification", () => {
|
|
123
|
-
logSuite("Security: read-back / confirmation hash verification");
|
|
124
|
-
|
|
125
|
-
it("getTransaction throws when the returned hash differs from the requested hash (negative)", async () => {
|
|
126
|
-
logTest("getTransaction rejects a mismatched returned hash", {});
|
|
127
|
-
await Initialize(null);
|
|
128
|
-
const p = new HashProvider({ hash: BB });
|
|
129
|
-
await assert.rejects(() => p.getTransaction(AA), /does not match the requested hash/i);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("getTransaction returns the response when the hash matches (positive)", async () => {
|
|
133
|
-
logTest("getTransaction accepts a matching hash", {});
|
|
134
|
-
await Initialize(null);
|
|
135
|
-
const p = new HashProvider({ hash: AA });
|
|
136
|
-
const tx = await p.getTransaction(AA);
|
|
137
|
-
assert.equal(tx.hash, AA);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("getTransactionReceipt throws when transactionHash differs (negative)", async () => {
|
|
141
|
-
logTest("getTransactionReceipt rejects a mismatched receipt", {});
|
|
142
|
-
await Initialize(null);
|
|
143
|
-
const p = new HashProvider({ transactionHash: BB, blockNumber: "0x1" });
|
|
144
|
-
await assert.rejects(() => p.getTransactionReceipt(AA), /does not match the requested hash/i);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("wait() rejects when the node returns a receipt for a different tx (negative)", async () => {
|
|
148
|
-
logTest("wait() rejects a mismatched receipt", {});
|
|
149
|
-
await Initialize(null);
|
|
150
|
-
const p = new HashProvider({ transactionHash: BB, blockNumber: "0x1" });
|
|
151
|
-
const resp = new qc.TransactionResponse({ hash: AA }, p);
|
|
152
|
-
await assert.rejects(() => resp.wait(1, 5000), /does not match the requested hash/i);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
describe("Security: event-log topic binding", () => {
|
|
157
|
-
logSuite("Security: event-log topic binding");
|
|
158
|
-
|
|
159
|
-
const eventAbi = [
|
|
160
|
-
{
|
|
161
|
-
type: "event",
|
|
162
|
-
name: "Transfer",
|
|
163
|
-
anonymous: false,
|
|
164
|
-
inputs: [
|
|
165
|
-
{ name: "from", type: "address", indexed: true },
|
|
166
|
-
{ name: "to", type: "address", indexed: true },
|
|
167
|
-
{ name: "value", type: "uint256", indexed: false },
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
];
|
|
171
|
-
|
|
172
|
-
it("getLogs drops logs whose topic0 does not match the requested topic (negative+positive)", async () => {
|
|
173
|
-
logTest("getLogs filters by topic0", {});
|
|
174
|
-
await Initialize(null);
|
|
175
|
-
const addr = "0x" + "11".repeat(32);
|
|
176
|
-
const wanted = "0x" + "cc".repeat(32);
|
|
177
|
-
const other = "0x" + "dd".repeat(32);
|
|
178
|
-
const p = new LogProvider([
|
|
179
|
-
{ address: addr, topics: [wanted], data: "0x", blockNumber: "0x1" },
|
|
180
|
-
{ address: addr, topics: [other], data: "0x", blockNumber: "0x1" },
|
|
181
|
-
]);
|
|
182
|
-
const logs = await p.getLogs({ address: addr, topics: [wanted] });
|
|
183
|
-
assert.equal(logs.length, 1);
|
|
184
|
-
assert.equal(logs[0].topics[0], wanted);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("queryFilter only returns logs matching the event's topic0 (negative+positive)", async () => {
|
|
188
|
-
logTest("queryFilter binds results to the event topic", {});
|
|
189
|
-
await Initialize(null);
|
|
190
|
-
const addr = "0x" + "11".repeat(32);
|
|
191
|
-
const topic0 = new qc.Interface(eventAbi).getEventTopic("Transfer");
|
|
192
|
-
const wrong = "0x" + "ee".repeat(32);
|
|
193
|
-
const p = new LogProvider([
|
|
194
|
-
{ address: addr, topics: [topic0], data: "0x", blockNumber: "0x1" },
|
|
195
|
-
{ address: addr, topics: [wrong], data: "0x", blockNumber: "0x1" },
|
|
196
|
-
]);
|
|
197
|
-
const contract = new qc.Contract(addr, eventAbi, p);
|
|
198
|
-
const events = await contract.queryFilter("Transfer", 0, "latest");
|
|
199
|
-
assert.equal(events.length, 1, "only the matching-topic log survives");
|
|
200
|
-
assert.equal(events[0].topics[0], topic0);
|
|
201
|
-
});
|
|
202
|
-
});
|