quantumcoin 7.0.15 → 8.0.1
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 +79 -0
- package/README.md +48 -1
- package/generate-sdk.js +8 -6
- package/package.json +26 -6
- 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 +128 -123
- 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 -18
- package/src/providers/json-rpc-provider.d.ts +1 -0
- package/src/providers/provider.d.ts +233 -222
- package/src/providers/provider.js +1 -1
- package/src/utils/encoding.js +16 -4
- package/src/utils/fixednumber.d.ts +57 -57
- package/src/utils/hashing.d.ts +97 -76
- package/src/utils/hashing.js +95 -177
- package/src/utils/index.d.ts +2 -1
- package/src/utils/rlp.js +1 -1
- package/src/wallet/index.d.ts +1 -0
- package/src/wallet/wallet.d.ts +85 -29
- package/src/wallet/wallet.js +114 -4
- 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 -1689
- 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 -100
- 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 -115
- package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +0 -69
- package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +0 -960
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +0 -34
- 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 -56
- 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 -1047
- package/examples/node_modules/quantum-coin-js-sdk/index.js +0 -3182
- 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/get-gas-price.test.js +0 -59
- 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 -945
- package/test/unit/address-wallet.test.ts +0 -899
- 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 -305
- package/test/unit/providers.test.ts +0 -304
- 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/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,36 @@ export class BaseWallet extends AbstractSigner {
|
|
|
47
51
|
* @returns {Promise<string>}
|
|
48
52
|
*/
|
|
49
53
|
signTransaction(tx: import("../providers/provider").TransactionRequest): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Sign an arbitrary message (EIP-191 personal-message scheme), synchronously.
|
|
56
|
+
* Returns an opaque post-quantum signature blob (0x hex) that embeds the
|
|
57
|
+
* signer's public key. Optional signingContext: when omitted/null the compact
|
|
58
|
+
* context is derived from the key type (0 for keyType 3, 1 for keyType 5);
|
|
59
|
+
* pass 2 for the full-signature scheme on a keyType 3 wallet.
|
|
60
|
+
* @param {string|Uint8Array} message
|
|
61
|
+
* @param {number|null=} signingContext
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
signMessageSync(message: string | Uint8Array, signingContext?: (number | null) | undefined): string;
|
|
65
|
+
/**
|
|
66
|
+
* Sign an arbitrary message (EIP-191). Async wrapper over signMessageSync.
|
|
67
|
+
* @param {string|Uint8Array} message
|
|
68
|
+
* @param {number|null=} signingContext
|
|
69
|
+
* @returns {Promise<string>}
|
|
70
|
+
*/
|
|
71
|
+
signMessage(message: string | Uint8Array, signingContext?: (number | null) | undefined): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Internal: sign a transaction and return both the raw serialized transaction
|
|
74
|
+
* and the signer-computed transaction hash. The hash is later used to
|
|
75
|
+
* verify that an untrusted RPC node broadcast exactly the transaction we
|
|
76
|
+
* signed rather than substituting a different one.
|
|
77
|
+
* @param {import("../providers/provider").TransactionRequest} tx
|
|
78
|
+
* @returns {Promise<{ raw: string, hash: string|null }>}
|
|
79
|
+
*/
|
|
80
|
+
_signDetailed(tx: import("../providers/provider").TransactionRequest): Promise<{
|
|
81
|
+
raw: string;
|
|
82
|
+
hash: string | null;
|
|
83
|
+
}>;
|
|
50
84
|
/**
|
|
51
85
|
* Signs and sends a transaction.
|
|
52
86
|
* @param {import("../providers/provider").TransactionRequest} tx
|
|
@@ -59,34 +93,21 @@ export class BaseWallet extends AbstractSigner {
|
|
|
59
93
|
*/
|
|
60
94
|
export class Wallet extends BaseWallet {
|
|
61
95
|
/**
|
|
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}
|
|
71
|
-
*/
|
|
72
|
-
getSigningContext(fullSign?: boolean | null): number;
|
|
73
|
-
/**
|
|
74
|
-
* Returns the key type of this wallet, derived from its public key length:
|
|
75
|
-
* 3 (KEY_TYPE_HYBRIDEDMLDSASLHDSA) or 5 (KEY_TYPE_HYBRIDEDMLDSASLHDSA5).
|
|
76
|
-
*
|
|
77
|
-
* The key type drives gas-price selection via `getFeeData`. Note that the
|
|
78
|
-
* underlying quantum-coin-js-sdk gas-price model supports only DynamicFeeTx
|
|
79
|
-
* (dynamic-fee transactions); legacy/other transaction fee types are not supported.
|
|
80
|
-
* @returns {number} 3 or 5.
|
|
96
|
+
* Encrypts raw seed bytes into a wallet JSON string (version 5 pre-expansion format).
|
|
97
|
+
* The resulting JSON can be opened with `Wallet.fromEncryptedJsonSync()` or
|
|
98
|
+
* Desktop/Mobile/Web/CLI wallet applications.
|
|
99
|
+
* @param {number[]|Uint8Array} seed Raw seed bytes: 64 (keyType 3), 72 (keyType 5), or 96 (legacy)
|
|
100
|
+
* @param {string|Uint8Array} password Passphrase (at least 12 characters)
|
|
101
|
+
* @returns {string}
|
|
81
102
|
*/
|
|
82
|
-
|
|
103
|
+
static encryptSeedSync(seed: number[] | Uint8Array, password: string | Uint8Array): string;
|
|
83
104
|
/**
|
|
84
105
|
* Creates a new random wallet.
|
|
85
106
|
* @param {import("../providers/provider").AbstractProvider=} provider
|
|
86
107
|
* @param {number|null=} keyType Optional key type: null (default=3), 3, or 5
|
|
87
108
|
* @returns {Wallet}
|
|
88
109
|
*/
|
|
89
|
-
static createRandom(provider?: import("../providers/provider").AbstractProvider | undefined, keyType?: number | null): Wallet;
|
|
110
|
+
static createRandom(provider?: import("../providers/provider").AbstractProvider | undefined, keyType?: (number | null) | undefined): Wallet;
|
|
90
111
|
/**
|
|
91
112
|
* Creates a wallet from raw seed bytes.
|
|
92
113
|
* @param {number[]} seed Raw seed bytes: 64 (keyType 3), 72 (keyType 5), or 96 (legacy)
|
|
@@ -153,14 +174,36 @@ export class Wallet extends BaseWallet {
|
|
|
153
174
|
*/
|
|
154
175
|
encryptSync(password: string | Uint8Array): string;
|
|
155
176
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
177
|
+
* Returns the seed phrase (list of words) if this wallet has a seed, else null.
|
|
178
|
+
* Derived from the stored pre-expansion seed via seed-words.getWordListFromSeedArray.
|
|
179
|
+
*
|
|
180
|
+
* Non-null for wallets created via createRandom, fromPhrase, fromSeed, and
|
|
181
|
+
* fromEncryptedJsonSync when the JSON is a version-5 keystore produced by
|
|
182
|
+
* encryptSync on a seed-bearing wallet or by encryptSeedSync.
|
|
183
|
+
* Null for fromKeys and for v3/v4 keystores without preExpansionSeed.
|
|
184
|
+
*
|
|
185
|
+
* @returns {string[]|null}
|
|
162
186
|
*/
|
|
163
|
-
|
|
187
|
+
getPhrase(): string[] | null;
|
|
188
|
+
/**
|
|
189
|
+
* Returns the recommended signing context for this wallet.
|
|
190
|
+
* Setting fullSign to true may incur additional gas cost.
|
|
191
|
+
* @param {boolean|null=} fullSign Defaults to false when null or omitted.
|
|
192
|
+
* @returns {number}
|
|
193
|
+
*/
|
|
194
|
+
getSigningContext(fullSign?: (boolean | null) | undefined): number;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the key type of this wallet, derived from its public key length:
|
|
197
|
+
* 3 (KEY_TYPE_HYBRIDEDMLDSASLHDSA) or 5 (KEY_TYPE_HYBRIDEDMLDSASLHDSA5).
|
|
198
|
+
*
|
|
199
|
+
* The key type drives gas-price selection via `getFeeData`. Note that the
|
|
200
|
+
* underlying quantum-coin-js-sdk gas-price model supports only DynamicFeeTx
|
|
201
|
+
* (dynamic-fee transactions); legacy/other transaction fee types are not supported.
|
|
202
|
+
*
|
|
203
|
+
* @returns {number} 3 or 5.
|
|
204
|
+
* @throws if the public key length is unsupported.
|
|
205
|
+
*/
|
|
206
|
+
getKeyType(): number;
|
|
164
207
|
/**
|
|
165
208
|
* Returns a new wallet connected to a provider.
|
|
166
209
|
* @param {import("../providers/provider").AbstractProvider} provider
|
|
@@ -200,3 +243,16 @@ export class VoidSigner extends AbstractSigner {
|
|
|
200
243
|
_address: string;
|
|
201
244
|
getAddress(): Promise<string>;
|
|
202
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Recover the signer's 32-byte address from an EIP-191 message signature.
|
|
248
|
+
*
|
|
249
|
+
* QuantumCoin has no ECDSA ecrecover; the post-quantum signature embeds the
|
|
250
|
+
* public key, which is extracted and verified against the message digest before
|
|
251
|
+
* the address is returned. Throws INVALID_ARGUMENT if the signature is malformed
|
|
252
|
+
* or does not verify. Synchronous, matching ethers' verifyMessage.
|
|
253
|
+
*
|
|
254
|
+
* @param {string|Uint8Array} message The original message (strings are UTF-8 encoded).
|
|
255
|
+
* @param {string|Uint8Array} signature The signature produced by signMessage.
|
|
256
|
+
* @returns {string} 0x-prefixed 32-byte signer address.
|
|
257
|
+
*/
|
|
258
|
+
export function verifyMessage(message: string | Uint8Array, signature: string | Uint8Array): string;
|
package/src/wallet/wallet.js
CHANGED
|
@@ -12,8 +12,9 @@ const qcsdk = require("quantum-coin-js-sdk");
|
|
|
12
12
|
const seedWords = require("seed-words");
|
|
13
13
|
const { JsonRpcProvider } = require("../providers/json-rpc-provider");
|
|
14
14
|
const { assertArgument, assertSecretArgument, makeError } = require("../errors");
|
|
15
|
-
const { arrayify, bytesToHex, hexToBytes, isHexString, normalizeHex } = require("../internal/hex");
|
|
16
|
-
const { getAddress } = require("../utils/address");
|
|
15
|
+
const { arrayify, bytesToHex, bytesToUtf8, hexToBytes, isHexString, normalizeHex, utf8ToBytes } = require("../internal/hex");
|
|
16
|
+
const { computeAddress, getAddress } = require("../utils/address");
|
|
17
|
+
const { hashMessage } = require("../utils/hashing");
|
|
17
18
|
const { WeiPerEther } = require("../constants");
|
|
18
19
|
|
|
19
20
|
function _requireInitialized() {
|
|
@@ -34,6 +35,13 @@ function _bytesToNumberArray(bytes) {
|
|
|
34
35
|
return Array.from(bytes);
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
// Upper bound on the message size accepted by signMessage/signMessageSync. The
|
|
39
|
+
// message is only ever hashed to a 32-byte digest, so there is no protocol need
|
|
40
|
+
// for large inputs; this cap is a guardrail against accidentally signing an
|
|
41
|
+
// unbounded buffer (e.g. a whole file passed in by mistake). 1 MiB is far larger
|
|
42
|
+
// than any realistic personal_sign payload.
|
|
43
|
+
const MAX_MESSAGE_BYTES = 1024 * 1024;
|
|
44
|
+
|
|
37
45
|
/**
|
|
38
46
|
* Verify that a private/public key pair is internally consistent (the public
|
|
39
47
|
* key really corresponds to the private key). Constructing a wallet from a
|
|
@@ -214,6 +222,74 @@ class BaseWallet extends AbstractSigner {
|
|
|
214
222
|
return raw;
|
|
215
223
|
}
|
|
216
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Sign an arbitrary message using QuantumCoin's EIP-191 personal-message
|
|
227
|
+
* scheme, synchronously.
|
|
228
|
+
*
|
|
229
|
+
* The message is hashed with {@link hashMessage} (the same
|
|
230
|
+
* `keccak256("\x19Ethereum Signed Message:\n" + len + message)` digest used by
|
|
231
|
+
* `personal_sign` in quantum-coin-go), producing a 32-byte digest that is then
|
|
232
|
+
* signed with the wallet's post-quantum key.
|
|
233
|
+
*
|
|
234
|
+
* Unlike Ethereum's 65-byte `(r, s, v)` signature, the returned value is an
|
|
235
|
+
* opaque, scheme-dependent multi-kilobyte blob whose first byte is the scheme
|
|
236
|
+
* id and which EMBEDS the signer's public key. This is what allows
|
|
237
|
+
* {@link verifyMessage} to recover the signer address without an ecrecover
|
|
238
|
+
* primitive.
|
|
239
|
+
*
|
|
240
|
+
* @param {string|Uint8Array} message The message to sign (strings are UTF-8 encoded).
|
|
241
|
+
* Must be at most {@link MAX_MESSAGE_BYTES} (1 MiB) once UTF-8 encoded.
|
|
242
|
+
* @param {number|null=} signingContext Optional signing context. When omitted or
|
|
243
|
+
* null, `quantum-coin-js-sdk` derives the compact context from the key type
|
|
244
|
+
* (0 for keyType 3, 1 for keyType 5); pass 2 to request the full-signature
|
|
245
|
+
* scheme for a keyType 3 wallet.
|
|
246
|
+
* @returns {string} 0x-prefixed signature blob (public key embedded).
|
|
247
|
+
* @throws {TypeError} INVALID_ARGUMENT if the message exceeds the size limit.
|
|
248
|
+
*/
|
|
249
|
+
signMessageSync(message, signingContext) {
|
|
250
|
+
_requireInitialized();
|
|
251
|
+
const msgBytes = typeof message === "string" ? utf8ToBytes(message) : arrayify(message);
|
|
252
|
+
assertArgument(
|
|
253
|
+
msgBytes.length <= MAX_MESSAGE_BYTES,
|
|
254
|
+
`message too long (max ${MAX_MESSAGE_BYTES} bytes)`,
|
|
255
|
+
"message",
|
|
256
|
+
msgBytes.length,
|
|
257
|
+
);
|
|
258
|
+
const digestArr = _bytesToNumberArray(hexToBytes(hashMessage(msgBytes)));
|
|
259
|
+
const privArr = _bytesToNumberArray(this.signingKey.privateKeyBytes);
|
|
260
|
+
const pubArr = _bytesToNumberArray(this.signingKey.publicKeyBytes);
|
|
261
|
+
const ctx = signingContext == null ? null : signingContext;
|
|
262
|
+
const res = qcsdk.sign(privArr, digestArr, ctx);
|
|
263
|
+
if (!res || typeof res !== "object" || res.resultCode !== 0 || res.signature == null) {
|
|
264
|
+
throw makeError("signMessage failed", "UNKNOWN_ERROR", {
|
|
265
|
+
resultCode: res && typeof res === "object" ? res.resultCode : null,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
// qcsdk.sign returns the signature-only bytes. Combine the public key into
|
|
269
|
+
// the blob (sig + pubKey) so the result is self-describing and verifyMessage
|
|
270
|
+
// can recover the signer without a separately supplied public key.
|
|
271
|
+
const sigArr = Array.from(res.signature);
|
|
272
|
+
const combined = qcsdk.combinePublicKeySignature(pubArr, sigArr);
|
|
273
|
+
if (typeof combined !== "string") {
|
|
274
|
+
throw makeError("signMessage failed to combine public key with signature", "UNKNOWN_ERROR", {});
|
|
275
|
+
}
|
|
276
|
+
return normalizeHex(combined);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Sign an arbitrary message (EIP-191). Async wrapper over
|
|
281
|
+
* {@link BaseWallet#signMessageSync} that honors the ethers `Signer` interface
|
|
282
|
+
* contract (`Signer.signMessage` is async); the underlying PQC signing is
|
|
283
|
+
* synchronous.
|
|
284
|
+
*
|
|
285
|
+
* @param {string|Uint8Array} message The message to sign (strings are UTF-8 encoded).
|
|
286
|
+
* @param {number|null=} signingContext Optional signing context (see signMessageSync).
|
|
287
|
+
* @returns {Promise<string>} 0x-prefixed signature blob (public key embedded).
|
|
288
|
+
*/
|
|
289
|
+
async signMessage(message, signingContext) {
|
|
290
|
+
return this.signMessageSync(message, signingContext);
|
|
291
|
+
}
|
|
292
|
+
|
|
217
293
|
/**
|
|
218
294
|
* Internal: sign a transaction and return both the raw serialized transaction
|
|
219
295
|
* and the signer-computed transaction hash. The hash is later used to
|
|
@@ -428,7 +504,7 @@ class Wallet extends BaseWallet {
|
|
|
428
504
|
// decision, not a local change.)
|
|
429
505
|
const pw = typeof password === "string"
|
|
430
506
|
? password.normalize("NFC")
|
|
431
|
-
:
|
|
507
|
+
: bytesToUtf8(arrayify(password)).normalize("NFC");
|
|
432
508
|
assertSecretArgument(pw.length >= 12, "password must be at least 12 characters", "password");
|
|
433
509
|
const json = qcsdk.serializeEncryptedWallet(this._qcWallet, pw);
|
|
434
510
|
if (typeof json !== "string") throw makeError("serializeEncryptedWallet failed", "UNKNOWN_ERROR", {});
|
|
@@ -455,7 +531,7 @@ class Wallet extends BaseWallet {
|
|
|
455
531
|
// (cross-app interop); prefer string passphrases.
|
|
456
532
|
const pw = typeof password === "string"
|
|
457
533
|
? password.normalize("NFC")
|
|
458
|
-
:
|
|
534
|
+
: bytesToUtf8(arrayify(password)).normalize("NFC");
|
|
459
535
|
assertSecretArgument(pw.length >= 12, "password must be at least 12 characters", "password");
|
|
460
536
|
const json = qcsdk.serializeSeedAsEncryptedWallet(seedArr, pw);
|
|
461
537
|
if (typeof json !== "string") throw makeError("serializeSeedAsEncryptedWallet failed", "UNKNOWN_ERROR", {});
|
|
@@ -739,6 +815,39 @@ class VoidSigner extends AbstractSigner {
|
|
|
739
815
|
}
|
|
740
816
|
}
|
|
741
817
|
|
|
818
|
+
/**
|
|
819
|
+
* Recover the signer's 32-byte address from an EIP-191 message signature.
|
|
820
|
+
*
|
|
821
|
+
* QuantumCoin has no ECDSA `ecrecover`: signatures are opaque post-quantum blobs
|
|
822
|
+
* that embed the signer's public key. This function re-derives the EIP-191
|
|
823
|
+
* digest with {@link hashMessage}, extracts and cryptographically verifies the
|
|
824
|
+
* embedded public key against that digest via
|
|
825
|
+
* `quantum-coin-js-sdk.publicKeyFromSignature`, and returns the corresponding
|
|
826
|
+
* 32-byte address. If the signature does not verify there is nothing to recover,
|
|
827
|
+
* so the function throws.
|
|
828
|
+
*
|
|
829
|
+
* Synchronous, matching ethers' `verifyMessage` (there is no async variant).
|
|
830
|
+
*
|
|
831
|
+
* @param {string|Uint8Array} message The original message (strings are UTF-8 encoded).
|
|
832
|
+
* @param {string|Uint8Array} signature The signature produced by `signMessage`.
|
|
833
|
+
* @returns {string} 0x-prefixed 32-byte signer address.
|
|
834
|
+
* @throws {TypeError} INVALID_ARGUMENT if the signature is malformed or does not verify.
|
|
835
|
+
*/
|
|
836
|
+
function verifyMessage(message, signature) {
|
|
837
|
+
_requireInitialized();
|
|
838
|
+
const digestHex = hashMessage(message);
|
|
839
|
+
const digestArr = _bytesToNumberArray(hexToBytes(digestHex));
|
|
840
|
+
const sigArr = _bytesToNumberArray(arrayify(signature));
|
|
841
|
+
const pubHex = qcsdk.publicKeyFromSignature(digestArr, sigArr);
|
|
842
|
+
if (typeof pubHex !== "string") {
|
|
843
|
+
throw makeError("verifyMessage failed: signature did not verify", "INVALID_ARGUMENT", {
|
|
844
|
+
argument: "signature",
|
|
845
|
+
value: "[signature]",
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return computeAddress(pubHex);
|
|
849
|
+
}
|
|
850
|
+
|
|
742
851
|
module.exports = {
|
|
743
852
|
SigningKey,
|
|
744
853
|
AbstractSigner,
|
|
@@ -747,5 +856,6 @@ module.exports = {
|
|
|
747
856
|
NonceManager,
|
|
748
857
|
JsonRpcSigner,
|
|
749
858
|
VoidSigner,
|
|
859
|
+
verifyMessage,
|
|
750
860
|
};
|
|
751
861
|
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
name: Publish Package to npmjs
|
|
2
|
-
on:
|
|
3
|
-
workflow_dispatch:
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
permissions:
|
|
9
|
-
contents: read
|
|
10
|
-
id-token: write
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v4
|
|
13
|
-
# Setup .npmrc file to publish to npm
|
|
14
|
-
- uses: actions/setup-node@v4
|
|
15
|
-
with:
|
|
16
|
-
node-version: '20.x'
|
|
17
|
-
registry-url: 'https://registry.npmjs.org'
|
|
18
|
-
- run: npm install
|
|
19
|
-
- run: npm ci
|
|
20
|
-
- run: npm publish --provenance --access public --otp=${{ secrets.OTP }}
|
|
21
|
-
env:
|
|
22
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.gitignore
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
node_modules/**
|
|
2
|
-
output/**
|
|
3
|
-
examples/node_modules/**
|
|
4
|
-
examples/example-generated-sdk-ts/**
|
|
5
|
-
examples/example-generated-sdk-js/**
|
|
6
|
-
test/e2e/generated-sdks/**
|
|
7
|
-
**/*.save
|
|
8
|
-
**/*.swp
|
|
9
|
-
**/*.tgz
|
|
10
|
-
dist/
|
|
11
|
-
.idea
|
|
12
|
-
.vscode
|
|
13
|
-
**/.DS_Store
|
|
14
|
-
|
|
15
|
-
.iterm2-project
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.7.6;
|
|
3
|
-
pragma experimental ABIEncoderV2;
|
|
4
|
-
|
|
5
|
-
/// @title AllSolidityTypes
|
|
6
|
-
/// @notice A Solidity 0.7.6 contract that exercises a wide surface of ABI-encodable types.
|
|
7
|
-
/// @dev
|
|
8
|
-
/// - Includes: bool, all int/uint widths, address/address payable, string, bytes, bytes1..bytes32
|
|
9
|
-
/// - Includes: enums, nested structs, fixed/dynamic arrays, arrays of structs, structs of structs
|
|
10
|
-
/// - Excludes: fixed-point types and function types (by request)
|
|
11
|
-
/// - Note: mappings are not ABI-encodable, so they are shown only as a storage type.
|
|
12
|
-
contract AllSolidityTypes {
|
|
13
|
-
enum Choice { None, One, Two }
|
|
14
|
-
|
|
15
|
-
// Mapping example (not ABI-encodable as param/return)
|
|
16
|
-
mapping(address => uint256) private _balances;
|
|
17
|
-
|
|
18
|
-
// --------------------------------------------------------------------------
|
|
19
|
-
// All integer widths
|
|
20
|
-
// --------------------------------------------------------------------------
|
|
21
|
-
struct AllUints {
|
|
22
|
-
uint8 u8; uint16 u16; uint24 u24; uint32 u32; uint40 u40; uint48 u48; uint56 u56; uint64 u64;
|
|
23
|
-
uint72 u72; uint80 u80; uint88 u88; uint96 u96; uint104 u104; uint112 u112; uint120 u120; uint128 u128;
|
|
24
|
-
uint136 u136; uint144 u144; uint152 u152; uint160 u160; uint168 u168; uint176 u176; uint184 u184; uint192 u192;
|
|
25
|
-
uint200 u200; uint208 u208; uint216 u216; uint224 u224; uint232 u232; uint240 u240; uint248 u248; uint256 u256;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
struct AllInts {
|
|
29
|
-
int8 i8; int16 i16; int24 i24; int32 i32; int40 i40; int48 i48; int56 i56; int64 i64;
|
|
30
|
-
int72 i72; int80 i80; int88 i88; int96 i96; int104 i104; int112 i112; int120 i120; int128 i128;
|
|
31
|
-
int136 i136; int144 i144; int152 i152; int160 i160; int168 i168; int176 i176; int184 i184; int192 i192;
|
|
32
|
-
int200 i200; int208 i208; int216 i216; int224 i224; int232 i232; int240 i240; int248 i248; int256 i256;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// --------------------------------------------------------------------------
|
|
36
|
-
// All fixed-size bytes
|
|
37
|
-
// --------------------------------------------------------------------------
|
|
38
|
-
struct AllFixedBytes {
|
|
39
|
-
bytes1 b1; bytes2 b2; bytes3 b3; bytes4 b4; bytes5 b5; bytes6 b6; bytes7 b7; bytes8 b8;
|
|
40
|
-
bytes9 b9; bytes10 b10; bytes11 b11; bytes12 b12; bytes13 b13; bytes14 b14; bytes15 b15; bytes16 b16;
|
|
41
|
-
bytes17 b17; bytes18 b18; bytes19 b19; bytes20 b20; bytes21 b21; bytes22 b22; bytes23 b23; bytes24 b24;
|
|
42
|
-
bytes25 b25; bytes26 b26; bytes27 b27; bytes28 b28; bytes29 b29; bytes30 b30; bytes31 b31; bytes32 b32;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// --------------------------------------------------------------------------
|
|
46
|
-
// Misc ABI value types (plus arrays)
|
|
47
|
-
// --------------------------------------------------------------------------
|
|
48
|
-
struct AllMisc {
|
|
49
|
-
bool bo;
|
|
50
|
-
address addr;
|
|
51
|
-
address payable payableAddr;
|
|
52
|
-
string str;
|
|
53
|
-
bytes dynBytes;
|
|
54
|
-
Choice choice;
|
|
55
|
-
// Arrays of elementary types
|
|
56
|
-
uint256[] u256s;
|
|
57
|
-
int256[] i256s;
|
|
58
|
-
bytes32[] b32s;
|
|
59
|
-
address[] addrs;
|
|
60
|
-
bool[] bools;
|
|
61
|
-
string[] strings;
|
|
62
|
-
bytes[] bytesArr;
|
|
63
|
-
// Fixed arrays
|
|
64
|
-
uint16[3] fixedU16;
|
|
65
|
-
bytes32[2] fixedB32;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Nested struct that contains structs and arrays of structs
|
|
69
|
-
struct Inner {
|
|
70
|
-
AllUints u;
|
|
71
|
-
AllInts i;
|
|
72
|
-
AllFixedBytes fb;
|
|
73
|
-
AllMisc misc;
|
|
74
|
-
// Array of structs
|
|
75
|
-
AllUints[] uStructs;
|
|
76
|
-
// Struct of structs
|
|
77
|
-
AllFixedBytes[2] fixedFb;
|
|
78
|
-
// Nested arrays
|
|
79
|
-
uint256[][] matrix;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
struct Outer {
|
|
83
|
-
Inner inner;
|
|
84
|
-
Inner[] inners; // dynamic array of structs
|
|
85
|
-
Inner[2] fixedInners; // fixed array of structs
|
|
86
|
-
bytes32[][] b32Matrix;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
AllUints private _storedU;
|
|
90
|
-
AllInts private _storedI;
|
|
91
|
-
AllFixedBytes private _storedFb;
|
|
92
|
-
AllMisc private _storedMisc;
|
|
93
|
-
|
|
94
|
-
/// @notice Constructor with multiple parameters (including structs and arrays).
|
|
95
|
-
constructor(
|
|
96
|
-
bool bo,
|
|
97
|
-
address payable payableAddr,
|
|
98
|
-
string memory str,
|
|
99
|
-
bytes memory dynBytes,
|
|
100
|
-
Choice choice,
|
|
101
|
-
AllUints memory u,
|
|
102
|
-
AllInts memory i,
|
|
103
|
-
AllFixedBytes memory fb,
|
|
104
|
-
AllMisc memory misc,
|
|
105
|
-
uint256[] memory seedU256s,
|
|
106
|
-
bytes32[2] memory seedB32
|
|
107
|
-
) {
|
|
108
|
-
_storedU = u;
|
|
109
|
-
_storedI = i;
|
|
110
|
-
_storedFb = fb;
|
|
111
|
-
|
|
112
|
-
// Store some misc fields (keep it simple; not all array fields are persisted).
|
|
113
|
-
_storedMisc.bo = bo;
|
|
114
|
-
_storedMisc.addr = msg.sender;
|
|
115
|
-
_storedMisc.payableAddr = payableAddr;
|
|
116
|
-
_storedMisc.str = str;
|
|
117
|
-
_storedMisc.dynBytes = dynBytes;
|
|
118
|
-
_storedMisc.choice = choice;
|
|
119
|
-
_storedMisc.u256s = seedU256s;
|
|
120
|
-
_storedMisc.fixedB32 = seedB32;
|
|
121
|
-
|
|
122
|
-
// Touch mapping to demonstrate mapping existence.
|
|
123
|
-
_balances[msg.sender] = seedU256s.length;
|
|
124
|
-
|
|
125
|
-
// Use "misc" parameter to avoid unused warnings and ensure ABIEncoderV2 path is exercised.
|
|
126
|
-
if (misc.fixedU16.length > 0) {
|
|
127
|
-
_balances[misc.addr] = uint256(misc.fixedU16[0]);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// --------------------------------------------------------------------------
|
|
132
|
-
// Echo / roundtrip helpers (ABI-encodable inputs and outputs)
|
|
133
|
-
// --------------------------------------------------------------------------
|
|
134
|
-
|
|
135
|
-
function echoAllUints(AllUints memory x) external pure returns (AllUints memory) { return x; }
|
|
136
|
-
function echoAllInts(AllInts memory x) external pure returns (AllInts memory) { return x; }
|
|
137
|
-
function echoAllFixedBytes(AllFixedBytes memory x) external pure returns (AllFixedBytes memory) { return x; }
|
|
138
|
-
function echoAllMisc(AllMisc memory x) external pure returns (AllMisc memory) { return x; }
|
|
139
|
-
|
|
140
|
-
function echoInner(Inner memory x) external pure returns (Inner memory) { return x; }
|
|
141
|
-
function echoOuter(Outer memory x) external pure returns (Outer memory) { return x; }
|
|
142
|
-
|
|
143
|
-
// Arrays of structs and nested arrays
|
|
144
|
-
function echoAllUintsArray(AllUints[] memory xs) external pure returns (AllUints[] memory) { return xs; }
|
|
145
|
-
function echoInnerArray(Inner[] memory xs) external pure returns (Inner[] memory) { return xs; }
|
|
146
|
-
function echoMatrix(uint256[][] memory m) external pure returns (uint256[][] memory) { return m; }
|
|
147
|
-
|
|
148
|
-
// Multiple input params + multiple return params
|
|
149
|
-
function multiReturn(
|
|
150
|
-
bool bo,
|
|
151
|
-
address addr,
|
|
152
|
-
bytes32 b32,
|
|
153
|
-
string memory s,
|
|
154
|
-
uint256 x,
|
|
155
|
-
AllUints memory u
|
|
156
|
-
)
|
|
157
|
-
external
|
|
158
|
-
pure
|
|
159
|
-
returns (
|
|
160
|
-
bool outBo,
|
|
161
|
-
address outAddr,
|
|
162
|
-
address payable outPayableAddr,
|
|
163
|
-
bytes32 outB32,
|
|
164
|
-
string memory outS,
|
|
165
|
-
uint256 outX,
|
|
166
|
-
AllUints memory outU
|
|
167
|
-
)
|
|
168
|
-
{
|
|
169
|
-
outBo = bo;
|
|
170
|
-
outAddr = addr;
|
|
171
|
-
outPayableAddr = payable(addr);
|
|
172
|
-
outB32 = b32;
|
|
173
|
-
outS = s;
|
|
174
|
-
outX = x;
|
|
175
|
-
outU = u;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Read-only getters to provide outputs without inputs
|
|
179
|
-
function getStoredUints() external view returns (AllUints memory) { return _storedU; }
|
|
180
|
-
function getStoredInts() external view returns (AllInts memory) { return _storedI; }
|
|
181
|
-
function getStoredFixedBytes() external view returns (AllFixedBytes memory) { return _storedFb; }
|
|
182
|
-
function getStoredMisc() external view returns (AllMisc memory) { return _storedMisc; }
|
|
183
|
-
}
|
|
184
|
-
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.7.6;
|
|
3
|
-
|
|
4
|
-
/// @title IERC20
|
|
5
|
-
/// @notice Minimal ERC-20 interface (standard ABI surface).
|
|
6
|
-
interface IERC20 {
|
|
7
|
-
event Transfer(address indexed from, address indexed to, uint256 value);
|
|
8
|
-
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
9
|
-
|
|
10
|
-
function totalSupply() external view returns (uint256);
|
|
11
|
-
function balanceOf(address account) external view returns (uint256);
|
|
12
|
-
function allowance(address owner, address spender) external view returns (uint256);
|
|
13
|
-
|
|
14
|
-
function transfer(address to, uint256 value) external returns (bool);
|
|
15
|
-
function approve(address spender, uint256 value) external returns (bool);
|
|
16
|
-
function transferFrom(address from, address to, uint256 value) external returns (bool);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/// @title SimpleERC20
|
|
20
|
-
/// @notice A small deployable ERC-20 implementation for generator examples.
|
|
21
|
-
contract SimpleERC20 is IERC20 {
|
|
22
|
-
string public name;
|
|
23
|
-
string public symbol;
|
|
24
|
-
uint8 public constant decimals = 18;
|
|
25
|
-
|
|
26
|
-
uint256 public override totalSupply;
|
|
27
|
-
mapping(address => uint256) public override balanceOf;
|
|
28
|
-
mapping(address => mapping(address => uint256)) public override allowance;
|
|
29
|
-
|
|
30
|
-
constructor(string memory _name, string memory _symbol, uint256 _initialSupply) {
|
|
31
|
-
name = _name;
|
|
32
|
-
symbol = _symbol;
|
|
33
|
-
_mint(msg.sender, _initialSupply);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function transfer(address to, uint256 value) external override returns (bool) {
|
|
37
|
-
_transfer(msg.sender, to, value);
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function approve(address spender, uint256 value) external override returns (bool) {
|
|
42
|
-
allowance[msg.sender][spender] = value;
|
|
43
|
-
emit Approval(msg.sender, spender, value);
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function transferFrom(address from, address to, uint256 value) external override returns (bool) {
|
|
48
|
-
uint256 allowed = allowance[from][msg.sender];
|
|
49
|
-
require(allowed >= value, "ALLOWANCE");
|
|
50
|
-
if (allowed != uint256(-1)) {
|
|
51
|
-
allowance[from][msg.sender] = allowed - value;
|
|
52
|
-
emit Approval(from, msg.sender, allowance[from][msg.sender]);
|
|
53
|
-
}
|
|
54
|
-
_transfer(from, to, value);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function _transfer(address from, address to, uint256 value) internal {
|
|
59
|
-
require(to != address(0), "TO_ZERO");
|
|
60
|
-
uint256 bal = balanceOf[from];
|
|
61
|
-
require(bal >= value, "BALANCE");
|
|
62
|
-
balanceOf[from] = bal - value;
|
|
63
|
-
balanceOf[to] += value;
|
|
64
|
-
emit Transfer(from, to, value);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function _mint(address to, uint256 value) internal {
|
|
68
|
-
require(to != address(0), "MINT_TO_ZERO");
|
|
69
|
-
totalSupply += value;
|
|
70
|
-
balanceOf[to] += value;
|
|
71
|
-
emit Transfer(address(0), to, value);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
package/examples/events.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Querying logs/events (read-only).
|
|
3
|
-
* Run with VERBOSE=1 for addresses, block range, and log counts.
|
|
4
|
-
*
|
|
5
|
-
* Note: This is a simple log query example; it does not keep a live subscription
|
|
6
|
-
* running. For long-running subscriptions, build on Provider polling or a future
|
|
7
|
-
* WebSocketProvider implementation.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const { Initialize } = require("../config");
|
|
11
|
-
const { getProvider, Contract } = require("..");
|
|
12
|
-
const { logExample, logAddress } = require("../test/verbose-logger");
|
|
13
|
-
|
|
14
|
-
const RPC = "https://public.rpc.quantumcoinapi.com";
|
|
15
|
-
const CHAIN_ID = 123123;
|
|
16
|
-
const STAKING_CONTRACT = "0x" + "00".repeat(30) + "10" + "00"; // 0x...1000
|
|
17
|
-
|
|
18
|
-
async function eventsExample() {
|
|
19
|
-
logExample("events.js", "starting", { rpc: RPC, chainId: CHAIN_ID });
|
|
20
|
-
await Initialize(null);
|
|
21
|
-
|
|
22
|
-
const provider = getProvider(RPC, CHAIN_ID);
|
|
23
|
-
logAddress("staking_contract", STAKING_CONTRACT);
|
|
24
|
-
const abi = require("../test/fixtures/StakingContract.abi.json");
|
|
25
|
-
const contract = new Contract(STAKING_CONTRACT, abi, provider);
|
|
26
|
-
|
|
27
|
-
// Query recent logs from the last 1000 blocks
|
|
28
|
-
const latest = await provider.getBlockNumber();
|
|
29
|
-
const fromBlock = Math.max(latest - 1000, 0);
|
|
30
|
-
logExample("events.js", "block range", { latest, fromBlock, toBlock: "latest" });
|
|
31
|
-
|
|
32
|
-
const logs = await contract.queryFilter("OnNewDeposit", fromBlock, "latest");
|
|
33
|
-
console.log(`Found ${logs.length} OnNewDeposit logs in last 1000 blocks`);
|
|
34
|
-
logExample("events.js", "queryFilter OnNewDeposit", { logCount: logs.length });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
eventsExample().catch((e) => {
|
|
38
|
-
console.error(e);
|
|
39
|
-
process.exitCode = 1;
|
|
40
|
-
});
|
|
41
|
-
|