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,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Typed contract generator (file output shape)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
import fs from "node:fs";
|
|
11
|
-
import os from "node:os";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
|
|
14
|
-
import { generate, generateFromArtifacts, generateTransactionalTestJs } from "../../src/generator";
|
|
15
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
16
|
-
|
|
17
|
-
describe("typed contract generator", () => {
|
|
18
|
-
logSuite("typed contract generator");
|
|
19
|
-
it("generates contract + factory + types + index files", () => {
|
|
20
|
-
logTest("generates contract + factory + types + index files", {});
|
|
21
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-"));
|
|
22
|
-
const abiPath = path.join(tmp, "Test.abi.json");
|
|
23
|
-
const binPath = path.join(tmp, "Test.bin");
|
|
24
|
-
const outDir = path.join(tmp, "out");
|
|
25
|
-
|
|
26
|
-
const abi = [
|
|
27
|
-
{
|
|
28
|
-
type: "function",
|
|
29
|
-
name: "balanceOf",
|
|
30
|
-
stateMutability: "view",
|
|
31
|
-
inputs: [{ name: "account", type: "address" }],
|
|
32
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: "function",
|
|
36
|
-
name: "transfer",
|
|
37
|
-
stateMutability: "nonpayable",
|
|
38
|
-
inputs: [
|
|
39
|
-
{ name: "to", type: "address" },
|
|
40
|
-
{ name: "amount", type: "uint256" },
|
|
41
|
-
],
|
|
42
|
-
outputs: [{ name: "", type: "bool" }],
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
fs.writeFileSync(abiPath, JSON.stringify(abi, null, 2), "utf8");
|
|
47
|
-
fs.writeFileSync(binPath, "0x6000", "utf8");
|
|
48
|
-
|
|
49
|
-
const res = generate({ abiPath, binPath, outDir, contractName: "TestToken" });
|
|
50
|
-
assert.ok(fs.existsSync(res.contractFile));
|
|
51
|
-
assert.ok(fs.existsSync(res.factoryFile));
|
|
52
|
-
assert.ok(fs.existsSync(res.typesFile));
|
|
53
|
-
assert.ok(fs.existsSync(res.indexFile));
|
|
54
|
-
|
|
55
|
-
const contractSrc = fs.readFileSync(res.contractFile, "utf8");
|
|
56
|
-
assert.ok(contractSrc.includes("export class TestToken"));
|
|
57
|
-
assert.ok(contractSrc.includes("async balanceOf"));
|
|
58
|
-
assert.ok(contractSrc.includes("async transfer"));
|
|
59
|
-
assert.ok(contractSrc.includes("populateTransaction"));
|
|
60
|
-
|
|
61
|
-
const factorySrc = fs.readFileSync(res.factoryFile, "utf8");
|
|
62
|
-
assert.ok(factorySrc.includes("export class TestToken__factory"));
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("generated test for a concrete contract (with bytecode) contains the provider.getCode bytecode assertion", () => {
|
|
66
|
-
logTest("generated test for a concrete contract contains the bytecode assertion", {});
|
|
67
|
-
const src = generateTransactionalTestJs({
|
|
68
|
-
contractName: "ConcreteToken",
|
|
69
|
-
abi: [{ type: "constructor", inputs: [], stateMutability: "nonpayable" }],
|
|
70
|
-
bytecode: "0x6080604052",
|
|
71
|
-
});
|
|
72
|
-
assert.ok(src.includes("provider.getCode(contract.target"));
|
|
73
|
-
assert.ok(src.includes('assert.ok(code && code !== "0x")'));
|
|
74
|
-
assert.ok(!src.includes("Skipping bytecode check"));
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("generated test for an interface (bytecode '0x') omits the provider.getCode bytecode assertion", () => {
|
|
78
|
-
logTest("generated test for an interface omits the bytecode assertion", {});
|
|
79
|
-
const src = generateTransactionalTestJs({
|
|
80
|
-
contractName: "IThing",
|
|
81
|
-
abi: [{
|
|
82
|
-
type: "function", name: "doThing",
|
|
83
|
-
inputs: [], outputs: [], stateMutability: "nonpayable",
|
|
84
|
-
}],
|
|
85
|
-
bytecode: "0x",
|
|
86
|
-
});
|
|
87
|
-
assert.ok(!src.includes("provider.getCode(contract.target"));
|
|
88
|
-
assert.ok(!src.includes('assert.ok(code && code !== "0x")'));
|
|
89
|
-
assert.ok(src.includes("Skipping bytecode check"));
|
|
90
|
-
assert.ok(src.includes("IThing is an interface"));
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("empty/undefined/null/'0X' bytecode variants are all treated as interface", () => {
|
|
94
|
-
logTest("empty bytecode variants are all treated as interface", {});
|
|
95
|
-
for (const bc of [undefined, null, "", "0x", "0X", " 0x "] as Array<string | null | undefined>) {
|
|
96
|
-
const src = generateTransactionalTestJs({
|
|
97
|
-
contractName: "IThing",
|
|
98
|
-
abi: [],
|
|
99
|
-
bytecode: bc as unknown as string,
|
|
100
|
-
});
|
|
101
|
-
assert.ok(
|
|
102
|
-
!src.includes("provider.getCode(contract.target"),
|
|
103
|
-
`bytecode=${JSON.stringify(bc)} should be treated as interface (no getCode assertion)`,
|
|
104
|
-
);
|
|
105
|
-
assert.ok(
|
|
106
|
-
src.includes("Skipping bytecode check"),
|
|
107
|
-
`bytecode=${JSON.stringify(bc)} should emit skip comment`,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("includes injected docs in generated TypeScript", () => {
|
|
113
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-docs-"));
|
|
114
|
-
const outDir = path.join(tmp, "out");
|
|
115
|
-
|
|
116
|
-
const abi = [
|
|
117
|
-
{
|
|
118
|
-
type: "function",
|
|
119
|
-
name: "set",
|
|
120
|
-
stateMutability: "nonpayable",
|
|
121
|
-
inputs: [{ name: "value", type: "uint256" }],
|
|
122
|
-
outputs: [],
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
const res = generateFromArtifacts({
|
|
127
|
-
outDir,
|
|
128
|
-
artifacts: [
|
|
129
|
-
{
|
|
130
|
-
contractName: "DocToken",
|
|
131
|
-
abi,
|
|
132
|
-
bytecode: "0x6000",
|
|
133
|
-
docs: {
|
|
134
|
-
contract: "Example contract doc from Solidity.",
|
|
135
|
-
functions: {
|
|
136
|
-
set: "Example function doc from Solidity.",
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const contractFile = res.contracts[0].contractFile;
|
|
144
|
-
const src = fs.readFileSync(contractFile, "utf8");
|
|
145
|
-
assert.ok(src.includes("Example contract doc from Solidity."));
|
|
146
|
-
assert.ok(src.includes("Example function doc from Solidity."));
|
|
147
|
-
});
|
|
148
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Hashing helpers (optional params, deterministic behavior)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
|
|
11
|
-
const qc = require("../../index");
|
|
12
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
|
-
|
|
14
|
-
describe("Hashing", () => {
|
|
15
|
-
logSuite("Hashing");
|
|
16
|
-
it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
|
|
17
|
-
logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
|
|
18
|
-
const out = qc.keccak256(new Uint8Array([]));
|
|
19
|
-
assert.equal(typeof out, "string");
|
|
20
|
-
assert.ok(out.startsWith("0x"));
|
|
21
|
-
assert.equal(out.length, 66);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("sha256/sha512/ripemd160 output lengths are correct", () => {
|
|
25
|
-
const data = qc.toUtf8Bytes("hello");
|
|
26
|
-
assert.equal(qc.sha256(data).length, 66);
|
|
27
|
-
assert.equal(qc.sha512(data).length, 130);
|
|
28
|
-
assert.equal(qc.ripemd160(data).length, 42);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("randomBytes returns requested length", () => {
|
|
32
|
-
const b = qc.randomBytes(16);
|
|
33
|
-
assert.ok(b instanceof Uint8Array);
|
|
34
|
-
assert.equal(b.length, 16);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
|
|
38
|
-
const pw = qc.toUtf8Bytes("password");
|
|
39
|
-
const salt = qc.toUtf8Bytes("salt");
|
|
40
|
-
|
|
41
|
-
const a = qc.pbkdf2(pw, salt, 1, 32);
|
|
42
|
-
const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
|
|
43
|
-
const c = qc.pbkdf2(pw, salt, 1, 32, null);
|
|
44
|
-
|
|
45
|
-
assert.equal(a, b);
|
|
46
|
-
assert.equal(a, c);
|
|
47
|
-
assert.ok(a.startsWith("0x") && a.length === 66);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("computeHmac produces a hex string", () => {
|
|
51
|
-
const key = qc.toUtf8Bytes("key");
|
|
52
|
-
const data = qc.toUtf8Bytes("data");
|
|
53
|
-
const out = qc.computeHmac("sha256", key, data);
|
|
54
|
-
assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
|
|
58
|
-
const pw = qc.toUtf8Bytes("password");
|
|
59
|
-
const salt = qc.toUtf8Bytes("salt");
|
|
60
|
-
const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
|
|
61
|
-
assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Hashing helpers (optional params, deterministic behavior)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
|
|
11
|
-
import qc from "../../index";
|
|
12
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
13
|
-
|
|
14
|
-
describe("Hashing", () => {
|
|
15
|
-
logSuite("Hashing");
|
|
16
|
-
it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
|
|
17
|
-
logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
|
|
18
|
-
const out = qc.keccak256(new Uint8Array([]));
|
|
19
|
-
assert.equal(typeof out, "string");
|
|
20
|
-
assert.ok(out.startsWith("0x"));
|
|
21
|
-
assert.equal(out.length, 66);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("sha256/sha512/ripemd160 output lengths are correct", () => {
|
|
25
|
-
const data = qc.toUtf8Bytes("hello");
|
|
26
|
-
assert.equal(qc.sha256(data).length, 66);
|
|
27
|
-
assert.equal(qc.sha512(data).length, 130);
|
|
28
|
-
assert.equal(qc.ripemd160(data).length, 42);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("randomBytes returns requested length", () => {
|
|
32
|
-
const b = qc.randomBytes(16);
|
|
33
|
-
assert.ok(b instanceof Uint8Array);
|
|
34
|
-
assert.equal(b.length, 16);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
|
|
38
|
-
const pw = qc.toUtf8Bytes("password");
|
|
39
|
-
const salt = qc.toUtf8Bytes("salt");
|
|
40
|
-
|
|
41
|
-
const a = qc.pbkdf2(pw, salt, 1, 32);
|
|
42
|
-
const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
|
|
43
|
-
const c = qc.pbkdf2(pw, salt, 1, 32, null);
|
|
44
|
-
|
|
45
|
-
assert.equal(a, b);
|
|
46
|
-
assert.equal(a, c);
|
|
47
|
-
assert.ok(a.startsWith("0x") && a.length === 66);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("computeHmac produces a hex string", () => {
|
|
51
|
-
const key = qc.toUtf8Bytes("key");
|
|
52
|
-
const data = qc.toUtf8Bytes("data");
|
|
53
|
-
const out = qc.computeHmac("sha256", key, data);
|
|
54
|
-
assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
|
|
58
|
-
const pw = qc.toUtf8Bytes("password");
|
|
59
|
-
const salt = qc.toUtf8Bytes("salt");
|
|
60
|
-
const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
|
|
61
|
-
assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
|
|
62
|
-
});
|
|
63
|
-
});
|
package/test/unit/init.test.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description SDK initialization and basic constants
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
|
|
11
|
-
const { Initialize, isInitialized, Config } = require("../../config");
|
|
12
|
-
const qc = require("../../index");
|
|
13
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
14
|
-
|
|
15
|
-
describe("Initialize()", () => {
|
|
16
|
-
logSuite("Initialize()");
|
|
17
|
-
it("initializes with default config (null)", async () => {
|
|
18
|
-
logTest("initializes with default config (null)", {});
|
|
19
|
-
const ok = await Initialize(null);
|
|
20
|
-
assert.equal(ok, true);
|
|
21
|
-
assert.equal(isInitialized(), true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("exposes constants with QuantumCoin address size", async () => {
|
|
25
|
-
await Initialize(null);
|
|
26
|
-
assert.equal(typeof qc.version, "string");
|
|
27
|
-
assert.equal(qc.ZeroAddress.length, 66);
|
|
28
|
-
assert.equal(qc.ZeroHash.length, 66);
|
|
29
|
-
assert.equal(qc.ZeroAddress, "0x" + "00".repeat(32));
|
|
30
|
-
assert.equal(qc.WeiPerEther, 1000000000000000000n);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("Config defaults match SPEC.md", () => {
|
|
34
|
-
const cfg = new Config();
|
|
35
|
-
assert.equal(cfg.chainId, 123123);
|
|
36
|
-
assert.equal(cfg.rpcEndpoint, "https://public.rpc.quantumcoinapi.com");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
package/test/unit/init.test.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description SDK initialization and basic constants
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
|
|
11
|
-
import { Initialize, isInitialized, Config } from "../../config";
|
|
12
|
-
import qc from "../../index";
|
|
13
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
14
|
-
|
|
15
|
-
describe("Initialize()", () => {
|
|
16
|
-
logSuite("Initialize()");
|
|
17
|
-
it("initializes with default config (null)", async () => {
|
|
18
|
-
logTest("initializes with default config (null)", {});
|
|
19
|
-
const ok = await Initialize(null);
|
|
20
|
-
assert.equal(ok, true);
|
|
21
|
-
assert.equal(isInitialized(), true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("exposes constants with QuantumCoin address size", async () => {
|
|
25
|
-
await Initialize(null);
|
|
26
|
-
assert.equal(typeof qc.version, "string");
|
|
27
|
-
assert.equal(qc.ZeroAddress.length, 66);
|
|
28
|
-
assert.equal(qc.ZeroHash.length, 66);
|
|
29
|
-
assert.equal(qc.ZeroAddress, "0x" + "00".repeat(32));
|
|
30
|
-
assert.equal(qc.WeiPerEther, 1000000000000000000n);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("Config defaults match SPEC.md", () => {
|
|
34
|
-
const cfg = new Config();
|
|
35
|
-
assert.equal(cfg.chainId, 123123);
|
|
36
|
-
assert.equal(cfg.rpcEndpoint, "https://public.rpc.quantumcoinapi.com");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @description Interface.parseLog (event decoding) using quantum-coin-js-sdk decodeEventLog
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { describe, it } = require("node:test");
|
|
8
|
-
const assert = require("node:assert/strict");
|
|
9
|
-
|
|
10
|
-
const { Initialize } = require("../../config");
|
|
11
|
-
const qc = require("../../index");
|
|
12
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
|
-
|
|
14
|
-
describe("Interface.parseLog", () => {
|
|
15
|
-
logSuite("Interface.parseLog");
|
|
16
|
-
it("parses an encoded event log and returns LogDescription-like result", async () => {
|
|
17
|
-
logTest("parses an encoded event log and returns LogDescription-like result", {});
|
|
18
|
-
await Initialize(null);
|
|
19
|
-
|
|
20
|
-
const abi = [
|
|
21
|
-
{
|
|
22
|
-
name: "Transfer",
|
|
23
|
-
type: "event",
|
|
24
|
-
anonymous: false,
|
|
25
|
-
inputs: [
|
|
26
|
-
{ name: "from", type: "address", indexed: true },
|
|
27
|
-
{ name: "to", type: "address", indexed: true },
|
|
28
|
-
{ name: "value", type: "uint256", indexed: false },
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const iface = new qc.Interface(abi);
|
|
34
|
-
const from = qc.Wallet.createRandom().address;
|
|
35
|
-
const to = qc.Wallet.createRandom().address;
|
|
36
|
-
const value = 123n;
|
|
37
|
-
|
|
38
|
-
const encoded = iface.encodeEventLog("Transfer", [from, to, value]);
|
|
39
|
-
assert.ok(Array.isArray(encoded.topics) && encoded.topics.length >= 1);
|
|
40
|
-
assert.ok(typeof encoded.data === "string");
|
|
41
|
-
|
|
42
|
-
const parsed = iface.parseLog({ topics: encoded.topics, data: encoded.data });
|
|
43
|
-
assert.equal(parsed.name, "Transfer");
|
|
44
|
-
assert.ok(parsed.topic && parsed.topic.startsWith("0x"));
|
|
45
|
-
assert.ok(parsed.signature.includes("Transfer("));
|
|
46
|
-
|
|
47
|
-
// Args should be array-like and have named keys
|
|
48
|
-
assert.equal(parsed.args.from.toLowerCase(), from.toLowerCase());
|
|
49
|
-
assert.equal(parsed.args.to.toLowerCase(), to.toLowerCase());
|
|
50
|
-
assert.equal(BigInt(parsed.args.value), value);
|
|
51
|
-
assert.equal(parsed.args[0].toLowerCase(), from.toLowerCase());
|
|
52
|
-
assert.equal(parsed.args[1].toLowerCase(), to.toLowerCase());
|
|
53
|
-
assert.equal(BigInt(parsed.args[2]), value);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @description Interface.parseLog (event decoding) using quantum-coin-js-sdk decodeEventLog
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { describe, it } from "node:test";
|
|
8
|
-
import assert from "node:assert/strict";
|
|
9
|
-
|
|
10
|
-
import { Initialize } from "../../config";
|
|
11
|
-
import qc from "../../index";
|
|
12
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
13
|
-
|
|
14
|
-
describe("Interface.parseLog", () => {
|
|
15
|
-
logSuite("Interface.parseLog");
|
|
16
|
-
it("parses an encoded event log and returns LogDescription-like result", async () => {
|
|
17
|
-
logTest("parses an encoded event log and returns LogDescription-like result", {});
|
|
18
|
-
await Initialize(null);
|
|
19
|
-
|
|
20
|
-
const abi = [
|
|
21
|
-
{
|
|
22
|
-
name: "Transfer",
|
|
23
|
-
type: "event",
|
|
24
|
-
anonymous: false,
|
|
25
|
-
inputs: [
|
|
26
|
-
{ name: "from", type: "address", indexed: true },
|
|
27
|
-
{ name: "to", type: "address", indexed: true },
|
|
28
|
-
{ name: "value", type: "uint256", indexed: false },
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const iface = new qc.Interface(abi);
|
|
34
|
-
const from = qc.Wallet.createRandom().address;
|
|
35
|
-
const to = qc.Wallet.createRandom().address;
|
|
36
|
-
const value = 123n;
|
|
37
|
-
|
|
38
|
-
const encoded = iface.encodeEventLog("Transfer", [from, to, value]);
|
|
39
|
-
assert.ok(Array.isArray(encoded.topics) && encoded.topics.length >= 1);
|
|
40
|
-
assert.ok(typeof encoded.data === "string");
|
|
41
|
-
|
|
42
|
-
const parsed = iface.parseLog({ topics: encoded.topics, data: encoded.data });
|
|
43
|
-
assert.equal(parsed.name, "Transfer");
|
|
44
|
-
assert.ok(parsed.topic && parsed.topic.startsWith("0x"));
|
|
45
|
-
assert.ok(parsed.signature.includes("Transfer("));
|
|
46
|
-
|
|
47
|
-
assert.equal(parsed.args.from.toLowerCase(), from.toLowerCase());
|
|
48
|
-
assert.equal(parsed.args.to.toLowerCase(), to.toLowerCase());
|
|
49
|
-
assert.equal(BigInt(parsed.args.value), value);
|
|
50
|
-
assert.equal(parsed.args[0].toLowerCase(), from.toLowerCase());
|
|
51
|
-
assert.equal(parsed.args[1].toLowerCase(), to.toLowerCase());
|
|
52
|
-
assert.equal(BigInt(parsed.args[2]), value);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Internal hex utilities (optional params, edge cases)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { describe, it } = require("node:test");
|
|
9
|
-
const assert = require("node:assert/strict");
|
|
10
|
-
|
|
11
|
-
const { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } = require("../../src/internal/hex");
|
|
12
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
|
-
|
|
14
|
-
describe("internal/hex", () => {
|
|
15
|
-
logSuite("internal/hex");
|
|
16
|
-
it("normalizeHex lowercases, adds 0x, pads odd length", () => {
|
|
17
|
-
logTest("normalizeHex lowercases, adds 0x, pads odd length", {});
|
|
18
|
-
assert.equal(normalizeHex("aa"), "0xaa");
|
|
19
|
-
assert.equal(normalizeHex("0xAa"), "0xaa");
|
|
20
|
-
assert.equal(normalizeHex("0xa"), "0x0a");
|
|
21
|
-
assert.equal(normalizeHex("0x0A"), "0x0a");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("toQuantityHex produces spec-compliant quantities (no leading zeros, 0x0 for zero)", () => {
|
|
25
|
-
logTest("toQuantityHex produces spec-compliant quantities", {});
|
|
26
|
-
assert.equal(toQuantityHex(0), "0x0");
|
|
27
|
-
assert.equal(toQuantityHex(0n), "0x0");
|
|
28
|
-
assert.equal(toQuantityHex(1), "0x1");
|
|
29
|
-
assert.equal(toQuantityHex(5), "0x5");
|
|
30
|
-
assert.equal(toQuantityHex(15), "0xf");
|
|
31
|
-
assert.equal(toQuantityHex(16), "0x10");
|
|
32
|
-
assert.equal(toQuantityHex(255), "0xff");
|
|
33
|
-
assert.equal(toQuantityHex(256), "0x100");
|
|
34
|
-
assert.equal(toQuantityHex(4095), "0xfff");
|
|
35
|
-
assert.equal(toQuantityHex(4096), "0x1000");
|
|
36
|
-
assert.equal(toQuantityHex(65535n), "0xffff");
|
|
37
|
-
assert.equal(toQuantityHex(2n ** 64n), "0x10000000000000000");
|
|
38
|
-
|
|
39
|
-
assert.equal(toQuantity, toQuantityHex);
|
|
40
|
-
assert.equal(toQuantity(5), "0x5");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("toQuantityHex rejects invalid inputs", () => {
|
|
44
|
-
logTest("toQuantityHex rejects invalid inputs", {});
|
|
45
|
-
assert.throws(() => toQuantityHex(-1), RangeError);
|
|
46
|
-
assert.throws(() => toQuantityHex(-1n), RangeError);
|
|
47
|
-
assert.throws(() => toQuantityHex(1.5), TypeError);
|
|
48
|
-
assert.throws(() => toQuantityHex(NaN), TypeError);
|
|
49
|
-
assert.throws(() => toQuantityHex(Infinity), TypeError);
|
|
50
|
-
assert.throws(() => toQuantityHex("5"), TypeError);
|
|
51
|
-
assert.throws(() => toQuantityHex(null), TypeError);
|
|
52
|
-
assert.throws(() => toQuantityHex(undefined), TypeError);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("isHexString validates and supports optional lengthBytes", () => {
|
|
56
|
-
const h32 = "0x" + "11".repeat(32);
|
|
57
|
-
assert.equal(isHexString(h32), true);
|
|
58
|
-
assert.equal(isHexString(h32, 32), true);
|
|
59
|
-
assert.equal(isHexString(h32, null), true); // optional param passed as null => ignored
|
|
60
|
-
assert.equal(isHexString(h32, 31), false);
|
|
61
|
-
|
|
62
|
-
assert.equal(isHexString("0x"), false);
|
|
63
|
-
assert.equal(isHexString("0x0"), false); // odd length after 0x
|
|
64
|
-
assert.equal(isHexString("0xzz"), false);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("hexToBytes/bytesToHex roundtrip", () => {
|
|
68
|
-
const h = "0x1234abcd";
|
|
69
|
-
const b = hexToBytes(h);
|
|
70
|
-
assert.ok(b instanceof Uint8Array);
|
|
71
|
-
assert.equal(bytesToHex(b), h);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("arrayify accepts hex string and Uint8Array; rejects others", () => {
|
|
75
|
-
assert.deepEqual(arrayify("0x1234"), new Uint8Array([0x12, 0x34]));
|
|
76
|
-
assert.deepEqual(arrayify(new Uint8Array([1, 2, 3])), new Uint8Array([1, 2, 3]));
|
|
77
|
-
assert.throws(() => arrayify("not-hex"));
|
|
78
|
-
assert.throws(() => arrayify(123));
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory unit
|
|
3
|
-
* @blockchainRequired false
|
|
4
|
-
* @transactional false
|
|
5
|
-
* @description Internal hex utilities (optional params, edge cases)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
|
|
11
|
-
import { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } from "../../src/internal/hex";
|
|
12
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
13
|
-
|
|
14
|
-
describe("internal/hex", () => {
|
|
15
|
-
logSuite("internal/hex");
|
|
16
|
-
it("normalizeHex lowercases, adds 0x, pads odd length", () => {
|
|
17
|
-
logTest("normalizeHex lowercases, adds 0x, pads odd length", {});
|
|
18
|
-
assert.equal(normalizeHex("aa"), "0xaa");
|
|
19
|
-
assert.equal(normalizeHex("0xAa"), "0xaa");
|
|
20
|
-
assert.equal(normalizeHex("0xa"), "0x0a");
|
|
21
|
-
assert.equal(normalizeHex("0x0A"), "0x0a");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("toQuantityHex produces spec-compliant quantities (no leading zeros, 0x0 for zero)", () => {
|
|
25
|
-
logTest("toQuantityHex produces spec-compliant quantities", {});
|
|
26
|
-
assert.equal(toQuantityHex(0), "0x0");
|
|
27
|
-
assert.equal(toQuantityHex(0n), "0x0");
|
|
28
|
-
assert.equal(toQuantityHex(1), "0x1");
|
|
29
|
-
assert.equal(toQuantityHex(5), "0x5");
|
|
30
|
-
assert.equal(toQuantityHex(15), "0xf");
|
|
31
|
-
assert.equal(toQuantityHex(16), "0x10");
|
|
32
|
-
assert.equal(toQuantityHex(255), "0xff");
|
|
33
|
-
assert.equal(toQuantityHex(256), "0x100");
|
|
34
|
-
assert.equal(toQuantityHex(4095), "0xfff");
|
|
35
|
-
assert.equal(toQuantityHex(4096), "0x1000");
|
|
36
|
-
assert.equal(toQuantityHex(65535n), "0xffff");
|
|
37
|
-
assert.equal(toQuantityHex(2n ** 64n), "0x10000000000000000");
|
|
38
|
-
|
|
39
|
-
assert.equal(toQuantity, toQuantityHex);
|
|
40
|
-
assert.equal(toQuantity(5), "0x5");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("toQuantityHex rejects invalid inputs", () => {
|
|
44
|
-
logTest("toQuantityHex rejects invalid inputs", {});
|
|
45
|
-
assert.throws(() => toQuantityHex(-1), RangeError);
|
|
46
|
-
assert.throws(() => toQuantityHex(-1n), RangeError);
|
|
47
|
-
assert.throws(() => toQuantityHex(1.5), TypeError);
|
|
48
|
-
assert.throws(() => toQuantityHex(NaN), TypeError);
|
|
49
|
-
assert.throws(() => toQuantityHex(Infinity), TypeError);
|
|
50
|
-
assert.throws(() => toQuantityHex("5" as unknown as number), TypeError);
|
|
51
|
-
assert.throws(() => toQuantityHex(null as unknown as number), TypeError);
|
|
52
|
-
assert.throws(() => toQuantityHex(undefined as unknown as number), TypeError);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("isHexString validates and supports optional lengthBytes", () => {
|
|
56
|
-
const h32 = "0x" + "11".repeat(32);
|
|
57
|
-
assert.equal(isHexString(h32), true);
|
|
58
|
-
assert.equal(isHexString(h32, 32), true);
|
|
59
|
-
assert.equal(isHexString(h32, null), true); // optional param passed as null => ignored
|
|
60
|
-
assert.equal(isHexString(h32, 31), false);
|
|
61
|
-
|
|
62
|
-
assert.equal(isHexString("0x"), false);
|
|
63
|
-
assert.equal(isHexString("0x0"), false); // odd length after 0x
|
|
64
|
-
assert.equal(isHexString("0xzz"), false);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("hexToBytes/bytesToHex roundtrip", () => {
|
|
68
|
-
const h = "0x1234abcd";
|
|
69
|
-
const b = hexToBytes(h);
|
|
70
|
-
assert.ok(b instanceof Uint8Array);
|
|
71
|
-
assert.equal(bytesToHex(b), h);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("arrayify accepts hex string and Uint8Array; rejects others", () => {
|
|
75
|
-
assert.deepEqual(arrayify("0x1234"), new Uint8Array([0x12, 0x34]));
|
|
76
|
-
assert.deepEqual(arrayify(new Uint8Array([1, 2, 3])), new Uint8Array([1, 2, 3]));
|
|
77
|
-
assert.throws(() => arrayify("not-hex"));
|
|
78
|
-
assert.throws(() => arrayify(123 as unknown));
|
|
79
|
-
});
|
|
80
|
-
});
|