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.
Files changed (226) hide show
  1. package/.gitignore +2 -1
  2. package/README.md +109 -768
  3. package/index.d.ts +76 -545
  4. package/index.js +319 -1194
  5. package/package.json +20 -5
  6. package/wasmBase64.js +7 -16
  7. package/wasm_exec.js +575 -587
  8. package/.idea/.name +0 -1
  9. package/.idea/modules.xml +0 -8
  10. package/.idea/quantum-coin-js-sdk.iml +0 -12
  11. package/.idea/vcs.xml +0 -6
  12. package/.vs/ProjectSettings.json +0 -3
  13. package/.vs/VSWorkspaceState.json +0 -8
  14. package/.vs/quantum-coin-js-sdk/FileContentIndex/a9d6de82-cfc3-4c22-ac38-06d706ff3673.vsidx +0 -0
  15. package/.vs/quantum-coin-js-sdk/FileContentIndex/fdc816df-1898-4153-99f2-c69ef4c2283b.vsidx +0 -0
  16. package/.vs/quantum-coin-js-sdk/config/applicationhost.config +0 -1011
  17. package/.vs/quantum-coin-js-sdk/v17/.wsuo +0 -0
  18. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.backup.json +0 -39
  19. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.json +0 -57
  20. package/.vs/slnx.sqlite +0 -0
  21. package/example/README.md +0 -14
  22. package/example/conversion-example.js +0 -19
  23. package/example/example-create-contract.js +0 -396
  24. package/example/example-encode-decode-rlp.js +0 -225
  25. package/example/example-event-pack-unpack.js +0 -391
  26. package/example/example-misc.js +0 -100
  27. package/example/example-rpc-send-signRawTransaction.js +0 -318
  28. package/example/example-rpc-send.js +0 -115
  29. package/example/example-send.js +0 -69
  30. package/example/example-token-pack-unpack.js +0 -960
  31. package/example/example-wallet-version4.js +0 -34
  32. package/example/example-wallet.js +0 -43
  33. package/example/example.js +0 -405
  34. package/example/node_modules/.bin/sdkgen +0 -16
  35. package/example/node_modules/.bin/sdkgen.cmd +0 -17
  36. package/example/node_modules/.bin/sdkgen.ps1 +0 -28
  37. package/example/node_modules/.package-lock.json +0 -47
  38. package/example/node_modules/quantumcoin/.github/workflows/publish-npmjs.yaml +0 -22
  39. package/example/node_modules/quantumcoin/LICENSE +0 -21
  40. package/example/node_modules/quantumcoin/README-SDK.md +0 -828
  41. package/example/node_modules/quantumcoin/README.md +0 -197
  42. package/example/node_modules/quantumcoin/config.d.ts +0 -50
  43. package/example/node_modules/quantumcoin/config.js +0 -123
  44. package/example/node_modules/quantumcoin/examples/AllSolidityTypes.sol +0 -184
  45. package/example/node_modules/quantumcoin/examples/SimpleIERC20.sol +0 -74
  46. package/example/node_modules/quantumcoin/examples/events.js +0 -41
  47. package/example/node_modules/quantumcoin/examples/events.ts +0 -35
  48. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.js +0 -100
  49. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.ts +0 -77
  50. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.js +0 -100
  51. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.ts +0 -77
  52. package/example/node_modules/quantumcoin/examples/example.js +0 -67
  53. package/example/node_modules/quantumcoin/examples/example.ts +0 -56
  54. package/example/node_modules/quantumcoin/examples/offline-signing.js +0 -77
  55. package/example/node_modules/quantumcoin/examples/offline-signing.ts +0 -65
  56. package/example/node_modules/quantumcoin/examples/package-lock.json +0 -596
  57. package/example/node_modules/quantumcoin/examples/package.json +0 -32
  58. package/example/node_modules/quantumcoin/examples/read-operations.js +0 -32
  59. package/example/node_modules/quantumcoin/examples/read-operations.ts +0 -31
  60. package/example/node_modules/quantumcoin/examples/sdk-generator-erc20.inline.json +0 -251
  61. package/example/node_modules/quantumcoin/examples/solidity-types.ts +0 -43
  62. package/example/node_modules/quantumcoin/examples/wallet-offline.js +0 -36
  63. package/example/node_modules/quantumcoin/examples/wallet-offline.ts +0 -26
  64. package/example/node_modules/quantumcoin/generate-sdk.js +0 -1846
  65. package/example/node_modules/quantumcoin/index.js +0 -12
  66. package/example/node_modules/quantumcoin/package.json +0 -95
  67. package/example/node_modules/quantumcoin/scripts/copy-declarations.js +0 -31
  68. package/example/node_modules/quantumcoin/scripts/run-all-one-by-one.js +0 -151
  69. package/example/node_modules/quantumcoin/src/abi/fragments.d.ts +0 -42
  70. package/example/node_modules/quantumcoin/src/abi/fragments.js +0 -63
  71. package/example/node_modules/quantumcoin/src/abi/index.d.ts +0 -13
  72. package/example/node_modules/quantumcoin/src/abi/index.js +0 -9
  73. package/example/node_modules/quantumcoin/src/abi/interface.d.ts +0 -128
  74. package/example/node_modules/quantumcoin/src/abi/interface.js +0 -605
  75. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.d.ts +0 -8
  76. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.js +0 -538
  77. package/example/node_modules/quantumcoin/src/constants.d.ts +0 -61
  78. package/example/node_modules/quantumcoin/src/constants.js +0 -94
  79. package/example/node_modules/quantumcoin/src/contract/contract-factory.d.ts +0 -28
  80. package/example/node_modules/quantumcoin/src/contract/contract-factory.js +0 -111
  81. package/example/node_modules/quantumcoin/src/contract/contract.d.ts +0 -113
  82. package/example/node_modules/quantumcoin/src/contract/contract.js +0 -408
  83. package/example/node_modules/quantumcoin/src/contract/index.d.ts +0 -9
  84. package/example/node_modules/quantumcoin/src/contract/index.js +0 -9
  85. package/example/node_modules/quantumcoin/src/errors/index.d.ts +0 -92
  86. package/example/node_modules/quantumcoin/src/errors/index.js +0 -200
  87. package/example/node_modules/quantumcoin/src/generator/index.d.ts +0 -81
  88. package/example/node_modules/quantumcoin/src/generator/index.js +0 -1571
  89. package/example/node_modules/quantumcoin/src/index.d.ts +0 -122
  90. package/example/node_modules/quantumcoin/src/index.js +0 -41
  91. package/example/node_modules/quantumcoin/src/internal/hex.d.ts +0 -68
  92. package/example/node_modules/quantumcoin/src/internal/hex.js +0 -180
  93. package/example/node_modules/quantumcoin/src/providers/extra-providers.d.ts +0 -139
  94. package/example/node_modules/quantumcoin/src/providers/extra-providers.js +0 -614
  95. package/example/node_modules/quantumcoin/src/providers/index.d.ts +0 -17
  96. package/example/node_modules/quantumcoin/src/providers/index.js +0 -10
  97. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.d.ts +0 -12
  98. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.js +0 -89
  99. package/example/node_modules/quantumcoin/src/providers/provider.d.ts +0 -206
  100. package/example/node_modules/quantumcoin/src/providers/provider.js +0 -524
  101. package/example/node_modules/quantumcoin/src/types/index.d.ts +0 -214
  102. package/example/node_modules/quantumcoin/src/types/index.js +0 -9
  103. package/example/node_modules/quantumcoin/src/utils/address.d.ts +0 -58
  104. package/example/node_modules/quantumcoin/src/utils/address.js +0 -144
  105. package/example/node_modules/quantumcoin/src/utils/encoding.d.ts +0 -120
  106. package/example/node_modules/quantumcoin/src/utils/encoding.js +0 -306
  107. package/example/node_modules/quantumcoin/src/utils/fixednumber.d.ts +0 -57
  108. package/example/node_modules/quantumcoin/src/utils/fixednumber.js +0 -366
  109. package/example/node_modules/quantumcoin/src/utils/hashing.d.ts +0 -76
  110. package/example/node_modules/quantumcoin/src/utils/hashing.js +0 -298
  111. package/example/node_modules/quantumcoin/src/utils/index.d.ts +0 -63
  112. package/example/node_modules/quantumcoin/src/utils/index.js +0 -14
  113. package/example/node_modules/quantumcoin/src/utils/result.d.ts +0 -57
  114. package/example/node_modules/quantumcoin/src/utils/result.js +0 -128
  115. package/example/node_modules/quantumcoin/src/utils/rlp.d.ts +0 -12
  116. package/example/node_modules/quantumcoin/src/utils/rlp.js +0 -215
  117. package/example/node_modules/quantumcoin/src/utils/units.d.ts +0 -29
  118. package/example/node_modules/quantumcoin/src/utils/units.js +0 -107
  119. package/example/node_modules/quantumcoin/src/wallet/index.d.ts +0 -10
  120. package/example/node_modules/quantumcoin/src/wallet/index.js +0 -8
  121. package/example/node_modules/quantumcoin/src/wallet/wallet.d.ts +0 -192
  122. package/example/node_modules/quantumcoin/src/wallet/wallet.js +0 -713
  123. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.js +0 -207
  124. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
  125. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.fixtures.js +0 -231
  126. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
  127. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
  128. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.js +0 -165
  129. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.ts +0 -160
  130. package/example/node_modules/quantumcoin/test/e2e/helpers.js +0 -59
  131. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
  132. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
  133. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
  134. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
  135. package/example/node_modules/quantumcoin/test/e2e/transactional.test.js +0 -245
  136. package/example/node_modules/quantumcoin/test/e2e/transactional.test.ts +0 -208
  137. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.js +0 -407
  138. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.ts +0 -337
  139. package/example/node_modules/quantumcoin/test/fixtures/ConstructorParam.sol +0 -23
  140. package/example/node_modules/quantumcoin/test/fixtures/MultiContracts.sol +0 -37
  141. package/example/node_modules/quantumcoin/test/fixtures/SimpleStorage.sol +0 -18
  142. package/example/node_modules/quantumcoin/test/fixtures/StakingContract.abi.json +0 -1
  143. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.js +0 -49
  144. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.ts +0 -44
  145. package/example/node_modules/quantumcoin/test/integration/provider.test.js +0 -88
  146. package/example/node_modules/quantumcoin/test/integration/provider.test.ts +0 -85
  147. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.js +0 -41
  148. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.ts +0 -38
  149. package/example/node_modules/quantumcoin/test/security/abi-decoder-bounds.test.js +0 -122
  150. package/example/node_modules/quantumcoin/test/security/contract-overrides.test.js +0 -112
  151. package/example/node_modules/quantumcoin/test/security/generator-injection.test.js +0 -195
  152. package/example/node_modules/quantumcoin/test/security/malformed-input.test.js +0 -330
  153. package/example/node_modules/quantumcoin/test/security/malformed-input.test.ts +0 -35
  154. package/example/node_modules/quantumcoin/test/security/rpc-numeric-bounds.test.js +0 -81
  155. package/example/node_modules/quantumcoin/test/security/rpc-trust.test.js +0 -202
  156. package/example/node_modules/quantumcoin/test/unit/_encrypted-output.txt +0 -6
  157. package/example/node_modules/quantumcoin/test/unit/_log-encrypted-jsons.js +0 -45
  158. package/example/node_modules/quantumcoin/test/unit/_write-keystore-fixture.js +0 -16
  159. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.js +0 -110
  160. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.ts +0 -109
  161. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.js +0 -923
  162. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.ts +0 -877
  163. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.js +0 -85
  164. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.ts +0 -79
  165. package/example/node_modules/quantumcoin/test/unit/contract.test.js +0 -85
  166. package/example/node_modules/quantumcoin/test/unit/contract.test.ts +0 -83
  167. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.js +0 -127
  168. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.ts +0 -91
  169. package/example/node_modules/quantumcoin/test/unit/errors.test.js +0 -77
  170. package/example/node_modules/quantumcoin/test/unit/errors.test.ts +0 -76
  171. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.js +0 -55
  172. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.ts +0 -54
  173. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.js +0 -656
  174. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.ts +0 -660
  175. package/example/node_modules/quantumcoin/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
  176. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.js +0 -42
  177. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.ts +0 -41
  178. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.js +0 -113
  179. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
  180. package/example/node_modules/quantumcoin/test/unit/generator.test.js +0 -149
  181. package/example/node_modules/quantumcoin/test/unit/generator.test.ts +0 -148
  182. package/example/node_modules/quantumcoin/test/unit/hashing.test.js +0 -64
  183. package/example/node_modules/quantumcoin/test/unit/hashing.test.ts +0 -63
  184. package/example/node_modules/quantumcoin/test/unit/init.test.js +0 -39
  185. package/example/node_modules/quantumcoin/test/unit/init.test.ts +0 -38
  186. package/example/node_modules/quantumcoin/test/unit/interface.test.js +0 -56
  187. package/example/node_modules/quantumcoin/test/unit/interface.test.ts +0 -54
  188. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.js +0 -81
  189. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.ts +0 -80
  190. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.js +0 -98
  191. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.ts +0 -64
  192. package/example/node_modules/quantumcoin/test/unit/providers.test.js +0 -252
  193. package/example/node_modules/quantumcoin/test/unit/providers.test.ts +0 -251
  194. package/example/node_modules/quantumcoin/test/unit/result.test.js +0 -80
  195. package/example/node_modules/quantumcoin/test/unit/result.test.ts +0 -79
  196. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.js +0 -49
  197. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.ts +0 -39
  198. package/example/node_modules/quantumcoin/test/unit/utils.test.js +0 -57
  199. package/example/node_modules/quantumcoin/test/unit/utils.test.ts +0 -56
  200. package/example/node_modules/quantumcoin/test/verbose-logger.js +0 -74
  201. package/example/node_modules/quantumcoin/tsconfig.build.json +0 -14
  202. package/example/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
  203. package/example/node_modules/seed-words/BUILD.md +0 -7
  204. package/example/node_modules/seed-words/LICENSE +0 -121
  205. package/example/node_modules/seed-words/README.md +0 -67
  206. package/example/node_modules/seed-words/dist/seedwords.d.ts +0 -39
  207. package/example/node_modules/seed-words/package.json +0 -27
  208. package/example/node_modules/seed-words/seedwords.js +0 -315
  209. package/example/node_modules/seed-words/seedwords.txt +0 -65536
  210. package/example/node_modules/seed-words/tsconfig.json +0 -21
  211. package/example/package-lock.json +0 -56
  212. package/example/package.json +0 -15
  213. package/tests/encrypted-32.json +0 -1
  214. package/tests/encrypted-36.json +0 -1
  215. package/tests/encrypted-48.json +0 -1
  216. package/tests/generate-verify-vectors.js +0 -91
  217. package/tests/get-gas-price.test.js +0 -59
  218. package/tests/non-transactional.preinit.test.js +0 -41
  219. package/tests/non-transactional.test.js +0 -1389
  220. package/tests/scrypt.test.js +0 -128
  221. package/tests/sign-raw-keytype5-context-null.test.js +0 -107
  222. package/tests/sign-raw-transaction.test.js +0 -196
  223. package/tests/sign-verify.test.js +0 -311
  224. package/tests/transactional.relay.test.js +0 -131
  225. package/tests/transactional.rpc.test.js +0 -103
  226. package/tests/verify-vectors.json +0 -95035
