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,298 +0,0 @@
1
- /**
2
- * @fileoverview Hash utilities (ethers.js v6 compatible names).
3
- *
4
- * Where possible, we use Node's built-in crypto module. For keccak256,
5
- * we prefer a native OpenSSL implementation if available, otherwise we
6
- * fall back to a small pure-JS Keccak-256 implementation.
7
- */
8
-
9
- const crypto = require("crypto");
10
- const { arrayify, bytesToHex, utf8ToBytes } = require("../internal/hex");
11
-
12
- const _MASK64 = (1n << 64n) - 1n;
13
-
14
- function _rotl64(x, n) {
15
- const nn = BigInt(n);
16
- return ((x << nn) | (x >> (64n - nn))) & _MASK64;
17
- }
18
-
19
- function _readU64LE(bytes, off) {
20
- let x = 0n;
21
- for (let i = 0; i < 8; i++) {
22
- x |= BigInt(bytes[off + i]) << (8n * BigInt(i));
23
- }
24
- return x;
25
- }
26
-
27
- function _writeU64LE(out, off, x) {
28
- let v = x & _MASK64;
29
- for (let i = 0; i < 8; i++) {
30
- out[off + i] = Number((v >> (8n * BigInt(i))) & 0xffn);
31
- }
32
- }
33
-
34
- // Keccak-f[1600] round constants
35
- const _RC = [
36
- 0x0000000000000001n, 0x0000000000008082n, 0x800000000000808an, 0x8000000080008000n,
37
- 0x000000000000808bn, 0x0000000080000001n, 0x8000000080008081n, 0x8000000000008009n,
38
- 0x000000000000008an, 0x0000000000000088n, 0x0000000080008009n, 0x000000008000000an,
39
- 0x000000008000808bn, 0x800000000000008bn, 0x8000000000008089n, 0x8000000000008003n,
40
- 0x8000000000008002n, 0x8000000000000080n, 0x000000000000800an, 0x800000008000000an,
41
- 0x8000000080008081n, 0x8000000000008080n, 0x0000000080000001n, 0x8000000080008008n,
42
- ];
43
-
44
- // Rotation offsets (rho step)
45
- const _R = [
46
- // Indexed by lane index (x + 5*y) where x,y in [0..4]
47
- // (This is the standard Keccak rho offsets table, flattened in y-major order.)
48
- 0, 1, 62, 28, 27,
49
- 36, 44, 6, 55, 20,
50
- 3, 10, 43, 25, 39,
51
- 41, 45, 15, 21, 8,
52
- 18, 2, 61, 56, 14,
53
- ];
54
-
55
- // Pi step mapping: index -> newIndex
56
- const _PI = [
57
- 0, 10, 20, 5, 15,
58
- 16, 1, 11, 21, 6,
59
- 7, 17, 2, 12, 22,
60
- 23, 8, 18, 3, 13,
61
- 14, 24, 9, 19, 4,
62
- ];
63
-
64
- function _keccakF1600(state) {
65
- const b = new Array(25);
66
- const c = new Array(5);
67
- const d = new Array(5);
68
-
69
- for (let round = 0; round < 24; round++) {
70
- // Theta
71
- for (let x = 0; x < 5; x++) {
72
- c[x] = state[x] ^ state[x + 5] ^ state[x + 10] ^ state[x + 15] ^ state[x + 20];
73
- }
74
- for (let x = 0; x < 5; x++) {
75
- d[x] = c[(x + 4) % 5] ^ _rotl64(c[(x + 1) % 5], 1);
76
- }
77
- for (let i = 0; i < 25; i++) {
78
- state[i] = (state[i] ^ d[i % 5]) & _MASK64;
79
- }
80
-
81
- // Rho + Pi
82
- for (let i = 0; i < 25; i++) {
83
- b[_PI[i]] = _rotl64(state[i], _R[i]);
84
- }
85
-
86
- // Chi
87
- for (let y = 0; y < 5; y++) {
88
- const row = y * 5;
89
- for (let x = 0; x < 5; x++) {
90
- state[row + x] = (b[row + x] ^ ((~b[row + ((x + 1) % 5)]) & b[row + ((x + 2) % 5)])) & _MASK64;
91
- }
92
- }
93
-
94
- // Iota
95
- state[0] = (state[0] ^ _RC[round]) & _MASK64;
96
- }
97
- }
98
-
99
- function _keccak256Bytes(bytes) {
100
- // Keccak-256: rate=1088 bits => 136 bytes
101
- const rate = 136;
102
- const outLen = 32;
103
- const state = new Array(25).fill(0n);
104
-
105
- let offset = 0;
106
- while (offset + rate <= bytes.length) {
107
- for (let i = 0; i < rate / 8; i++) {
108
- state[i] = (state[i] ^ _readU64LE(bytes, offset + i * 8)) & _MASK64;
109
- }
110
- _keccakF1600(state);
111
- offset += rate;
112
- }
113
-
114
- // Final block + padding (keccak pad10*1 with domain 0x01)
115
- const block = new Uint8Array(rate);
116
- const remaining = bytes.length - offset;
117
- block.set(bytes.slice(offset), 0);
118
- block[remaining] = 0x01;
119
- block[rate - 1] |= 0x80;
120
-
121
- for (let i = 0; i < rate / 8; i++) {
122
- state[i] = (state[i] ^ _readU64LE(block, i * 8)) & _MASK64;
123
- }
124
- _keccakF1600(state);
125
-
126
- const out = new Uint8Array(outLen);
127
- let outOff = 0;
128
- let lane = 0;
129
- while (outOff < outLen) {
130
- const tmp = new Uint8Array(8);
131
- _writeU64LE(tmp, 0, state[lane]);
132
- const take = Math.min(8, outLen - outOff);
133
- out.set(tmp.slice(0, take), outOff);
134
- outOff += take;
135
- lane++;
136
- }
137
- return out;
138
- }
139
-
140
- function _hash(alg, data) {
141
- const bytes = arrayify(data);
142
- return bytesToHex(crypto.createHash(alg).update(Buffer.from(bytes)).digest());
143
- }
144
-
145
- /**
146
- * keccak256 hash of BytesLike.
147
- * @param {string|Uint8Array} data
148
- * @returns {string}
149
- */
150
- function keccak256(data) {
151
- const bytes = arrayify(data);
152
- const hashes = crypto.getHashes();
153
-
154
- // Prefer native keccak if available (varies by Node/OpenSSL build).
155
- if (hashes.includes("keccak256")) {
156
- return bytesToHex(crypto.createHash("keccak256").update(Buffer.from(bytes)).digest());
157
- }
158
- if (hashes.includes("keccak-256")) {
159
- return bytesToHex(crypto.createHash("keccak-256").update(Buffer.from(bytes)).digest());
160
- }
161
-
162
- // Fallback: pure JS Keccak-256
163
- return bytesToHex(_keccak256Bytes(bytes));
164
- }
165
-
166
- /**
167
- * sha256 hash of BytesLike.
168
- * @param {string|Uint8Array} data
169
- * @returns {string}
170
- */
171
- function sha256(data) {
172
- return _hash("sha256", data);
173
- }
174
-
175
- /**
176
- * sha512 hash of BytesLike.
177
- * @param {string|Uint8Array} data
178
- * @returns {string}
179
- */
180
- function sha512(data) {
181
- return _hash("sha512", data);
182
- }
183
-
184
- /**
185
- * ripemd160 hash of BytesLike.
186
- * @param {string|Uint8Array} data
187
- * @returns {string}
188
- */
189
- function ripemd160(data) {
190
- return _hash("ripemd160", data);
191
- }
192
-
193
- /**
194
- * ethers-style id(text) => keccak256(utf8Bytes(text))
195
- * @param {string} text
196
- * @returns {string}
197
- */
198
- function id(text) {
199
- return keccak256(utf8ToBytes(text));
200
- }
201
-
202
- /**
203
- * Generate cryptographically strong random bytes.
204
- * @param {number} length
205
- * @returns {Uint8Array}
206
- */
207
- function randomBytes(length) {
208
- return new Uint8Array(crypto.randomBytes(length));
209
- }
210
-
211
- /**
212
- * Compute HMAC over data.
213
- * @param {string} algorithm
214
- * @param {string|Uint8Array} key
215
- * @param {string|Uint8Array} data
216
- * @returns {string}
217
- */
218
- function computeHmac(algorithm, key, data) {
219
- const k = typeof key === "string" ? utf8ToBytes(key) : arrayify(key);
220
- const d = typeof data === "string" ? utf8ToBytes(data) : arrayify(data);
221
- const h = crypto.createHmac(algorithm, Buffer.from(k)).update(Buffer.from(d)).digest();
222
- return bytesToHex(new Uint8Array(h));
223
- }
224
-
225
- /**
226
- * PBKDF2 (sync) helper returning hex string.
227
- * @param {string|Uint8Array} password
228
- * @param {string|Uint8Array} salt
229
- * @param {number} iterations
230
- * @param {number} keylen
231
- * @param {string=} algorithm
232
- * @returns {string}
233
- */
234
- function pbkdf2(password, salt, iterations, keylen, algorithm) {
235
- const p = typeof password === "string" ? utf8ToBytes(password) : arrayify(password);
236
- const s = typeof salt === "string" ? utf8ToBytes(salt) : arrayify(salt);
237
- const a = algorithm || "sha256";
238
- const out = crypto.pbkdf2Sync(Buffer.from(p), Buffer.from(s), iterations, keylen, a);
239
- return bytesToHex(new Uint8Array(out));
240
- }
241
-
242
- /**
243
- * scrypt (async) helper returning hex string.
244
- * @param {string|Uint8Array} password
245
- * @param {string|Uint8Array} salt
246
- * @param {number} N
247
- * @param {number} r
248
- * @param {number} p
249
- * @param {number} dkLen
250
- * @returns {Promise<string>}
251
- */
252
- function scrypt(password, salt, N, r, p, dkLen) {
253
- const pw = typeof password === "string" ? utf8ToBytes(password) : arrayify(password);
254
- const sa = typeof salt === "string" ? utf8ToBytes(salt) : arrayify(salt);
255
- return new Promise((resolve, reject) => {
256
- crypto.scrypt(
257
- Buffer.from(pw),
258
- Buffer.from(sa),
259
- dkLen,
260
- { N, r, p, maxmem: 128 * 1024 * 1024 },
261
- (err, derived) => {
262
- if (err) return reject(err);
263
- resolve(bytesToHex(new Uint8Array(derived)));
264
- },
265
- );
266
- });
267
- }
268
-
269
- /**
270
- * scrypt (sync) helper returning hex string.
271
- * @param {string|Uint8Array} password
272
- * @param {string|Uint8Array} salt
273
- * @param {number} N
274
- * @param {number} r
275
- * @param {number} p
276
- * @param {number} dkLen
277
- * @returns {string}
278
- */
279
- function scryptSync(password, salt, N, r, p, dkLen) {
280
- const pw = typeof password === "string" ? utf8ToBytes(password) : arrayify(password);
281
- const sa = typeof salt === "string" ? utf8ToBytes(salt) : arrayify(salt);
282
- const out = crypto.scryptSync(Buffer.from(pw), Buffer.from(sa), dkLen, { N, r, p, maxmem: 257 * 1024 * 1024 }); //257 instead of 256 for buffer for compat for N=262144, r=8, p=1
283
- return bytesToHex(new Uint8Array(out));
284
- }
285
-
286
- module.exports = {
287
- keccak256,
288
- sha256,
289
- sha512,
290
- ripemd160,
291
- id,
292
- randomBytes,
293
- computeHmac,
294
- pbkdf2,
295
- scrypt,
296
- scryptSync,
297
- };
298
-
@@ -1,63 +0,0 @@
1
- declare const _exports: {
2
- formatUnits(value: import("./units").BigNumberish, decimals?: number | undefined): string;
3
- parseUnits(value: string, decimals?: number | undefined): bigint;
4
- formatEther(value: import("./units").BigNumberish): string;
5
- parseEther(value: string): bigint;
6
- WeiPerEther: bigint;
7
- checkResultErrors(result: any): Array<{
8
- error: Error;
9
- path: Array<string | number>;
10
- }>;
11
- Result: typeof import("./result").Result;
12
- encodeRlp(value: any): string;
13
- decodeRlp(data: string): any;
14
- keccak256(data: string | Uint8Array): string;
15
- sha256(data: string | Uint8Array): string;
16
- sha512(data: string | Uint8Array): string;
17
- ripemd160(data: string | Uint8Array): string;
18
- id(text: string): string;
19
- randomBytes(length: number): Uint8Array;
20
- computeHmac(algorithm: string, key: string | Uint8Array, data: string | Uint8Array): string;
21
- pbkdf2(password: string | Uint8Array, salt: string | Uint8Array, iterations: number, keylen: number, algorithm?: string | undefined): string;
22
- scrypt(password: string | Uint8Array, salt: string | Uint8Array, N: number, r: number, p: number, dkLen: number): Promise<string>;
23
- scryptSync(password: string | Uint8Array, salt: string | Uint8Array, N: number, r: number, p: number, dkLen: number): string;
24
- toUtf8String(data: import("./encoding").BytesLike): string;
25
- toUtf8Bytes(str: string): Uint8Array;
26
- toHex(data: import("./encoding").BytesLike): string;
27
- hexlify(data: import("./encoding").BytesLike): string;
28
- arrayify(data: import("./encoding").BytesLike): Uint8Array;
29
- concat(items: import("./encoding").BytesLike[]): string;
30
- stripZerosLeft(data: import("./encoding").BytesLike): string;
31
- encodeBytes32String(text: string): string;
32
- decodeBytes32String(bytes: import("./encoding").BytesLike): string;
33
- decodeBase58(data: string): Uint8Array;
34
- decodeBase64(data: string): Uint8Array;
35
- encodeBase58(data: import("./encoding").BytesLike): string;
36
- encodeBase64(data: import("./encoding").BytesLike): string;
37
- toUtf8CodePoints(str: string): number[];
38
- isBytesLike(value: any): boolean;
39
- zeroPad(value: import("./encoding").BytesLike, length: number): string;
40
- zeroPadValue(value: import("./encoding").BytesLike, length: number): string;
41
- solidityPacked(): void;
42
- solidityPackedKeccak256(): void;
43
- solidityPackedSha256(): void;
44
- isHexString: typeof import("./encoding").isHexString;
45
- bytesToHex: typeof import("./encoding").bytesToHex;
46
- hexToBytes: typeof import("./encoding").hexToBytes;
47
- isAddress(address: string): boolean;
48
- getAddress(address: string): string;
49
- isAddressable(value: any): boolean;
50
- resolveAddress(target: any): string | Promise<string>;
51
- getContractAddress(tx: {
52
- from: string;
53
- nonce: number;
54
- }): string;
55
- getCreateAddress(tx: {
56
- from: string;
57
- nonce: number;
58
- }): string;
59
- getCreate2Address(from: string, salt: string, initCodeHash: string): string;
60
- computeAddress(key: string | Uint8Array): string;
61
- FixedNumber: typeof import("./fixednumber").FixedNumber;
62
- };
63
- export = _exports;
@@ -1,14 +0,0 @@
1
- /**
2
- * @fileoverview Utilities export barrel.
3
- */
4
-
5
- module.exports = {
6
- ...require("./address"),
7
- ...require("./encoding"),
8
- ...require("./hashing"),
9
- ...require("./rlp"),
10
- ...require("./result"),
11
- ...require("./units"),
12
- ...require("./fixednumber"),
13
- };
14
-
@@ -1,57 +0,0 @@
1
- /**
2
- * @fileoverview Result utility (ethers.js v6 compatible).
3
- *
4
- * ethers.js Result is an Array-like with optional named keys.
5
- * This simplified implementation covers the common patterns used in this SDK.
6
- */
7
- export class Result extends Array<any> {
8
- /**
9
- * @param {Array<any>} items
10
- * @param {Array<null|string>=} keys
11
- * @returns {Result}
12
- */
13
- static fromItems(items: Array<any>, keys?: Array<null | string> | undefined): Result;
14
- /**
15
- * @param {any[]=} items
16
- * @param {(null|string)[]=} keys
17
- */
18
- constructor(items?: any[] | undefined, keys?: (null | string)[] | undefined);
19
- /** @type {(null|string)[]|null} */
20
- _keys: (null | string)[] | null;
21
- /**
22
- * Get a value by key.
23
- * @param {string} name
24
- * @returns {any}
25
- */
26
- getValue(name: string): any;
27
- /**
28
- * Convert to array (optionally deep).
29
- * @param {boolean=} deep
30
- * @returns {any[]}
31
- */
32
- toArray(deep?: boolean | undefined): any[];
33
- /**
34
- * Convert to object (optionally deep).
35
- * @param {boolean=} deep
36
- * @returns {Record<string, any>}
37
- */
38
- toObject(deep?: boolean | undefined): Record<string, any>;
39
- }
40
- /**
41
- * Scan a decoded Result (or nested structure) for embedded Error objects.
42
- *
43
- * ethers.js uses this to surface nested decode errors (especially for tuples
44
- * and structs). This lightweight implementation walks:
45
- * - Result instances (by index; prefers named keys in the path when available)
46
- * - Arrays
47
- * - Plain objects (for struct-like outputs)
48
- *
49
- * It is cycle-safe.
50
- *
51
- * @param {any} result
52
- * @returns {Array<{ error: Error, path: Array<string|number> }>}
53
- */
54
- export function checkResultErrors(result: any): Array<{
55
- error: Error;
56
- path: Array<string | number>;
57
- }>;
@@ -1,128 +0,0 @@
1
- /**
2
- * @fileoverview Result utility (ethers.js v6 compatible).
3
- *
4
- * ethers.js Result is an Array-like with optional named keys.
5
- * This simplified implementation covers the common patterns used in this SDK.
6
- */
7
-
8
- class Result extends Array {
9
- /**
10
- * @param {any[]=} items
11
- * @param {(null|string)[]=} keys
12
- */
13
- constructor(items, keys) {
14
- super();
15
- if (Array.isArray(items)) this.push(...items);
16
- /** @type {(null|string)[]|null} */
17
- this._keys = Array.isArray(keys) ? keys : null;
18
-
19
- if (this._keys) {
20
- for (let i = 0; i < this._keys.length; i++) {
21
- const k = this._keys[i];
22
- if (k) this[k] = this[i];
23
- }
24
- }
25
- }
26
-
27
- /**
28
- * @param {Array<any>} items
29
- * @param {Array<null|string>=} keys
30
- * @returns {Result}
31
- */
32
- static fromItems(items, keys) {
33
- return new Result(items, keys);
34
- }
35
-
36
- /**
37
- * Get a value by key.
38
- * @param {string} name
39
- * @returns {any}
40
- */
41
- getValue(name) {
42
- return this[name];
43
- }
44
-
45
- /**
46
- * Convert to array (optionally deep).
47
- * @param {boolean=} deep
48
- * @returns {any[]}
49
- */
50
- toArray(deep) {
51
- if (!deep) return Array.from(this);
52
- return Array.from(this).map((v) => (v instanceof Result ? v.toArray(true) : v));
53
- }
54
-
55
- /**
56
- * Convert to object (optionally deep).
57
- * @param {boolean=} deep
58
- * @returns {Record<string, any>}
59
- */
60
- toObject(deep) {
61
- const out = {};
62
- if (!this._keys) return out;
63
- for (const k of this._keys) {
64
- if (!k) continue;
65
- const v = this[k];
66
- out[k] = deep && v instanceof Result ? v.toObject(true) : v;
67
- }
68
- return out;
69
- }
70
- }
71
-
72
- /**
73
- * Scan a decoded Result (or nested structure) for embedded Error objects.
74
- *
75
- * ethers.js uses this to surface nested decode errors (especially for tuples
76
- * and structs). This lightweight implementation walks:
77
- * - Result instances (by index; prefers named keys in the path when available)
78
- * - Arrays
79
- * - Plain objects (for struct-like outputs)
80
- *
81
- * It is cycle-safe.
82
- *
83
- * @param {any} result
84
- * @returns {Array<{ error: Error, path: Array<string|number> }>}
85
- */
86
- function checkResultErrors(result) {
87
- /** @type {Array<{ error: Error, path: Array<string|number> }>} */
88
- const out = [];
89
- const seen = new WeakSet();
90
-
91
- /**
92
- * @param {any} value
93
- * @param {Array<string|number>} path
94
- */
95
- function walk(value, path) {
96
- if (value instanceof Error) {
97
- out.push({ error: value, path });
98
- return;
99
- }
100
- if (!value || (typeof value !== "object" && typeof value !== "function")) return;
101
- if (seen.has(value)) return;
102
- seen.add(value);
103
-
104
- // Prefer walking Result/Array by index to avoid duplicates (Result also has named keys).
105
- if (value instanceof Result || Array.isArray(value)) {
106
- const keys = value instanceof Result ? value._keys : null;
107
- for (let i = 0; i < value.length; i++) {
108
- const k = Array.isArray(keys) && keys[i] ? keys[i] : i;
109
- walk(value[i], path.concat([k]));
110
- }
111
- return;
112
- }
113
-
114
- // Walk only plain objects to avoid traversing things like Buffers, Dates, etc.
115
- const proto = Object.getPrototypeOf(value);
116
- if (proto === Object.prototype || proto === null) {
117
- for (const k of Object.keys(value)) {
118
- walk(value[k], path.concat([k]));
119
- }
120
- }
121
- }
122
-
123
- walk(result, []);
124
- return out;
125
- }
126
-
127
- module.exports = { Result, checkResultErrors };
128
-
@@ -1,12 +0,0 @@
1
- /**
2
- * RLP-encode a value.
3
- * @param {any} value
4
- * @returns {string}
5
- */
6
- export function encodeRlp(value: any): string;
7
- /**
8
- * RLP-decode a hex string.
9
- * @param {string} data
10
- * @returns {any}
11
- */
12
- export function decodeRlp(data: string): any;