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,215 +0,0 @@
1
- /**
2
- * @fileoverview RLP encoding utilities.
3
- *
4
- * SPEC.md section 5.9 mirrors ethers.js v6 RLP helpers.
5
- *
6
- * This implementation is self-contained (no vendored ethers.js dependency).
7
- */
8
-
9
- const { arrayify, bytesToHex, hexToBytes, isHexString, normalizeHex, utf8ToBytes } = require("../internal/hex");
10
-
11
- function _toBytes(value) {
12
- if (value == null) return new Uint8Array([]);
13
-
14
- if (value instanceof Uint8Array) return new Uint8Array(value);
15
- if (Buffer.isBuffer(value)) return new Uint8Array(value);
16
-
17
- if (Array.isArray(value)) {
18
- // List gets handled elsewhere; here we accept array-of-bytes as a BytesLike.
19
- if (value.every((v) => Number.isInteger(v) && v >= 0 && v <= 255)) {
20
- return new Uint8Array(value);
21
- }
22
- throw new TypeError("invalid RLP bytes array");
23
- }
24
-
25
- if (typeof value === "string") {
26
- // Prefer hex strings (ethers-style); otherwise treat as utf8.
27
- if (value === "0x" || value === "") return new Uint8Array([]);
28
- if (isHexString(value)) return hexToBytes(normalizeHex(value));
29
- return utf8ToBytes(value);
30
- }
31
-
32
- if (typeof value === "number") {
33
- if (!Number.isSafeInteger(value) || value < 0) throw new TypeError("invalid RLP number");
34
- if (value === 0) return new Uint8Array([]);
35
- let n = BigInt(value);
36
- const out = [];
37
- while (n > 0n) {
38
- out.push(Number(n & 0xffn));
39
- n >>= 8n;
40
- }
41
- out.reverse();
42
- return new Uint8Array(out);
43
- }
44
-
45
- if (typeof value === "bigint") {
46
- if (value < 0n) throw new TypeError("invalid RLP bigint");
47
- if (value === 0n) return new Uint8Array([]);
48
- let n = value;
49
- const out = [];
50
- while (n > 0n) {
51
- out.push(Number(n & 0xffn));
52
- n >>= 8n;
53
- }
54
- out.reverse();
55
- return new Uint8Array(out);
56
- }
57
-
58
- throw new TypeError("unsupported RLP value type");
59
- }
60
-
61
- function _encodeLen(len, offsetShort, offsetLong) {
62
- if (len <= 55) {
63
- return new Uint8Array([offsetShort + len]);
64
- }
65
- // length-of-length (big-endian)
66
- let l = len;
67
- const bytes = [];
68
- while (l > 0) {
69
- bytes.push(l & 0xff);
70
- l >>= 8;
71
- }
72
- bytes.reverse();
73
- return new Uint8Array([offsetLong + bytes.length, ...bytes]);
74
- }
75
-
76
- function _concat(a, b) {
77
- const out = new Uint8Array(a.length + b.length);
78
- out.set(a, 0);
79
- out.set(b, a.length);
80
- return out;
81
- }
82
-
83
- function _encode(value) {
84
- if (Array.isArray(value) && !value.every((v) => Number.isInteger(v) && v >= 0 && v <= 255)) {
85
- // List
86
- let payload = new Uint8Array([]);
87
- for (const item of value) {
88
- payload = _concat(payload, _encode(item));
89
- }
90
- const prefix = _encodeLen(payload.length, 0xc0, 0xf7);
91
- return _concat(prefix, payload);
92
- }
93
-
94
- // String/bytes/integer
95
- const bytes = _toBytes(value);
96
- if (bytes.length === 1 && bytes[0] < 0x80) {
97
- return bytes;
98
- }
99
- const prefix = _encodeLen(bytes.length, 0x80, 0xb7);
100
- return _concat(prefix, bytes);
101
- }
102
-
103
- function _readLen(bytes, offset, lenOfLen) {
104
- if (lenOfLen === 0) return 0;
105
- if (offset + lenOfLen > bytes.length) throw new Error("RLP: insufficient data for length");
106
- // Canonical encoding forbids a leading zero byte in the length field.
107
- if (bytes[offset] === 0) throw new Error("RLP: non-canonical length (leading zero byte)");
108
- // Accumulate with multiplication (not `<< 8`, which is a signed 32-bit op
109
- // that overflows/wraps for 4+ byte lengths) and reject impossibly large lengths.
110
- let len = 0;
111
- for (let i = 0; i < lenOfLen; i++) {
112
- len = len * 256 + bytes[offset + i];
113
- if (len > Number.MAX_SAFE_INTEGER) throw new Error("RLP: length exceeds maximum safe integer");
114
- }
115
- return len;
116
- }
117
-
118
- const MAX_RLP_DEPTH = 64;
119
-
120
- function _decode(bytes, start, end, depth) {
121
- if (depth > MAX_RLP_DEPTH) throw new Error("RLP: maximum nesting depth exceeded");
122
- if (start >= end) throw new Error("RLP: empty input");
123
- const prefix = bytes[start];
124
-
125
- // Single byte
126
- if (prefix <= 0x7f) {
127
- return { value: bytesToHex(new Uint8Array([prefix])), next: start + 1 };
128
- }
129
-
130
- // Short string
131
- if (prefix <= 0xb7) {
132
- const len = prefix - 0x80;
133
- const dataStart = start + 1;
134
- const dataEnd = dataStart + len;
135
- if (dataEnd > end) throw new Error("RLP: out of bounds");
136
- // Canonical encoding requires a single byte < 0x80 to be encoded as
137
- // itself, never as a 1-byte string.
138
- if (len === 1 && bytes[dataStart] < 0x80) throw new Error("RLP: non-canonical single byte encoding");
139
- const out = bytesToHex(bytes.slice(dataStart, dataEnd));
140
- return { value: out, next: dataEnd };
141
- }
142
-
143
- // Long string
144
- if (prefix <= 0xbf) {
145
- const lenOfLen = prefix - 0xb7;
146
- const len = _readLen(bytes, start + 1, lenOfLen);
147
- // Lengths <= 55 must use the short-string form.
148
- if (len <= 55) throw new Error("RLP: non-canonical long string (length fits short form)");
149
- const dataStart = start + 1 + lenOfLen;
150
- const dataEnd = dataStart + len;
151
- if (dataEnd > end) throw new Error("RLP: out of bounds");
152
- const out = bytesToHex(bytes.slice(dataStart, dataEnd));
153
- return { value: out, next: dataEnd };
154
- }
155
-
156
- // Short list
157
- if (prefix <= 0xf7) {
158
- const len = prefix - 0xc0;
159
- const dataStart = start + 1;
160
- const dataEnd = dataStart + len;
161
- if (dataEnd > end) throw new Error("RLP: out of bounds");
162
- const out = [];
163
- let pos = dataStart;
164
- while (pos < dataEnd) {
165
- const decoded = _decode(bytes, pos, dataEnd, depth + 1);
166
- out.push(decoded.value);
167
- pos = decoded.next;
168
- }
169
- if (pos !== dataEnd) throw new Error("RLP: list length mismatch");
170
- return { value: out, next: dataEnd };
171
- }
172
-
173
- // Long list
174
- const lenOfLen = prefix - 0xf7;
175
- const len = _readLen(bytes, start + 1, lenOfLen);
176
- // Lengths <= 55 must use the short-list form.
177
- if (len <= 55) throw new Error("RLP: non-canonical long list (length fits short form)");
178
- const dataStart = start + 1 + lenOfLen;
179
- const dataEnd = dataStart + len;
180
- if (dataEnd > end) throw new Error("RLP: out of bounds");
181
- const out = [];
182
- let pos = dataStart;
183
- while (pos < dataEnd) {
184
- const decoded = _decode(bytes, pos, dataEnd, depth + 1);
185
- out.push(decoded.value);
186
- pos = decoded.next;
187
- }
188
- if (pos !== dataEnd) throw new Error("RLP: list length mismatch");
189
- return { value: out, next: dataEnd };
190
- }
191
-
192
- /**
193
- * RLP-encode a value.
194
- * @param {any} value
195
- * @returns {string}
196
- */
197
- function encodeRlp(value) {
198
- return bytesToHex(_encode(value));
199
- }
200
-
201
- /**
202
- * RLP-decode a hex string.
203
- * @param {string} data
204
- * @returns {any}
205
- */
206
- function decodeRlp(data) {
207
- if (typeof data !== "string") throw new TypeError("RLP data must be a hex string");
208
- const bytes = arrayify(data);
209
- const decoded = _decode(bytes, 0, bytes.length, 0);
210
- if (decoded.next !== bytes.length) throw new Error("RLP: trailing data");
211
- return decoded.value;
212
- }
213
-
214
- module.exports = { encodeRlp, decodeRlp };
215
-
@@ -1,29 +0,0 @@
1
- export type BigNumberish = string | number | bigint;
2
- /**
3
- * Format a BigNumberish into a decimal string with `decimals` places.
4
- * @param {BigNumberish} value
5
- * @param {number=} decimals
6
- * @returns {string}
7
- */
8
- export function formatUnits(value: BigNumberish, decimals?: number | undefined): string;
9
- /**
10
- * Parse a decimal string into bigint with `decimals` places.
11
- * @param {string} value
12
- * @param {number=} decimals
13
- * @returns {bigint}
14
- */
15
- export function parseUnits(value: string, decimals?: number | undefined): bigint;
16
- /**
17
- * Format wei as coin string.
18
- * @param {BigNumberish} value
19
- * @returns {string}
20
- */
21
- export function formatEther(value: BigNumberish): string;
22
- /**
23
- * Parse coin string to wei.
24
- * @param {string} value
25
- * @returns {bigint}
26
- */
27
- export function parseEther(value: string): bigint;
28
- import { WeiPerEther } from "../constants";
29
- export { WeiPerEther };
@@ -1,107 +0,0 @@
1
- /**
2
- * @fileoverview Unit conversion helpers (ethers.js v6 compatible names).
3
- */
4
-
5
- const { WeiPerEther } = require("../constants");
6
- const { assertArgument, makeError } = require("../errors");
7
-
8
- /**
9
- * @typedef {string | number | bigint} BigNumberish
10
- */
11
-
12
- function _toBigInt(value) {
13
- if (typeof value === "bigint") return value;
14
- if (typeof value === "number") {
15
- assertArgument(Number.isFinite(value) && Math.floor(value) === value, "invalid number", "value", value);
16
- return BigInt(value);
17
- }
18
- if (typeof value === "string") {
19
- if (value.trim() === "") throw makeError("invalid BigNumberish string", "INVALID_ARGUMENT", { value });
20
- if (value.startsWith("0x") || value.startsWith("0X")) return BigInt(value);
21
- return BigInt(value);
22
- }
23
- throw makeError("invalid BigNumberish", "INVALID_ARGUMENT", { value });
24
- }
25
-
26
- /**
27
- * Format a BigNumberish into a decimal string with `decimals` places.
28
- * @param {BigNumberish} value
29
- * @param {number=} decimals
30
- * @returns {string}
31
- */
32
- function formatUnits(value, decimals) {
33
- const dec = decimals == null ? 18 : decimals;
34
- assertArgument(Number.isInteger(dec) && dec >= 0 && dec <= 256, "invalid decimals", "decimals", decimals);
35
- const v = _toBigInt(value);
36
- const neg = v < 0n;
37
- const abs = neg ? -v : v;
38
-
39
- const base = 10n ** BigInt(dec);
40
- const whole = abs / base;
41
- const frac = abs % base;
42
-
43
- let fracStr = frac.toString().padStart(dec, "0");
44
- // trim trailing zeros
45
- fracStr = fracStr.replace(/0+$/, "");
46
- const out = fracStr.length ? `${whole.toString()}.${fracStr}` : whole.toString();
47
- return neg ? "-" + out : out;
48
- }
49
-
50
- /**
51
- * Parse a decimal string into bigint with `decimals` places.
52
- * @param {string} value
53
- * @param {number=} decimals
54
- * @returns {bigint}
55
- */
56
- function parseUnits(value, decimals) {
57
- const dec = decimals == null ? 18 : decimals;
58
- assertArgument(Number.isInteger(dec) && dec >= 0 && dec <= 256, "invalid decimals", "decimals", decimals);
59
- assertArgument(typeof value === "string", "value must be a string", "value", value);
60
-
61
- const v = value.trim();
62
- assertArgument(v.length > 0, "invalid value", "value", value);
63
-
64
- const neg = v.startsWith("-");
65
- const s = neg ? v.slice(1) : v;
66
- const parts = s.split(".");
67
- assertArgument(parts.length <= 2, "invalid decimal string", "value", value);
68
-
69
- const whole = parts[0] || "0";
70
- const frac = parts[1] || "";
71
- assertArgument(/^\d+$/.test(whole), "invalid whole component", "value", value);
72
- assertArgument(/^\d*$/.test(frac), "invalid fractional component", "value", value);
73
- assertArgument(frac.length <= dec, "fractional component exceeds decimals", "value", value);
74
-
75
- const base = 10n ** BigInt(dec);
76
- const wholeBI = BigInt(whole) * base;
77
- const fracBI = frac.length ? BigInt(frac.padEnd(dec, "0")) : 0n;
78
- const out = wholeBI + fracBI;
79
- return neg ? -out : out;
80
- }
81
-
82
- /**
83
- * Format wei as coin string.
84
- * @param {BigNumberish} value
85
- * @returns {string}
86
- */
87
- function formatEther(value) {
88
- return formatUnits(value, 18);
89
- }
90
-
91
- /**
92
- * Parse coin string to wei.
93
- * @param {string} value
94
- * @returns {bigint}
95
- */
96
- function parseEther(value) {
97
- return parseUnits(value, 18);
98
- }
99
-
100
- module.exports = {
101
- formatUnits,
102
- parseUnits,
103
- formatEther,
104
- parseEther,
105
- WeiPerEther,
106
- };
107
-
@@ -1,10 +0,0 @@
1
- declare const _exports: {
2
- SigningKey: typeof import("./wallet").SigningKey;
3
- AbstractSigner: typeof import("./wallet").AbstractSigner;
4
- BaseWallet: typeof import("./wallet").BaseWallet;
5
- Wallet: typeof import("./wallet").Wallet;
6
- NonceManager: typeof import("./wallet").NonceManager;
7
- JsonRpcSigner: typeof import("./wallet").JsonRpcSigner;
8
- VoidSigner: typeof import("./wallet").VoidSigner;
9
- };
10
- export = _exports;
@@ -1,8 +0,0 @@
1
- /**
2
- * @fileoverview Wallet exports.
3
- */
4
-
5
- module.exports = {
6
- ...require("./wallet"),
7
- };
8
-
@@ -1,192 +0,0 @@
1
- /**
2
- * SigningKey wrapper (PQC private/public key bytes).
3
- */
4
- export class SigningKey {
5
- /**
6
- * @param {Uint8Array} privateKeyBytes
7
- * @param {Uint8Array} publicKeyBytes
8
- */
9
- constructor(privateKeyBytes: Uint8Array, publicKeyBytes: Uint8Array);
10
- privateKeyBytes: Uint8Array<ArrayBuffer>;
11
- publicKeyBytes: Uint8Array<ArrayBuffer>;
12
- }
13
- /**
14
- * AbstractSigner base (minimal).
15
- */
16
- export class AbstractSigner {
17
- /**
18
- * @param {import("../providers/provider").AbstractProvider|null} provider
19
- */
20
- constructor(provider: import("../providers/provider").AbstractProvider | null);
21
- provider: import("../providers/provider").AbstractProvider;
22
- getAddress(): Promise<void>;
23
- }
24
- /**
25
- * BaseWallet - core signing implementation.
26
- */
27
- export class BaseWallet extends AbstractSigner {
28
- /**
29
- * @param {SigningKey} signingKey
30
- * @param {import("../providers/provider").AbstractProvider|null=} provider
31
- * @param {{ address: string }=} precomputed
32
- * @param {any=} qcWallet Internal quantum-coin-js-sdk Wallet (optional)
33
- */
34
- constructor(signingKey: SigningKey, provider?: (import("../providers/provider").AbstractProvider | null) | undefined, precomputed?: {
35
- address: string;
36
- } | undefined, qcWallet?: any | undefined);
37
- signingKey: SigningKey;
38
- _qcWallet: any;
39
- /** @type {string} */
40
- address: string;
41
- readonly publicKey: string;
42
- readonly seed: string | null;
43
- getAddress(): Promise<string>;
44
- /**
45
- * Sign a transaction using quantum-coin-js-sdk signRawTransaction().
46
- * @param {import("../providers/provider").TransactionRequest} tx
47
- * @returns {Promise<string>}
48
- */
49
- signTransaction(tx: import("../providers/provider").TransactionRequest): Promise<string>;
50
- /**
51
- * Signs and sends a transaction.
52
- * @param {import("../providers/provider").TransactionRequest} tx
53
- * @returns {Promise<import("../providers/provider").TransactionResponse>}
54
- */
55
- sendTransaction(tx: import("../providers/provider").TransactionRequest): Promise<import("../providers/provider").TransactionResponse>;
56
- }
57
- /**
58
- * Wallet - convenience methods around BaseWallet.
59
- */
60
- export class Wallet extends BaseWallet {
61
- /**
62
- * Returns the seed phrase (list of words) if this wallet has a seed, else null.
63
- * Derived from the stored pre-expansion seed via seed-words.getWordListFromSeedArray.
64
- */
65
- getPhrase(): string[] | null;
66
- /**
67
- * Returns the recommended signing context for this wallet.
68
- * Setting fullSign to true may incur additional gas cost.
69
- * @param {boolean|null=} fullSign Defaults to false when null or omitted.
70
- * @returns {number}
71
- */
72
- getSigningContext(fullSign?: boolean | null): number;
73
- /**
74
- * Creates a new random wallet.
75
- * @param {import("../providers/provider").AbstractProvider=} provider
76
- * @param {number|null=} keyType Optional key type: null (default=3), 3, or 5
77
- * @returns {Wallet}
78
- */
79
- static createRandom(provider?: import("../providers/provider").AbstractProvider | undefined, keyType?: number | null): Wallet;
80
- /**
81
- * Creates a wallet from raw seed bytes.
82
- * @param {number[]} seed Raw seed bytes: 64 (keyType 3), 72 (keyType 5), or 96 (legacy)
83
- * @param {import("../providers/provider").AbstractProvider=} provider
84
- * @returns {Wallet}
85
- */
86
- static fromSeed(seed: number[], provider?: import("../providers/provider").AbstractProvider | undefined): Wallet;
87
- /**
88
- * Creates a wallet from an encrypted JSON string.
89
- * @param {string} json
90
- * @param {string} password
91
- * @param {import("../providers/provider").AbstractProvider=} provider
92
- * @returns {Wallet}
93
- */
94
- static fromEncryptedJsonSync(json: string, password: string, provider?: import("../providers/provider").AbstractProvider | undefined): Wallet;
95
- /**
96
- * Creates a wallet from a seed phrase (32, 36, or 48 words).
97
- * @param {string|string[]} phrase
98
- * @param {import("../providers/provider").AbstractProvider=} provider
99
- * @returns {Wallet}
100
- */
101
- static fromPhrase(phrase: string | string[], provider?: import("../providers/provider").AbstractProvider | undefined): Wallet;
102
- /**
103
- * Creates a wallet from raw private and public key bytes.
104
- * @param {Uint8Array|string} privateKey Private key bytes or hex string
105
- * @param {Uint8Array|string} publicKey Public key bytes or hex string
106
- * @param {import("../providers/provider").AbstractProvider=} provider
107
- * @returns {Wallet}
108
- */
109
- static fromKeys(privateKey: Uint8Array | string, publicKey: Uint8Array | string, provider?: import("../providers/provider").AbstractProvider | undefined): Wallet;
110
- /**
111
- * Internal helper: build a Wallet from a quantum-coin-js-sdk Wallet object.
112
- * @param {any} qcWallet
113
- * @param {import("../providers/provider").AbstractProvider|null} provider
114
- * @returns {Wallet}
115
- */
116
- static _fromQcWallet(qcWallet: any, provider: import("../providers/provider").AbstractProvider | null): Wallet;
117
- /**
118
- * @param {string|Uint8Array|SigningKey} key
119
- * @param {import("../providers/provider").AbstractProvider=} provider
120
- */
121
- constructor(key: string | Uint8Array | SigningKey, provider?: import("../providers/provider").AbstractProvider | undefined);
122
- /**
123
- * Returns wallet address (sync).
124
- * @returns {string}
125
- */
126
- getAddress(): string;
127
- /**
128
- * Returns wallet balance.
129
- * @param {string=} blockTag
130
- * @returns {Promise<bigint>}
131
- */
132
- getBalance(blockTag?: string | undefined): Promise<bigint>;
133
- /**
134
- * Returns wallet nonce.
135
- * @param {string=} blockTag
136
- * @returns {Promise<number>}
137
- */
138
- getTransactionCount(blockTag?: string | undefined): Promise<number>;
139
- /**
140
- * Encrypts and serializes this wallet to JSON.
141
- * @param {string|Uint8Array} password
142
- * @returns {string}
143
- */
144
- encryptSync(password: string | Uint8Array): string;
145
- /**
146
- * Encrypts raw seed bytes into a wallet JSON string (version 5 pre-expansion format).
147
- * The resulting JSON can be opened with `Wallet.fromEncryptedJsonSync()` or
148
- * Desktop/Mobile/Web/CLI wallet applications.
149
- * @param {number[]|Uint8Array} seed Raw seed bytes: 64 (keyType 3), 72 (keyType 5), or 96 (legacy)
150
- * @param {string|Uint8Array} password Passphrase (at least 12 characters)
151
- * @returns {string}
152
- */
153
- static encryptSeedSync(seed: number[] | Uint8Array, password: string | Uint8Array): string;
154
- /**
155
- * Returns a new wallet connected to a provider.
156
- * @param {import("../providers/provider").AbstractProvider} provider
157
- * @returns {Wallet}
158
- */
159
- connect(provider: import("../providers/provider").AbstractProvider): Wallet;
160
- }
161
- /**
162
- * NonceManager wrapper.
163
- */
164
- export class NonceManager extends AbstractSigner {
165
- /**
166
- * @param {AbstractSigner} signer
167
- */
168
- constructor(signer: AbstractSigner);
169
- signer: AbstractSigner;
170
- _nonce: any;
171
- getTransactionCount(blockTag: any): any;
172
- sendTransaction(tx: any): Promise<any>;
173
- reset(): void;
174
- increment(): void;
175
- }
176
- /**
177
- * JsonRpcSigner placeholder (ethers-like).
178
- * This SDK encourages using Wallet directly for signing.
179
- */
180
- export class JsonRpcSigner extends AbstractSigner {
181
- constructor(provider: any, address: any);
182
- _address: any;
183
- getAddress(): Promise<any>;
184
- }
185
- /**
186
- * VoidSigner (cannot sign, only provides address).
187
- */
188
- export class VoidSigner extends AbstractSigner {
189
- constructor(address: any, provider: any);
190
- _address: string;
191
- getAddress(): Promise<string>;
192
- }