quantumcoin 7.0.11 → 7.0.13
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 +828 -807
- package/README.md +17 -0
- package/config.d.ts +50 -50
- package/examples/example-generated-sdk-js/README.md +65 -0
- package/examples/example-generated-sdk-js/examples/_test-wallet.js +17 -0
- package/examples/example-generated-sdk-js/examples/deploy.js +41 -0
- package/examples/example-generated-sdk-js/examples/events.js +36 -0
- package/examples/example-generated-sdk-js/examples/read-operations.js +46 -0
- package/examples/example-generated-sdk-js/examples/write-operations.js +44 -0
- package/examples/example-generated-sdk-js/index.d.ts +1 -0
- package/examples/example-generated-sdk-js/index.js +15 -0
- package/examples/example-generated-sdk-js/package-lock.json +59 -0
- package/examples/example-generated-sdk-js/package.json +22 -0
- package/examples/example-generated-sdk-js/src/SimpleERC20.d.ts +19 -0
- package/examples/example-generated-sdk-js/src/SimpleERC20.js +353 -0
- package/examples/example-generated-sdk-js/src/SimpleERC20__factory.d.ts +10 -0
- package/examples/example-generated-sdk-js/src/SimpleERC20__factory.js +29 -0
- package/examples/example-generated-sdk-js/src/index.d.ts +4 -0
- package/examples/example-generated-sdk-js/src/index.js +5 -0
- package/examples/example-generated-sdk-js/src/quantumcoin-shims.d.ts +23 -0
- package/examples/example-generated-sdk-js/src/types.d.ts +3 -0
- package/examples/example-generated-sdk-js/src/types.js +3 -0
- package/examples/example-generated-sdk-js/test/e2e/SimpleERC20.e2e.test.js +78 -0
- package/examples/example-generated-sdk-ts/README.md +65 -0
- package/examples/example-generated-sdk-ts/examples/_test-wallet.js +17 -0
- package/examples/example-generated-sdk-ts/examples/deploy.js +41 -0
- package/examples/example-generated-sdk-ts/examples/events.js +36 -0
- package/examples/example-generated-sdk-ts/examples/read-operations.js +46 -0
- package/examples/example-generated-sdk-ts/examples/write-operations.js +44 -0
- package/examples/example-generated-sdk-ts/index.d.ts +1 -0
- package/examples/example-generated-sdk-ts/index.js +15 -0
- package/examples/example-generated-sdk-ts/package-lock.json +59 -0
- package/examples/example-generated-sdk-ts/package.json +23 -0
- package/examples/example-generated-sdk-ts/src/SimpleERC20.ts +334 -0
- package/examples/example-generated-sdk-ts/src/SimpleERC20__factory.ts +28 -0
- package/examples/example-generated-sdk-ts/src/index.ts +4 -0
- package/examples/example-generated-sdk-ts/src/quantumcoin-shims.d.ts +23 -0
- package/examples/example-generated-sdk-ts/src/types.ts +4 -0
- package/examples/example-generated-sdk-ts/test/e2e/SimpleERC20.e2e.test.js +78 -0
- package/examples/example-generated-sdk-ts/tsconfig.json +14 -0
- package/examples/package-lock.json +1 -1
- package/examples/sdk-generator-erc20.inline.json +251 -251
- package/generate-sdk.js +1825 -1823
- package/package.json +1 -1
- package/src/abi/fragments.d.ts +42 -42
- package/src/abi/index.d.ts +13 -13
- package/src/contract/index.d.ts +9 -9
- package/src/errors/index.d.ts +92 -92
- package/src/generator/index.d.ts +11 -4
- package/src/generator/index.js +33 -5
- package/src/internal/hex.d.ts +68 -61
- package/src/internal/hex.js +36 -0
- package/src/providers/json-rpc-provider.d.ts +12 -12
- package/src/providers/provider.js +3 -3
- package/src/utils/address.d.ts +58 -58
- package/src/utils/encoding.d.ts +120 -120
- package/src/utils/hashing.js +298 -298
- package/src/utils/index.d.ts +63 -63
- package/src/utils/index.js +14 -14
- package/src/utils/result.d.ts +57 -57
- package/src/utils/rlp.d.ts +12 -12
- package/src/utils/units.d.ts +29 -29
- package/src/wallet/index.d.ts +10 -10
- package/src/wallet/wallet.d.ts +192 -187
- package/src/wallet/wallet.js +630 -610
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/README.md +83 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.abi.json +12544 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.bin +1 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.js +17 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.ts +10 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.js +41 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.ts +41 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.js +36 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.ts +36 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.js +82 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.ts +80 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.js +46 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.ts +44 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.js +44 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.ts +44 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.d.ts +1 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.js +21 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package-lock.json +597 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package.json +25 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.d.ts +1280 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.js +14021 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.d.ts +11 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.js +29 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.d.ts +4 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.js +5 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/quantumcoin-shims.d.ts +25 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.d.ts +3 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.js +3 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.e2e.test.js +77 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.extra.test.js +195 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/README.md +83 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.abi.json +12544 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.bin +1 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.js +17 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.ts +10 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.js +41 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.ts +41 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.js +36 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.ts +36 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.js +82 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.ts +80 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.js +46 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.ts +44 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.js +44 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.ts +44 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.d.ts +1 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.js +21 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package-lock.json +597 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package.json +26 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes.ts +13940 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes__factory.ts +29 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/index.ts +4 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/quantumcoin-shims.d.ts +25 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/types.ts +4 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.e2e.test.js +77 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.extra.test.js +195 -0
- package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/tsconfig.json +18 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/README.md +74 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.abi.json +245 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.bin +1 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.js +17 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.ts +10 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.js +41 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.ts +41 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.js +36 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.ts +36 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.js +82 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.ts +80 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.js +46 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.ts +44 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.js +44 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.ts +44 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.d.ts +1 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.js +16 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package-lock.json +597 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package.json +25 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.d.ts +24 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.js +372 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.d.ts +10 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.js +29 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.d.ts +4 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.js +5 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/quantumcoin-shims.d.ts +25 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.d.ts +3 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.js +3 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/test/e2e/SimpleERC20.e2e.test.js +90 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/README.md +74 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.abi.json +245 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.bin +1 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.js +17 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.ts +10 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.js +41 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.ts +41 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.js +36 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.ts +36 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.js +82 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.ts +80 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.js +46 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.ts +44 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.js +44 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.ts +44 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.d.ts +1 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.js +16 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package-lock.json +597 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package.json +26 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20.ts +355 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20__factory.ts +28 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/index.ts +4 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/quantumcoin-shims.d.ts +25 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/types.ts +4 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/test/e2e/SimpleERC20.e2e.test.js +90 -0
- package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/tsconfig.json +18 -0
- package/test/e2e/generator-interface.e2e.test.js +163 -0
- package/test/e2e/generator-interface.e2e.test.ts +158 -0
- package/test/e2e/signing-context-and-fee.e2e.test.js +141 -141
- package/test/e2e/signing-context-and-fee.e2e.test.ts +128 -128
- package/test/integration/provider.test.js +88 -88
- package/test/unit/address-wallet.test.js +892 -751
- package/test/unit/address-wallet.test.ts +877 -736
- package/test/unit/generator.test.js +48 -1
- package/test/unit/generator.test.ts +48 -1
- package/test/unit/hashing.test.js +64 -64
- package/test/unit/hashing.test.ts +63 -63
- package/test/unit/internal-hex.test.js +32 -1
- package/test/unit/internal-hex.test.ts +32 -1
- package/test/unit/providers.test.js +51 -1
- package/test/unit/providers.test.ts +53 -0
- package/SPEC.md +0 -3784
- 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 -235
- 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/.github/workflows/publish-npmjs.yaml +0 -22
- 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 -1665
- 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 -1024
- package/examples/node_modules/quantum-coin-js-sdk/index.js +0 -3062
- 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 -686
- 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
|
@@ -11,7 +11,7 @@ const fs = require("node:fs");
|
|
|
11
11
|
const os = require("node:os");
|
|
12
12
|
const path = require("node:path");
|
|
13
13
|
|
|
14
|
-
const { generate, generateFromArtifacts } = require("../../src/generator");
|
|
14
|
+
const { generate, generateFromArtifacts, generateTransactionalTestJs } = require("../../src/generator");
|
|
15
15
|
const { logSuite, logTest } = require("../verbose-logger");
|
|
16
16
|
|
|
17
17
|
describe("typed contract generator", () => {
|
|
@@ -62,6 +62,53 @@ describe("typed contract generator", () => {
|
|
|
62
62
|
assert.ok(factorySrc.includes("export class TestToken__factory"));
|
|
63
63
|
});
|
|
64
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 "]) {
|
|
96
|
+
const src = generateTransactionalTestJs({
|
|
97
|
+
contractName: "IThing",
|
|
98
|
+
abi: [],
|
|
99
|
+
bytecode: bc,
|
|
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
|
+
|
|
65
112
|
it("includes injected docs in generated TypeScript", () => {
|
|
66
113
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-docs-"));
|
|
67
114
|
const outDir = path.join(tmp, "out");
|
|
@@ -11,7 +11,7 @@ import fs from "node:fs";
|
|
|
11
11
|
import os from "node:os";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
|
|
14
|
-
import { generate, generateFromArtifacts } from "../../src/generator";
|
|
14
|
+
import { generate, generateFromArtifacts, generateTransactionalTestJs } from "../../src/generator";
|
|
15
15
|
import { logSuite, logTest } from "../verbose-logger";
|
|
16
16
|
|
|
17
17
|
describe("typed contract generator", () => {
|
|
@@ -62,6 +62,53 @@ describe("typed contract generator", () => {
|
|
|
62
62
|
assert.ok(factorySrc.includes("export class TestToken__factory"));
|
|
63
63
|
});
|
|
64
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
|
+
|
|
65
112
|
it("includes injected docs in generated TypeScript", () => {
|
|
66
113
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-docs-"));
|
|
67
114
|
const outDir = path.join(tmp, "out");
|
|
@@ -1,64 +1,64 @@
|
|
|
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
|
+
/**
|
|
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 +1,63 @@
|
|
|
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
|
-
});
|
|
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
|
+
});
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const { describe, it } = require("node:test");
|
|
9
9
|
const assert = require("node:assert/strict");
|
|
10
10
|
|
|
11
|
-
const { normalizeHex, isHexString, hexToBytes, bytesToHex, arrayify } = require("../../src/internal/hex");
|
|
11
|
+
const { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } = require("../../src/internal/hex");
|
|
12
12
|
const { logSuite, logTest } = require("../verbose-logger");
|
|
13
13
|
|
|
14
14
|
describe("internal/hex", () => {
|
|
@@ -20,6 +20,37 @@
|
|
|
20
20
|
assert.equal(normalizeHex("0xa"), "0x0a");
|
|
21
21
|
assert.equal(normalizeHex("0x0A"), "0x0a");
|
|
22
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
|
+
});
|
|
23
54
|
|
|
24
55
|
it("isHexString validates and supports optional lengthBytes", () => {
|
|
25
56
|
const h32 = "0x" + "11".repeat(32);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { describe, it } from "node:test";
|
|
9
9
|
import assert from "node:assert/strict";
|
|
10
10
|
|
|
11
|
-
import { normalizeHex, isHexString, hexToBytes, bytesToHex, arrayify } from "../../src/internal/hex";
|
|
11
|
+
import { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } from "../../src/internal/hex";
|
|
12
12
|
import { logSuite, logTest } from "../verbose-logger";
|
|
13
13
|
|
|
14
14
|
describe("internal/hex", () => {
|
|
@@ -21,6 +21,37 @@ describe("internal/hex", () => {
|
|
|
21
21
|
assert.equal(normalizeHex("0x0A"), "0x0a");
|
|
22
22
|
});
|
|
23
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
|
+
|
|
24
55
|
it("isHexString validates and supports optional lengthBytes", () => {
|
|
25
56
|
const h32 = "0x" + "11".repeat(32);
|
|
26
57
|
assert.equal(isHexString(h32), true);
|
|
@@ -94,7 +94,57 @@
|
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
describe("
|
|
97
|
+
describe("AbstractProvider block-tag QUANTITY formatting", () => {
|
|
98
|
+
logSuite("AbstractProvider block-tag QUANTITY formatting");
|
|
99
|
+
|
|
100
|
+
it("getBlock encodes block numbers as spec-compliant quantities (no leading zeros)", async () => {
|
|
101
|
+
logTest("getBlock encodes block numbers as spec-compliant quantities", {});
|
|
102
|
+
class BlockStub extends qc.AbstractProvider {
|
|
103
|
+
constructor() { super(); this.calls = []; }
|
|
104
|
+
async _perform(method, params) {
|
|
105
|
+
this.calls.push({ method, params });
|
|
106
|
+
return { number: "0x5", timestamp: "0x64" };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const p = new BlockStub();
|
|
110
|
+
await p.getBlock(0); assert.equal(p.calls.at(-1).params[0], "0x0");
|
|
111
|
+
await p.getBlock(5); assert.equal(p.calls.at(-1).params[0], "0x5");
|
|
112
|
+
await p.getBlock(15); assert.equal(p.calls.at(-1).params[0], "0xf");
|
|
113
|
+
await p.getBlock(16); assert.equal(p.calls.at(-1).params[0], "0x10");
|
|
114
|
+
await p.getBlock(256); assert.equal(p.calls.at(-1).params[0], "0x100");
|
|
115
|
+
await p.getBlock(4095); assert.equal(p.calls.at(-1).params[0], "0xfff");
|
|
116
|
+
await p.getBlock(4096); assert.equal(p.calls.at(-1).params[0], "0x1000");
|
|
117
|
+
await p.getBlock("latest"); assert.equal(p.calls.at(-1).params[0], "latest");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("getLogs encodes fromBlock/toBlock as spec-compliant quantities (no leading zeros)", async () => {
|
|
121
|
+
logTest("getLogs encodes fromBlock/toBlock as spec-compliant quantities", {});
|
|
122
|
+
class LogStub extends qc.AbstractProvider {
|
|
123
|
+
constructor() { super(); this.calls = []; }
|
|
124
|
+
async _perform(method, params) { this.calls.push({ method, params }); return []; }
|
|
125
|
+
}
|
|
126
|
+
const lp = new LogStub();
|
|
127
|
+
await lp.getLogs({ fromBlock: 5, toBlock: 256 });
|
|
128
|
+
assert.equal(lp.calls[0].params[0].fromBlock, "0x5");
|
|
129
|
+
assert.equal(lp.calls[0].params[0].toBlock, "0x100");
|
|
130
|
+
await lp.getLogs({ fromBlock: "latest", toBlock: "pending" });
|
|
131
|
+
assert.equal(lp.calls[1].params[0].fromBlock, "latest");
|
|
132
|
+
assert.equal(lp.calls[1].params[0].toBlock, "pending");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("getBlock rejects invalid block numbers with a clear typed error", async () => {
|
|
136
|
+
logTest("getBlock rejects invalid block numbers", {});
|
|
137
|
+
class StubP extends qc.AbstractProvider {
|
|
138
|
+
async _perform() { return { number: "0x0" }; }
|
|
139
|
+
}
|
|
140
|
+
const p = new StubP();
|
|
141
|
+
await assert.rejects(() => p.getBlock(-1), (e) => e instanceof RangeError);
|
|
142
|
+
await assert.rejects(() => p.getBlock(1.5), (e) => e instanceof TypeError);
|
|
143
|
+
await assert.rejects(() => p.getBlock(NaN), (e) => e instanceof TypeError);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("TransactionResponse.wait", () => {
|
|
98
148
|
logSuite("TransactionResponse.wait");
|
|
99
149
|
it("uses default confirmations when omitted vs null", async () => {
|
|
100
150
|
logTest("uses default confirmations when omitted vs null", {});
|
|
@@ -91,6 +91,59 @@ describe("AbstractProvider defaults", () => {
|
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
+
describe("AbstractProvider block-tag QUANTITY formatting", () => {
|
|
95
|
+
logSuite("AbstractProvider block-tag QUANTITY formatting");
|
|
96
|
+
|
|
97
|
+
it("getBlock encodes block numbers as spec-compliant quantities (no leading zeros)", async () => {
|
|
98
|
+
logTest("getBlock encodes block numbers as spec-compliant quantities", {});
|
|
99
|
+
class BlockStub extends qc.AbstractProvider {
|
|
100
|
+
calls: { method: string; params: any[] }[] = [];
|
|
101
|
+
async _perform(method: string, params: any[]) {
|
|
102
|
+
this.calls.push({ method, params });
|
|
103
|
+
return { number: "0x5", timestamp: "0x64" };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const p = new BlockStub();
|
|
107
|
+
await p.getBlock(0); assert.equal(p.calls.at(-1)!.params[0], "0x0");
|
|
108
|
+
await p.getBlock(5); assert.equal(p.calls.at(-1)!.params[0], "0x5");
|
|
109
|
+
await p.getBlock(15); assert.equal(p.calls.at(-1)!.params[0], "0xf");
|
|
110
|
+
await p.getBlock(16); assert.equal(p.calls.at(-1)!.params[0], "0x10");
|
|
111
|
+
await p.getBlock(256); assert.equal(p.calls.at(-1)!.params[0], "0x100");
|
|
112
|
+
await p.getBlock(4095); assert.equal(p.calls.at(-1)!.params[0], "0xfff");
|
|
113
|
+
await p.getBlock(4096); assert.equal(p.calls.at(-1)!.params[0], "0x1000");
|
|
114
|
+
await p.getBlock("latest"); assert.equal(p.calls.at(-1)!.params[0], "latest");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("getLogs encodes fromBlock/toBlock as spec-compliant quantities (no leading zeros)", async () => {
|
|
118
|
+
logTest("getLogs encodes fromBlock/toBlock as spec-compliant quantities", {});
|
|
119
|
+
class LogStub extends qc.AbstractProvider {
|
|
120
|
+
calls: { method: string; params: any[] }[] = [];
|
|
121
|
+
async _perform(method: string, params: any[]) {
|
|
122
|
+
this.calls.push({ method, params });
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const lp = new LogStub();
|
|
127
|
+
await lp.getLogs({ fromBlock: 5, toBlock: 256 });
|
|
128
|
+
assert.equal(lp.calls[0].params[0].fromBlock, "0x5");
|
|
129
|
+
assert.equal(lp.calls[0].params[0].toBlock, "0x100");
|
|
130
|
+
await lp.getLogs({ fromBlock: "latest", toBlock: "pending" });
|
|
131
|
+
assert.equal(lp.calls[1].params[0].fromBlock, "latest");
|
|
132
|
+
assert.equal(lp.calls[1].params[0].toBlock, "pending");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("getBlock rejects invalid block numbers with a clear typed error", async () => {
|
|
136
|
+
logTest("getBlock rejects invalid block numbers", {});
|
|
137
|
+
class StubP extends qc.AbstractProvider {
|
|
138
|
+
async _perform() { return { number: "0x0" }; }
|
|
139
|
+
}
|
|
140
|
+
const p = new StubP();
|
|
141
|
+
await assert.rejects(() => p.getBlock(-1 as unknown as number), (e) => e instanceof RangeError);
|
|
142
|
+
await assert.rejects(() => p.getBlock(1.5 as unknown as number), (e) => e instanceof TypeError);
|
|
143
|
+
await assert.rejects(() => p.getBlock(NaN as unknown as number), (e) => e instanceof TypeError);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
94
147
|
describe("TransactionResponse.wait", () => {
|
|
95
148
|
logSuite("TransactionResponse.wait");
|
|
96
149
|
it("uses default confirmations when omitted vs null", async () => {
|