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
package/src/utils/hashing.d.ts
CHANGED
|
@@ -1,76 +1,79 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* keccak256 hash of BytesLike.
|
|
3
|
-
* @param {string|Uint8Array} data
|
|
4
|
-
* @returns {string}
|
|
5
|
-
*/
|
|
6
|
-
export function keccak256(data: string | Uint8Array): string;
|
|
7
|
-
/**
|
|
8
|
-
* sha256 hash of BytesLike.
|
|
9
|
-
* @param {string|Uint8Array} data
|
|
10
|
-
* @returns {string}
|
|
11
|
-
*/
|
|
12
|
-
export function sha256(data: string | Uint8Array): string;
|
|
13
|
-
/**
|
|
14
|
-
* sha512 hash of BytesLike.
|
|
15
|
-
* @param {string|Uint8Array} data
|
|
16
|
-
* @returns {string}
|
|
17
|
-
*/
|
|
18
|
-
export function sha512(data: string | Uint8Array): string;
|
|
19
|
-
/**
|
|
20
|
-
* ripemd160 hash of BytesLike.
|
|
21
|
-
* @param {string|Uint8Array} data
|
|
22
|
-
* @returns {string}
|
|
23
|
-
*/
|
|
24
|
-
export function ripemd160(data: string | Uint8Array): string;
|
|
25
|
-
/**
|
|
26
|
-
* ethers-style id(text) => keccak256(utf8Bytes(text))
|
|
27
|
-
* @param {string} text
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
export function id(text: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* Generate cryptographically strong random bytes.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
* @param {
|
|
51
|
-
* @param {string
|
|
52
|
-
* @
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {number}
|
|
63
|
-
* @
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
* @param {
|
|
72
|
-
* @param {
|
|
73
|
-
* @param {number}
|
|
74
|
-
* @
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
/**
|
|
2
|
+
* keccak256 hash of BytesLike.
|
|
3
|
+
* @param {string|Uint8Array} data
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function keccak256(data: string | Uint8Array): string;
|
|
7
|
+
/**
|
|
8
|
+
* sha256 hash of BytesLike.
|
|
9
|
+
* @param {string|Uint8Array} data
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
export function sha256(data: string | Uint8Array): string;
|
|
13
|
+
/**
|
|
14
|
+
* sha512 hash of BytesLike.
|
|
15
|
+
* @param {string|Uint8Array} data
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
export function sha512(data: string | Uint8Array): string;
|
|
19
|
+
/**
|
|
20
|
+
* ripemd160 hash of BytesLike.
|
|
21
|
+
* @param {string|Uint8Array} data
|
|
22
|
+
* @returns {string}
|
|
23
|
+
*/
|
|
24
|
+
export function ripemd160(data: string | Uint8Array): string;
|
|
25
|
+
/**
|
|
26
|
+
* ethers-style id(text) => keccak256(utf8Bytes(text))
|
|
27
|
+
* @param {string} text
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
export function id(text: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate cryptographically strong random bytes.
|
|
33
|
+
*
|
|
34
|
+
* Uses the platform Web Crypto API (`globalThis.crypto`), which is available in
|
|
35
|
+
* modern browsers and Node.js 20+.
|
|
36
|
+
* @param {number} length
|
|
37
|
+
* @returns {Uint8Array}
|
|
38
|
+
*/
|
|
39
|
+
export function randomBytes(length: number): Uint8Array;
|
|
40
|
+
/**
|
|
41
|
+
* Compute HMAC over data.
|
|
42
|
+
* @param {string} algorithm "sha256" or "sha512"
|
|
43
|
+
* @param {string|Uint8Array} key
|
|
44
|
+
* @param {string|Uint8Array} data
|
|
45
|
+
* @returns {string}
|
|
46
|
+
*/
|
|
47
|
+
export function computeHmac(algorithm: string, key: string | Uint8Array, data: string | Uint8Array): string;
|
|
48
|
+
/**
|
|
49
|
+
* PBKDF2 (sync) helper returning hex string.
|
|
50
|
+
* @param {string|Uint8Array} password
|
|
51
|
+
* @param {string|Uint8Array} salt
|
|
52
|
+
* @param {number} iterations
|
|
53
|
+
* @param {number} keylen
|
|
54
|
+
* @param {string=} algorithm "sha256" (default) or "sha512"
|
|
55
|
+
* @returns {string}
|
|
56
|
+
*/
|
|
57
|
+
export function pbkdf2(password: string | Uint8Array, salt: string | Uint8Array, iterations: number, keylen: number, algorithm?: string | undefined): string;
|
|
58
|
+
/**
|
|
59
|
+
* scrypt (async) helper returning hex string.
|
|
60
|
+
* @param {string|Uint8Array} password
|
|
61
|
+
* @param {string|Uint8Array} salt
|
|
62
|
+
* @param {number} N
|
|
63
|
+
* @param {number} r
|
|
64
|
+
* @param {number} p
|
|
65
|
+
* @param {number} dkLen
|
|
66
|
+
* @returns {Promise<string>}
|
|
67
|
+
*/
|
|
68
|
+
export function scrypt(password: string | Uint8Array, salt: string | Uint8Array, N: number, r: number, p: number, dkLen: number): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* scrypt (sync) helper returning hex string.
|
|
71
|
+
* @param {string|Uint8Array} password
|
|
72
|
+
* @param {string|Uint8Array} salt
|
|
73
|
+
* @param {number} N
|
|
74
|
+
* @param {number} r
|
|
75
|
+
* @param {number} p
|
|
76
|
+
* @param {number} dkLen
|
|
77
|
+
* @returns {string}
|
|
78
|
+
*/
|
|
79
|
+
export function scryptSync(password: string | Uint8Array, salt: string | Uint8Array, N: number, r: number, p: number, dkLen: number): string;
|
package/src/utils/hashing.js
CHANGED
|
@@ -1,145 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Hash utilities (ethers.js v6 compatible names).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* All cryptographic primitives are provided by `quantum-coin-js-sdk`, which
|
|
5
|
+
* runs in both Node.js and modern browsers (WebAssembly + Web Crypto). This
|
|
6
|
+
* keeps the SDK platform agnostic and free of Node's built-in `crypto` module.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: The underlying primitives require the SDK to be initialized. Call
|
|
9
|
+
* `Initialize()` (see the `quantumcoin/config` module) before using these
|
|
10
|
+
* helpers, otherwise a `NOT_INITIALIZED` error is thrown.
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
|
-
const
|
|
13
|
+
const qcsdk = require("quantum-coin-js-sdk");
|
|
10
14
|
const { arrayify, bytesToHex, utf8ToBytes } = require("../internal/hex");
|
|
15
|
+
const { makeError } = require("../errors");
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const nn = BigInt(n);
|
|
16
|
-
return ((x << nn) | (x >> (64n - nn))) & _MASK64;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _readU64LE(bytes, off) {
|
|
20
|
-
let x = 0n;
|
|
21
|
-
for (let i = 0; i < 8; i++) {
|
|
22
|
-
x |= BigInt(bytes[off + i]) << (8n * BigInt(i));
|
|
23
|
-
}
|
|
24
|
-
return x;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function _writeU64LE(out, off, x) {
|
|
28
|
-
let v = x & _MASK64;
|
|
29
|
-
for (let i = 0; i < 8; i++) {
|
|
30
|
-
out[off + i] = Number((v >> (8n * BigInt(i))) & 0xffn);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Keccak-f[1600] round constants
|
|
35
|
-
const _RC = [
|
|
36
|
-
0x0000000000000001n, 0x0000000000008082n, 0x800000000000808an, 0x8000000080008000n,
|
|
37
|
-
0x000000000000808bn, 0x0000000080000001n, 0x8000000080008081n, 0x8000000000008009n,
|
|
38
|
-
0x000000000000008an, 0x0000000000000088n, 0x0000000080008009n, 0x000000008000000an,
|
|
39
|
-
0x000000008000808bn, 0x800000000000008bn, 0x8000000000008089n, 0x8000000000008003n,
|
|
40
|
-
0x8000000000008002n, 0x8000000000000080n, 0x000000000000800an, 0x800000008000000an,
|
|
41
|
-
0x8000000080008081n, 0x8000000000008080n, 0x0000000080000001n, 0x8000000080008008n,
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
// Rotation offsets (rho step)
|
|
45
|
-
const _R = [
|
|
46
|
-
// Indexed by lane index (x + 5*y) where x,y in [0..4]
|
|
47
|
-
// (This is the standard Keccak rho offsets table, flattened in y-major order.)
|
|
48
|
-
0, 1, 62, 28, 27,
|
|
49
|
-
36, 44, 6, 55, 20,
|
|
50
|
-
3, 10, 43, 25, 39,
|
|
51
|
-
41, 45, 15, 21, 8,
|
|
52
|
-
18, 2, 61, 56, 14,
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
// Pi step mapping: index -> newIndex
|
|
56
|
-
const _PI = [
|
|
57
|
-
0, 10, 20, 5, 15,
|
|
58
|
-
16, 1, 11, 21, 6,
|
|
59
|
-
7, 17, 2, 12, 22,
|
|
60
|
-
23, 8, 18, 3, 13,
|
|
61
|
-
14, 24, 9, 19, 4,
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
function _keccakF1600(state) {
|
|
65
|
-
const b = new Array(25);
|
|
66
|
-
const c = new Array(5);
|
|
67
|
-
const d = new Array(5);
|
|
68
|
-
|
|
69
|
-
for (let round = 0; round < 24; round++) {
|
|
70
|
-
// Theta
|
|
71
|
-
for (let x = 0; x < 5; x++) {
|
|
72
|
-
c[x] = state[x] ^ state[x + 5] ^ state[x + 10] ^ state[x + 15] ^ state[x + 20];
|
|
73
|
-
}
|
|
74
|
-
for (let x = 0; x < 5; x++) {
|
|
75
|
-
d[x] = c[(x + 4) % 5] ^ _rotl64(c[(x + 1) % 5], 1);
|
|
76
|
-
}
|
|
77
|
-
for (let i = 0; i < 25; i++) {
|
|
78
|
-
state[i] = (state[i] ^ d[i % 5]) & _MASK64;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Rho + Pi
|
|
82
|
-
for (let i = 0; i < 25; i++) {
|
|
83
|
-
b[_PI[i]] = _rotl64(state[i], _R[i]);
|
|
84
|
-
}
|
|
17
|
+
// quantum-coin-js-sdk returns -1000 from crypto helpers when the SDK has not
|
|
18
|
+
// been initialized yet, and null when the input is invalid.
|
|
19
|
+
const _NOT_INITIALIZED = -1000;
|
|
85
20
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const rate = 136;
|
|
102
|
-
const outLen = 32;
|
|
103
|
-
const state = new Array(25).fill(0n);
|
|
104
|
-
|
|
105
|
-
let offset = 0;
|
|
106
|
-
while (offset + rate <= bytes.length) {
|
|
107
|
-
for (let i = 0; i < rate / 8; i++) {
|
|
108
|
-
state[i] = (state[i] ^ _readU64LE(bytes, offset + i * 8)) & _MASK64;
|
|
109
|
-
}
|
|
110
|
-
_keccakF1600(state);
|
|
111
|
-
offset += rate;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Final block + padding (keccak pad10*1 with domain 0x01)
|
|
115
|
-
const block = new Uint8Array(rate);
|
|
116
|
-
const remaining = bytes.length - offset;
|
|
117
|
-
block.set(bytes.slice(offset), 0);
|
|
118
|
-
block[remaining] = 0x01;
|
|
119
|
-
block[rate - 1] |= 0x80;
|
|
120
|
-
|
|
121
|
-
for (let i = 0; i < rate / 8; i++) {
|
|
122
|
-
state[i] = (state[i] ^ _readU64LE(block, i * 8)) & _MASK64;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a byte array returned by a quantum-coin-js-sdk crypto helper into a
|
|
23
|
+
* normalized hex string, throwing a clear error when the SDK is not
|
|
24
|
+
* initialized or the operation failed.
|
|
25
|
+
* @param {number[]|Uint8Array|number|null} result
|
|
26
|
+
* @param {string} operation
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
function _hexFromQcsdk(result, operation) {
|
|
30
|
+
if (result === _NOT_INITIALIZED) {
|
|
31
|
+
throw makeError(
|
|
32
|
+
"quantum-coin-js-sdk not initialized; call Initialize() first",
|
|
33
|
+
"NOT_INITIALIZED",
|
|
34
|
+
{ operation },
|
|
35
|
+
);
|
|
123
36
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const out = new Uint8Array(outLen);
|
|
127
|
-
let outOff = 0;
|
|
128
|
-
let lane = 0;
|
|
129
|
-
while (outOff < outLen) {
|
|
130
|
-
const tmp = new Uint8Array(8);
|
|
131
|
-
_writeU64LE(tmp, 0, state[lane]);
|
|
132
|
-
const take = Math.min(8, outLen - outOff);
|
|
133
|
-
out.set(tmp.slice(0, take), outOff);
|
|
134
|
-
outOff += take;
|
|
135
|
-
lane++;
|
|
37
|
+
if (result == null || typeof result === "number") {
|
|
38
|
+
throw makeError(`${operation} failed`, "UNKNOWN_ERROR", { operation });
|
|
136
39
|
}
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function _hash(alg, data) {
|
|
141
|
-
const bytes = arrayify(data);
|
|
142
|
-
return bytesToHex(crypto.createHash(alg).update(Buffer.from(bytes)).digest());
|
|
40
|
+
return bytesToHex(result instanceof Uint8Array ? result : Uint8Array.from(result));
|
|
143
41
|
}
|
|
144
42
|
|
|
145
43
|
/**
|
|
@@ -149,18 +47,7 @@ function _hash(alg, data) {
|
|
|
149
47
|
*/
|
|
150
48
|
function keccak256(data) {
|
|
151
49
|
const bytes = arrayify(data);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// Prefer native keccak if available (varies by Node/OpenSSL build).
|
|
155
|
-
if (hashes.includes("keccak256")) {
|
|
156
|
-
return bytesToHex(crypto.createHash("keccak256").update(Buffer.from(bytes)).digest());
|
|
157
|
-
}
|
|
158
|
-
if (hashes.includes("keccak-256")) {
|
|
159
|
-
return bytesToHex(crypto.createHash("keccak-256").update(Buffer.from(bytes)).digest());
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Fallback: pure JS Keccak-256
|
|
163
|
-
return bytesToHex(_keccak256Bytes(bytes));
|
|
50
|
+
return _hexFromQcsdk(qcsdk.keccak256(bytes), "keccak256");
|
|
164
51
|
}
|
|
165
52
|
|
|
166
53
|
/**
|
|
@@ -169,7 +56,8 @@ function keccak256(data) {
|
|
|
169
56
|
* @returns {string}
|
|
170
57
|
*/
|
|
171
58
|
function sha256(data) {
|
|
172
|
-
|
|
59
|
+
const bytes = arrayify(data);
|
|
60
|
+
return _hexFromQcsdk(qcsdk.sha256(bytes), "sha256");
|
|
173
61
|
}
|
|
174
62
|
|
|
175
63
|
/**
|
|
@@ -178,7 +66,8 @@ function sha256(data) {
|
|
|
178
66
|
* @returns {string}
|
|
179
67
|
*/
|
|
180
68
|
function sha512(data) {
|
|
181
|
-
|
|
69
|
+
const bytes = arrayify(data);
|
|
70
|
+
return _hexFromQcsdk(qcsdk.sha512(bytes), "sha512");
|
|
182
71
|
}
|
|
183
72
|
|
|
184
73
|
/**
|
|
@@ -187,7 +76,8 @@ function sha512(data) {
|
|
|
187
76
|
* @returns {string}
|
|
188
77
|
*/
|
|
189
78
|
function ripemd160(data) {
|
|
190
|
-
|
|
79
|
+
const bytes = arrayify(data);
|
|
80
|
+
return _hexFromQcsdk(qcsdk.ripemd160(bytes), "ripemd160");
|
|
191
81
|
}
|
|
192
82
|
|
|
193
83
|
/**
|
|
@@ -201,16 +91,34 @@ function id(text) {
|
|
|
201
91
|
|
|
202
92
|
/**
|
|
203
93
|
* Generate cryptographically strong random bytes.
|
|
94
|
+
*
|
|
95
|
+
* Uses the platform Web Crypto API (`globalThis.crypto`), which is available in
|
|
96
|
+
* modern browsers and Node.js 20+.
|
|
204
97
|
* @param {number} length
|
|
205
98
|
* @returns {Uint8Array}
|
|
206
99
|
*/
|
|
207
100
|
function randomBytes(length) {
|
|
208
|
-
|
|
101
|
+
const webcrypto = typeof globalThis !== "undefined" ? globalThis.crypto : undefined;
|
|
102
|
+
if (!webcrypto || typeof webcrypto.getRandomValues !== "function") {
|
|
103
|
+
throw makeError(
|
|
104
|
+
"secure random source (globalThis.crypto.getRandomValues) not available in this environment",
|
|
105
|
+
"UNKNOWN_ERROR",
|
|
106
|
+
{ operation: "randomBytes" },
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
const out = new Uint8Array(length);
|
|
110
|
+
// getRandomValues rejects requests larger than 65536 bytes; fill in chunks.
|
|
111
|
+
const MAX_CHUNK = 65536;
|
|
112
|
+
for (let offset = 0; offset < length; offset += MAX_CHUNK) {
|
|
113
|
+
const chunk = out.subarray(offset, Math.min(offset + MAX_CHUNK, length));
|
|
114
|
+
webcrypto.getRandomValues(chunk);
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
209
117
|
}
|
|
210
118
|
|
|
211
119
|
/**
|
|
212
120
|
* Compute HMAC over data.
|
|
213
|
-
* @param {string} algorithm
|
|
121
|
+
* @param {string} algorithm "sha256" or "sha512"
|
|
214
122
|
* @param {string|Uint8Array} key
|
|
215
123
|
* @param {string|Uint8Array} data
|
|
216
124
|
* @returns {string}
|
|
@@ -218,8 +126,7 @@ function randomBytes(length) {
|
|
|
218
126
|
function computeHmac(algorithm, key, data) {
|
|
219
127
|
const k = typeof key === "string" ? utf8ToBytes(key) : arrayify(key);
|
|
220
128
|
const d = typeof data === "string" ? utf8ToBytes(data) : arrayify(data);
|
|
221
|
-
|
|
222
|
-
return bytesToHex(new Uint8Array(h));
|
|
129
|
+
return _hexFromQcsdk(qcsdk.computeHmac(algorithm, k, d), "computeHmac");
|
|
223
130
|
}
|
|
224
131
|
|
|
225
132
|
/**
|
|
@@ -228,59 +135,44 @@ function computeHmac(algorithm, key, data) {
|
|
|
228
135
|
* @param {string|Uint8Array} salt
|
|
229
136
|
* @param {number} iterations
|
|
230
137
|
* @param {number} keylen
|
|
231
|
-
* @param {string=} algorithm
|
|
138
|
+
* @param {string=} algorithm "sha256" (default) or "sha512"
|
|
232
139
|
* @returns {string}
|
|
233
140
|
*/
|
|
234
141
|
function pbkdf2(password, salt, iterations, keylen, algorithm) {
|
|
235
142
|
const p = typeof password === "string" ? utf8ToBytes(password) : arrayify(password);
|
|
236
143
|
const s = typeof salt === "string" ? utf8ToBytes(salt) : arrayify(salt);
|
|
237
144
|
const a = algorithm || "sha256";
|
|
238
|
-
|
|
239
|
-
return bytesToHex(new Uint8Array(out));
|
|
145
|
+
return _hexFromQcsdk(qcsdk.pbkdf2(p, s, iterations, keylen, a), "pbkdf2");
|
|
240
146
|
}
|
|
241
147
|
|
|
242
148
|
/**
|
|
243
|
-
* scrypt (
|
|
149
|
+
* scrypt (sync) helper returning hex string.
|
|
244
150
|
* @param {string|Uint8Array} password
|
|
245
151
|
* @param {string|Uint8Array} salt
|
|
246
152
|
* @param {number} N
|
|
247
153
|
* @param {number} r
|
|
248
154
|
* @param {number} p
|
|
249
155
|
* @param {number} dkLen
|
|
250
|
-
* @returns {
|
|
156
|
+
* @returns {string}
|
|
251
157
|
*/
|
|
252
|
-
function
|
|
158
|
+
function scryptSync(password, salt, N, r, p, dkLen) {
|
|
253
159
|
const pw = typeof password === "string" ? utf8ToBytes(password) : arrayify(password);
|
|
254
160
|
const sa = typeof salt === "string" ? utf8ToBytes(salt) : arrayify(salt);
|
|
255
|
-
return
|
|
256
|
-
crypto.scrypt(
|
|
257
|
-
Buffer.from(pw),
|
|
258
|
-
Buffer.from(sa),
|
|
259
|
-
dkLen,
|
|
260
|
-
{ N, r, p, maxmem: 128 * 1024 * 1024 },
|
|
261
|
-
(err, derived) => {
|
|
262
|
-
if (err) return reject(err);
|
|
263
|
-
resolve(bytesToHex(new Uint8Array(derived)));
|
|
264
|
-
},
|
|
265
|
-
);
|
|
266
|
-
});
|
|
161
|
+
return _hexFromQcsdk(qcsdk.scryptDeriveKey(pw, sa, N, r, p, dkLen), "scrypt");
|
|
267
162
|
}
|
|
268
163
|
|
|
269
164
|
/**
|
|
270
|
-
* scrypt (
|
|
165
|
+
* scrypt (async) helper returning hex string.
|
|
271
166
|
* @param {string|Uint8Array} password
|
|
272
167
|
* @param {string|Uint8Array} salt
|
|
273
168
|
* @param {number} N
|
|
274
169
|
* @param {number} r
|
|
275
170
|
* @param {number} p
|
|
276
171
|
* @param {number} dkLen
|
|
277
|
-
* @returns {string}
|
|
172
|
+
* @returns {Promise<string>}
|
|
278
173
|
*/
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
const sa = typeof salt === "string" ? utf8ToBytes(salt) : arrayify(salt);
|
|
282
|
-
const out = crypto.scryptSync(Buffer.from(pw), Buffer.from(sa), dkLen, { N, r, p, maxmem: 257 * 1024 * 1024 }); //257 instead of 256 for buffer for compat for N=262144, r=8, p=1
|
|
283
|
-
return bytesToHex(new Uint8Array(out));
|
|
174
|
+
function scrypt(password, salt, N, r, p, dkLen) {
|
|
175
|
+
return Promise.resolve().then(() => scryptSync(password, salt, N, r, p, dkLen));
|
|
284
176
|
}
|
|
285
177
|
|
|
286
178
|
module.exports = {
|
|
@@ -295,4 +187,3 @@ module.exports = {
|
|
|
295
187
|
scrypt,
|
|
296
188
|
scryptSync,
|
|
297
189
|
};
|
|
298
|
-
|
package/src/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const _exports: {
|
|
2
|
+
FixedNumber: typeof import("./fixednumber").FixedNumber;
|
|
2
3
|
formatUnits(value: import("./units").BigNumberish, decimals?: number | undefined): string;
|
|
3
4
|
parseUnits(value: string, decimals?: number | undefined): bigint;
|
|
4
5
|
formatEther(value: import("./units").BigNumberish): string;
|
|
@@ -58,6 +59,5 @@ declare const _exports: {
|
|
|
58
59
|
}): string;
|
|
59
60
|
getCreate2Address(from: string, salt: string, initCodeHash: string): string;
|
|
60
61
|
computeAddress(key: string | Uint8Array): string;
|
|
61
|
-
FixedNumber: typeof import("./fixednumber").FixedNumber;
|
|
62
62
|
};
|
|
63
63
|
export = _exports;
|
package/src/utils/rlp.js
CHANGED
|
@@ -11,8 +11,8 @@ const { arrayify, bytesToHex, hexToBytes, isHexString, normalizeHex, utf8ToBytes
|
|
|
11
11
|
function _toBytes(value) {
|
|
12
12
|
if (value == null) return new Uint8Array([]);
|
|
13
13
|
|
|
14
|
+
// Node Buffers are Uint8Array subclasses, so this covers both.
|
|
14
15
|
if (value instanceof Uint8Array) return new Uint8Array(value);
|
|
15
|
-
if (Buffer.isBuffer(value)) return new Uint8Array(value);
|
|
16
16
|
|
|
17
17
|
if (Array.isArray(value)) {
|
|
18
18
|
// List gets handled elsewhere; here we accept array-of-bytes as a BytesLike.
|
package/src/wallet/wallet.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export class SigningKey {
|
|
|
9
9
|
constructor(privateKeyBytes: Uint8Array, publicKeyBytes: Uint8Array);
|
|
10
10
|
privateKeyBytes: Uint8Array<ArrayBuffer>;
|
|
11
11
|
publicKeyBytes: Uint8Array<ArrayBuffer>;
|
|
12
|
+
toJSON(): {};
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* AbstractSigner base (minimal).
|
|
@@ -18,7 +19,7 @@ export class AbstractSigner {
|
|
|
18
19
|
* @param {import("../providers/provider").AbstractProvider|null} provider
|
|
19
20
|
*/
|
|
20
21
|
constructor(provider: import("../providers/provider").AbstractProvider | null);
|
|
21
|
-
provider: import("../providers/provider").AbstractProvider;
|
|
22
|
+
provider: import("../providers/provider").AbstractProvider | null;
|
|
22
23
|
getAddress(): Promise<void>;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
@@ -40,6 +41,9 @@ export class BaseWallet extends AbstractSigner {
|
|
|
40
41
|
address: string;
|
|
41
42
|
readonly publicKey: string;
|
|
42
43
|
readonly seed: string | null;
|
|
44
|
+
toJSON(): {
|
|
45
|
+
address: string;
|
|
46
|
+
};
|
|
43
47
|
getAddress(): Promise<string>;
|
|
44
48
|
/**
|
|
45
49
|
* Sign a transaction using quantum-coin-js-sdk signRawTransaction().
|
|
@@ -47,6 +51,18 @@ export class BaseWallet extends AbstractSigner {
|
|
|
47
51
|
* @returns {Promise<string>}
|
|
48
52
|
*/
|
|
49
53
|
signTransaction(tx: import("../providers/provider").TransactionRequest): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Internal: sign a transaction and return both the raw serialized transaction
|
|
56
|
+
* and the signer-computed transaction hash. The hash is later used to
|
|
57
|
+
* verify that an untrusted RPC node broadcast exactly the transaction we
|
|
58
|
+
* signed rather than substituting a different one.
|
|
59
|
+
* @param {import("../providers/provider").TransactionRequest} tx
|
|
60
|
+
* @returns {Promise<{ raw: string, hash: string|null }>}
|
|
61
|
+
*/
|
|
62
|
+
_signDetailed(tx: import("../providers/provider").TransactionRequest): Promise<{
|
|
63
|
+
raw: string;
|
|
64
|
+
hash: string | null;
|
|
65
|
+
}>;
|
|
50
66
|
/**
|
|
51
67
|
* Signs and sends a transaction.
|
|
52
68
|
* @param {import("../providers/provider").TransactionRequest} tx
|
|
@@ -59,24 +75,21 @@ export class BaseWallet extends AbstractSigner {
|
|
|
59
75
|
*/
|
|
60
76
|
export class Wallet extends BaseWallet {
|
|
61
77
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
* Setting fullSign to true may incur additional gas cost.
|
|
69
|
-
* @param {boolean|null=} fullSign Defaults to false when null or omitted.
|
|
70
|
-
* @returns {number}
|
|
78
|
+
* Encrypts raw seed bytes into a wallet JSON string (version 5 pre-expansion format).
|
|
79
|
+
* The resulting JSON can be opened with `Wallet.fromEncryptedJsonSync()` or
|
|
80
|
+
* Desktop/Mobile/Web/CLI wallet applications.
|
|
81
|
+
* @param {number[]|Uint8Array} seed Raw seed bytes: 64 (keyType 3), 72 (keyType 5), or 96 (legacy)
|
|
82
|
+
* @param {string|Uint8Array} password Passphrase (at least 12 characters)
|
|
83
|
+
* @returns {string}
|
|
71
84
|
*/
|
|
72
|
-
|
|
85
|
+
static encryptSeedSync(seed: number[] | Uint8Array, password: string | Uint8Array): string;
|
|
73
86
|
/**
|
|
74
87
|
* Creates a new random wallet.
|
|
75
88
|
* @param {import("../providers/provider").AbstractProvider=} provider
|
|
76
89
|
* @param {number|null=} keyType Optional key type: null (default=3), 3, or 5
|
|
77
90
|
* @returns {Wallet}
|
|
78
91
|
*/
|
|
79
|
-
static createRandom(provider?: import("../providers/provider").AbstractProvider | undefined, keyType?: number | null): Wallet;
|
|
92
|
+
static createRandom(provider?: import("../providers/provider").AbstractProvider | undefined, keyType?: (number | null) | undefined): Wallet;
|
|
80
93
|
/**
|
|
81
94
|
* Creates a wallet from raw seed bytes.
|
|
82
95
|
* @param {number[]} seed Raw seed bytes: 64 (keyType 3), 72 (keyType 5), or 96 (legacy)
|
|
@@ -143,14 +156,36 @@ export class Wallet extends BaseWallet {
|
|
|
143
156
|
*/
|
|
144
157
|
encryptSync(password: string | Uint8Array): string;
|
|
145
158
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
159
|
+
* Returns the seed phrase (list of words) if this wallet has a seed, else null.
|
|
160
|
+
* Derived from the stored pre-expansion seed via seed-words.getWordListFromSeedArray.
|
|
161
|
+
*
|
|
162
|
+
* Non-null for wallets created via createRandom, fromPhrase, fromSeed, and
|
|
163
|
+
* fromEncryptedJsonSync when the JSON is a version-5 keystore produced by
|
|
164
|
+
* encryptSync on a seed-bearing wallet or by encryptSeedSync.
|
|
165
|
+
* Null for fromKeys and for v3/v4 keystores without preExpansionSeed.
|
|
166
|
+
*
|
|
167
|
+
* @returns {string[]|null}
|
|
152
168
|
*/
|
|
153
|
-
|
|
169
|
+
getPhrase(): string[] | null;
|
|
170
|
+
/**
|
|
171
|
+
* Returns the recommended signing context for this wallet.
|
|
172
|
+
* Setting fullSign to true may incur additional gas cost.
|
|
173
|
+
* @param {boolean|null=} fullSign Defaults to false when null or omitted.
|
|
174
|
+
* @returns {number}
|
|
175
|
+
*/
|
|
176
|
+
getSigningContext(fullSign?: (boolean | null) | undefined): number;
|
|
177
|
+
/**
|
|
178
|
+
* Returns the key type of this wallet, derived from its public key length:
|
|
179
|
+
* 3 (KEY_TYPE_HYBRIDEDMLDSASLHDSA) or 5 (KEY_TYPE_HYBRIDEDMLDSASLHDSA5).
|
|
180
|
+
*
|
|
181
|
+
* The key type drives gas-price selection via `getFeeData`. Note that the
|
|
182
|
+
* underlying quantum-coin-js-sdk gas-price model supports only DynamicFeeTx
|
|
183
|
+
* (dynamic-fee transactions); legacy/other transaction fee types are not supported.
|
|
184
|
+
*
|
|
185
|
+
* @returns {number} 3 or 5.
|
|
186
|
+
* @throws if the public key length is unsupported.
|
|
187
|
+
*/
|
|
188
|
+
getKeyType(): number;
|
|
154
189
|
/**
|
|
155
190
|
* Returns a new wallet connected to a provider.
|
|
156
191
|
* @param {import("../providers/provider").AbstractProvider} provider
|