quantum-coin-js-sdk 1.0.39 → 2.1.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/.gitignore +2 -1
- package/README.md +109 -768
- package/index.d.ts +76 -545
- package/index.js +319 -1194
- package/package.json +20 -5
- package/wasmBase64.js +7 -16
- package/wasm_exec.js +575 -587
- package/.idea/.name +0 -1
- package/.idea/modules.xml +0 -8
- package/.idea/quantum-coin-js-sdk.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/.vs/ProjectSettings.json +0 -3
- package/.vs/VSWorkspaceState.json +0 -8
- package/.vs/quantum-coin-js-sdk/FileContentIndex/a9d6de82-cfc3-4c22-ac38-06d706ff3673.vsidx +0 -0
- package/.vs/quantum-coin-js-sdk/FileContentIndex/fdc816df-1898-4153-99f2-c69ef4c2283b.vsidx +0 -0
- package/.vs/quantum-coin-js-sdk/config/applicationhost.config +0 -1011
- package/.vs/quantum-coin-js-sdk/v17/.wsuo +0 -0
- package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.backup.json +0 -39
- package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.json +0 -57
- package/.vs/slnx.sqlite +0 -0
- package/example/README.md +0 -14
- package/example/conversion-example.js +0 -19
- package/example/example-create-contract.js +0 -396
- package/example/example-encode-decode-rlp.js +0 -225
- package/example/example-event-pack-unpack.js +0 -391
- package/example/example-misc.js +0 -100
- package/example/example-rpc-send-signRawTransaction.js +0 -318
- package/example/example-rpc-send.js +0 -115
- package/example/example-send.js +0 -69
- package/example/example-token-pack-unpack.js +0 -960
- package/example/example-wallet-version4.js +0 -34
- package/example/example-wallet.js +0 -43
- package/example/example.js +0 -405
- package/example/node_modules/.bin/sdkgen +0 -16
- package/example/node_modules/.bin/sdkgen.cmd +0 -17
- package/example/node_modules/.bin/sdkgen.ps1 +0 -28
- package/example/node_modules/.package-lock.json +0 -47
- package/example/node_modules/quantumcoin/.github/workflows/publish-npmjs.yaml +0 -22
- package/example/node_modules/quantumcoin/LICENSE +0 -21
- package/example/node_modules/quantumcoin/README-SDK.md +0 -828
- package/example/node_modules/quantumcoin/README.md +0 -197
- package/example/node_modules/quantumcoin/config.d.ts +0 -50
- package/example/node_modules/quantumcoin/config.js +0 -123
- package/example/node_modules/quantumcoin/examples/AllSolidityTypes.sol +0 -184
- package/example/node_modules/quantumcoin/examples/SimpleIERC20.sol +0 -74
- package/example/node_modules/quantumcoin/examples/events.js +0 -41
- package/example/node_modules/quantumcoin/examples/events.ts +0 -35
- package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.js +0 -100
- package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.ts +0 -77
- package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.js +0 -100
- package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.ts +0 -77
- package/example/node_modules/quantumcoin/examples/example.js +0 -67
- package/example/node_modules/quantumcoin/examples/example.ts +0 -56
- package/example/node_modules/quantumcoin/examples/offline-signing.js +0 -77
- package/example/node_modules/quantumcoin/examples/offline-signing.ts +0 -65
- package/example/node_modules/quantumcoin/examples/package-lock.json +0 -596
- package/example/node_modules/quantumcoin/examples/package.json +0 -32
- package/example/node_modules/quantumcoin/examples/read-operations.js +0 -32
- package/example/node_modules/quantumcoin/examples/read-operations.ts +0 -31
- package/example/node_modules/quantumcoin/examples/sdk-generator-erc20.inline.json +0 -251
- package/example/node_modules/quantumcoin/examples/solidity-types.ts +0 -43
- package/example/node_modules/quantumcoin/examples/wallet-offline.js +0 -36
- package/example/node_modules/quantumcoin/examples/wallet-offline.ts +0 -26
- package/example/node_modules/quantumcoin/generate-sdk.js +0 -1846
- package/example/node_modules/quantumcoin/index.js +0 -12
- package/example/node_modules/quantumcoin/package.json +0 -95
- package/example/node_modules/quantumcoin/scripts/copy-declarations.js +0 -31
- package/example/node_modules/quantumcoin/scripts/run-all-one-by-one.js +0 -151
- package/example/node_modules/quantumcoin/src/abi/fragments.d.ts +0 -42
- package/example/node_modules/quantumcoin/src/abi/fragments.js +0 -63
- package/example/node_modules/quantumcoin/src/abi/index.d.ts +0 -13
- package/example/node_modules/quantumcoin/src/abi/index.js +0 -9
- package/example/node_modules/quantumcoin/src/abi/interface.d.ts +0 -128
- package/example/node_modules/quantumcoin/src/abi/interface.js +0 -605
- package/example/node_modules/quantumcoin/src/abi/js-abi-coder.d.ts +0 -8
- package/example/node_modules/quantumcoin/src/abi/js-abi-coder.js +0 -538
- package/example/node_modules/quantumcoin/src/constants.d.ts +0 -61
- package/example/node_modules/quantumcoin/src/constants.js +0 -94
- package/example/node_modules/quantumcoin/src/contract/contract-factory.d.ts +0 -28
- package/example/node_modules/quantumcoin/src/contract/contract-factory.js +0 -111
- package/example/node_modules/quantumcoin/src/contract/contract.d.ts +0 -113
- package/example/node_modules/quantumcoin/src/contract/contract.js +0 -408
- package/example/node_modules/quantumcoin/src/contract/index.d.ts +0 -9
- package/example/node_modules/quantumcoin/src/contract/index.js +0 -9
- package/example/node_modules/quantumcoin/src/errors/index.d.ts +0 -92
- package/example/node_modules/quantumcoin/src/errors/index.js +0 -200
- package/example/node_modules/quantumcoin/src/generator/index.d.ts +0 -81
- package/example/node_modules/quantumcoin/src/generator/index.js +0 -1571
- package/example/node_modules/quantumcoin/src/index.d.ts +0 -122
- package/example/node_modules/quantumcoin/src/index.js +0 -41
- package/example/node_modules/quantumcoin/src/internal/hex.d.ts +0 -68
- package/example/node_modules/quantumcoin/src/internal/hex.js +0 -180
- package/example/node_modules/quantumcoin/src/providers/extra-providers.d.ts +0 -139
- package/example/node_modules/quantumcoin/src/providers/extra-providers.js +0 -614
- package/example/node_modules/quantumcoin/src/providers/index.d.ts +0 -17
- package/example/node_modules/quantumcoin/src/providers/index.js +0 -10
- package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.d.ts +0 -12
- package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.js +0 -89
- package/example/node_modules/quantumcoin/src/providers/provider.d.ts +0 -206
- package/example/node_modules/quantumcoin/src/providers/provider.js +0 -524
- package/example/node_modules/quantumcoin/src/types/index.d.ts +0 -214
- package/example/node_modules/quantumcoin/src/types/index.js +0 -9
- package/example/node_modules/quantumcoin/src/utils/address.d.ts +0 -58
- package/example/node_modules/quantumcoin/src/utils/address.js +0 -144
- package/example/node_modules/quantumcoin/src/utils/encoding.d.ts +0 -120
- package/example/node_modules/quantumcoin/src/utils/encoding.js +0 -306
- package/example/node_modules/quantumcoin/src/utils/fixednumber.d.ts +0 -57
- package/example/node_modules/quantumcoin/src/utils/fixednumber.js +0 -366
- package/example/node_modules/quantumcoin/src/utils/hashing.d.ts +0 -76
- package/example/node_modules/quantumcoin/src/utils/hashing.js +0 -298
- package/example/node_modules/quantumcoin/src/utils/index.d.ts +0 -63
- package/example/node_modules/quantumcoin/src/utils/index.js +0 -14
- package/example/node_modules/quantumcoin/src/utils/result.d.ts +0 -57
- package/example/node_modules/quantumcoin/src/utils/result.js +0 -128
- package/example/node_modules/quantumcoin/src/utils/rlp.d.ts +0 -12
- package/example/node_modules/quantumcoin/src/utils/rlp.js +0 -215
- package/example/node_modules/quantumcoin/src/utils/units.d.ts +0 -29
- package/example/node_modules/quantumcoin/src/utils/units.js +0 -107
- package/example/node_modules/quantumcoin/src/wallet/index.d.ts +0 -10
- package/example/node_modules/quantumcoin/src/wallet/index.js +0 -8
- package/example/node_modules/quantumcoin/src/wallet/wallet.d.ts +0 -192
- package/example/node_modules/quantumcoin/src/wallet/wallet.js +0 -713
- package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.js +0 -207
- package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
- package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.fixtures.js +0 -231
- package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
- package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
- package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.js +0 -165
- package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.ts +0 -160
- package/example/node_modules/quantumcoin/test/e2e/helpers.js +0 -59
- package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
- package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
- package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
- package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
- package/example/node_modules/quantumcoin/test/e2e/transactional.test.js +0 -245
- package/example/node_modules/quantumcoin/test/e2e/transactional.test.ts +0 -208
- package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.js +0 -407
- package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.ts +0 -337
- package/example/node_modules/quantumcoin/test/fixtures/ConstructorParam.sol +0 -23
- package/example/node_modules/quantumcoin/test/fixtures/MultiContracts.sol +0 -37
- package/example/node_modules/quantumcoin/test/fixtures/SimpleStorage.sol +0 -18
- package/example/node_modules/quantumcoin/test/fixtures/StakingContract.abi.json +0 -1
- package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.js +0 -49
- package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.ts +0 -44
- package/example/node_modules/quantumcoin/test/integration/provider.test.js +0 -88
- package/example/node_modules/quantumcoin/test/integration/provider.test.ts +0 -85
- package/example/node_modules/quantumcoin/test/integration/ws-provider.test.js +0 -41
- package/example/node_modules/quantumcoin/test/integration/ws-provider.test.ts +0 -38
- package/example/node_modules/quantumcoin/test/security/abi-decoder-bounds.test.js +0 -122
- package/example/node_modules/quantumcoin/test/security/contract-overrides.test.js +0 -112
- package/example/node_modules/quantumcoin/test/security/generator-injection.test.js +0 -195
- package/example/node_modules/quantumcoin/test/security/malformed-input.test.js +0 -330
- package/example/node_modules/quantumcoin/test/security/malformed-input.test.ts +0 -35
- package/example/node_modules/quantumcoin/test/security/rpc-numeric-bounds.test.js +0 -81
- package/example/node_modules/quantumcoin/test/security/rpc-trust.test.js +0 -202
- package/example/node_modules/quantumcoin/test/unit/_encrypted-output.txt +0 -6
- package/example/node_modules/quantumcoin/test/unit/_log-encrypted-jsons.js +0 -45
- package/example/node_modules/quantumcoin/test/unit/_write-keystore-fixture.js +0 -16
- package/example/node_modules/quantumcoin/test/unit/abi-interface.test.js +0 -110
- package/example/node_modules/quantumcoin/test/unit/abi-interface.test.ts +0 -109
- package/example/node_modules/quantumcoin/test/unit/address-wallet.test.js +0 -923
- package/example/node_modules/quantumcoin/test/unit/address-wallet.test.ts +0 -877
- package/example/node_modules/quantumcoin/test/unit/browser-provider.test.js +0 -85
- package/example/node_modules/quantumcoin/test/unit/browser-provider.test.ts +0 -79
- package/example/node_modules/quantumcoin/test/unit/contract.test.js +0 -85
- package/example/node_modules/quantumcoin/test/unit/contract.test.ts +0 -83
- package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.js +0 -127
- package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.ts +0 -91
- package/example/node_modules/quantumcoin/test/unit/errors.test.js +0 -77
- package/example/node_modules/quantumcoin/test/unit/errors.test.ts +0 -76
- package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.js +0 -55
- package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.ts +0 -54
- package/example/node_modules/quantumcoin/test/unit/fixednumber.test.js +0 -656
- package/example/node_modules/quantumcoin/test/unit/fixednumber.test.ts +0 -660
- package/example/node_modules/quantumcoin/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
- package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.js +0 -42
- package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.ts +0 -41
- package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.js +0 -113
- package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
- package/example/node_modules/quantumcoin/test/unit/generator.test.js +0 -149
- package/example/node_modules/quantumcoin/test/unit/generator.test.ts +0 -148
- package/example/node_modules/quantumcoin/test/unit/hashing.test.js +0 -64
- package/example/node_modules/quantumcoin/test/unit/hashing.test.ts +0 -63
- package/example/node_modules/quantumcoin/test/unit/init.test.js +0 -39
- package/example/node_modules/quantumcoin/test/unit/init.test.ts +0 -38
- package/example/node_modules/quantumcoin/test/unit/interface.test.js +0 -56
- package/example/node_modules/quantumcoin/test/unit/interface.test.ts +0 -54
- package/example/node_modules/quantumcoin/test/unit/internal-hex.test.js +0 -81
- package/example/node_modules/quantumcoin/test/unit/internal-hex.test.ts +0 -80
- package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.js +0 -98
- package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.ts +0 -64
- package/example/node_modules/quantumcoin/test/unit/providers.test.js +0 -252
- package/example/node_modules/quantumcoin/test/unit/providers.test.ts +0 -251
- package/example/node_modules/quantumcoin/test/unit/result.test.js +0 -80
- package/example/node_modules/quantumcoin/test/unit/result.test.ts +0 -79
- package/example/node_modules/quantumcoin/test/unit/solidity-types.test.js +0 -49
- package/example/node_modules/quantumcoin/test/unit/solidity-types.test.ts +0 -39
- package/example/node_modules/quantumcoin/test/unit/utils.test.js +0 -57
- package/example/node_modules/quantumcoin/test/unit/utils.test.ts +0 -56
- package/example/node_modules/quantumcoin/test/verbose-logger.js +0 -74
- package/example/node_modules/quantumcoin/tsconfig.build.json +0 -14
- package/example/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
- package/example/node_modules/seed-words/BUILD.md +0 -7
- package/example/node_modules/seed-words/LICENSE +0 -121
- package/example/node_modules/seed-words/README.md +0 -67
- package/example/node_modules/seed-words/dist/seedwords.d.ts +0 -39
- package/example/node_modules/seed-words/package.json +0 -27
- package/example/node_modules/seed-words/seedwords.js +0 -315
- package/example/node_modules/seed-words/seedwords.txt +0 -65536
- package/example/node_modules/seed-words/tsconfig.json +0 -21
- package/example/package-lock.json +0 -56
- package/example/package.json +0 -15
- package/tests/encrypted-32.json +0 -1
- package/tests/encrypted-36.json +0 -1
- package/tests/encrypted-48.json +0 -1
- package/tests/generate-verify-vectors.js +0 -91
- package/tests/get-gas-price.test.js +0 -59
- package/tests/non-transactional.preinit.test.js +0 -41
- package/tests/non-transactional.test.js +0 -1389
- package/tests/scrypt.test.js +0 -128
- package/tests/sign-raw-keytype5-context-null.test.js +0 -107
- package/tests/sign-raw-transaction.test.js +0 -196
- package/tests/sign-verify.test.js +0 -311
- package/tests/transactional.relay.test.js +0 -131
- package/tests/transactional.rpc.test.js +0 -103
- package/tests/verify-vectors.json +0 -95035
package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory e2e
|
|
3
|
-
* @blockchainRequired write
|
|
4
|
-
* @transactional true
|
|
5
|
-
* Generates typed SDK packages (TS and JS) for AllSolidityTypes.sol, then injects additional tests.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
import fs from "node:fs";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import { spawnSync } from "node:child_process";
|
|
13
|
-
|
|
14
|
-
import { getRpcUrl, getChainId, logE2eConfig } from "./helpers";
|
|
15
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
16
|
-
|
|
17
|
-
const TEST_WALLET_JSON =
|
|
18
|
-
"{\"address\":\"1a846abe71c8b989e8337c55d608be81c28ab3b2e40c83eaa2a68d516049aec6\",\"crypto\":{\"cipher\":\"aes-256-ctr\",\"ciphertext\":\"ab7e620dd66cb55ac201b9c6796de92bbb06f3681b5932eabe099871f1f7d79acabe30921a39ad13bfe74f42c515734882b6723760142aa3e26e011df514a534ae47bd15d86badd9c6f17c48d4c892711d54d441ee3a0ee0e5b060f816e79c7badd13ff4c235934b1986774223ecf6e8761388969bb239c759b54c8c70e6a2e27c93a4b70129c8159f461d271ae8f3573414c78b88e4d0abfa6365ed45456636d4ed971c7a0c6b84e6f0c2621e819268b135e2bcc169a54d1847b39e6ba2ae8ec969b69f330b7db9e785ed02204d5a1185915ae5338b0f40ef2a7f4d5aaf7563d502135e57f4eb89d5ec1efa5c77e374969d6cd85be625a2ed1225d68ecdd84067bfc69adb83ecd5c6050472eca28a5a646fcdd28077165c629975bec8a79fe1457cb53389b788b25e1f8eff8b2ca326d7dfcaba3f8839225a08057c018a458891fd2caa0d2b27632cffd80f592147ccec9a10dc8a08a48fb55047bff5cf85cda39eb089096bef63842fc3686412f298a54a9e4b0bf4ad36907ba373cbd6d32e7ac494af371da5aa9d38a3463220865114c4adc5e4ac258ba9c6af9fa2ddfd1aec2e16887e4b3977c69561df8599ac9d411c9dd2a4d57f92ea4e5c02aae3f49fb3bc83e16673e6c2dbe96bb181c8dfd0f9757ade2e4ff27215a836058c5ffeab042f6f97c7c02339f76a6284680e01b4bb733690eb3347fbfcc26614b8bf755f9dfce3fea9d4e4d15b164983201732c2e87593a86bca6da6972e128490338f76ae68135888070f4e59e90db54d23834769bdbda9769213faf5357f9167a224523975a946367b68f0cec98658575609f58bfd329e420a921c06713326e4cb20a0df1d77f37e78a320a637a96c604ca3fa89e24beb42313751b8f09b14f9c14c77e4fd13fc6382505d27c771bca0d821ec7c3765acffa99d83c50140a56b0b28101c762bd682fe55cb6f23cbeb3f421d7b36021010e45ac27160dd7ead99c864a1b550c7edb1246950fe32dcc049799f9085287f0a747a6ef7a023df46a23a22f3e833bbf8d404f84344870492658256ee1dfc40fda33bb8d48fc72d4520ba9fc820c9123104a045206809037709f2a5f6723fa77d6bac5a573823d4ec3a7f1cb786a52ee2697e622e5d75962fa554d1024a6c355e21f33a63b2b72e6c4742a8b1c373aa532b40518c38c90b5373c2eb8c9d7be2a9e16047a3ee09dc9a6849deac5183ace6cfe91a9bef2ffc0a7df6ccebfd4c858c84b0e0355650d7466971e66f1e3883013e5ad1be33199b1d110b79070ac1b745ccb14cf63a08f8cca3a21c9525e626ff5f0c34746e10750fb742ad51f11f2acae3676c2111853d7250d01b77821a6ba9e04400ba2c543ca9f2d701ae6f47bfad14ffe3039ee9e71f7b2401359ade9938750ddb9c5a8b018a7929ed8d0e717ff1861446ce17535e9b17c187711190aae3388bd9490837a636c25ed4d42d7079ad1a51e13292c683d5d012abcf46965c534b83ab53f2c1f0cf5830ef7582e06863a33c19a70511df632885d63245965047ea96b56f1af5b3b94a54999f784fb9574fdfcd7c1230e07a2aaa04acd3097b2b9f8ddba05ae9734491deb5c1a513c76ed276cb78bbf4839dae3156d76af444a5805129d5df791167a9c8576a1d7f760b2d2797c4658669608706fbd0ace1be2346f74862dfc9ef518e55632e43c043186e5d070deb34d12fb9e5aba84e5cb50213dc88efd39cc35bf42455aa82d5e3b707b3140be3b8623b34fdd81d08615c188ae8438a13881fdf6bf32f2cb9ff5fa625561040c6b71d4b8eccc90bc3b99650d28dd1ee63773e49664e3d48c484996b290943635a6f2eb1ce9796d3fa144a3f00ef82faaa32d6a413668f7b521517cb68b2b017fcf56c79326fa5e4060e643631ca3f0a0dc0ed718798b6f46b130d437c33f64039e887324b6f5e604b1669d613923794edbf04b1b3caea54793b52b44b170173a4f25c7ecef3b71e2aad76e556b1cb9f1d637ec52ececfa950dd31dbb6a60828a3ad34c1beffe09eb4785786d63bad10a0b0f66ea88c57380f38ea85f018dbd7f538cf1ee7624095b9a01ec5edd528f281168af020609e651ff316aa1320a710134ddfca600cc72174dcdb846d2aa29916488aa1b537b66da92e61af526debef4eb38c984569eaf549ff2129449269b492d030cd74d885f6f5785881cc4804b4a8a09ba4ff7aefe9074ac7d0c4f05d51fe4cc0ff7388a772092b9d02d70e5433a5cf3e02f46a6bd6b818d59a07ce3b9fbbf8b5faba74563bcc5240930c2d406c9aaee3e3ce0429bf68ac2b0a57adb09414cff50817d2a48fb9fa624ab863cb0c31a8b8dc5eaf6fa68cc1d7c6c685c5a33edd5c8933b9e8ab628ee428d0743699b2ff17f25586c7ce959280bb0b8c5342251f0a30b53dbc7bf1ee426ac9619c3560f811f2268ee37f189794e2e4b3db3a2fb2e34b649e504fb467438abfd1082619cc4a0b30d66beb831077812e418d2e2148db10cf4d4a29101ca52ec445b8d83519dd7de85a98e0beae9ee537096d3f1a55a7a80cdfa93d25f07c9f98e8af18cde19ec1f99c5dd4588b717a5039ddb7f177717caf0d0fd45420a70dbd6d3146890d9e450d5224146db4c33b779e3c3a04b976c052bad042ac57dd38be45407808c0fb0d7e2a8819e6cd53c6739e6612996ddaa6f066552590aa0343bc1e62b298ff2514a0cef8be21956c2e942816f7a3a3a0935eaf9b37251409ce444c986c3817e82835555fe18239f3ae33469d7965c2bde9991fde556bd07af01df52bbde0c35bb4ef48e3b5d0db53f8ca4ed35b83f760f0a1bc4ed9f86e85d6039a17df373c85402ef956f01db00eb39c4b74bd0660d29ee746714d9780d738e05c6cca414ce3d7b40dda8036a9eea9ab1388805f913eb19bdd3f09d9e161eaa50231bd9caba61971f194332dd28c696a60458c1c6c2cc5da8b1192611c7c553e9e12fe48ce46bbb891be8bb118721c86222e671ddd1da8f0ccb2b68e02f2014b4925e904e88369aaf7466bd7033a60c265d45955944916ecbdb84bf1b522b01b0149c632e04c568a7eb627c5bb90ece052ebcf79166c28b30d23fe52da0a5ab5dea83ca479a3e3b7a9cfbbfea04dbe6137c19d067317c2ec427a8c75a6b06bec6dcd5d5c0edc9aa80b9003b8e17c088b2f3db327d3e42630d82d20120240c3ba56232280787da4aabbf5bc95a864029f00710e195f2a76460a0317d10b552fe1bea097e41d49756c680a41d6ac186e62169b6b6cd7776ea84618b5b752328a5bacaa10aa122ff9b2698b43efe73d852a899db644863c8c9bc8068ea86ea843fd6fe36272b91cdc5d5317083ef3fd1e5462a0b0d0604dc57b3bbfceb0fca4cd349625dd7b25166af30efe5ee6a0af953a74d65f4736c59918ee55a3b0d9d9d42e04c7f8a77e479109f740e20c464d5d7e3d16805f47b61f403ff7f408c9e850d9baacd8067e544536a4953480b0f9ee9cd45f41ebd67b51f78788a6470cb1e5ca72ca346ce8a50d0ca0c921d5576a4455a1afb6d0bc688004712ee122cacdb29c51e84893324c27fa4a3f1917edf5352272b4c97579a6152e4b77663d0ab532915f2eeb6a862de8b696452321b660c3f2449673d086e95a7af28845a5259b763e0fcd09f72acf7b6c811066263060e5aa5b24658e880a01fd56bda4dad5ab604e129290f7d5489728f2a40968c6168b21cebbbcd11727cc9e9160c4e92e04387d3b0d62aab06a61f26daedd9fed11816ef2180172a47f47184ac4032b88758c98a2e0fb200f70e93ba695f5ebb7a1029610ad360d3b7fa1b4640b9dc674d3625eef786da93dff19bc7991b5d6193a3896664763fde479b5dfc04812111a80782854f2cf68ca7d82765cc9eb40fba4b44640710ed6e653abf9f07b466333f4fd22784d53cf40e17120f42caa841eaa24056b237827b0f47f7257c103c35027e9f503e5acfd023e7357b600d3084d361d5ee65ba319b45c153212a54e6fed85af7e43e0a926ebcbc2edf8de7e2ec9528f00bec262ad04d5c9dafccaea06a24748d28bf1799bae0e895543084539c50b5aaa4fb50d7431d6f0c8cee2a54aaf7ee7919b55bf40adb688632e5dbe273cea09e97b19c3d8e1f4de000deb66fa1942ad03a62d3252f51992244366c156000b49c297167a6cbdedea7ebae139d295f0ad298e0864249b905b7eb812886ec70ecdb286702274b5b8574149bf3866f9e46b997ff5ed622b169a0eb071347f18d530db1663906a28f4544ee4e004ab87b65476af30ede118052ff052b8dc986ca2c93dd5d4943266a579c7698ea014f688b3e8063a107feb162d392e2177b01bff77fb5abe5feebd0607158049a5a093325b7c9ee6b4dfa7a9f65c7c2fb628920d3603a1c2dad979eaa047cd661a268af1078c9788d720e64e4ce9d12e68de1e417ef2f293323681e1071f9220e1ee43d2e29d111b870ce3439f5100ecd4551ab65ee74aa1667e564957e9bc0ae1ea193980da2a0ec2698073388c85bec25ef447f0d5e93a5203fa44dff268e5cb799ed3b66e63d5e07b487e7534f24934c73a62a243e0151843a0fd3807711a101eaa7fc71f0ba68aebb9534d57cba41b094eebfb4c31cca8eddfa426f676aa347be8a7023a4e91ddb154b35cd4d5f7dbc2e5db491de99f33fc2cff2d57029ac950e1ccd681980af6a4e8969dfe39b3c7bfcbcf8fac92f1e6ec9fe572bfa6a7d65860eab2ed10ac01a71290b52e3148e84b7376a8605cd2bb0e8681ffc54691ce087685e33921bd44d36c78291713dce17569570f62137e6904f0d68cf53aa2ec395c389a75141f08114fb293ea63950e4ffee55ec6fc83cf44876b8e7f25cdd393ff87b9eda6eb746085b61a6900de191f0ce2cb388d61ece52e78bc47368194e8e00277e0d1631e6b9d4626ef76f8522582ccd5a40be3febc699bb510acc6271d55ff0f4cf3bb7669855a72efd9ca3e1056a2fe592a5bc877cce2b1f63b58383971da87873d2d1349cf5881242cdce4e7e2c5c514755746a0e0a7c2a6d9701cde005ae3420beb17c379a3516662253554f51f0423bb1844b0b90c54ed8177ceb0e1036a6609d836e748ca06c40ca64befadc6443ec286a0ce464678e8d11eb455f7bb305acebf6cb1f50e394a9bfeb752df1687831bac9cdd811f4f112ef6658d0f8799a866374ff96c5e2b79f30e7a74f8a2bc9ed1f88f01f30e30cb78ffb2bff10108f35e910ee3be4463e9e6f0ed910e8d598326e71dfa2277ffe5579d7fe9b6018bfe295b25219eae07b3b0270665c3fa00c3e0d180812b5cd62925585de84a7c48a9a86dba96544a251654d1966e082432dc85b6149cf21e91a46020ec32b66d28ba3b6a90c0617bc6fdd55aea819af2bcf84864ad60c28fe3c9f8339d0aee68b39d97f63b6e082835d86119cf9b9fdc8b827c847ce40aa10e1577a710132316845e825345e95bdf94d0c66ec65a6c4319fce4792313663b5f7a651a6710783e6ab71608ac6cbbf3af6911adf596ccf7c172b9bd5bceb6db379967b32b143bdd11d2ee12ddf64ecef6391e0f8570e6cddd3db95204919362b89b739fa94e7c1bfde799fd5e22aa25ca6ca42e30c08e23aae2385d99ebab441072a880dcefdab74a4c9bd39d363f6d1933d59400fca161d432aa00f23b1b1c19a154be8989699d549b66d44e39896f5523443bc6ddf4a65e91f1f3fb7b52318869a05856a4fc92f3694c81ed833c972fb918f7e5\",\"cipherparams\":{\"iv\":\"8c46d6162cd4c765759aedcbce2a5874\"},\"kdf\":\"scrypt\",\"kdfparams\":{\"dklen\":32,\"n\":262144,\"p\":1,\"r\":8,\"salt\":\"82fb6cdc6917609135277badacf15baa31899d08b71a5a0fa33167167c161537\"},\"mac\":\"9187b17f7eca48e6b8c586b0cd790dbe0feb876ac8385f93faa7d5e22a3c8fc7\"},\"id\":\"92caf6ee-2d43-48c0-859e-ffa1e0e23312\",\"version\":3}";
|
|
19
|
-
|
|
20
|
-
function getNpmCmd(): string {
|
|
21
|
-
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function run(cmd: string, args: string[], cwd: string, env: NodeJS.ProcessEnv): { status: number | null; stdout: string; stderr: string } {
|
|
25
|
-
const res = spawnSync(cmd, args, {
|
|
26
|
-
cwd,
|
|
27
|
-
env,
|
|
28
|
-
encoding: "utf8",
|
|
29
|
-
stdio: "pipe",
|
|
30
|
-
shell: false,
|
|
31
|
-
windowsHide: true,
|
|
32
|
-
});
|
|
33
|
-
if (res.error) throw res.error;
|
|
34
|
-
return res;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function _quoteIfNeeded(s: unknown): string {
|
|
38
|
-
if (typeof s !== "string") return String(s);
|
|
39
|
-
return /[ \t"]/g.test(s) ? `"${s.replace(/"/g, '\\"')}"` : s;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function runNpm(args: string[], cwd: string, env: NodeJS.ProcessEnv) {
|
|
43
|
-
if (process.platform === "win32") {
|
|
44
|
-
const cmd = `${getNpmCmd()} ${args.map(_quoteIfNeeded).join(" ")}`;
|
|
45
|
-
return run("cmd.exe", ["/d", "/s", "/c", cmd], cwd, env);
|
|
46
|
-
}
|
|
47
|
-
return run(getNpmCmd(), args, cwd, env);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function writeExtraTest(pkgRoot: string): void {
|
|
51
|
-
const testDir = path.join(pkgRoot, "test", "e2e");
|
|
52
|
-
fs.mkdirSync(testDir, { recursive: true });
|
|
53
|
-
|
|
54
|
-
const content = `/**
|
|
55
|
-
* @testCategory e2e
|
|
56
|
-
* @blockchainRequired write
|
|
57
|
-
* @transactional true
|
|
58
|
-
* @description Extra exhaustive checks for AllSolidityTypes
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
const { describe, it } = require("node:test");
|
|
62
|
-
const assert = require("node:assert/strict");
|
|
63
|
-
|
|
64
|
-
const { Initialize } = require("quantumcoin/config");
|
|
65
|
-
const { getProvider, Wallet } = require("quantumcoin");
|
|
66
|
-
|
|
67
|
-
const { AllSolidityTypes__factory } = require("../..");
|
|
68
|
-
|
|
69
|
-
const TEST_WALLET_ENCRYPTED_JSON =
|
|
70
|
-
${JSON.stringify(TEST_WALLET_JSON)};
|
|
71
|
-
const TEST_WALLET_PASSPHRASE = "QuantumCoinExample123!";
|
|
72
|
-
|
|
73
|
-
function normalizeHex(s) {
|
|
74
|
-
const t = String(s || "").trim();
|
|
75
|
-
const x = t.startsWith("0x") ? t : "0x" + t;
|
|
76
|
-
return "0x" + x.slice(2).toLowerCase();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function canon(v) {
|
|
80
|
-
if (v == null) return v;
|
|
81
|
-
if (typeof v === "bigint") return v.toString();
|
|
82
|
-
if (typeof v === "number") return String(v);
|
|
83
|
-
if (typeof v === "string") {
|
|
84
|
-
if (/^0x[0-9a-fA-F]*$/.test(v)) return normalizeHex(v);
|
|
85
|
-
if (/^-?\\d+$/.test(v.trim())) return v.trim();
|
|
86
|
-
return v;
|
|
87
|
-
}
|
|
88
|
-
if (Array.isArray(v)) return v.map(canon);
|
|
89
|
-
if (typeof v === "object") {
|
|
90
|
-
const keys = Object.keys(v);
|
|
91
|
-
const hasNonNumeric = keys.some((k) => !/^\\d+$/.test(k));
|
|
92
|
-
const picked = hasNonNumeric ? keys.filter((k) => !/^\\d+$/.test(k)) : keys;
|
|
93
|
-
picked.sort();
|
|
94
|
-
const out = {};
|
|
95
|
-
for (const k of picked) out[k] = canon(v[k]);
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
return v;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function hexOf(byteHex, lenBytes) {
|
|
102
|
-
const b = byteHex.replace(/^0x/i, "");
|
|
103
|
-
return normalizeHex("0x" + b.repeat(lenBytes));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function buildAllUints(seed) {
|
|
107
|
-
const s = seed || 1;
|
|
108
|
-
const num = (n) => Number(n);
|
|
109
|
-
return {
|
|
110
|
-
u8: num(8 + s), u16: num(16 + s), u24: num(24 + s), u32: num(32 + s), u40: num(40 + s), u48: num(48 + s), u56: num(56 + s), u64: num(64 + s),
|
|
111
|
-
u72: num(72 + s), u80: num(80 + s), u88: num(88 + s), u96: num(96 + s), u104: num(104 + s), u112: num(112 + s), u120: num(120 + s), u128: num(128 + s),
|
|
112
|
-
u136: num(136 + s), u144: num(144 + s), u152: num(152 + s), u160: num(160 + s), u168: num(168 + s), u176: num(176 + s), u184: num(184 + s), u192: num(192 + s),
|
|
113
|
-
u200: num(200 + s), u208: num(208 + s), u216: num(216 + s), u224: num(224 + s), u232: num(232 + s), u240: num(240 + s), u248: num(248 + s), u256: num(256 + s),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function buildAllInts(seed) {
|
|
118
|
-
const s = seed || 1;
|
|
119
|
-
const num = (n) => Number(n);
|
|
120
|
-
return {
|
|
121
|
-
i8: num(-8 - s), i16: num(-16 - s), i24: num(-24 - s), i32: num(-32 - s), i40: num(-40 - s), i48: num(-48 - s), i56: num(-56 - s), i64: num(-64 - s),
|
|
122
|
-
i72: num(-72 - s), i80: num(-80 - s), i88: num(-88 - s), i96: num(-96 - s), i104: num(-104 - s), i112: num(-112 - s), i120: num(-120 - s), i128: num(-128 - s),
|
|
123
|
-
i136: num(-136 - s), i144: num(-144 - s), i152: num(-152 - s), i160: num(-160 - s), i168: num(-168 - s), i176: num(-176 - s), i184: num(-184 - s), i192: num(-192 - s),
|
|
124
|
-
i200: num(-200 - s), i208: num(-208 - s), i216: num(-216 - s), i224: num(-224 - s), i232: num(-232 - s), i240: num(-240 - s), i248: num(-248 - s), i256: num(-256 - s),
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function buildAllFixedBytes(seedByte) {
|
|
129
|
-
const b = seedByte || "11";
|
|
130
|
-
const o = {};
|
|
131
|
-
for (let i = 1; i <= 32; i++) o["b" + i] = hexOf(b, i);
|
|
132
|
-
return o;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function buildAllMisc(addr) {
|
|
136
|
-
return {
|
|
137
|
-
bo: true,
|
|
138
|
-
addr,
|
|
139
|
-
payableAddr: addr,
|
|
140
|
-
str: "hello",
|
|
141
|
-
dynBytes: normalizeHex("0x1234"),
|
|
142
|
-
choice: 1,
|
|
143
|
-
u256s: [1, 2, 3],
|
|
144
|
-
i256s: [-1, -2],
|
|
145
|
-
b32s: [hexOf("aa", 32), hexOf("bb", 32)],
|
|
146
|
-
addrs: [addr],
|
|
147
|
-
bools: [true, false, true],
|
|
148
|
-
strings: ["a", "b"],
|
|
149
|
-
bytesArr: [normalizeHex("0x00"), normalizeHex("0x12")],
|
|
150
|
-
fixedU16: [1, 2, 3],
|
|
151
|
-
fixedB32: [hexOf("cc", 32), hexOf("dd", 32)],
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function buildInner(addr, seed) {
|
|
156
|
-
const u = buildAllUints(seed);
|
|
157
|
-
const i = buildAllInts(seed);
|
|
158
|
-
const fb = buildAllFixedBytes(seed % 2 ? "11" : "22");
|
|
159
|
-
const misc = buildAllMisc(addr);
|
|
160
|
-
const u2 = buildAllUints((seed || 1) + 10);
|
|
161
|
-
const fb2 = buildAllFixedBytes(seed % 2 ? "33" : "44");
|
|
162
|
-
return { u, i, fb, misc, uStructs: [u2], fixedFb: [fb, fb2], matrix: [[1,2],[3]] };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function buildOuter(addr) {
|
|
166
|
-
const inner1 = buildInner(addr, 1);
|
|
167
|
-
const inner2 = buildInner(addr, 2);
|
|
168
|
-
return { inner: inner1, inners: [inner2], fixedInners: [inner1, inner2], b32Matrix: [[hexOf("01",32)],[hexOf("02",32),hexOf("03",32)]] };
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
describe("AllSolidityTypes (extra)", () => {
|
|
172
|
-
it("roundtrips all methods", async (t) => {
|
|
173
|
-
const rpcUrl = process.env.QC_RPC_URL || process.env.QC_ENDPOINT;
|
|
174
|
-
if (!rpcUrl) { t.skip("QC_RPC_URL/QC_ENDPOINT not provided"); return; }
|
|
175
|
-
const chainId = Number(process.env.QC_CHAIN_ID || 0);
|
|
176
|
-
await Initialize(null);
|
|
177
|
-
|
|
178
|
-
const provider = getProvider(rpcUrl, chainId);
|
|
179
|
-
const wallet = Wallet.fromEncryptedJsonSync(TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE, provider);
|
|
180
|
-
|
|
181
|
-
const expectedU = buildAllUints(1);
|
|
182
|
-
const expectedI = buildAllInts(1);
|
|
183
|
-
const expectedFb = buildAllFixedBytes("11");
|
|
184
|
-
|
|
185
|
-
const ctorSeedU256s = [1,2,3];
|
|
186
|
-
const ctorSeedB32 = [expectedFb.b32, buildAllFixedBytes("22").b32];
|
|
187
|
-
const miscParam = buildAllMisc(wallet.address);
|
|
188
|
-
|
|
189
|
-
const factory = new AllSolidityTypes__factory(wallet);
|
|
190
|
-
const contract = await factory.deploy(
|
|
191
|
-
true,
|
|
192
|
-
wallet.address,
|
|
193
|
-
"hello",
|
|
194
|
-
"0x1234",
|
|
195
|
-
1,
|
|
196
|
-
expectedU,
|
|
197
|
-
expectedI,
|
|
198
|
-
expectedFb,
|
|
199
|
-
miscParam,
|
|
200
|
-
ctorSeedU256s,
|
|
201
|
-
ctorSeedB32,
|
|
202
|
-
{ gasLimit: 6_000_000 },
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
const tx = contract.deployTransaction();
|
|
206
|
-
if (tx) await tx.wait(1, 600_000);
|
|
207
|
-
|
|
208
|
-
assert.deepEqual(canon(await contract.echoAllUints(expectedU)), canon(expectedU));
|
|
209
|
-
assert.deepEqual(canon(await contract.echoAllInts(expectedI)), canon(expectedI));
|
|
210
|
-
assert.deepEqual(canon(await contract.echoAllFixedBytes(expectedFb)), canon(expectedFb));
|
|
211
|
-
assert.deepEqual(canon(await contract.echoAllMisc(miscParam)), canon(miscParam));
|
|
212
|
-
|
|
213
|
-
const inner = buildInner(wallet.address, 1);
|
|
214
|
-
assert.deepEqual(canon(await contract.echoInner(inner)), canon(inner));
|
|
215
|
-
|
|
216
|
-
const outer = buildOuter(wallet.address);
|
|
217
|
-
assert.deepEqual(canon(await contract.echoOuter(outer)), canon(outer));
|
|
218
|
-
|
|
219
|
-
const uArr = [buildAllUints(3), buildAllUints(4)];
|
|
220
|
-
assert.deepEqual(canon(await contract.echoAllUintsArray(uArr)), canon(uArr));
|
|
221
|
-
|
|
222
|
-
const innerArr = [buildInner(wallet.address, 3), buildInner(wallet.address, 4)];
|
|
223
|
-
assert.deepEqual(canon(await contract.echoInnerArray(innerArr)), canon(innerArr));
|
|
224
|
-
|
|
225
|
-
const matrix = [[1,2],[3,4,5]];
|
|
226
|
-
assert.deepEqual(canon(await contract.echoMatrix(matrix)), canon(matrix));
|
|
227
|
-
|
|
228
|
-
const multi = await contract.multiReturn(true, wallet.address, expectedFb.b32, "hello", 999, expectedU);
|
|
229
|
-
const multiC = canon(multi);
|
|
230
|
-
if (Array.isArray(multiC)) {
|
|
231
|
-
assert.equal(multiC[0] === true || multiC[0] === "true", true);
|
|
232
|
-
assert.equal(multiC[1], wallet.address);
|
|
233
|
-
assert.equal(multiC[2], wallet.address);
|
|
234
|
-
assert.equal(multiC[3], canon(expectedFb.b32));
|
|
235
|
-
assert.equal(multiC[4], "hello");
|
|
236
|
-
assert.equal(multiC[5], "999");
|
|
237
|
-
assert.deepEqual(multiC[6], canon(expectedU));
|
|
238
|
-
} else {
|
|
239
|
-
assert.equal(multiC.outBo === true || multiC.outBo === "true", true);
|
|
240
|
-
assert.equal(multiC.outAddr, wallet.address);
|
|
241
|
-
assert.equal(multiC.outPayableAddr, wallet.address);
|
|
242
|
-
assert.equal(multiC.outB32, canon(expectedFb.b32));
|
|
243
|
-
assert.equal(multiC.outS, "hello");
|
|
244
|
-
assert.equal(multiC.outX, "999");
|
|
245
|
-
assert.deepEqual(multiC.outU, canon(expectedU));
|
|
246
|
-
}
|
|
247
|
-
}, { timeout: 1_800_000 });
|
|
248
|
-
});
|
|
249
|
-
`;
|
|
250
|
-
|
|
251
|
-
fs.writeFileSync(path.join(testDir, "AllSolidityTypes.extra.test.js"), content, "utf8");
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function assertNoLegacyGenericTypes(pkgRoot: string, contractName: string, lang: "ts" | "js"): void {
|
|
255
|
-
const srcDir = path.join(pkgRoot, "src");
|
|
256
|
-
const files =
|
|
257
|
-
lang === "ts"
|
|
258
|
-
? [path.join(srcDir, `${contractName}.ts`)]
|
|
259
|
-
: [path.join(srcDir, `${contractName}.js`), path.join(srcDir, `${contractName}.d.ts`)];
|
|
260
|
-
for (const file of files) {
|
|
261
|
-
const text = fs.readFileSync(file, "utf8");
|
|
262
|
-
assert.equal(/SolidityInputValue\s*</.test(text), false, `${path.basename(file)} still contains SolidityInputValue<>`);
|
|
263
|
-
assert.equal(/SolidityOutputValue\s*</.test(text), false, `${path.basename(file)} still contains SolidityOutputValue<>`);
|
|
264
|
-
assert.equal(/Promise<any>/.test(text), false, `${path.basename(file)} still contains Promise<any>`);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
describe("AllSolidityTypes generated SDKs (extra tests)", () => {
|
|
269
|
-
it("generates TS and JS packages and runs extra tests", async (t: { skip: (msg: string) => void }) => {
|
|
270
|
-
logSuite("AllSolidityTypes generated SDKs (extra tests)");
|
|
271
|
-
logTest("generates TS and JS packages and runs extra tests", {});
|
|
272
|
-
const rpcUrl = getRpcUrl();
|
|
273
|
-
if (!rpcUrl) {
|
|
274
|
-
t.skip("QC_RPC_URL not provided");
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
logE2eConfig();
|
|
278
|
-
const chainId = getChainId();
|
|
279
|
-
const repoRoot = path.resolve(__dirname, "..", "..");
|
|
280
|
-
const solPath = path.join(repoRoot, "examples", "AllSolidityTypes.sol");
|
|
281
|
-
assert.ok(fs.existsSync(solPath), "missing examples/AllSolidityTypes.sol");
|
|
282
|
-
|
|
283
|
-
const outBase = path.join(repoRoot, "test", "e2e", "generated-sdks", "all-solidity-types");
|
|
284
|
-
fs.mkdirSync(outBase, { recursive: true });
|
|
285
|
-
|
|
286
|
-
const mkPkg = (lang: "ts" | "js") => {
|
|
287
|
-
const pkgName = `all-solidity-types-${lang}`;
|
|
288
|
-
const pkgRoot = path.join(outBase, pkgName);
|
|
289
|
-
fs.rmSync(pkgRoot, { recursive: true, force: true });
|
|
290
|
-
const genCli = path.join(repoRoot, "generate-sdk.js");
|
|
291
|
-
const res = run(
|
|
292
|
-
process.execPath,
|
|
293
|
-
[
|
|
294
|
-
genCli,
|
|
295
|
-
"--lang", lang,
|
|
296
|
-
"--sol", solPath,
|
|
297
|
-
"--name", "AllSolidityTypes",
|
|
298
|
-
"--create-package",
|
|
299
|
-
"--package-dir", outBase,
|
|
300
|
-
"--package-name", pkgName,
|
|
301
|
-
"--package-description", `${lang.toUpperCase()} typed package generated from AllSolidityTypes.sol (e2e)`,
|
|
302
|
-
"--package-author", "quantumcoin.js test",
|
|
303
|
-
"--package-license", "MIT",
|
|
304
|
-
"--package-version", "0.0.1",
|
|
305
|
-
"--non-interactive",
|
|
306
|
-
],
|
|
307
|
-
repoRoot,
|
|
308
|
-
process.env,
|
|
309
|
-
);
|
|
310
|
-
assert.equal(res.status, 0, `generator failed:\n${res.stdout}\n${res.stderr}`);
|
|
311
|
-
return pkgRoot;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
let succeeded = false;
|
|
315
|
-
try {
|
|
316
|
-
const tsPkg = mkPkg("ts");
|
|
317
|
-
const jsPkg = mkPkg("js");
|
|
318
|
-
|
|
319
|
-
writeExtraTest(tsPkg);
|
|
320
|
-
writeExtraTest(jsPkg);
|
|
321
|
-
|
|
322
|
-
assertNoLegacyGenericTypes(tsPkg, "AllSolidityTypes", "ts");
|
|
323
|
-
assertNoLegacyGenericTypes(jsPkg, "AllSolidityTypes", "js");
|
|
324
|
-
|
|
325
|
-
const env = { ...process.env, QC_RPC_URL: rpcUrl, QC_CHAIN_ID: String(chainId) };
|
|
326
|
-
|
|
327
|
-
const tsRun = runNpm(["test"], tsPkg, env);
|
|
328
|
-
assert.equal(tsRun.status, 0, `TS package tests failed:\n${tsRun.stdout}\n${tsRun.stderr}`);
|
|
329
|
-
|
|
330
|
-
const jsRun = runNpm(["test"], jsPkg, env);
|
|
331
|
-
assert.equal(jsRun.status, 0, `JS package tests failed:\n${jsRun.stdout}\n${jsRun.stderr}`);
|
|
332
|
-
|
|
333
|
-
const tsExample = run(process.execPath, [path.join(tsPkg, "examples", "offline-signing.js")], tsPkg, env);
|
|
334
|
-
assert.equal(tsExample.status, 0, `TS offline-signing example failed:\n${tsExample.stdout}\n${tsExample.stderr}`);
|
|
335
|
-
|
|
336
|
-
const jsExample = run(process.execPath, [path.join(jsPkg, "examples", "offline-signing.js")], jsPkg, env);
|
|
337
|
-
assert.equal(jsExample.status, 0, `JS offline-signing example failed:\n${jsExample.stdout}\n${jsExample.stderr}`);
|
|
338
|
-
|
|
339
|
-
succeeded = true;
|
|
340
|
-
} finally {
|
|
341
|
-
if (succeeded) {
|
|
342
|
-
for (const lang of ["ts", "js"]) {
|
|
343
|
-
const pkgRoot = path.join(outBase, `all-solidity-types-${lang}`);
|
|
344
|
-
fs.rmSync(path.join(pkgRoot, "node_modules"), { recursive: true, force: true });
|
|
345
|
-
fs.rmSync(path.join(pkgRoot, "dist"), { recursive: true, force: true });
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}, { timeout: 3_600_000 });
|
|
350
|
-
});
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory e2e
|
|
3
|
-
* @blockchainRequired write
|
|
4
|
-
* @transactional true
|
|
5
|
-
* @description Real-chain e2e test verifying the generator skips the bytecode
|
|
6
|
-
* validation for interface contracts. Materializes a tiny interface
|
|
7
|
-
* SDK to a tmpdir and runs the generator's emitted `node --test`
|
|
8
|
-
* file against the real QC_RPC_URL chain with the real test wallet.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const { describe, it } = require("node:test");
|
|
12
|
-
const assert = require("node:assert/strict");
|
|
13
|
-
const fs = require("node:fs");
|
|
14
|
-
const os = require("node:os");
|
|
15
|
-
const path = require("node:path");
|
|
16
|
-
const { spawnSync } = require("node:child_process");
|
|
17
|
-
|
|
18
|
-
const { generateFromArtifacts, generateTransactionalTestJs } = require("../../src/generator");
|
|
19
|
-
const { getRpcUrl, getChainId, logE2eConfig } = require("./helpers");
|
|
20
|
-
const { logSuite, logTest } = require("../verbose-logger");
|
|
21
|
-
|
|
22
|
-
function _materializeInterfaceSdk({ contractName, abi, bytecode }) {
|
|
23
|
-
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-iface-e2e-"));
|
|
24
|
-
const srcDir = path.join(tmpRoot, "src");
|
|
25
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
26
|
-
|
|
27
|
-
generateFromArtifacts({
|
|
28
|
-
outDir: srcDir,
|
|
29
|
-
artifacts: [{ contractName, abi, bytecode }],
|
|
30
|
-
lang: "js",
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
fs.writeFileSync(
|
|
34
|
-
path.join(tmpRoot, "index.js"),
|
|
35
|
-
`module.exports = require("./src");\n`,
|
|
36
|
-
);
|
|
37
|
-
fs.writeFileSync(
|
|
38
|
-
path.join(tmpRoot, "package.json"),
|
|
39
|
-
JSON.stringify(
|
|
40
|
-
{ name: `qcgen-iface-${Date.now()}`, version: "0.0.1", main: "index.js", private: true },
|
|
41
|
-
null,
|
|
42
|
-
2,
|
|
43
|
-
),
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const repoRoot = path.resolve(__dirname, "..", "..");
|
|
47
|
-
const qcShim = path.join(tmpRoot, "node_modules", "quantumcoin");
|
|
48
|
-
fs.mkdirSync(qcShim, { recursive: true });
|
|
49
|
-
fs.writeFileSync(
|
|
50
|
-
path.join(qcShim, "package.json"),
|
|
51
|
-
JSON.stringify(
|
|
52
|
-
{ name: "quantumcoin", version: "0.0.0", main: "index.js", private: true },
|
|
53
|
-
null,
|
|
54
|
-
2,
|
|
55
|
-
),
|
|
56
|
-
);
|
|
57
|
-
fs.writeFileSync(
|
|
58
|
-
path.join(qcShim, "index.js"),
|
|
59
|
-
`module.exports = require(${JSON.stringify(path.join(repoRoot, "index.js"))});\n`,
|
|
60
|
-
);
|
|
61
|
-
fs.writeFileSync(
|
|
62
|
-
path.join(qcShim, "config.js"),
|
|
63
|
-
`module.exports = require(${JSON.stringify(path.join(repoRoot, "config.js"))});\n`,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const testFile = path.join(tmpRoot, "test", "e2e", `${contractName}.e2e.test.js`);
|
|
67
|
-
fs.mkdirSync(path.dirname(testFile), { recursive: true });
|
|
68
|
-
fs.writeFileSync(
|
|
69
|
-
testFile,
|
|
70
|
-
generateTransactionalTestJs({ contractName, abi, bytecode }),
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
return { tmpRoot, testFile };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
describe("auto-generator: interface contract end-to-end (real chain)", () => {
|
|
77
|
-
logSuite("auto-generator: interface contract end-to-end (real chain)");
|
|
78
|
-
|
|
79
|
-
it("generated interface test runs against the real chain and passes (bytecode check skipped)", async (t) => {
|
|
80
|
-
logTest("generated interface test runs against the real chain and passes", {});
|
|
81
|
-
const rpcUrl = getRpcUrl();
|
|
82
|
-
if (!rpcUrl) {
|
|
83
|
-
t.skip("QC_RPC_URL not provided");
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
logE2eConfig();
|
|
87
|
-
const chainId = getChainId();
|
|
88
|
-
|
|
89
|
-
const contractName = "IThing";
|
|
90
|
-
const abi = [
|
|
91
|
-
{
|
|
92
|
-
type: "function",
|
|
93
|
-
name: "doThing",
|
|
94
|
-
inputs: [],
|
|
95
|
-
outputs: [],
|
|
96
|
-
stateMutability: "nonpayable",
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
const bytecode = "0x";
|
|
100
|
-
|
|
101
|
-
const { tmpRoot, testFile } = _materializeInterfaceSdk({ contractName, abi, bytecode });
|
|
102
|
-
|
|
103
|
-
// Sanity: the generator should not have emitted a bytecode assertion for this interface.
|
|
104
|
-
const generatedSrc = fs.readFileSync(testFile, "utf8");
|
|
105
|
-
assert.ok(
|
|
106
|
-
!/provider\.getCode\(contract\.target/.test(generatedSrc),
|
|
107
|
-
"interface-generated test must not contain provider.getCode bytecode assertion",
|
|
108
|
-
);
|
|
109
|
-
assert.ok(
|
|
110
|
-
/Skipping bytecode check/.test(generatedSrc),
|
|
111
|
-
"interface-generated test must contain the skip-comment marker",
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
// IMPORTANT: scrub Node's internal --test child-context markers from the
|
|
115
|
-
// spawn env. The outer `node --test` runner sets NODE_TEST_CONTEXT (and
|
|
116
|
-
// related vars) which would make our spawned child short-circuit as a
|
|
117
|
-
// "test child" instead of running the generated test normally.
|
|
118
|
-
const childEnv = { ...process.env, QC_RPC_URL: rpcUrl, QC_CHAIN_ID: String(chainId) };
|
|
119
|
-
delete childEnv.NODE_TEST_CONTEXT;
|
|
120
|
-
delete childEnv.NODE_TEST_OPTIONS;
|
|
121
|
-
if (childEnv.NODE_OPTIONS && /--test\b/.test(childEnv.NODE_OPTIONS)) {
|
|
122
|
-
childEnv.NODE_OPTIONS = childEnv.NODE_OPTIONS.replace(/(^|\s)--test\b\S*/g, "").trim();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
let succeeded = false;
|
|
126
|
-
try {
|
|
127
|
-
const res = spawnSync(
|
|
128
|
-
process.execPath,
|
|
129
|
-
["--test", "--test-reporter=tap", testFile],
|
|
130
|
-
{
|
|
131
|
-
cwd: tmpRoot,
|
|
132
|
-
env: childEnv,
|
|
133
|
-
encoding: "utf8",
|
|
134
|
-
shell: false,
|
|
135
|
-
windowsHide: true,
|
|
136
|
-
},
|
|
137
|
-
);
|
|
138
|
-
assert.equal(
|
|
139
|
-
res.status,
|
|
140
|
-
0,
|
|
141
|
-
`generated interface test failed:\nSTDOUT:\n${res.stdout}\nSTDERR:\n${res.stderr}`,
|
|
142
|
-
);
|
|
143
|
-
// Accept either the TAP reporter ("# pass 1") or the spec reporter
|
|
144
|
-
// ("\u2139 pass 1") summary line so the assertion is reporter-agnostic.
|
|
145
|
-
assert.match(
|
|
146
|
-
res.stdout || "",
|
|
147
|
-
/(?:#|\u2139)\s*pass 1\b/,
|
|
148
|
-
`generated interface test did not actually run (no 'pass 1' summary in test output);\nSTDOUT:\n${res.stdout}\nSTDERR:\n${res.stderr}`,
|
|
149
|
-
);
|
|
150
|
-
assert.doesNotMatch(
|
|
151
|
-
res.stdout || "",
|
|
152
|
-
/(?:#|\u2139)\s*pass 0\b|(?:#|\u2139)\s*tests 0\b|(?:#|\u2139)\s*skipped 1\b/,
|
|
153
|
-
`generated interface test was skipped or did not run any tests;\nSTDOUT:\n${res.stdout}\nSTDERR:\n${res.stderr}`,
|
|
154
|
-
);
|
|
155
|
-
succeeded = true;
|
|
156
|
-
} finally {
|
|
157
|
-
if (succeeded) {
|
|
158
|
-
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
159
|
-
} else {
|
|
160
|
-
// eslint-disable-next-line no-console
|
|
161
|
-
console.error("Generated interface package kept at:", tmpRoot);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}, { timeout: 1_800_000 });
|
|
165
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @testCategory e2e
|
|
3
|
-
* @blockchainRequired write
|
|
4
|
-
* @transactional true
|
|
5
|
-
* @description Real-chain e2e test verifying the generator skips the bytecode
|
|
6
|
-
* validation for interface contracts. Materializes a tiny interface
|
|
7
|
-
* SDK to a tmpdir and runs the generator's emitted `node --test`
|
|
8
|
-
* file against the real QC_RPC_URL chain with the real test wallet.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { describe, it } from "node:test";
|
|
12
|
-
import assert from "node:assert/strict";
|
|
13
|
-
import fs from "node:fs";
|
|
14
|
-
import os from "node:os";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import { spawnSync } from "node:child_process";
|
|
17
|
-
|
|
18
|
-
import { generateFromArtifacts, generateTransactionalTestJs } from "../../src/generator";
|
|
19
|
-
import { getRpcUrl, getChainId, logE2eConfig } from "./helpers";
|
|
20
|
-
import { logSuite, logTest } from "../verbose-logger";
|
|
21
|
-
|
|
22
|
-
function _materializeInterfaceSdk({ contractName, abi, bytecode }: { contractName: string; abi: any[]; bytecode?: string }) {
|
|
23
|
-
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-iface-e2e-"));
|
|
24
|
-
const srcDir = path.join(tmpRoot, "src");
|
|
25
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
26
|
-
|
|
27
|
-
generateFromArtifacts({
|
|
28
|
-
outDir: srcDir,
|
|
29
|
-
artifacts: [{ contractName, abi, bytecode }],
|
|
30
|
-
lang: "js",
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
fs.writeFileSync(
|
|
34
|
-
path.join(tmpRoot, "index.js"),
|
|
35
|
-
`module.exports = require("./src");\n`,
|
|
36
|
-
);
|
|
37
|
-
fs.writeFileSync(
|
|
38
|
-
path.join(tmpRoot, "package.json"),
|
|
39
|
-
JSON.stringify(
|
|
40
|
-
{ name: `qcgen-iface-${Date.now()}`, version: "0.0.1", main: "index.js", private: true },
|
|
41
|
-
null,
|
|
42
|
-
2,
|
|
43
|
-
),
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const repoRoot = path.resolve(__dirname, "..", "..");
|
|
47
|
-
const qcShim = path.join(tmpRoot, "node_modules", "quantumcoin");
|
|
48
|
-
fs.mkdirSync(qcShim, { recursive: true });
|
|
49
|
-
fs.writeFileSync(
|
|
50
|
-
path.join(qcShim, "package.json"),
|
|
51
|
-
JSON.stringify(
|
|
52
|
-
{ name: "quantumcoin", version: "0.0.0", main: "index.js", private: true },
|
|
53
|
-
null,
|
|
54
|
-
2,
|
|
55
|
-
),
|
|
56
|
-
);
|
|
57
|
-
fs.writeFileSync(
|
|
58
|
-
path.join(qcShim, "index.js"),
|
|
59
|
-
`module.exports = require(${JSON.stringify(path.join(repoRoot, "index.js"))});\n`,
|
|
60
|
-
);
|
|
61
|
-
fs.writeFileSync(
|
|
62
|
-
path.join(qcShim, "config.js"),
|
|
63
|
-
`module.exports = require(${JSON.stringify(path.join(repoRoot, "config.js"))});\n`,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const testFile = path.join(tmpRoot, "test", "e2e", `${contractName}.e2e.test.js`);
|
|
67
|
-
fs.mkdirSync(path.dirname(testFile), { recursive: true });
|
|
68
|
-
fs.writeFileSync(
|
|
69
|
-
testFile,
|
|
70
|
-
generateTransactionalTestJs({ contractName, abi, bytecode }),
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
return { tmpRoot, testFile };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
describe("auto-generator: interface contract end-to-end (real chain)", () => {
|
|
77
|
-
logSuite("auto-generator: interface contract end-to-end (real chain)");
|
|
78
|
-
|
|
79
|
-
it("generated interface test runs against the real chain and passes (bytecode check skipped)", async (t) => {
|
|
80
|
-
logTest("generated interface test runs against the real chain and passes", {});
|
|
81
|
-
const rpcUrl = getRpcUrl();
|
|
82
|
-
if (!rpcUrl) {
|
|
83
|
-
t.skip("QC_RPC_URL not provided");
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
logE2eConfig();
|
|
87
|
-
const chainId = getChainId();
|
|
88
|
-
|
|
89
|
-
const contractName = "IThing";
|
|
90
|
-
const abi = [
|
|
91
|
-
{
|
|
92
|
-
type: "function",
|
|
93
|
-
name: "doThing",
|
|
94
|
-
inputs: [],
|
|
95
|
-
outputs: [],
|
|
96
|
-
stateMutability: "nonpayable",
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
const bytecode = "0x";
|
|
100
|
-
|
|
101
|
-
const { tmpRoot, testFile } = _materializeInterfaceSdk({ contractName, abi, bytecode });
|
|
102
|
-
|
|
103
|
-
const generatedSrc = fs.readFileSync(testFile, "utf8");
|
|
104
|
-
assert.ok(
|
|
105
|
-
!/provider\.getCode\(contract\.target/.test(generatedSrc),
|
|
106
|
-
"interface-generated test must not contain provider.getCode bytecode assertion",
|
|
107
|
-
);
|
|
108
|
-
assert.ok(
|
|
109
|
-
/Skipping bytecode check/.test(generatedSrc),
|
|
110
|
-
"interface-generated test must contain the skip-comment marker",
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const childEnv: NodeJS.ProcessEnv = { ...process.env, QC_RPC_URL: rpcUrl, QC_CHAIN_ID: String(chainId) };
|
|
114
|
-
delete childEnv.NODE_TEST_CONTEXT;
|
|
115
|
-
delete childEnv.NODE_TEST_OPTIONS;
|
|
116
|
-
if (childEnv.NODE_OPTIONS && /--test\b/.test(childEnv.NODE_OPTIONS)) {
|
|
117
|
-
childEnv.NODE_OPTIONS = childEnv.NODE_OPTIONS.replace(/(^|\s)--test\b\S*/g, "").trim();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let succeeded = false;
|
|
121
|
-
try {
|
|
122
|
-
const res = spawnSync(
|
|
123
|
-
process.execPath,
|
|
124
|
-
["--test", "--test-reporter=tap", testFile],
|
|
125
|
-
{
|
|
126
|
-
cwd: tmpRoot,
|
|
127
|
-
env: childEnv,
|
|
128
|
-
encoding: "utf8",
|
|
129
|
-
shell: false,
|
|
130
|
-
windowsHide: true,
|
|
131
|
-
},
|
|
132
|
-
);
|
|
133
|
-
assert.equal(
|
|
134
|
-
res.status,
|
|
135
|
-
0,
|
|
136
|
-
`generated interface test failed:\nSTDOUT:\n${res.stdout}\nSTDERR:\n${res.stderr}`,
|
|
137
|
-
);
|
|
138
|
-
// Accept either the TAP reporter ("# pass 1") or the spec reporter
|
|
139
|
-
// ("\u2139 pass 1") summary line so the assertion is reporter-agnostic.
|
|
140
|
-
assert.match(
|
|
141
|
-
res.stdout || "",
|
|
142
|
-
/(?:#|\u2139)\s*pass 1\b/,
|
|
143
|
-
`generated interface test did not actually run (no 'pass 1' summary in test output);\nSTDOUT:\n${res.stdout}\nSTDERR:\n${res.stderr}`,
|
|
144
|
-
);
|
|
145
|
-
assert.doesNotMatch(
|
|
146
|
-
res.stdout || "",
|
|
147
|
-
/(?:#|\u2139)\s*pass 0\b|(?:#|\u2139)\s*tests 0\b|(?:#|\u2139)\s*skipped 1\b/,
|
|
148
|
-
`generated interface test was skipped or did not run any tests;\nSTDOUT:\n${res.stdout}\nSTDERR:\n${res.stderr}`,
|
|
149
|
-
);
|
|
150
|
-
succeeded = true;
|
|
151
|
-
} finally {
|
|
152
|
-
if (succeeded) {
|
|
153
|
-
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
154
|
-
} else {
|
|
155
|
-
// eslint-disable-next-line no-console
|
|
156
|
-
console.error("Generated interface package kept at:", tmpRoot);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}, { timeout: 1_800_000 });
|
|
160
|
-
});
|