@@ -1,407 +0,0 @@
1
- /**
2
- * @testCategory e2e
3
- * @blockchainRequired write
4
- * @transactional true
5
- *
6
- * End-to-end test for the typed contract generator:
7
- * - Compiles a Solidity contract with a constructor parameter
8
- * - Generates a standalone typed-contract package into a temp folder
9
- * - Runs `npm install`
10
- * - Verifies tests/examples were generated
11
- * - Runs the generated package tests against the provided JSON-RPC URL
12
- */
13
-
14
- const { describe, it } = require("node:test");
15
- const assert = require("node:assert/strict");
16
- const fs = require("node:fs");
17
- const path = require("node:path");
18
- const os = require("node:os");
19
- const { execFileSync, spawnSync } = require("node:child_process");
20
-
21
- const { getRpcUrl, getChainId, getSolcPath, assertSolcExists, logE2eConfig } = require("./helpers");
22
- const { logSuite, logTest } = require("../verbose-logger");
23
-
24
- function getNpmCmd() {
25
- return process.platform === "win32" ? "npm.cmd" : "npm";
26
- }
27
-
28
- function run(cmd, args, cwd, env) {
29
- const res = spawnSync(cmd, args, {
30
- cwd,
31
- env,
32
- encoding: "utf8",
33
- stdio: "pipe",
34
- shell: false,
35
- windowsHide: true,
36
- });
37
- if (res.error) throw res.error;
38
- return res;
39
- }
40
-
41
- function _quoteIfNeeded(s) {
42
- if (typeof s !== "string") return s;
43
- return /[ \t"]/g.test(s) ? `"${s.replace(/"/g, '\\"')}"` : s;
44
- }
45
-
46
- function runNpm(args, cwd, env) {
47
- if (process.platform === "win32") {
48
- const cmd = `${getNpmCmd()} ${args.map(_quoteIfNeeded).join(" ")}`;
49
- return run("cmd.exe", ["/d", "/s", "/c", cmd], cwd, env);
50
- }
51
- return run(getNpmCmd(), args, cwd, env);
52
- }
53
-
54
- function compileSolidity({ solcPath, solPath, contractName }) {
55
- const out = execFileSync(solcPath, ["--optimize", "--combined-json", "abi,bin", solPath], { encoding: "utf8" });
56
- const parsed = JSON.parse(out);
57
- const key = Object.keys(parsed.contracts || {}).find((k) => k.endsWith(`:${contractName}`));
58
- if (!key) throw new Error(`Compiled contract ${contractName} not found in solc output`);
59
- const c = parsed.contracts[key];
60
- const abi = JSON.parse(c.abi);
61
- const bin = c.bin || "";
62
- return { abi, bin };
63
- }
64
-
65
- describe("typed contract generator package e2e", () => {
66
- it("generates a package and runs its transactional tests", async (t) => {
67
- logSuite("typed contract generator package e2e");
68
- logTest("generates a package and runs its transactional tests", {});
69
- const rpcUrl = getRpcUrl();
70
- if (!rpcUrl) {
71
- t.skip("QC_RPC_URL not provided");
72
- return;
73
- }
74
- logE2eConfig();
75
- const chainId = getChainId();
76
- const solcPath = getSolcPath();
77
- assertSolcExists(solcPath);
78
-
79
- const repoRoot = path.resolve(__dirname, "..", "..");
80
- const fixtureSol = path.join(repoRoot, "test", "fixtures", "ConstructorParam.sol");
81
- const contractName = "ConstructorParam";
82
-
83
- const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-"));
84
- const pkgName = `qcgen-${Date.now()}`;
85
- const pkgDir = tmpBase;
86
- const pkgRoot = path.join(pkgDir, pkgName);
87
-
88
- let succeeded = false;
89
- try {
90
- // 1) Compile fixture to ABI + BIN
91
- const { abi, bin } = compileSolidity({ solcPath, solPath: fixtureSol, contractName });
92
-
93
- const abiPath = path.join(tmpBase, `${contractName}.abi.json`);
94
- const binPath = path.join(tmpBase, `${contractName}.bin`);
95
- fs.writeFileSync(abiPath, JSON.stringify(abi, null, 2), "utf8");
96
- fs.writeFileSync(binPath, bin.trim().startsWith("0x") ? bin.trim() : `0x${bin.trim()}`, "utf8");
97
-
98
- // 2) Generate package
99
- const generatorCli = path.join(repoRoot, "generate-sdk.js");
100
- const gen = run(
101
- process.execPath,
102
- [
103
- generatorCli,
104
- "--abi",
105
- abiPath,
106
- "--bin",
107
- binPath,
108
- "--name",
109
- contractName,
110
- "--create-package",
111
- "--package-dir",
112
- pkgDir,
113
- "--package-name",
114
- pkgName,
115
- "--package-description",
116
- "Temporary typed-contract package generated by quantumcoin.js e2e tests",
117
- "--package-author",
118
- "quantumcoin.js test",
119
- "--package-license",
120
- "MIT",
121
- "--package-version",
122
- "0.0.1",
123
- "--non-interactive",
124
- ],
125
- repoRoot,
126
- process.env,
127
- );
128
- assert.equal(gen.status, 0, `generator failed:\n${gen.stdout}\n${gen.stderr}`);
129
-
130
- // 3) Verify expected files exist
131
- assert.ok(fs.existsSync(path.join(pkgRoot, "package.json")));
132
- assert.ok(fs.existsSync(path.join(pkgRoot, "tsconfig.json")));
133
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", `${contractName}.ts`)));
134
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", `${contractName}__factory.ts`)));
135
- assert.ok(fs.existsSync(path.join(pkgRoot, "test", "e2e", `${contractName}.e2e.test.js`)));
136
- assert.ok(fs.existsSync(path.join(pkgRoot, "examples", "deploy.js")));
137
- assert.ok(fs.existsSync(path.join(pkgRoot, "examples", "read-operations.js")));
138
- assert.ok(fs.existsSync(path.join(pkgRoot, "examples", "write-operations.js")));
139
- assert.ok(fs.existsSync(path.join(pkgRoot, "examples", "events.js")));
140
- assert.ok(fs.existsSync(path.join(pkgRoot, "index.js")));
141
- assert.ok(fs.existsSync(path.join(pkgRoot, "index.d.ts")));
142
- assert.ok(fs.existsSync(path.join(pkgRoot, "README.md")));
143
-
144
- // This test uses ABI+BIN input, so Solidity source comments are not available here.
145
- // Ensure the doc build ran and included the contract name.
146
- const readme = fs.readFileSync(path.join(pkgRoot, "README.md"), "utf8");
147
- assert.ok(readme.includes(contractName));
148
-
149
- // 4) Install deps (generator runs install+build, but keep this idempotent)
150
- if (!fs.existsSync(path.join(pkgRoot, "node_modules"))) {
151
- const install = runNpm(["install", "--no-fund", "--no-audit"], pkgRoot, process.env);
152
- assert.equal(install.status, 0, `npm install failed:\n${install.stdout}\n${install.stderr}`);
153
- }
154
-
155
- // 5) Run generated tests against the configured chain
156
- const env = {
157
- ...process.env,
158
- QC_RPC_URL: rpcUrl,
159
- QC_CHAIN_ID: String(chainId),
160
- };
161
- const testRun = runNpm(["test"], pkgRoot, env);
162
- assert.equal(testRun.status, 0, `generated package tests failed:\n${testRun.stdout}\n${testRun.stderr}`);
163
-
164
- succeeded = true;
165
- } finally {
166
- // Keep artifacts on failure for debugging.
167
- if (succeeded) {
168
- fs.rmSync(tmpBase, { recursive: true, force: true });
169
- } else {
170
- // eslint-disable-next-line no-console
171
- console.error("Generated package kept at:", pkgRoot);
172
- }
173
- }
174
- }, { timeout: 1_800_000 });
175
-
176
- it("generates a package from artifacts JSON input (multiple contracts) and runs its transactional tests", async (t) => {
177
- const rpcUrl = getRpcUrl();
178
- if (!rpcUrl) {
179
- t.skip("QC_RPC_URL not provided");
180
- return;
181
- }
182
-
183
- const chainId = getChainId();
184
- const solcPath = getSolcPath();
185
- assertSolcExists(solcPath);
186
-
187
- const repoRoot = path.resolve(__dirname, "..", "..");
188
- const fixtureCtorSol = path.join(repoRoot, "test", "fixtures", "ConstructorParam.sol");
189
- const fixtureMultiSol = path.join(repoRoot, "test", "fixtures", "MultiContracts.sol");
190
-
191
- const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-json-"));
192
- const pkgName = `qcgen-json-${Date.now()}`;
193
- const pkgDir = tmpBase;
194
- const pkgRoot = path.join(pkgDir, pkgName);
195
-
196
- let succeeded = false;
197
- try {
198
- // Compile 2 contracts into ABI+BIN pairs
199
- const ctorName = "ConstructorParam";
200
- const alphaName = "Alpha";
201
-
202
- const { abi: ctorAbi, bin: ctorBin } = compileSolidity({ solcPath, solPath: fixtureCtorSol, contractName: ctorName });
203
- const { abi: alphaAbi, bin: alphaBin } = compileSolidity({ solcPath, solPath: fixtureMultiSol, contractName: alphaName });
204
-
205
- const ctorAbiPath = path.join(tmpBase, `${ctorName}.abi.json`);
206
- const ctorBinPath = path.join(tmpBase, `${ctorName}.bin`);
207
- fs.writeFileSync(ctorAbiPath, JSON.stringify(ctorAbi, null, 2), "utf8");
208
- fs.writeFileSync(ctorBinPath, ctorBin.trim().startsWith("0x") ? ctorBin.trim() : `0x${ctorBin.trim()}`, "utf8");
209
-
210
- const alphaAbiPath = path.join(tmpBase, `${alphaName}.abi.json`);
211
- const alphaBinPath = path.join(tmpBase, `${alphaName}.bin`);
212
- fs.writeFileSync(alphaAbiPath, JSON.stringify(alphaAbi, null, 2), "utf8");
213
- fs.writeFileSync(alphaBinPath, alphaBin.trim().startsWith("0x") ? alphaBin.trim() : `0x${alphaBin.trim()}`, "utf8");
214
-
215
- const artifactsJsonPath = path.join(tmpBase, "artifacts.json");
216
- fs.writeFileSync(
217
- artifactsJsonPath,
218
- JSON.stringify(
219
- [
220
- { abi: path.basename(alphaAbiPath), bin: path.basename(alphaBinPath) },
221
- { abi: path.basename(ctorAbiPath), bin: path.basename(ctorBinPath) },
222
- ],
223
- null,
224
- 2,
225
- ),
226
- "utf8",
227
- );
228
-
229
- // Generate package using artifacts JSON input
230
- const generatorCli = path.join(repoRoot, "generate-sdk.js");
231
- const gen = run(
232
- process.execPath,
233
- [
234
- generatorCli,
235
- "--artifacts-json",
236
- artifactsJsonPath,
237
- "--create-package",
238
- "--package-dir",
239
- pkgDir,
240
- "--package-name",
241
- pkgName,
242
- "--package-description",
243
- "Temporary typed-contract package generated from artifacts JSON input",
244
- "--package-author",
245
- "quantumcoin.js test",
246
- "--package-license",
247
- "MIT",
248
- "--package-version",
249
- "0.0.1",
250
- "--non-interactive",
251
- ],
252
- repoRoot,
253
- process.env,
254
- );
255
- assert.equal(gen.status, 0, `generator failed:\n${gen.stdout}\n${gen.stderr}`);
256
-
257
- // Verify multiple contracts were generated
258
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "Alpha.ts")));
259
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "Alpha__factory.ts")));
260
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "ConstructorParam.ts")));
261
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "ConstructorParam__factory.ts")));
262
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "index.ts")));
263
- assert.ok(fs.existsSync(path.join(pkgRoot, "index.js")));
264
- assert.ok(fs.existsSync(path.join(pkgRoot, "index.d.ts")));
265
- assert.ok(fs.existsSync(path.join(pkgRoot, "README.md")));
266
-
267
- // Verify tests exist for each contract
268
- assert.ok(fs.existsSync(path.join(pkgRoot, "test", "e2e", "Alpha.e2e.test.js")));
269
- assert.ok(fs.existsSync(path.join(pkgRoot, "test", "e2e", "ConstructorParam.e2e.test.js")));
270
- assert.ok(fs.existsSync(path.join(pkgRoot, "test", "e2e", "all-contracts.e2e.test.js")));
271
-
272
- // Multi-contract packages use per-contract example filenames.
273
- assert.ok(fs.existsSync(path.join(pkgRoot, "examples", "deploy-Alpha.js")));
274
- assert.ok(fs.existsSync(path.join(pkgRoot, "examples", "deploy-ConstructorParam.js")));
275
-
276
- const readme = fs.readFileSync(path.join(pkgRoot, "README.md"), "utf8");
277
- assert.ok(readme.includes("Alpha"));
278
- assert.ok(readme.includes("ConstructorParam"));
279
-
280
- // Install deps + run tests against chain
281
- if (!fs.existsSync(path.join(pkgRoot, "node_modules"))) {
282
- const install = runNpm(["install", "--no-fund", "--no-audit"], pkgRoot, process.env);
283
- assert.equal(install.status, 0, `npm install failed:\n${install.stdout}\n${install.stderr}`);
284
- }
285
-
286
- const env = {
287
- ...process.env,
288
- QC_RPC_URL: rpcUrl,
289
- QC_CHAIN_ID: String(chainId),
290
- };
291
- const testRun = runNpm(["test"], pkgRoot, env);
292
- assert.equal(testRun.status, 0, `generated package tests failed:\n${testRun.stdout}\n${testRun.stderr}`);
293
-
294
- succeeded = true;
295
- } finally {
296
- if (succeeded) {
297
- fs.rmSync(tmpBase, { recursive: true, force: true });
298
- } else {
299
- // eslint-disable-next-line no-console
300
- console.error("Generated package kept at:", pkgRoot);
301
- }
302
- }
303
- }, { timeout: 1_800_000 });
304
-
305
- it("generates a package from Solidity input (multiple contracts) and runs its transactional tests", async (t) => {
306
- const rpcUrl = getRpcUrl();
307
- if (!rpcUrl) {
308
- t.skip("QC_RPC_URL not provided");
309
- return;
310
- }
311
-
312
- const chainId = getChainId();
313
- const solcPath = getSolcPath();
314
- assertSolcExists(solcPath);
315
-
316
- const repoRoot = path.resolve(__dirname, "..", "..");
317
- const fixtureSol = path.join(repoRoot, "test", "fixtures", "MultiContracts.sol");
318
-
319
- const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-sol-"));
320
- const pkgName = `qcgen-sol-${Date.now()}`;
321
- const pkgDir = tmpBase;
322
- const pkgRoot = path.join(pkgDir, pkgName);
323
-
324
- let succeeded = false;
325
- try {
326
- // Generate package directly from Solidity sources
327
- const generatorCli = path.join(repoRoot, "generate-sdk.js");
328
- const gen = run(
329
- process.execPath,
330
- [
331
- generatorCli,
332
- "--sol",
333
- fixtureSol,
334
- "--solc",
335
- solcPath,
336
- "--create-package",
337
- "--package-dir",
338
- pkgDir,
339
- "--package-name",
340
- pkgName,
341
- "--package-description",
342
- "Temporary typed-contract package generated from Solidity input",
343
- "--package-author",
344
- "quantumcoin.js test",
345
- "--package-license",
346
- "MIT",
347
- "--package-version",
348
- "0.0.1",
349
- "--non-interactive",
350
- ],
351
- repoRoot,
352
- process.env,
353
- );
354
- assert.equal(gen.status, 0, `generator failed:\n${gen.stdout}\n${gen.stderr}`);
355
-
356
- // Verify multiple contracts were generated
357
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "Alpha.ts")));
358
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "Alpha__factory.ts")));
359
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "Beta.ts")));
360
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "Beta__factory.ts")));
361
- assert.ok(fs.existsSync(path.join(pkgRoot, "src", "index.ts")));
362
- assert.ok(fs.existsSync(path.join(pkgRoot, "index.js")));
363
- assert.ok(fs.existsSync(path.join(pkgRoot, "index.d.ts")));
364
- assert.ok(fs.existsSync(path.join(pkgRoot, "README.md")));
365
-
366
- // Verify artifacts were emitted
367
- assert.ok(fs.existsSync(path.join(pkgRoot, "artifacts", "Alpha.abi.json")));
368
- assert.ok(fs.existsSync(path.join(pkgRoot, "artifacts", "Alpha.bin")));
369
- assert.ok(fs.existsSync(path.join(pkgRoot, "artifacts", "Beta.abi.json")));
370
- assert.ok(fs.existsSync(path.join(pkgRoot, "artifacts", "Beta.bin")));
371
-
372
- // Verify tests exist for each contract
373
- assert.ok(fs.existsSync(path.join(pkgRoot, "test", "e2e", "Alpha.e2e.test.js")));
374
- assert.ok(fs.existsSync(path.join(pkgRoot, "test", "e2e", "Beta.e2e.test.js")));
375
- assert.ok(fs.existsSync(path.join(pkgRoot, "test", "e2e", "all-contracts.e2e.test.js")));
376
-
377
- // Verify Solidity comments were propagated into generated TS
378
- const alphaTs = fs.readFileSync(path.join(pkgRoot, "src", "Alpha.ts"), "utf8");
379
- assert.ok(alphaTs.includes("Alpha contract for multi-contract generator test."));
380
- assert.ok(alphaTs.includes("Set a new value in Alpha."));
381
-
382
- // Install deps + run tests against chain
383
- if (!fs.existsSync(path.join(pkgRoot, "node_modules"))) {
384
- const install = runNpm(["install", "--no-fund", "--no-audit"], pkgRoot, process.env);
385
- assert.equal(install.status, 0, `npm install failed:\n${install.stdout}\n${install.stderr}`);
386
- }
387
-
388
- const env = {
389
- ...process.env,
390
- QC_RPC_URL: rpcUrl,
391
- QC_CHAIN_ID: String(chainId),
392
- };
393
- const testRun = runNpm(["test"], pkgRoot, env);
394
- assert.equal(testRun.status, 0, `generated package tests failed:\n${testRun.stdout}\n${testRun.stderr}`);
395
-
396
- succeeded = true;
397
- } finally {
398
- if (succeeded) {
399
- fs.rmSync(tmpBase, { recursive: true, force: true });
400
- } else {
401
- // eslint-disable-next-line no-console
402
- console.error("Generated package kept at:", pkgRoot);
403
- }
404
- }
405
- }, { timeout: 1_800_000 });
406
- });
407
-