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,148 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Typed contract generator (file output shape)
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
- import fs from "node:fs";
11
- import os from "node:os";
12
- import path from "node:path";
13
-
14
- import { generate, generateFromArtifacts, generateTransactionalTestJs } from "../../src/generator";
15
- import { logSuite, logTest } from "../verbose-logger";
16
-
17
- describe("typed contract generator", () => {
18
- logSuite("typed contract generator");
19
- it("generates contract + factory + types + index files", () => {
20
- logTest("generates contract + factory + types + index files", {});
21
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-"));
22
- const abiPath = path.join(tmp, "Test.abi.json");
23
- const binPath = path.join(tmp, "Test.bin");
24
- const outDir = path.join(tmp, "out");
25
-
26
- const abi = [
27
- {
28
- type: "function",
29
- name: "balanceOf",
30
- stateMutability: "view",
31
- inputs: [{ name: "account", type: "address" }],
32
- outputs: [{ name: "", type: "uint256" }],
33
- },
34
- {
35
- type: "function",
36
- name: "transfer",
37
- stateMutability: "nonpayable",
38
- inputs: [
39
- { name: "to", type: "address" },
40
- { name: "amount", type: "uint256" },
41
- ],
42
- outputs: [{ name: "", type: "bool" }],
43
- },
44
- ];
45
-
46
- fs.writeFileSync(abiPath, JSON.stringify(abi, null, 2), "utf8");
47
- fs.writeFileSync(binPath, "0x6000", "utf8");
48
-
49
- const res = generate({ abiPath, binPath, outDir, contractName: "TestToken" });
50
- assert.ok(fs.existsSync(res.contractFile));
51
- assert.ok(fs.existsSync(res.factoryFile));
52
- assert.ok(fs.existsSync(res.typesFile));
53
- assert.ok(fs.existsSync(res.indexFile));
54
-
55
- const contractSrc = fs.readFileSync(res.contractFile, "utf8");
56
- assert.ok(contractSrc.includes("export class TestToken"));
57
- assert.ok(contractSrc.includes("async balanceOf"));
58
- assert.ok(contractSrc.includes("async transfer"));
59
- assert.ok(contractSrc.includes("populateTransaction"));
60
-
61
- const factorySrc = fs.readFileSync(res.factoryFile, "utf8");
62
- assert.ok(factorySrc.includes("export class TestToken__factory"));
63
- });
64
-
65
- it("generated test for a concrete contract (with bytecode) contains the provider.getCode bytecode assertion", () => {
66
- logTest("generated test for a concrete contract contains the bytecode assertion", {});
67
- const src = generateTransactionalTestJs({
68
- contractName: "ConcreteToken",
69
- abi: [{ type: "constructor", inputs: [], stateMutability: "nonpayable" }],
70
- bytecode: "0x6080604052",
71
- });
72
- assert.ok(src.includes("provider.getCode(contract.target"));
73
- assert.ok(src.includes('assert.ok(code && code !== "0x")'));
74
- assert.ok(!src.includes("Skipping bytecode check"));
75
- });
76
-
77
- it("generated test for an interface (bytecode '0x') omits the provider.getCode bytecode assertion", () => {
78
- logTest("generated test for an interface omits the bytecode assertion", {});
79
- const src = generateTransactionalTestJs({
80
- contractName: "IThing",
81
- abi: [{
82
- type: "function", name: "doThing",
83
- inputs: [], outputs: [], stateMutability: "nonpayable",
84
- }],
85
- bytecode: "0x",
86
- });
87
- assert.ok(!src.includes("provider.getCode(contract.target"));
88
- assert.ok(!src.includes('assert.ok(code && code !== "0x")'));
89
- assert.ok(src.includes("Skipping bytecode check"));
90
- assert.ok(src.includes("IThing is an interface"));
91
- });
92
-
93
- it("empty/undefined/null/'0X' bytecode variants are all treated as interface", () => {
94
- logTest("empty bytecode variants are all treated as interface", {});
95
- for (const bc of [undefined, null, "", "0x", "0X", " 0x "] as Array<string | null | undefined>) {
96
- const src = generateTransactionalTestJs({
97
- contractName: "IThing",
98
- abi: [],
99
- bytecode: bc as unknown as string,
100
- });
101
- assert.ok(
102
- !src.includes("provider.getCode(contract.target"),
103
- `bytecode=${JSON.stringify(bc)} should be treated as interface (no getCode assertion)`,
104
- );
105
- assert.ok(
106
- src.includes("Skipping bytecode check"),
107
- `bytecode=${JSON.stringify(bc)} should emit skip comment`,
108
- );
109
- }
110
- });
111
-
112
- it("includes injected docs in generated TypeScript", () => {
113
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-docs-"));
114
- const outDir = path.join(tmp, "out");
115
-
116
- const abi = [
117
- {
118
- type: "function",
119
- name: "set",
120
- stateMutability: "nonpayable",
121
- inputs: [{ name: "value", type: "uint256" }],
122
- outputs: [],
123
- },
124
- ];
125
-
126
- const res = generateFromArtifacts({
127
- outDir,
128
- artifacts: [
129
- {
130
- contractName: "DocToken",
131
- abi,
132
- bytecode: "0x6000",
133
- docs: {
134
- contract: "Example contract doc from Solidity.",
135
- functions: {
136
- set: "Example function doc from Solidity.",
137
- },
138
- },
139
- },
140
- ],
141
- });
142
-
143
- const contractFile = res.contracts[0].contractFile;
144
- const src = fs.readFileSync(contractFile, "utf8");
145
- assert.ok(src.includes("Example contract doc from Solidity."));
146
- assert.ok(src.includes("Example function doc from Solidity."));
147
- });
148
- });
@@ -1,64 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Hashing helpers (optional params, deterministic behavior)
6
- */
7
-
8
- const { describe, it } = require("node:test");
9
- const assert = require("node:assert/strict");
10
-
11
- const qc = require("../../index");
12
- const { logSuite, logTest } = require("../verbose-logger");
13
-
14
- describe("Hashing", () => {
15
- logSuite("Hashing");
16
- it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
17
- logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
18
- const out = qc.keccak256(new Uint8Array([]));
19
- assert.equal(typeof out, "string");
20
- assert.ok(out.startsWith("0x"));
21
- assert.equal(out.length, 66);
22
- });
23
-
24
- it("sha256/sha512/ripemd160 output lengths are correct", () => {
25
- const data = qc.toUtf8Bytes("hello");
26
- assert.equal(qc.sha256(data).length, 66);
27
- assert.equal(qc.sha512(data).length, 130);
28
- assert.equal(qc.ripemd160(data).length, 42);
29
- });
30
-
31
- it("randomBytes returns requested length", () => {
32
- const b = qc.randomBytes(16);
33
- assert.ok(b instanceof Uint8Array);
34
- assert.equal(b.length, 16);
35
- });
36
-
37
- it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
38
- const pw = qc.toUtf8Bytes("password");
39
- const salt = qc.toUtf8Bytes("salt");
40
-
41
- const a = qc.pbkdf2(pw, salt, 1, 32);
42
- const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
43
- const c = qc.pbkdf2(pw, salt, 1, 32, null);
44
-
45
- assert.equal(a, b);
46
- assert.equal(a, c);
47
- assert.ok(a.startsWith("0x") && a.length === 66);
48
- });
49
-
50
- it("computeHmac produces a hex string", () => {
51
- const key = qc.toUtf8Bytes("key");
52
- const data = qc.toUtf8Bytes("data");
53
- const out = qc.computeHmac("sha256", key, data);
54
- assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
55
- });
56
-
57
- it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
58
- const pw = qc.toUtf8Bytes("password");
59
- const salt = qc.toUtf8Bytes("salt");
60
- const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
61
- assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
62
- });
63
- });
64
-
@@ -1,63 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Hashing helpers (optional params, deterministic behavior)
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
-
11
- import qc from "../../index";
12
- import { logSuite, logTest } from "../verbose-logger";
13
-
14
- describe("Hashing", () => {
15
- logSuite("Hashing");
16
- it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
17
- logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
18
- const out = qc.keccak256(new Uint8Array([]));
19
- assert.equal(typeof out, "string");
20
- assert.ok(out.startsWith("0x"));
21
- assert.equal(out.length, 66);
22
- });
23
-
24
- it("sha256/sha512/ripemd160 output lengths are correct", () => {
25
- const data = qc.toUtf8Bytes("hello");
26
- assert.equal(qc.sha256(data).length, 66);
27
- assert.equal(qc.sha512(data).length, 130);
28
- assert.equal(qc.ripemd160(data).length, 42);
29
- });
30
-
31
- it("randomBytes returns requested length", () => {
32
- const b = qc.randomBytes(16);
33
- assert.ok(b instanceof Uint8Array);
34
- assert.equal(b.length, 16);
35
- });
36
-
37
- it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
38
- const pw = qc.toUtf8Bytes("password");
39
- const salt = qc.toUtf8Bytes("salt");
40
-
41
- const a = qc.pbkdf2(pw, salt, 1, 32);
42
- const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
43
- const c = qc.pbkdf2(pw, salt, 1, 32, null);
44
-
45
- assert.equal(a, b);
46
- assert.equal(a, c);
47
- assert.ok(a.startsWith("0x") && a.length === 66);
48
- });
49
-
50
- it("computeHmac produces a hex string", () => {
51
- const key = qc.toUtf8Bytes("key");
52
- const data = qc.toUtf8Bytes("data");
53
- const out = qc.computeHmac("sha256", key, data);
54
- assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
55
- });
56
-
57
- it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
58
- const pw = qc.toUtf8Bytes("password");
59
- const salt = qc.toUtf8Bytes("salt");
60
- const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
61
- assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
62
- });
63
- });
@@ -1,39 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description SDK initialization and basic constants
6
- */
7
-
8
- const { describe, it } = require("node:test");
9
- const assert = require("node:assert/strict");
10
-
11
- const { Initialize, isInitialized, Config } = require("../../config");
12
- const qc = require("../../index");
13
- const { logSuite, logTest } = require("../verbose-logger");
14
-
15
- describe("Initialize()", () => {
16
- logSuite("Initialize()");
17
- it("initializes with default config (null)", async () => {
18
- logTest("initializes with default config (null)", {});
19
- const ok = await Initialize(null);
20
- assert.equal(ok, true);
21
- assert.equal(isInitialized(), true);
22
- });
23
-
24
- it("exposes constants with QuantumCoin address size", async () => {
25
- await Initialize(null);
26
- assert.equal(typeof qc.version, "string");
27
- assert.equal(qc.ZeroAddress.length, 66);
28
- assert.equal(qc.ZeroHash.length, 66);
29
- assert.equal(qc.ZeroAddress, "0x" + "00".repeat(32));
30
- assert.equal(qc.WeiPerEther, 1000000000000000000n);
31
- });
32
-
33
- it("Config defaults match SPEC.md", () => {
34
- const cfg = new Config();
35
- assert.equal(cfg.chainId, 123123);
36
- assert.equal(cfg.rpcEndpoint, "https://public.rpc.quantumcoinapi.com");
37
- });
38
- });
39
-
@@ -1,38 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description SDK initialization and basic constants
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
-
11
- import { Initialize, isInitialized, Config } from "../../config";
12
- import qc from "../../index";
13
- import { logSuite, logTest } from "../verbose-logger";
14
-
15
- describe("Initialize()", () => {
16
- logSuite("Initialize()");
17
- it("initializes with default config (null)", async () => {
18
- logTest("initializes with default config (null)", {});
19
- const ok = await Initialize(null);
20
- assert.equal(ok, true);
21
- assert.equal(isInitialized(), true);
22
- });
23
-
24
- it("exposes constants with QuantumCoin address size", async () => {
25
- await Initialize(null);
26
- assert.equal(typeof qc.version, "string");
27
- assert.equal(qc.ZeroAddress.length, 66);
28
- assert.equal(qc.ZeroHash.length, 66);
29
- assert.equal(qc.ZeroAddress, "0x" + "00".repeat(32));
30
- assert.equal(qc.WeiPerEther, 1000000000000000000n);
31
- });
32
-
33
- it("Config defaults match SPEC.md", () => {
34
- const cfg = new Config();
35
- assert.equal(cfg.chainId, 123123);
36
- assert.equal(cfg.rpcEndpoint, "https://public.rpc.quantumcoinapi.com");
37
- });
38
- });
@@ -1,56 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @description Interface.parseLog (event decoding) using quantum-coin-js-sdk decodeEventLog
5
- */
6
-
7
- const { describe, it } = require("node:test");
8
- const assert = require("node:assert/strict");
9
-
10
- const { Initialize } = require("../../config");
11
- const qc = require("../../index");
12
- const { logSuite, logTest } = require("../verbose-logger");
13
-
14
- describe("Interface.parseLog", () => {
15
- logSuite("Interface.parseLog");
16
- it("parses an encoded event log and returns LogDescription-like result", async () => {
17
- logTest("parses an encoded event log and returns LogDescription-like result", {});
18
- await Initialize(null);
19
-
20
- const abi = [
21
- {
22
- name: "Transfer",
23
- type: "event",
24
- anonymous: false,
25
- inputs: [
26
- { name: "from", type: "address", indexed: true },
27
- { name: "to", type: "address", indexed: true },
28
- { name: "value", type: "uint256", indexed: false },
29
- ],
30
- },
31
- ];
32
-
33
- const iface = new qc.Interface(abi);
34
- const from = qc.Wallet.createRandom().address;
35
- const to = qc.Wallet.createRandom().address;
36
- const value = 123n;
37
-
38
- const encoded = iface.encodeEventLog("Transfer", [from, to, value]);
39
- assert.ok(Array.isArray(encoded.topics) && encoded.topics.length >= 1);
40
- assert.ok(typeof encoded.data === "string");
41
-
42
- const parsed = iface.parseLog({ topics: encoded.topics, data: encoded.data });
43
- assert.equal(parsed.name, "Transfer");
44
- assert.ok(parsed.topic && parsed.topic.startsWith("0x"));
45
- assert.ok(parsed.signature.includes("Transfer("));
46
-
47
- // Args should be array-like and have named keys
48
- assert.equal(parsed.args.from.toLowerCase(), from.toLowerCase());
49
- assert.equal(parsed.args.to.toLowerCase(), to.toLowerCase());
50
- assert.equal(BigInt(parsed.args.value), value);
51
- assert.equal(parsed.args[0].toLowerCase(), from.toLowerCase());
52
- assert.equal(parsed.args[1].toLowerCase(), to.toLowerCase());
53
- assert.equal(BigInt(parsed.args[2]), value);
54
- });
55
- });
56
-
@@ -1,54 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @description Interface.parseLog (event decoding) using quantum-coin-js-sdk decodeEventLog
5
- */
6
-
7
- import { describe, it } from "node:test";
8
- import assert from "node:assert/strict";
9
-
10
- import { Initialize } from "../../config";
11
- import qc from "../../index";
12
- import { logSuite, logTest } from "../verbose-logger";
13
-
14
- describe("Interface.parseLog", () => {
15
- logSuite("Interface.parseLog");
16
- it("parses an encoded event log and returns LogDescription-like result", async () => {
17
- logTest("parses an encoded event log and returns LogDescription-like result", {});
18
- await Initialize(null);
19
-
20
- const abi = [
21
- {
22
- name: "Transfer",
23
- type: "event",
24
- anonymous: false,
25
- inputs: [
26
- { name: "from", type: "address", indexed: true },
27
- { name: "to", type: "address", indexed: true },
28
- { name: "value", type: "uint256", indexed: false },
29
- ],
30
- },
31
- ];
32
-
33
- const iface = new qc.Interface(abi);
34
- const from = qc.Wallet.createRandom().address;
35
- const to = qc.Wallet.createRandom().address;
36
- const value = 123n;
37
-
38
- const encoded = iface.encodeEventLog("Transfer", [from, to, value]);
39
- assert.ok(Array.isArray(encoded.topics) && encoded.topics.length >= 1);
40
- assert.ok(typeof encoded.data === "string");
41
-
42
- const parsed = iface.parseLog({ topics: encoded.topics, data: encoded.data });
43
- assert.equal(parsed.name, "Transfer");
44
- assert.ok(parsed.topic && parsed.topic.startsWith("0x"));
45
- assert.ok(parsed.signature.includes("Transfer("));
46
-
47
- assert.equal(parsed.args.from.toLowerCase(), from.toLowerCase());
48
- assert.equal(parsed.args.to.toLowerCase(), to.toLowerCase());
49
- assert.equal(BigInt(parsed.args.value), value);
50
- assert.equal(parsed.args[0].toLowerCase(), from.toLowerCase());
51
- assert.equal(parsed.args[1].toLowerCase(), to.toLowerCase());
52
- assert.equal(BigInt(parsed.args[2]), value);
53
- });
54
- });
@@ -1,81 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Internal hex utilities (optional params, edge cases)
6
- */
7
-
8
- const { describe, it } = require("node:test");
9
- const assert = require("node:assert/strict");
10
-
11
- const { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } = require("../../src/internal/hex");
12
- const { logSuite, logTest } = require("../verbose-logger");
13
-
14
- describe("internal/hex", () => {
15
- logSuite("internal/hex");
16
- it("normalizeHex lowercases, adds 0x, pads odd length", () => {
17
- logTest("normalizeHex lowercases, adds 0x, pads odd length", {});
18
- assert.equal(normalizeHex("aa"), "0xaa");
19
- assert.equal(normalizeHex("0xAa"), "0xaa");
20
- assert.equal(normalizeHex("0xa"), "0x0a");
21
- assert.equal(normalizeHex("0x0A"), "0x0a");
22
- });
23
-
24
- it("toQuantityHex produces spec-compliant quantities (no leading zeros, 0x0 for zero)", () => {
25
- logTest("toQuantityHex produces spec-compliant quantities", {});
26
- assert.equal(toQuantityHex(0), "0x0");
27
- assert.equal(toQuantityHex(0n), "0x0");
28
- assert.equal(toQuantityHex(1), "0x1");
29
- assert.equal(toQuantityHex(5), "0x5");
30
- assert.equal(toQuantityHex(15), "0xf");
31
- assert.equal(toQuantityHex(16), "0x10");
32
- assert.equal(toQuantityHex(255), "0xff");
33
- assert.equal(toQuantityHex(256), "0x100");
34
- assert.equal(toQuantityHex(4095), "0xfff");
35
- assert.equal(toQuantityHex(4096), "0x1000");
36
- assert.equal(toQuantityHex(65535n), "0xffff");
37
- assert.equal(toQuantityHex(2n ** 64n), "0x10000000000000000");
38
-
39
- assert.equal(toQuantity, toQuantityHex);
40
- assert.equal(toQuantity(5), "0x5");
41
- });
42
-
43
- it("toQuantityHex rejects invalid inputs", () => {
44
- logTest("toQuantityHex rejects invalid inputs", {});
45
- assert.throws(() => toQuantityHex(-1), RangeError);
46
- assert.throws(() => toQuantityHex(-1n), RangeError);
47
- assert.throws(() => toQuantityHex(1.5), TypeError);
48
- assert.throws(() => toQuantityHex(NaN), TypeError);
49
- assert.throws(() => toQuantityHex(Infinity), TypeError);
50
- assert.throws(() => toQuantityHex("5"), TypeError);
51
- assert.throws(() => toQuantityHex(null), TypeError);
52
- assert.throws(() => toQuantityHex(undefined), TypeError);
53
- });
54
-
55
- it("isHexString validates and supports optional lengthBytes", () => {
56
- const h32 = "0x" + "11".repeat(32);
57
- assert.equal(isHexString(h32), true);
58
- assert.equal(isHexString(h32, 32), true);
59
- assert.equal(isHexString(h32, null), true); // optional param passed as null => ignored
60
- assert.equal(isHexString(h32, 31), false);
61
-
62
- assert.equal(isHexString("0x"), false);
63
- assert.equal(isHexString("0x0"), false); // odd length after 0x
64
- assert.equal(isHexString("0xzz"), false);
65
- });
66
-
67
- it("hexToBytes/bytesToHex roundtrip", () => {
68
- const h = "0x1234abcd";
69
- const b = hexToBytes(h);
70
- assert.ok(b instanceof Uint8Array);
71
- assert.equal(bytesToHex(b), h);
72
- });
73
-
74
- it("arrayify accepts hex string and Uint8Array; rejects others", () => {
75
- assert.deepEqual(arrayify("0x1234"), new Uint8Array([0x12, 0x34]));
76
- assert.deepEqual(arrayify(new Uint8Array([1, 2, 3])), new Uint8Array([1, 2, 3]));
77
- assert.throws(() => arrayify("not-hex"));
78
- assert.throws(() => arrayify(123));
79
- });
80
- });
81
-
@@ -1,80 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Internal hex utilities (optional params, edge cases)
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
-
11
- import { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } from "../../src/internal/hex";
12
- import { logSuite, logTest } from "../verbose-logger";
13
-
14
- describe("internal/hex", () => {
15
- logSuite("internal/hex");
16
- it("normalizeHex lowercases, adds 0x, pads odd length", () => {
17
- logTest("normalizeHex lowercases, adds 0x, pads odd length", {});
18
- assert.equal(normalizeHex("aa"), "0xaa");
19
- assert.equal(normalizeHex("0xAa"), "0xaa");
20
- assert.equal(normalizeHex("0xa"), "0x0a");
21
- assert.equal(normalizeHex("0x0A"), "0x0a");
22
- });
23
-
24
- it("toQuantityHex produces spec-compliant quantities (no leading zeros, 0x0 for zero)", () => {
25
- logTest("toQuantityHex produces spec-compliant quantities", {});
26
- assert.equal(toQuantityHex(0), "0x0");
27
- assert.equal(toQuantityHex(0n), "0x0");
28
- assert.equal(toQuantityHex(1), "0x1");
29
- assert.equal(toQuantityHex(5), "0x5");
30
- assert.equal(toQuantityHex(15), "0xf");
31
- assert.equal(toQuantityHex(16), "0x10");
32
- assert.equal(toQuantityHex(255), "0xff");
33
- assert.equal(toQuantityHex(256), "0x100");
34
- assert.equal(toQuantityHex(4095), "0xfff");
35
- assert.equal(toQuantityHex(4096), "0x1000");
36
- assert.equal(toQuantityHex(65535n), "0xffff");
37
- assert.equal(toQuantityHex(2n ** 64n), "0x10000000000000000");
38
-
39
- assert.equal(toQuantity, toQuantityHex);
40
- assert.equal(toQuantity(5), "0x5");
41
- });
42
-
43
- it("toQuantityHex rejects invalid inputs", () => {
44
- logTest("toQuantityHex rejects invalid inputs", {});
45
- assert.throws(() => toQuantityHex(-1), RangeError);
46
- assert.throws(() => toQuantityHex(-1n), RangeError);
47
- assert.throws(() => toQuantityHex(1.5), TypeError);
48
- assert.throws(() => toQuantityHex(NaN), TypeError);
49
- assert.throws(() => toQuantityHex(Infinity), TypeError);
50
- assert.throws(() => toQuantityHex("5" as unknown as number), TypeError);
51
- assert.throws(() => toQuantityHex(null as unknown as number), TypeError);
52
- assert.throws(() => toQuantityHex(undefined as unknown as number), TypeError);
53
- });
54
-
55
- it("isHexString validates and supports optional lengthBytes", () => {
56
- const h32 = "0x" + "11".repeat(32);
57
- assert.equal(isHexString(h32), true);
58
- assert.equal(isHexString(h32, 32), true);
59
- assert.equal(isHexString(h32, null), true); // optional param passed as null => ignored
60
- assert.equal(isHexString(h32, 31), false);
61
-
62
- assert.equal(isHexString("0x"), false);
63
- assert.equal(isHexString("0x0"), false); // odd length after 0x
64
- assert.equal(isHexString("0xzz"), false);
65
- });
66
-
67
- it("hexToBytes/bytesToHex roundtrip", () => {
68
- const h = "0x1234abcd";
69
- const b = hexToBytes(h);
70
- assert.ok(b instanceof Uint8Array);
71
- assert.equal(bytesToHex(b), h);
72
- });
73
-
74
- it("arrayify accepts hex string and Uint8Array; rejects others", () => {
75
- assert.deepEqual(arrayify("0x1234"), new Uint8Array([0x12, 0x34]));
76
- assert.deepEqual(arrayify(new Uint8Array([1, 2, 3])), new Uint8Array([1, 2, 3]));
77
- assert.throws(() => arrayify("not-hex"));
78
- assert.throws(() => arrayify(123 as unknown));
79
- });
80
- });