quantum-coin-js-sdk 2.0.1 → 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 (232) hide show
  1. package/README.md +13 -0
  2. package/index.d.ts +9 -0
  3. package/index.js +37 -4
  4. package/package.json +12 -4
  5. package/wasmBase64.js +3 -2
  6. package/.idea/.name +0 -1
  7. package/.idea/modules.xml +0 -8
  8. package/.idea/quantum-coin-js-sdk.iml +0 -12
  9. package/.idea/vcs.xml +0 -6
  10. package/.vs/ProjectSettings.json +0 -3
  11. package/.vs/VSWorkspaceState.json +0 -8
  12. package/.vs/quantum-coin-js-sdk/FileContentIndex/a9d6de82-cfc3-4c22-ac38-06d706ff3673.vsidx +0 -0
  13. package/.vs/quantum-coin-js-sdk/FileContentIndex/fdc816df-1898-4153-99f2-c69ef4c2283b.vsidx +0 -0
  14. package/.vs/quantum-coin-js-sdk/config/applicationhost.config +0 -1011
  15. package/.vs/quantum-coin-js-sdk/v17/.wsuo +0 -0
  16. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.backup.json +0 -39
  17. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.json +0 -57
  18. package/.vs/slnx.sqlite +0 -0
  19. package/example/README.md +0 -14
  20. package/example/conversion-example.js +0 -19
  21. package/example/example-create-contract.js +0 -396
  22. package/example/example-encode-decode-rlp.js +0 -225
  23. package/example/example-event-pack-unpack.js +0 -391
  24. package/example/example-misc.js +0 -96
  25. package/example/example-token-pack-unpack.js +0 -960
  26. package/example/example-wallet-version4.js +0 -34
  27. package/example/example-wallet.js +0 -39
  28. package/example/example.js +0 -115
  29. package/example/node_modules/.bin/sdkgen +0 -16
  30. package/example/node_modules/.bin/sdkgen.cmd +0 -17
  31. package/example/node_modules/.bin/sdkgen.ps1 +0 -28
  32. package/example/node_modules/.package-lock.json +0 -51
  33. package/example/node_modules/quantumcoin/.github/workflows/publish-npmjs.yaml +0 -22
  34. package/example/node_modules/quantumcoin/LICENSE +0 -21
  35. package/example/node_modules/quantumcoin/README-SDK.md +0 -828
  36. package/example/node_modules/quantumcoin/README.md +0 -197
  37. package/example/node_modules/quantumcoin/config.d.ts +0 -50
  38. package/example/node_modules/quantumcoin/config.js +0 -123
  39. package/example/node_modules/quantumcoin/examples/AllSolidityTypes.sol +0 -184
  40. package/example/node_modules/quantumcoin/examples/SimpleIERC20.sol +0 -74
  41. package/example/node_modules/quantumcoin/examples/events.js +0 -41
  42. package/example/node_modules/quantumcoin/examples/events.ts +0 -35
  43. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.js +0 -100
  44. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.ts +0 -77
  45. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.js +0 -100
  46. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.ts +0 -77
  47. package/example/node_modules/quantumcoin/examples/example.js +0 -67
  48. package/example/node_modules/quantumcoin/examples/example.ts +0 -56
  49. package/example/node_modules/quantumcoin/examples/offline-signing.js +0 -77
  50. package/example/node_modules/quantumcoin/examples/offline-signing.ts +0 -65
  51. package/example/node_modules/quantumcoin/examples/package-lock.json +0 -596
  52. package/example/node_modules/quantumcoin/examples/package.json +0 -32
  53. package/example/node_modules/quantumcoin/examples/read-operations.js +0 -32
  54. package/example/node_modules/quantumcoin/examples/read-operations.ts +0 -31
  55. package/example/node_modules/quantumcoin/examples/sdk-generator-erc20.inline.json +0 -251
  56. package/example/node_modules/quantumcoin/examples/solidity-types.ts +0 -43
  57. package/example/node_modules/quantumcoin/examples/wallet-offline.js +0 -36
  58. package/example/node_modules/quantumcoin/examples/wallet-offline.ts +0 -26
  59. package/example/node_modules/quantumcoin/generate-sdk.js +0 -1846
  60. package/example/node_modules/quantumcoin/index.js +0 -12
  61. package/example/node_modules/quantumcoin/package.json +0 -95
  62. package/example/node_modules/quantumcoin/scripts/copy-declarations.js +0 -31
  63. package/example/node_modules/quantumcoin/scripts/run-all-one-by-one.js +0 -151
  64. package/example/node_modules/quantumcoin/src/abi/fragments.d.ts +0 -42
  65. package/example/node_modules/quantumcoin/src/abi/fragments.js +0 -63
  66. package/example/node_modules/quantumcoin/src/abi/index.d.ts +0 -13
  67. package/example/node_modules/quantumcoin/src/abi/index.js +0 -9
  68. package/example/node_modules/quantumcoin/src/abi/interface.d.ts +0 -128
  69. package/example/node_modules/quantumcoin/src/abi/interface.js +0 -605
  70. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.d.ts +0 -8
  71. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.js +0 -538
  72. package/example/node_modules/quantumcoin/src/constants.d.ts +0 -61
  73. package/example/node_modules/quantumcoin/src/constants.js +0 -94
  74. package/example/node_modules/quantumcoin/src/contract/contract-factory.d.ts +0 -28
  75. package/example/node_modules/quantumcoin/src/contract/contract-factory.js +0 -111
  76. package/example/node_modules/quantumcoin/src/contract/contract.d.ts +0 -113
  77. package/example/node_modules/quantumcoin/src/contract/contract.js +0 -408
  78. package/example/node_modules/quantumcoin/src/contract/index.d.ts +0 -9
  79. package/example/node_modules/quantumcoin/src/contract/index.js +0 -9
  80. package/example/node_modules/quantumcoin/src/errors/index.d.ts +0 -92
  81. package/example/node_modules/quantumcoin/src/errors/index.js +0 -200
  82. package/example/node_modules/quantumcoin/src/generator/index.d.ts +0 -81
  83. package/example/node_modules/quantumcoin/src/generator/index.js +0 -1571
  84. package/example/node_modules/quantumcoin/src/index.d.ts +0 -122
  85. package/example/node_modules/quantumcoin/src/index.js +0 -41
  86. package/example/node_modules/quantumcoin/src/internal/hex.d.ts +0 -68
  87. package/example/node_modules/quantumcoin/src/internal/hex.js +0 -180
  88. package/example/node_modules/quantumcoin/src/providers/extra-providers.d.ts +0 -139
  89. package/example/node_modules/quantumcoin/src/providers/extra-providers.js +0 -614
  90. package/example/node_modules/quantumcoin/src/providers/index.d.ts +0 -17
  91. package/example/node_modules/quantumcoin/src/providers/index.js +0 -10
  92. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.d.ts +0 -12
  93. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.js +0 -89
  94. package/example/node_modules/quantumcoin/src/providers/provider.d.ts +0 -206
  95. package/example/node_modules/quantumcoin/src/providers/provider.js +0 -524
  96. package/example/node_modules/quantumcoin/src/types/index.d.ts +0 -214
  97. package/example/node_modules/quantumcoin/src/types/index.js +0 -9
  98. package/example/node_modules/quantumcoin/src/utils/address.d.ts +0 -58
  99. package/example/node_modules/quantumcoin/src/utils/address.js +0 -144
  100. package/example/node_modules/quantumcoin/src/utils/encoding.d.ts +0 -120
  101. package/example/node_modules/quantumcoin/src/utils/encoding.js +0 -306
  102. package/example/node_modules/quantumcoin/src/utils/fixednumber.d.ts +0 -57
  103. package/example/node_modules/quantumcoin/src/utils/fixednumber.js +0 -366
  104. package/example/node_modules/quantumcoin/src/utils/hashing.d.ts +0 -76
  105. package/example/node_modules/quantumcoin/src/utils/hashing.js +0 -298
  106. package/example/node_modules/quantumcoin/src/utils/index.d.ts +0 -63
  107. package/example/node_modules/quantumcoin/src/utils/index.js +0 -14
  108. package/example/node_modules/quantumcoin/src/utils/result.d.ts +0 -57
  109. package/example/node_modules/quantumcoin/src/utils/result.js +0 -128
  110. package/example/node_modules/quantumcoin/src/utils/rlp.d.ts +0 -12
  111. package/example/node_modules/quantumcoin/src/utils/rlp.js +0 -215
  112. package/example/node_modules/quantumcoin/src/utils/units.d.ts +0 -29
  113. package/example/node_modules/quantumcoin/src/utils/units.js +0 -107
  114. package/example/node_modules/quantumcoin/src/wallet/index.d.ts +0 -10
  115. package/example/node_modules/quantumcoin/src/wallet/index.js +0 -8
  116. package/example/node_modules/quantumcoin/src/wallet/wallet.d.ts +0 -192
  117. package/example/node_modules/quantumcoin/src/wallet/wallet.js +0 -713
  118. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.js +0 -207
  119. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
  120. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.fixtures.js +0 -231
  121. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
  122. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
  123. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.js +0 -165
  124. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.ts +0 -160
  125. package/example/node_modules/quantumcoin/test/e2e/helpers.js +0 -59
  126. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
  127. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
  128. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
  129. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
  130. package/example/node_modules/quantumcoin/test/e2e/transactional.test.js +0 -245
  131. package/example/node_modules/quantumcoin/test/e2e/transactional.test.ts +0 -208
  132. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.js +0 -407
  133. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.ts +0 -337
  134. package/example/node_modules/quantumcoin/test/fixtures/ConstructorParam.sol +0 -23
  135. package/example/node_modules/quantumcoin/test/fixtures/MultiContracts.sol +0 -37
  136. package/example/node_modules/quantumcoin/test/fixtures/SimpleStorage.sol +0 -18
  137. package/example/node_modules/quantumcoin/test/fixtures/StakingContract.abi.json +0 -1
  138. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.js +0 -49
  139. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.ts +0 -44
  140. package/example/node_modules/quantumcoin/test/integration/provider.test.js +0 -88
  141. package/example/node_modules/quantumcoin/test/integration/provider.test.ts +0 -85
  142. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.js +0 -41
  143. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.ts +0 -38
  144. package/example/node_modules/quantumcoin/test/security/abi-decoder-bounds.test.js +0 -122
  145. package/example/node_modules/quantumcoin/test/security/contract-overrides.test.js +0 -112
  146. package/example/node_modules/quantumcoin/test/security/generator-injection.test.js +0 -195
  147. package/example/node_modules/quantumcoin/test/security/malformed-input.test.js +0 -330
  148. package/example/node_modules/quantumcoin/test/security/malformed-input.test.ts +0 -35
  149. package/example/node_modules/quantumcoin/test/security/rpc-numeric-bounds.test.js +0 -81
  150. package/example/node_modules/quantumcoin/test/security/rpc-trust.test.js +0 -202
  151. package/example/node_modules/quantumcoin/test/unit/_encrypted-output.txt +0 -6
  152. package/example/node_modules/quantumcoin/test/unit/_log-encrypted-jsons.js +0 -45
  153. package/example/node_modules/quantumcoin/test/unit/_write-keystore-fixture.js +0 -16
  154. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.js +0 -110
  155. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.ts +0 -109
  156. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.js +0 -923
  157. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.ts +0 -877
  158. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.js +0 -85
  159. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.ts +0 -79
  160. package/example/node_modules/quantumcoin/test/unit/contract.test.js +0 -85
  161. package/example/node_modules/quantumcoin/test/unit/contract.test.ts +0 -83
  162. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.js +0 -127
  163. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.ts +0 -91
  164. package/example/node_modules/quantumcoin/test/unit/errors.test.js +0 -77
  165. package/example/node_modules/quantumcoin/test/unit/errors.test.ts +0 -76
  166. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.js +0 -55
  167. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.ts +0 -54
  168. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.js +0 -656
  169. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.ts +0 -660
  170. package/example/node_modules/quantumcoin/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
  171. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.js +0 -42
  172. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.ts +0 -41
  173. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.js +0 -113
  174. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
  175. package/example/node_modules/quantumcoin/test/unit/generator.test.js +0 -149
  176. package/example/node_modules/quantumcoin/test/unit/generator.test.ts +0 -148
  177. package/example/node_modules/quantumcoin/test/unit/hashing.test.js +0 -64
  178. package/example/node_modules/quantumcoin/test/unit/hashing.test.ts +0 -63
  179. package/example/node_modules/quantumcoin/test/unit/init.test.js +0 -39
  180. package/example/node_modules/quantumcoin/test/unit/init.test.ts +0 -38
  181. package/example/node_modules/quantumcoin/test/unit/interface.test.js +0 -56
  182. package/example/node_modules/quantumcoin/test/unit/interface.test.ts +0 -54
  183. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.js +0 -81
  184. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.ts +0 -80
  185. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.js +0 -98
  186. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.ts +0 -64
  187. package/example/node_modules/quantumcoin/test/unit/providers.test.js +0 -252
  188. package/example/node_modules/quantumcoin/test/unit/providers.test.ts +0 -251
  189. package/example/node_modules/quantumcoin/test/unit/result.test.js +0 -80
  190. package/example/node_modules/quantumcoin/test/unit/result.test.ts +0 -79
  191. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.js +0 -49
  192. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.ts +0 -39
  193. package/example/node_modules/quantumcoin/test/unit/utils.test.js +0 -57
  194. package/example/node_modules/quantumcoin/test/unit/utils.test.ts +0 -56
  195. package/example/node_modules/quantumcoin/test/verbose-logger.js +0 -74
  196. package/example/node_modules/quantumcoin/tsconfig.build.json +0 -14
  197. package/example/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
  198. package/example/node_modules/seed-words/BUILD.md +0 -7
  199. package/example/node_modules/seed-words/LICENSE +0 -121
  200. package/example/node_modules/seed-words/README.md +0 -67
  201. package/example/node_modules/seed-words/dist/seedwords.d.ts +0 -39
  202. package/example/node_modules/seed-words/package.json +0 -27
  203. package/example/node_modules/seed-words/seedwords.js +0 -315
  204. package/example/node_modules/seed-words/seedwords.txt +0 -65536
  205. package/example/node_modules/seed-words/tsconfig.json +0 -21
  206. package/example/package-lock.json +0 -60
  207. package/example/package.json +0 -15
  208. package/scripts/build-browser-tests.js +0 -29
  209. package/scripts/build-wasm.js +0 -85
  210. package/tests/browser/bundle.js +0 -97643
  211. package/tests/browser/entry.js +0 -57
  212. package/tests/browser/harness.html +0 -20
  213. package/tests/browser/run-browser.js +0 -50
  214. package/tests/encrypted-32.json +0 -1
  215. package/tests/encrypted-36.json +0 -1
  216. package/tests/encrypted-48.json +0 -1
  217. package/tests/generate-verify-vectors.js +0 -88
  218. package/tests/get-gas-price.test.js +0 -59
  219. package/tests/hashing.test.js +0 -34
  220. package/tests/non-transactional.preinit.test.js +0 -33
  221. package/tests/non-transactional.test.js +0 -1318
  222. package/tests/sign-raw-keytype5-context-null.test.js +0 -105
  223. package/tests/sign-raw-transaction.test.js +0 -194
  224. package/tests/sign-verify.test.js +0 -308
  225. package/tests/specs/assert.js +0 -74
  226. package/tests/specs/crypto.spec.js +0 -104
  227. package/tests/specs/hex.js +0 -31
  228. package/tests/specs/preinit.spec.js +0 -19
  229. package/tests/specs/sign.spec.js +0 -90
  230. package/tests/specs/wallet.spec.js +0 -98
  231. package/tests/transactional.rpc.test.js +0 -102
  232. package/tests/verify-vectors.json +0 -95035
@@ -1,197 +0,0 @@
1
- > **CAUTION:** This is an experimental SDK. Use at your own risk.
2
-
3
- **Comprehensive SDK documentation:** see [`README-SDK.md`](./README-SDK.md).
4
-
5
- ## QuantumCoin.js
6
-
7
- QuantumCoin.js is an **ethers.js v6-compatible** SDK surface for the QuantumCoin blockchain.
8
-
9
- Key differences vs Ethereum/ethers:
10
-
11
- - **Addresses are 32 bytes** (66 hex chars including `0x`)
12
- - **No HDWallet support** (not applicable to QuantumCoin)
13
- - **All signing, address derivation, and ABI packing/unpacking** are delegated to `quantum-coin-js-sdk` (as required by `SPEC.md`)
14
-
15
- ## Install
16
-
17
- ```bash
18
- npm install quantumcoin
19
- ```
20
-
21
- ## Initialize (required)
22
-
23
- You **must** initialize once before using wallet/address/ABI helpers:
24
-
25
- ```js
26
- const { Initialize, Config } = require("quantumcoin/config");
27
-
28
- // defaults: chainId=123123, rpcEndpoint=https://public.rpc.quantumcoinapi.com
29
- await Initialize(null);
30
-
31
- // or custom
32
- await Initialize(new Config(123123, "https://public.rpc.quantumcoinapi.com"));
33
- ```
34
-
35
- ## Provider (read-only)
36
-
37
- ```js
38
- const { JsonRpcProvider } = require("quantumcoin");
39
-
40
- const provider = new JsonRpcProvider("https://public.rpc.quantumcoinapi.com", 123123);
41
- console.log(await provider.getBlockNumber());
42
- ```
43
-
44
- ## Wallet (offline + online)
45
-
46
- ```js
47
- const { Wallet } = require("quantumcoin");
48
- const { Initialize } = require("quantumcoin/config");
49
-
50
- await Initialize(null);
51
-
52
- const wallet = Wallet.createRandom();
53
-
54
- const encrypted = wallet.encryptSync("mySecurePassword123");
55
- const restored = Wallet.fromEncryptedJsonSync(encrypted, "mySecurePassword123");
56
- console.log(restored.address);
57
- ```
58
-
59
- ### Seed phrase (`getPhrase()`)
60
-
61
- Any wallet that was constructed from a seed exposes its seed words via `getPhrase()`:
62
-
63
- ```js
64
- const wallet = Wallet.createRandom();
65
- const phrase = wallet.getPhrase(); // string[] of seed words, or null
66
- const restored = Wallet.fromPhrase(phrase);
67
- console.log(restored.address === wallet.address); // true
68
- ```
69
-
70
- `getPhrase()` returns the seed words whenever `wallet.seed` is non-null — i.e. wallets produced by `createRandom`, `fromPhrase`, `fromSeed`, or `fromEncryptedJsonSync` on a version-5 keystore (produced by `encryptSync` on a seed-bearing wallet or by `encryptSeedSync`). It returns `null` for wallets constructed via `fromKeys` or from v3/v4 keystores.
71
-
72
- ### Encrypt a raw seed
73
-
74
- You can encrypt raw seed bytes (pre-expansion) into a portable wallet JSON (version 5 format) without first opening the wallet:
75
-
76
- ```js
77
- const { Wallet } = require("quantumcoin");
78
- const { Initialize } = require("quantumcoin/config");
79
-
80
- await Initialize(null);
81
-
82
- // 64-byte seed (keyType 3), 72-byte (keyType 5), or 96-byte (legacy)
83
- const seed = [51,214,149,165, /* ...remaining bytes... */];
84
- const json = Wallet.encryptSeedSync(seed, "mySecurePassword123");
85
- const restored = Wallet.fromEncryptedJsonSync(json, "mySecurePassword123");
86
- console.log(restored.address);
87
- ```
88
-
89
- ## Contracts (read-only)
90
-
91
- ```js
92
- const { Initialize } = require("quantumcoin/config");
93
- const { JsonRpcProvider, Contract } = require("quantumcoin");
94
-
95
- await Initialize(null);
96
-
97
- const provider = new JsonRpcProvider("https://public.rpc.quantumcoinapi.com", 123123);
98
- const abi = require("./test/fixtures/StakingContract.abi.json");
99
- const address = "0x0000000000000000000000000000000000000000000000000000000000001000";
100
-
101
- const staking = new Contract(address, abi, provider);
102
- console.log(await staking.getDepositorCount());
103
- ```
104
-
105
- ## Typed contract generator
106
-
107
- This repo includes a generator described in `SPEC.md` section 15.
108
-
109
- ```bash
110
- # Non-interactive
111
- node generate-sdk.js --abi path/to/abi.json --bin path/to/bytecode.bin --out ./generated --name MyContract --non-interactive
112
-
113
- # JavaScript output (with TypeScript `.d.ts` types)
114
- node generate-sdk.js --lang js --abi path/to/abi.json --bin path/to/bytecode.bin --out ./generated --name MyContract --non-interactive
115
-
116
- # Interactive
117
- node generate-sdk.js --abi path/to/abi.json --bin path/to/bytecode.bin
118
- ```
119
-
120
- If installed as a package, you can also run:
121
-
122
- ```bash
123
- npx sdkgen --abi path/to/abi.json --bin path/to/bytecode.bin --out ./generated --name MyContract --non-interactive
124
- ```
125
-
126
- For more options (Solidity sources, artifacts JSON, package scaffolding), see [README-SDK.md](./README-SDK.md#typed-sdk-generator-generate-sdkjs).
127
-
128
- ### Generator typing model
129
-
130
- - **Hard types**: generated wrappers use concrete types from `quantumcoin/types` (e.g. `Uint256Like` for inputs, `Uint256` for outputs).
131
- - **Single return values are unwrapped**: a Solidity function returning one value returns that value directly (not `[value]`).
132
- - **Multiple returns**: returned as a tuple type (e.g. `Promise<[Uint256, Bool]>`).
133
- - **No returns**: `Promise<void>`.
134
- - **Structs / tuples**: generated as `export type <Name>Input` / `export type <Name>Output` and used directly in method signatures.
135
-
136
- ### Interface contracts
137
-
138
- When the input artifact has empty bytecode (`"0x"` or empty `.bin`, typically produced by `solc` for a Solidity `interface`), the generator emits a transactional test that **skips the post-deploy bytecode check**. The deploy step still runs (the receipt-status assertion validates SDK wrapper wiring), but `provider.getCode(contract.target)` is not asserted to be non-empty — an interface deploys with no runtime code by design. Concrete contracts (non-empty bytecode) continue to assert that `provider.getCode(contract.target)` is non-empty.
139
-
140
- ## Solidity types (TypeScript)
141
-
142
- QuantumCoin.js exports core Solidity-related typings from:
143
-
144
- - `quantumcoin/types`
145
-
146
- Common types:
147
-
148
- - `AddressLike` (currently `string`, 32-byte address)
149
- - `BytesLike` (`string | Uint8Array`)
150
- - `BigNumberish` (`string | number | bigint`)
151
- - **Hard Solidity aliases** (preferred for typed wrappers): `Uint256Like` / `Uint256`, `Int256Like` / `Int256`, `Bytes32Like` / `Bytes32`, and all widths `Uint8Like`…`Uint256Like`, `Int8Like`…`Int256Like`, plus `Bytes1Like`…`Bytes32Like`
152
- - `SolidityTypeName`, `SolidityInputValue<T>`, `SolidityOutputValue<T>` (advanced type-level mapping helpers; the generator no longer uses these for wrapper signatures)
153
-
154
- ## Examples
155
-
156
- ```bash
157
- npm run example
158
- npm run example:wallet
159
- npm run example:contract:read
160
- npm run example:events
161
- # Run all examples (including SDK generator JS/TS)
162
- npm run examples
163
- ```
164
-
165
- To try the typed SDK generator (generates a full package from Solidity or ABI+BIN):
166
-
167
- ```bash
168
- node examples/example-generator-sdk-js.js # JavaScript output
169
- node examples/example-generator-sdk-ts.js # TypeScript output
170
- ```
171
-
172
- Requires `solc` on `QC_SOLC_PATH` or `SOLC_PATH`, or at default `c:\solc\solc.exe`. See [README-SDK.md](./README-SDK.md) for all generator options (`--artifacts-json`, `--sol`, `--create-package`, etc.).
173
-
174
- ## Tests
175
-
176
- ```bash
177
- npm test
178
- npm run test:unit
179
- npm run test:non-transactional
180
- npm run test:e2e
181
- ```
182
-
183
- ## Troubleshooting
184
-
185
- - **“SDK not initialized”**: call `Initialize(null)` once at startup.
186
- - **JSON-RPC errors/timeouts**: verify `Config.rpcEndpoint` or pass an explicit URL to `JsonRpcProvider`.
187
- - **Node version**: `quantum-coin-js-sdk` tooling is developed primarily against Node 20+. If you see runtime issues, try Node 20 LTS.
188
-
189
- ### Transactional (write) tests
190
-
191
- The E2E tests broadcast real transactions and require a funded test wallet.
192
-
193
- - Set RPC URL via env var: `QC_RPC_URL`
194
- - (Optional) chain id via env var: `QC_CHAIN_ID` (default: 123123)
195
- - (Optional) solc path via env var: `QC_SOLC_PATH` (default: `c:\solc\solc.exe`)
196
-
197
-
@@ -1,50 +0,0 @@
1
- /**
2
- * Configuration class for QuantumCoin SDK
3
- * @class
4
- */
5
- export class Config {
6
- /**
7
- * Creates a Config instance
8
- * @param {number} chainId - The chain ID (default: 123123 for mainnet)
9
- * @param {string} rpcEndpoint - The RPC endpoint URL (default: https://public.rpc.quantumcoinapi.com)
10
- */
11
- constructor(chainId?: number, rpcEndpoint?: string);
12
- chainId: number;
13
- rpcEndpoint: string;
14
- }
15
- /**
16
- * Initializes the QuantumCoin SDK with the provided configuration.
17
- *
18
- * WARNING: This function MUST be called before using any SDK functionality.
19
- * If Initialize() is not called, the SDK behavior can be unpredictable and
20
- * may result in errors or incorrect validation results.
21
- *
22
- * If config is null or undefined, the SDK will be initialized with default values:
23
- * - chainId: 123123 (mainnet)
24
- * - rpcEndpoint: https://public.rpc.quantumcoinapi.com
25
- *
26
- * @param {Config|null} config - The configuration object containing chainId and rpcEndpoint.
27
- * If null or undefined, default values will be used.
28
- * @return {Promise<boolean>} Promise that resolves to true if initialization succeeded, false otherwise
29
- * @example
30
- * // Initialize with custom config
31
- * const { Config, Initialize } = require('quantumcoin/config');
32
- * const config = new Config(123123, 'https://rpc.example.com');
33
- * await Initialize(config);
34
- *
35
- * @example
36
- * // Initialize with default config (chainId: 123123, rpcEndpoint: https://public.rpc.quantumcoinapi.com)
37
- * const { Initialize } = require('quantumcoin/config');
38
- * await Initialize(null);
39
- */
40
- export function Initialize(config: Config | null): Promise<boolean>;
41
- /**
42
- * Checks if the SDK has been initialized
43
- * @return {boolean} True if initialized, false otherwise
44
- */
45
- export function isInitialized(): boolean;
46
- /**
47
- * Returns the currently active SDK config (or null if not initialized).
48
- * @return {Config|null}
49
- */
50
- export function getConfig(): Config | null;
@@ -1,123 +0,0 @@
1
- /**
2
- * Configuration class for QuantumCoin SDK
3
- *
4
- * This module provides the Config class and Initialize function
5
- * for setting up the QuantumCoin SDK.
6
- *
7
- * @module config
8
- */
9
-
10
- const qcsdk = require('quantum-coin-js-sdk');
11
-
12
- let _isInitialized = false;
13
- let _initializationPromise = null;
14
- let _config = null;
15
-
16
- // Default configuration values
17
- const DEFAULT_CHAIN_ID = 123123;
18
- const DEFAULT_RPC_ENDPOINT = "https://public.rpc.quantumcoinapi.com";
19
- const DEFAULT_READ_URL = "https://sdk.readrelay.quantumcoinapi.com";
20
- const DEFAULT_WRITE_URL = "https://sdk.writerelay.quantumcoinapi.com";
21
-
22
- /**
23
- * Configuration class for QuantumCoin SDK
24
- * @class
25
- */
26
- class Config {
27
- /**
28
- * Creates a Config instance
29
- * @param {number} chainId - The chain ID (default: 123123 for mainnet)
30
- * @param {string} rpcEndpoint - The RPC endpoint URL (default: https://public.rpc.quantumcoinapi.com)
31
- */
32
- constructor(chainId = DEFAULT_CHAIN_ID, rpcEndpoint = DEFAULT_RPC_ENDPOINT) {
33
- this.chainId = chainId;
34
- this.rpcEndpoint = rpcEndpoint;
35
- }
36
- }
37
-
38
- /**
39
- * Initializes the QuantumCoin SDK with the provided configuration.
40
- *
41
- * WARNING: This function MUST be called before using any SDK functionality.
42
- * If Initialize() is not called, the SDK behavior can be unpredictable and
43
- * may result in errors or incorrect validation results.
44
- *
45
- * If config is null or undefined, the SDK will be initialized with default values:
46
- * - chainId: 123123 (mainnet)
47
- * - rpcEndpoint: https://public.rpc.quantumcoinapi.com
48
- *
49
- * @param {Config|null} config - The configuration object containing chainId and rpcEndpoint.
50
- * If null or undefined, default values will be used.
51
- * @return {Promise<boolean>} Promise that resolves to true if initialization succeeded, false otherwise
52
- * @example
53
- * // Initialize with custom config
54
- * const { Config, Initialize } = require('quantumcoin/config');
55
- * const config = new Config(123123, 'https://rpc.example.com');
56
- * await Initialize(config);
57
- *
58
- * @example
59
- * // Initialize with default config (chainId: 123123, rpcEndpoint: https://public.rpc.quantumcoinapi.com)
60
- * const { Initialize } = require('quantumcoin/config');
61
- * await Initialize(null);
62
- */
63
- function Initialize(config) {
64
- // If config is null or undefined, use default values
65
- if (config === null || config === undefined) {
66
- config = new Config(DEFAULT_CHAIN_ID, DEFAULT_RPC_ENDPOINT);
67
- } else if (!(config instanceof Config)) {
68
- throw new Error('Initialize() requires a Config instance as parameter, or null/undefined for default config');
69
- }
70
-
71
- if (_initializationPromise === null) {
72
- _config = config;
73
-
74
- // Initialize quantum-coin-js-sdk (WASM + crypto helpers).
75
- // Note: quantum-coin-js-sdk expects relay URLs for some network operations.
76
- // We provide community defaults here; the ethers-compatible Provider uses `config.rpcEndpoint`.
77
- const clientConfigVal = new qcsdk.Config(DEFAULT_READ_URL, DEFAULT_WRITE_URL, config.chainId, "", "");
78
-
79
- _initializationPromise = qcsdk.initialize(clientConfigVal).then((initResult) => {
80
- if (initResult === true) {
81
- _isInitialized = true;
82
- }
83
- return initResult === true;
84
- }).catch((error) => {
85
- console.error('SDK initialization failed:', error);
86
- return false;
87
- });
88
- }
89
-
90
- return _initializationPromise;
91
- }
92
-
93
- /**
94
- * Checks if the SDK has been initialized
95
- * @return {boolean} True if initialized, false otherwise
96
- */
97
- function isInitialized() {
98
- return _isInitialized;
99
- }
100
-
101
- /**
102
- * Returns the currently active SDK config (or null if not initialized).
103
- * @return {Config|null}
104
- */
105
- function getConfig() {
106
- return _config;
107
- }
108
-
109
- /**
110
- * Returns the pending initialization promise, or null if Initialize() has not been called.
111
- * @return {Promise<boolean>|null}
112
- */
113
- function getInitializationPromise() {
114
- return _initializationPromise;
115
- }
116
-
117
- module.exports = {
118
- Config,
119
- Initialize,
120
- isInitialized,
121
- getConfig,
122
- getInitializationPromise
123
- };
@@ -1,184 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.7.6;
3
- pragma experimental ABIEncoderV2;
4
-
5
- /// @title AllSolidityTypes
6
- /// @notice A Solidity 0.7.6 contract that exercises a wide surface of ABI-encodable types.
7
- /// @dev
8
- /// - Includes: bool, all int/uint widths, address/address payable, string, bytes, bytes1..bytes32
9
- /// - Includes: enums, nested structs, fixed/dynamic arrays, arrays of structs, structs of structs
10
- /// - Excludes: fixed-point types and function types (by request)
11
- /// - Note: mappings are not ABI-encodable, so they are shown only as a storage type.
12
- contract AllSolidityTypes {
13
- enum Choice { None, One, Two }
14
-
15
- // Mapping example (not ABI-encodable as param/return)
16
- mapping(address => uint256) private _balances;
17
-
18
- // --------------------------------------------------------------------------
19
- // All integer widths
20
- // --------------------------------------------------------------------------
21
- struct AllUints {
22
- uint8 u8; uint16 u16; uint24 u24; uint32 u32; uint40 u40; uint48 u48; uint56 u56; uint64 u64;
23
- uint72 u72; uint80 u80; uint88 u88; uint96 u96; uint104 u104; uint112 u112; uint120 u120; uint128 u128;
24
- uint136 u136; uint144 u144; uint152 u152; uint160 u160; uint168 u168; uint176 u176; uint184 u184; uint192 u192;
25
- uint200 u200; uint208 u208; uint216 u216; uint224 u224; uint232 u232; uint240 u240; uint248 u248; uint256 u256;
26
- }
27
-
28
- struct AllInts {
29
- int8 i8; int16 i16; int24 i24; int32 i32; int40 i40; int48 i48; int56 i56; int64 i64;
30
- int72 i72; int80 i80; int88 i88; int96 i96; int104 i104; int112 i112; int120 i120; int128 i128;
31
- int136 i136; int144 i144; int152 i152; int160 i160; int168 i168; int176 i176; int184 i184; int192 i192;
32
- int200 i200; int208 i208; int216 i216; int224 i224; int232 i232; int240 i240; int248 i248; int256 i256;
33
- }
34
-
35
- // --------------------------------------------------------------------------
36
- // All fixed-size bytes
37
- // --------------------------------------------------------------------------
38
- struct AllFixedBytes {
39
- bytes1 b1; bytes2 b2; bytes3 b3; bytes4 b4; bytes5 b5; bytes6 b6; bytes7 b7; bytes8 b8;
40
- bytes9 b9; bytes10 b10; bytes11 b11; bytes12 b12; bytes13 b13; bytes14 b14; bytes15 b15; bytes16 b16;
41
- bytes17 b17; bytes18 b18; bytes19 b19; bytes20 b20; bytes21 b21; bytes22 b22; bytes23 b23; bytes24 b24;
42
- bytes25 b25; bytes26 b26; bytes27 b27; bytes28 b28; bytes29 b29; bytes30 b30; bytes31 b31; bytes32 b32;
43
- }
44
-
45
- // --------------------------------------------------------------------------
46
- // Misc ABI value types (plus arrays)
47
- // --------------------------------------------------------------------------
48
- struct AllMisc {
49
- bool bo;
50
- address addr;
51
- address payable payableAddr;
52
- string str;
53
- bytes dynBytes;
54
- Choice choice;
55
- // Arrays of elementary types
56
- uint256[] u256s;
57
- int256[] i256s;
58
- bytes32[] b32s;
59
- address[] addrs;
60
- bool[] bools;
61
- string[] strings;
62
- bytes[] bytesArr;
63
- // Fixed arrays
64
- uint16[3] fixedU16;
65
- bytes32[2] fixedB32;
66
- }
67
-
68
- // Nested struct that contains structs and arrays of structs
69
- struct Inner {
70
- AllUints u;
71
- AllInts i;
72
- AllFixedBytes fb;
73
- AllMisc misc;
74
- // Array of structs
75
- AllUints[] uStructs;
76
- // Struct of structs
77
- AllFixedBytes[2] fixedFb;
78
- // Nested arrays
79
- uint256[][] matrix;
80
- }
81
-
82
- struct Outer {
83
- Inner inner;
84
- Inner[] inners; // dynamic array of structs
85
- Inner[2] fixedInners; // fixed array of structs
86
- bytes32[][] b32Matrix;
87
- }
88
-
89
- AllUints private _storedU;
90
- AllInts private _storedI;
91
- AllFixedBytes private _storedFb;
92
- AllMisc private _storedMisc;
93
-
94
- /// @notice Constructor with multiple parameters (including structs and arrays).
95
- constructor(
96
- bool bo,
97
- address payable payableAddr,
98
- string memory str,
99
- bytes memory dynBytes,
100
- Choice choice,
101
- AllUints memory u,
102
- AllInts memory i,
103
- AllFixedBytes memory fb,
104
- AllMisc memory misc,
105
- uint256[] memory seedU256s,
106
- bytes32[2] memory seedB32
107
- ) {
108
- _storedU = u;
109
- _storedI = i;
110
- _storedFb = fb;
111
-
112
- // Store some misc fields (keep it simple; not all array fields are persisted).
113
- _storedMisc.bo = bo;
114
- _storedMisc.addr = msg.sender;
115
- _storedMisc.payableAddr = payableAddr;
116
- _storedMisc.str = str;
117
- _storedMisc.dynBytes = dynBytes;
118
- _storedMisc.choice = choice;
119
- _storedMisc.u256s = seedU256s;
120
- _storedMisc.fixedB32 = seedB32;
121
-
122
- // Touch mapping to demonstrate mapping existence.
123
- _balances[msg.sender] = seedU256s.length;
124
-
125
- // Use "misc" parameter to avoid unused warnings and ensure ABIEncoderV2 path is exercised.
126
- if (misc.fixedU16.length > 0) {
127
- _balances[misc.addr] = uint256(misc.fixedU16[0]);
128
- }
129
- }
130
-
131
- // --------------------------------------------------------------------------
132
- // Echo / roundtrip helpers (ABI-encodable inputs and outputs)
133
- // --------------------------------------------------------------------------
134
-
135
- function echoAllUints(AllUints memory x) external pure returns (AllUints memory) { return x; }
136
- function echoAllInts(AllInts memory x) external pure returns (AllInts memory) { return x; }
137
- function echoAllFixedBytes(AllFixedBytes memory x) external pure returns (AllFixedBytes memory) { return x; }
138
- function echoAllMisc(AllMisc memory x) external pure returns (AllMisc memory) { return x; }
139
-
140
- function echoInner(Inner memory x) external pure returns (Inner memory) { return x; }
141
- function echoOuter(Outer memory x) external pure returns (Outer memory) { return x; }
142
-
143
- // Arrays of structs and nested arrays
144
- function echoAllUintsArray(AllUints[] memory xs) external pure returns (AllUints[] memory) { return xs; }
145
- function echoInnerArray(Inner[] memory xs) external pure returns (Inner[] memory) { return xs; }
146
- function echoMatrix(uint256[][] memory m) external pure returns (uint256[][] memory) { return m; }
147
-
148
- // Multiple input params + multiple return params
149
- function multiReturn(
150
- bool bo,
151
- address addr,
152
- bytes32 b32,
153
- string memory s,
154
- uint256 x,
155
- AllUints memory u
156
- )
157
- external
158
- pure
159
- returns (
160
- bool outBo,
161
- address outAddr,
162
- address payable outPayableAddr,
163
- bytes32 outB32,
164
- string memory outS,
165
- uint256 outX,
166
- AllUints memory outU
167
- )
168
- {
169
- outBo = bo;
170
- outAddr = addr;
171
- outPayableAddr = payable(addr);
172
- outB32 = b32;
173
- outS = s;
174
- outX = x;
175
- outU = u;
176
- }
177
-
178
- // Read-only getters to provide outputs without inputs
179
- function getStoredUints() external view returns (AllUints memory) { return _storedU; }
180
- function getStoredInts() external view returns (AllInts memory) { return _storedI; }
181
- function getStoredFixedBytes() external view returns (AllFixedBytes memory) { return _storedFb; }
182
- function getStoredMisc() external view returns (AllMisc memory) { return _storedMisc; }
183
- }
184
-
@@ -1,74 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.7.6;
3
-
4
- /// @title IERC20
5
- /// @notice Minimal ERC-20 interface (standard ABI surface).
6
- interface IERC20 {
7
- event Transfer(address indexed from, address indexed to, uint256 value);
8
- event Approval(address indexed owner, address indexed spender, uint256 value);
9
-
10
- function totalSupply() external view returns (uint256);
11
- function balanceOf(address account) external view returns (uint256);
12
- function allowance(address owner, address spender) external view returns (uint256);
13
-
14
- function transfer(address to, uint256 value) external returns (bool);
15
- function approve(address spender, uint256 value) external returns (bool);
16
- function transferFrom(address from, address to, uint256 value) external returns (bool);
17
- }
18
-
19
- /// @title SimpleERC20
20
- /// @notice A small deployable ERC-20 implementation for generator examples.
21
- contract SimpleERC20 is IERC20 {
22
- string public name;
23
- string public symbol;
24
- uint8 public constant decimals = 18;
25
-
26
- uint256 public override totalSupply;
27
- mapping(address => uint256) public override balanceOf;
28
- mapping(address => mapping(address => uint256)) public override allowance;
29
-
30
- constructor(string memory _name, string memory _symbol, uint256 _initialSupply) {
31
- name = _name;
32
- symbol = _symbol;
33
- _mint(msg.sender, _initialSupply);
34
- }
35
-
36
- function transfer(address to, uint256 value) external override returns (bool) {
37
- _transfer(msg.sender, to, value);
38
- return true;
39
- }
40
-
41
- function approve(address spender, uint256 value) external override returns (bool) {
42
- allowance[msg.sender][spender] = value;
43
- emit Approval(msg.sender, spender, value);
44
- return true;
45
- }
46
-
47
- function transferFrom(address from, address to, uint256 value) external override returns (bool) {
48
- uint256 allowed = allowance[from][msg.sender];
49
- require(allowed >= value, "ALLOWANCE");
50
- if (allowed != uint256(-1)) {
51
- allowance[from][msg.sender] = allowed - value;
52
- emit Approval(from, msg.sender, allowance[from][msg.sender]);
53
- }
54
- _transfer(from, to, value);
55
- return true;
56
- }
57
-
58
- function _transfer(address from, address to, uint256 value) internal {
59
- require(to != address(0), "TO_ZERO");
60
- uint256 bal = balanceOf[from];
61
- require(bal >= value, "BALANCE");
62
- balanceOf[from] = bal - value;
63
- balanceOf[to] += value;
64
- emit Transfer(from, to, value);
65
- }
66
-
67
- function _mint(address to, uint256 value) internal {
68
- require(to != address(0), "MINT_TO_ZERO");
69
- totalSupply += value;
70
- balanceOf[to] += value;
71
- emit Transfer(address(0), to, value);
72
- }
73
- }
74
-
@@ -1,41 +0,0 @@
1
- /**
2
- * Example: Querying logs/events (read-only).
3
- * Run with VERBOSE=1 for addresses, block range, and log counts.
4
- *
5
- * Note: This is a simple log query example; it does not keep a live subscription
6
- * running. For long-running subscriptions, build on Provider polling or a future
7
- * WebSocketProvider implementation.
8
- */
9
-
10
- const { Initialize } = require("../config");
11
- const { getProvider, Contract } = require("..");
12
- const { logExample, logAddress } = require("../test/verbose-logger");
13
-
14
- const RPC = "https://public.rpc.quantumcoinapi.com";
15
- const CHAIN_ID = 123123;
16
- const STAKING_CONTRACT = "0x" + "00".repeat(30) + "10" + "00"; // 0x...1000
17
-
18
- async function eventsExample() {
19
- logExample("events.js", "starting", { rpc: RPC, chainId: CHAIN_ID });
20
- await Initialize(null);
21
-
22
- const provider = getProvider(RPC, CHAIN_ID);
23
- logAddress("staking_contract", STAKING_CONTRACT);
24
- const abi = require("../test/fixtures/StakingContract.abi.json");
25
- const contract = new Contract(STAKING_CONTRACT, abi, provider);
26
-
27
- // Query recent logs from the last 1000 blocks
28
- const latest = await provider.getBlockNumber();
29
- const fromBlock = Math.max(latest - 1000, 0);
30
- logExample("events.js", "block range", { latest, fromBlock, toBlock: "latest" });
31
-
32
- const logs = await contract.queryFilter("OnNewDeposit", fromBlock, "latest");
33
- console.log(`Found ${logs.length} OnNewDeposit logs in last 1000 blocks`);
34
- logExample("events.js", "queryFilter OnNewDeposit", { logCount: logs.length });
35
- }
36
-
37
- eventsExample().catch((e) => {
38
- console.error(e);
39
- process.exitCode = 1;
40
- });
41
-