quantumcoin 7.0.12 → 7.0.14

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 (214) hide show
  1. package/README-SDK.md +828 -823
  2. package/README.md +4 -0
  3. package/config.d.ts +50 -50
  4. package/examples/example-generated-sdk-js/README.md +65 -0
  5. package/examples/example-generated-sdk-js/examples/_test-wallet.js +17 -0
  6. package/examples/example-generated-sdk-js/examples/deploy.js +41 -0
  7. package/examples/example-generated-sdk-js/examples/events.js +36 -0
  8. package/examples/example-generated-sdk-js/examples/read-operations.js +46 -0
  9. package/examples/example-generated-sdk-js/examples/write-operations.js +44 -0
  10. package/examples/example-generated-sdk-js/index.d.ts +1 -0
  11. package/examples/example-generated-sdk-js/index.js +15 -0
  12. package/examples/example-generated-sdk-js/package-lock.json +59 -0
  13. package/examples/example-generated-sdk-js/package.json +22 -0
  14. package/examples/example-generated-sdk-js/src/SimpleERC20.d.ts +19 -0
  15. package/examples/example-generated-sdk-js/src/SimpleERC20.js +353 -0
  16. package/examples/example-generated-sdk-js/src/SimpleERC20__factory.d.ts +10 -0
  17. package/examples/example-generated-sdk-js/src/SimpleERC20__factory.js +29 -0
  18. package/examples/example-generated-sdk-js/src/index.d.ts +4 -0
  19. package/examples/example-generated-sdk-js/src/index.js +5 -0
  20. package/examples/example-generated-sdk-js/src/quantumcoin-shims.d.ts +23 -0
  21. package/examples/example-generated-sdk-js/src/types.d.ts +3 -0
  22. package/examples/example-generated-sdk-js/src/types.js +3 -0
  23. package/examples/example-generated-sdk-js/test/e2e/SimpleERC20.e2e.test.js +78 -0
  24. package/examples/example-generated-sdk-ts/README.md +65 -0
  25. package/examples/example-generated-sdk-ts/examples/_test-wallet.js +17 -0
  26. package/examples/example-generated-sdk-ts/examples/deploy.js +41 -0
  27. package/examples/example-generated-sdk-ts/examples/events.js +36 -0
  28. package/examples/example-generated-sdk-ts/examples/read-operations.js +46 -0
  29. package/examples/example-generated-sdk-ts/examples/write-operations.js +44 -0
  30. package/examples/example-generated-sdk-ts/index.d.ts +1 -0
  31. package/examples/example-generated-sdk-ts/index.js +15 -0
  32. package/examples/example-generated-sdk-ts/package-lock.json +59 -0
  33. package/examples/example-generated-sdk-ts/package.json +23 -0
  34. package/examples/example-generated-sdk-ts/src/SimpleERC20.ts +334 -0
  35. package/examples/example-generated-sdk-ts/src/SimpleERC20__factory.ts +28 -0
  36. package/examples/example-generated-sdk-ts/src/index.ts +4 -0
  37. package/examples/example-generated-sdk-ts/src/quantumcoin-shims.d.ts +23 -0
  38. package/examples/example-generated-sdk-ts/src/types.ts +4 -0
  39. package/examples/example-generated-sdk-ts/test/e2e/SimpleERC20.e2e.test.js +78 -0
  40. package/examples/example-generated-sdk-ts/tsconfig.json +14 -0
  41. package/examples/node_modules/.package-lock.json +5 -5
  42. package/examples/node_modules/quantum-coin-js-sdk/README.md +5 -5
  43. package/examples/node_modules/quantum-coin-js-sdk/example/package-lock.json +1 -1
  44. package/examples/node_modules/quantum-coin-js-sdk/index.d.ts +1031 -1031
  45. package/examples/node_modules/quantum-coin-js-sdk/index.js +15 -15
  46. package/examples/node_modules/quantum-coin-js-sdk/package.json +1 -1
  47. package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.js +2 -2
  48. package/examples/package-lock.json +6 -6
  49. package/examples/package.json +1 -1
  50. package/examples/sdk-generator-erc20.inline.json +251 -251
  51. package/generate-sdk.js +1845 -1822
  52. package/package.json +2 -2
  53. package/src/abi/fragments.d.ts +42 -42
  54. package/src/abi/index.d.ts +13 -13
  55. package/src/abi/interface.js +11 -2
  56. package/src/abi/js-abi-coder.js +61 -2
  57. package/src/contract/contract.js +53 -5
  58. package/src/contract/index.d.ts +9 -9
  59. package/src/errors/index.d.ts +92 -92
  60. package/src/generator/index.d.ts +11 -4
  61. package/src/generator/index.js +185 -18
  62. package/src/internal/hex.d.ts +68 -61
  63. package/src/internal/hex.js +36 -0
  64. package/src/providers/json-rpc-provider.d.ts +12 -12
  65. package/src/providers/provider.js +141 -8
  66. package/src/utils/address.d.ts +58 -58
  67. package/src/utils/encoding.d.ts +120 -120
  68. package/src/utils/hashing.js +298 -298
  69. package/src/utils/index.d.ts +63 -63
  70. package/src/utils/index.js +14 -14
  71. package/src/utils/result.d.ts +57 -57
  72. package/src/utils/rlp.d.ts +12 -12
  73. package/src/utils/rlp.js +13 -1
  74. package/src/utils/units.d.ts +29 -29
  75. package/src/wallet/index.d.ts +10 -10
  76. package/src/wallet/wallet.d.ts +192 -192
  77. package/src/wallet/wallet.js +713 -630
  78. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/README.md +83 -0
  79. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.abi.json +12544 -0
  80. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.bin +1 -0
  81. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.js +17 -0
  82. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.ts +10 -0
  83. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.js +41 -0
  84. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.ts +41 -0
  85. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.js +36 -0
  86. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.ts +36 -0
  87. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.js +82 -0
  88. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.ts +80 -0
  89. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.js +46 -0
  90. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.ts +44 -0
  91. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.js +44 -0
  92. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.ts +44 -0
  93. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.d.ts +1 -0
  94. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.js +21 -0
  95. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package-lock.json +597 -0
  96. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package.json +25 -0
  97. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.d.ts +1280 -0
  98. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.js +14021 -0
  99. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.d.ts +11 -0
  100. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.js +31 -0
  101. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.d.ts +4 -0
  102. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.js +5 -0
  103. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/quantumcoin-shims.d.ts +25 -0
  104. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.d.ts +3 -0
  105. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.js +3 -0
  106. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.e2e.test.js +77 -0
  107. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.extra.test.js +195 -0
  108. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/README.md +83 -0
  109. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.abi.json +12544 -0
  110. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.bin +1 -0
  111. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.js +17 -0
  112. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.ts +10 -0
  113. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.js +41 -0
  114. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.ts +41 -0
  115. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.js +36 -0
  116. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.ts +36 -0
  117. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.js +82 -0
  118. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.ts +80 -0
  119. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.js +46 -0
  120. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.ts +44 -0
  121. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.js +44 -0
  122. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.ts +44 -0
  123. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.d.ts +1 -0
  124. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.js +21 -0
  125. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package-lock.json +597 -0
  126. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package.json +26 -0
  127. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes.ts +13940 -0
  128. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes__factory.ts +31 -0
  129. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/index.ts +4 -0
  130. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/quantumcoin-shims.d.ts +25 -0
  131. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/types.ts +4 -0
  132. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.e2e.test.js +77 -0
  133. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.extra.test.js +195 -0
  134. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/tsconfig.json +18 -0
  135. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/README.md +74 -0
  136. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.abi.json +245 -0
  137. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.bin +1 -0
  138. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.js +17 -0
  139. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.ts +10 -0
  140. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.js +41 -0
  141. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.ts +41 -0
  142. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.js +36 -0
  143. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.ts +36 -0
  144. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.js +82 -0
  145. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.ts +80 -0
  146. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.js +46 -0
  147. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.ts +44 -0
  148. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.js +44 -0
  149. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.ts +44 -0
  150. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.d.ts +1 -0
  151. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.js +16 -0
  152. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package-lock.json +597 -0
  153. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package.json +25 -0
  154. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.d.ts +24 -0
  155. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.js +378 -0
  156. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.d.ts +10 -0
  157. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.js +31 -0
  158. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.d.ts +4 -0
  159. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.js +5 -0
  160. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/quantumcoin-shims.d.ts +25 -0
  161. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.d.ts +3 -0
  162. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.js +3 -0
  163. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/test/e2e/SimpleERC20.e2e.test.js +90 -0
  164. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/README.md +74 -0
  165. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.abi.json +245 -0
  166. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.bin +1 -0
  167. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.js +17 -0
  168. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.ts +10 -0
  169. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.js +41 -0
  170. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.ts +41 -0
  171. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.js +36 -0
  172. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.ts +36 -0
  173. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.js +82 -0
  174. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.ts +80 -0
  175. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.js +46 -0
  176. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.ts +44 -0
  177. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.js +44 -0
  178. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.ts +44 -0
  179. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.d.ts +1 -0
  180. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.js +16 -0
  181. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package-lock.json +597 -0
  182. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package.json +26 -0
  183. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20.ts +361 -0
  184. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20__factory.ts +30 -0
  185. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/index.ts +4 -0
  186. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/quantumcoin-shims.d.ts +25 -0
  187. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/types.ts +4 -0
  188. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/test/e2e/SimpleERC20.e2e.test.js +90 -0
  189. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/tsconfig.json +18 -0
  190. package/test/e2e/generator-interface.e2e.test.js +165 -0
  191. package/test/e2e/generator-interface.e2e.test.ts +160 -0
  192. package/test/e2e/signing-context-and-fee.e2e.test.js +141 -141
  193. package/test/e2e/signing-context-and-fee.e2e.test.ts +128 -128
  194. package/test/integration/provider.test.js +88 -88
  195. package/test/security/abi-decoder-bounds.test.js +122 -0
  196. package/test/security/contract-overrides.test.js +112 -0
  197. package/test/security/generator-injection.test.js +195 -0
  198. package/test/security/malformed-input.test.js +26 -27
  199. package/test/security/rpc-numeric-bounds.test.js +81 -0
  200. package/test/security/rpc-trust.test.js +202 -0
  201. package/test/unit/abi-interface.test.js +12 -5
  202. package/test/unit/abi-interface.test.ts +8 -1
  203. package/test/unit/address-wallet.test.js +923 -892
  204. package/test/unit/address-wallet.test.ts +877 -877
  205. package/test/unit/encoding-units-rlp.test.js +35 -0
  206. package/test/unit/generator.test.js +48 -1
  207. package/test/unit/generator.test.ts +48 -1
  208. package/test/unit/hashing.test.js +64 -64
  209. package/test/unit/hashing.test.ts +63 -63
  210. package/test/unit/internal-hex.test.js +32 -1
  211. package/test/unit/internal-hex.test.ts +32 -1
  212. package/test/unit/populate-transaction.test.js +33 -0
  213. package/test/unit/providers.test.js +51 -1
  214. package/test/unit/providers.test.ts +53 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quantumcoin",
3
- "version": "7.0.12",
3
+ "version": "7.0.14",
4
4
  "description": "QuantumCoin.js - a post quantum cryptography SDK for QuantumCoin",
5
5
  "main": "index.js",
6
6
  "types": "src/index.d.ts",
@@ -90,6 +90,6 @@
90
90
  },
91
91
  "dependencies": {
92
92
  "seed-words": "^1.0.2",
93
- "quantum-coin-js-sdk": "1.0.35"
93
+ "quantum-coin-js-sdk": "1.0.36"
94
94
  }
95
95
  }
@@ -1,42 +1,42 @@
1
- /**
2
- * @fileoverview Minimal ABI fragment classes (ethers.js v6 compatible surface).
3
- *
4
- * This SDK keeps fragment handling lightweight and delegates ABI encoding/decoding
5
- * to `quantum-coin-js-sdk` (WASM).
6
- */
7
- export class Fragment {
8
- /**
9
- * @param {any} fragment
10
- */
11
- constructor(fragment: any);
12
- type: any;
13
- name: any;
14
- inputs: any;
15
- outputs: any;
16
- stateMutability: any;
17
- anonymous: any;
18
- /**
19
- * Formats the fragment.
20
- * @param {string=} format
21
- * @returns {string}
22
- */
23
- format(format?: string | undefined): string;
24
- /**
25
- * @returns {any}
26
- */
27
- toJSON(): any;
28
- }
29
- export class NamedFragment extends Fragment {
30
- }
31
- export class FunctionFragment extends NamedFragment {
32
- }
33
- export class EventFragment extends NamedFragment {
34
- }
35
- export class ErrorFragment extends NamedFragment {
36
- }
37
- export class ConstructorFragment extends Fragment {
38
- }
39
- export class StructFragment extends Fragment {
40
- }
41
- export class FallbackFragment extends Fragment {
42
- }
1
+ /**
2
+ * @fileoverview Minimal ABI fragment classes (ethers.js v6 compatible surface).
3
+ *
4
+ * This SDK keeps fragment handling lightweight and delegates ABI encoding/decoding
5
+ * to `quantum-coin-js-sdk` (WASM).
6
+ */
7
+ export class Fragment {
8
+ /**
9
+ * @param {any} fragment
10
+ */
11
+ constructor(fragment: any);
12
+ type: any;
13
+ name: any;
14
+ inputs: any;
15
+ outputs: any;
16
+ stateMutability: any;
17
+ anonymous: any;
18
+ /**
19
+ * Formats the fragment.
20
+ * @param {string=} format
21
+ * @returns {string}
22
+ */
23
+ format(format?: string | undefined): string;
24
+ /**
25
+ * @returns {any}
26
+ */
27
+ toJSON(): any;
28
+ }
29
+ export class NamedFragment extends Fragment {
30
+ }
31
+ export class FunctionFragment extends NamedFragment {
32
+ }
33
+ export class EventFragment extends NamedFragment {
34
+ }
35
+ export class ErrorFragment extends NamedFragment {
36
+ }
37
+ export class ConstructorFragment extends Fragment {
38
+ }
39
+ export class StructFragment extends Fragment {
40
+ }
41
+ export class FallbackFragment extends Fragment {
42
+ }
@@ -1,13 +1,13 @@
1
- declare const _exports: {
2
- Interface: typeof import("./interface").Interface;
3
- AbiCoder: typeof import("./interface").AbiCoder;
4
- Fragment: typeof import("./fragments").Fragment;
5
- NamedFragment: typeof import("./fragments").NamedFragment;
6
- FunctionFragment: typeof import("./fragments").FunctionFragment;
7
- EventFragment: typeof import("./fragments").EventFragment;
8
- ErrorFragment: typeof import("./fragments").ErrorFragment;
9
- ConstructorFragment: typeof import("./fragments").ConstructorFragment;
10
- StructFragment: typeof import("./fragments").StructFragment;
11
- FallbackFragment: typeof import("./fragments").FallbackFragment;
12
- };
13
- export = _exports;
1
+ declare const _exports: {
2
+ Interface: typeof import("./interface").Interface;
3
+ AbiCoder: typeof import("./interface").AbiCoder;
4
+ Fragment: typeof import("./fragments").Fragment;
5
+ NamedFragment: typeof import("./fragments").NamedFragment;
6
+ FunctionFragment: typeof import("./fragments").FunctionFragment;
7
+ EventFragment: typeof import("./fragments").EventFragment;
8
+ ErrorFragment: typeof import("./fragments").ErrorFragment;
9
+ ConstructorFragment: typeof import("./fragments").ConstructorFragment;
10
+ StructFragment: typeof import("./fragments").StructFragment;
11
+ FallbackFragment: typeof import("./fragments").FallbackFragment;
12
+ };
13
+ export = _exports;
@@ -518,8 +518,17 @@ class Interface {
518
518
  getSighash() {
519
519
  throw makeError("getSighash not implemented", "NOT_IMPLEMENTED", {});
520
520
  }
521
- getEventTopic() {
522
- throw makeError("getEventTopic not implemented", "NOT_IMPLEMENTED", {});
521
+ /**
522
+ * Compute the topic0 (event signature hash) for an event.
523
+ * @param {string|EventFragment|any} nameOrFragment
524
+ * @returns {string} normalized 0x-prefixed topic hash
525
+ */
526
+ getEventTopic(nameOrFragment) {
527
+ const name = typeof nameOrFragment === "string" ? nameOrFragment : nameOrFragment?.name;
528
+ const frag = this.getEvent(name);
529
+ const inputs = Array.isArray(frag.inputs) ? frag.inputs : [];
530
+ const sig = `${frag.name}(${inputs.map((i) => String(i.type || "")).join(",")})`;
531
+ return normalizeHex(id(sig));
523
532
  }
524
533
  getFallback() {
525
534
  return null;
@@ -304,7 +304,21 @@ function encodeFunctionData(name, inputs, values) {
304
304
  return normalizeHex(selector + strip0x(bytesToHex(enc)));
305
305
  }
306
306
 
307
+ // A 32-byte word must lie fully within the data. Without this check
308
+ // `data.slice(offset, offset + 32)` silently returns a short/empty array, so an
309
+ // out-of-bounds read decodes to `0n` / the zero address — letting a malicious RPC
310
+ // response corrupt static return values (e.g. a balance silently reads as 0).
311
+ function _assertWordInBounds(data, offset) {
312
+ if (!Number.isInteger(offset) || offset < 0 || offset + 32 > data.length) {
313
+ throw makeError("ABI decoding: read past end of data", "INVALID_ARGUMENT", {
314
+ offset,
315
+ length: data.length,
316
+ });
317
+ }
318
+ }
319
+
307
320
  function _readWordAsBigInt(data, offset) {
321
+ _assertWordInBounds(data, offset);
308
322
  const chunk = data.slice(offset, offset + 32);
309
323
  const hex = bytesToHex(chunk);
310
324
  return BigInt(hex);
@@ -338,11 +352,13 @@ function _decodeBool(data, offset) {
338
352
  }
339
353
 
340
354
  function _decodeAddress(data, offset) {
355
+ _assertWordInBounds(data, offset);
341
356
  const chunk = data.slice(offset, offset + 32);
342
357
  return normalizeHex(bytesToHex(chunk));
343
358
  }
344
359
 
345
360
  function _decodeFixedBytes(type, data, offset) {
361
+ _assertWordInBounds(data, offset);
346
362
  const n = _bytesNLen(type);
347
363
  const chunk = data.slice(offset, offset + 32);
348
364
  return normalizeHex(bytesToHex(chunk.slice(0, n)));
@@ -351,6 +367,12 @@ function _decodeFixedBytes(type, data, offset) {
351
367
  function _decodeBytesDynamic(data, baseOffset) {
352
368
  const len = _readWordAsNumber(data, baseOffset);
353
369
  const start = baseOffset + 32;
370
+ // The declared length must fit within the available data; otherwise a
371
+ // malicious response could declare a huge length and cause silent truncation
372
+ // or oversized allocation.
373
+ if (start + len > data.length) {
374
+ throw makeError("ABI decoding: bytes length exceeds available data", "INVALID_ARGUMENT", { length: len });
375
+ }
354
376
  const out = data.slice(start, start + len);
355
377
  return normalizeHex(bytesToHex(out));
356
378
  }
@@ -358,6 +380,10 @@ function _decodeBytesDynamic(data, baseOffset) {
358
380
  function _decodeString(data, baseOffset) {
359
381
  const len = _readWordAsNumber(data, baseOffset);
360
382
  const start = baseOffset + 32;
383
+ // The declared length must fit within the available data.
384
+ if (start + len > data.length) {
385
+ throw makeError("ABI decoding: string length exceeds available data", "INVALID_ARGUMENT", { length: len });
386
+ }
361
387
  const out = data.slice(start, start + len);
362
388
  return bytesToUtf8(out);
363
389
  }
@@ -377,6 +403,22 @@ function decodeTupleLike(params, data, baseOffset, depth) {
377
403
  const p = ps[i];
378
404
  if (_isDynamicType(p)) {
379
405
  const rel = _readWordAsNumber(data, baseOffset + headOff);
406
+ // The dynamic offset is attacker-controlled. In canonical ABI encoding
407
+ // the tail always starts at or after the head, so reject offsets that point
408
+ // back into the head region (aliasing) and offsets that fall outside the
409
+ // available data before following the pointer.
410
+ if (rel < headSize) {
411
+ throw makeError("ABI decoding: dynamic offset points into head region", "INVALID_ARGUMENT", {
412
+ offset: rel,
413
+ headSize,
414
+ });
415
+ }
416
+ if (baseOffset + rel + 32 > data.length) {
417
+ throw makeError("ABI decoding: dynamic offset out of bounds", "INVALID_ARGUMENT", {
418
+ offset: rel,
419
+ length: data.length,
420
+ });
421
+ }
380
422
  values.push(decodeParam(p, data, baseOffset + rel, depth));
381
423
  headOff += 32;
382
424
  } else {
@@ -385,7 +427,6 @@ function decodeTupleLike(params, data, baseOffset, depth) {
385
427
  }
386
428
  }
387
429
 
388
- void headSize;
389
430
  return values;
390
431
  }
391
432
 
@@ -400,11 +441,29 @@ function decodeParam(param, data, offset, depth) {
400
441
 
401
442
  if (_isDynamicArray(type)) {
402
443
  const len = _readWordAsNumber(data, offset);
403
- const elems = decodeTupleLike(Array.from({ length: len }).map(() => innerParam), data, offset + 32, depth + 1);
444
+ // Each element consumes at least one 32-byte head word. Reject lengths
445
+ // that cannot possibly fit in the remaining calldata before allocating an
446
+ // array of `len` entries (prevents unbounded allocation / OOM from a
447
+ // hostile ABI response declaring an enormous length).
448
+ const elemsStart = offset + 32;
449
+ if (len * 32 > data.length - elemsStart) {
450
+ throw makeError("ABI decoding: array length exceeds available data", "INVALID_ARGUMENT", { length: len });
451
+ }
452
+ const elems = decodeTupleLike(Array.from({ length: len }).map(() => innerParam), data, elemsStart, depth + 1);
404
453
  return elems;
405
454
  }
406
455
 
407
456
  const n = _fixedArrayLength(type);
457
+ // A fixed-array dimension comes from the (attacker-controllable) type
458
+ // string. Each element occupies at least one 32-byte head word, so reject a
459
+ // length that cannot possibly fit in the remaining data before allocating an
460
+ // array of `n` entries (prevents unbounded allocation / OOM from e.g.
461
+ // `uint256[1000000000]`).
462
+ if (n * 32 > data.length - offset) {
463
+ throw makeError("ABI decoding: fixed array length exceeds available data", "INVALID_ARGUMENT", {
464
+ length: n,
465
+ });
466
+ }
408
467
  return decodeTupleLike(Array.from({ length: n }).map(() => innerParam), data, offset, depth + 1);
409
468
  }
410
469
 
@@ -37,6 +37,40 @@ function _isOverridesLike(value) {
37
37
  return true;
38
38
  }
39
39
 
40
+ // Fields a caller is allowed to set via `overrides`. Protected routing /
41
+ // payload fields (`to`, `data`, `from`) are intentionally excluded so that a
42
+ // caller-supplied overrides object can never redirect the transaction to a
43
+ // different contract or replace the encoded calldata. Unknown keys are dropped.
44
+ const _ALLOWED_OVERRIDE_KEYS = [
45
+ "value",
46
+ "gasLimit",
47
+ "gasPrice",
48
+ "maxFeePerGas",
49
+ "maxPriorityFeePerGas",
50
+ "nonce",
51
+ "chainId",
52
+ "remarks",
53
+ "signingContext",
54
+ ];
55
+
56
+ /**
57
+ * Return a copy of `overrides` containing only the allow-listed fields.
58
+ * Drops `to`, `data`, `from`, and any unknown/prototype keys so the protected
59
+ * fields computed by the contract layer always win.
60
+ * @param {any} overrides
61
+ * @returns {Record<string, any>}
62
+ */
63
+ function _sanitizeOverrides(overrides) {
64
+ const out = {};
65
+ if (!_isOverridesLike(overrides)) return out;
66
+ for (const key of _ALLOWED_OVERRIDE_KEYS) {
67
+ if (Object.prototype.hasOwnProperty.call(overrides, key) && overrides[key] !== undefined) {
68
+ out[key] = overrides[key];
69
+ }
70
+ }
71
+ return out;
72
+ }
73
+
40
74
  /**
41
75
  * BaseContract placeholder (ethers-like).
42
76
  */
@@ -228,7 +262,8 @@ class Contract extends BaseContract {
228
262
  }
229
263
 
230
264
  const data = this.interface.encodeFunctionData(methodName, callArgs);
231
- return { to: this.address, data, ...(overrides || {}) };
265
+ // Protected fields (to/data) must win over caller-supplied overrides.
266
+ return { ..._sanitizeOverrides(overrides), to: this.address, data };
232
267
  }
233
268
 
234
269
  /**
@@ -241,7 +276,8 @@ class Contract extends BaseContract {
241
276
  async call(methodName, args, overrides) {
242
277
  if (!this.provider) throw makeError("missing provider", "UNKNOWN_ERROR", { operation: "call" });
243
278
  const data = this.interface.encodeFunctionData(methodName, args);
244
- const tx = { to: this.address, data, ...(overrides || {}) };
279
+ // Protected fields (to/data) must win over caller-supplied overrides.
280
+ const tx = { ..._sanitizeOverrides(overrides), to: this.address, data };
245
281
  const raw = await this.provider.call(tx, "latest");
246
282
  const decoded = this.interface.decodeFunctionResult(methodName, raw);
247
283
  return decoded;
@@ -257,7 +293,8 @@ class Contract extends BaseContract {
257
293
  async send(methodName, args, overrides) {
258
294
  if (!this.signer) throw makeError("missing signer", "UNKNOWN_ERROR", { operation: "send" });
259
295
  const data = this.interface.encodeFunctionData(methodName, args);
260
- const tx = { to: this.address, data, ...(overrides || {}) };
296
+ // Protected fields (to/data) must win over caller-supplied overrides.
297
+ const tx = { ..._sanitizeOverrides(overrides), to: this.address, data };
261
298
  const resp = await this.signer.sendTransaction(tx);
262
299
  return new ContractTransactionResponse(resp);
263
300
  }
@@ -273,9 +310,19 @@ class Contract extends BaseContract {
273
310
  if (!this.provider) throw makeError("missing provider", "UNKNOWN_ERROR", { operation: "queryFilter" });
274
311
  const name = typeof event === "string" ? event : event?.name;
275
312
  assertArgument(typeof name === "string", "invalid event", "event", event);
276
- const filter = { address: this.address, fromBlock, toBlock };
313
+
314
+ // Bind the query to the requested event's topic0 so a malicious node cannot
315
+ // return same-address logs for a *different* event. We both constrain the RPC
316
+ // filter and verify the returned logs' topic0 client-side.
317
+ const topic0 = this.interface.getEventTopic(name);
318
+ const filter = { address: this.address, topics: [topic0], fromBlock, toBlock };
277
319
  const logs = await this.provider.getLogs(filter);
278
- return logs.map((l) => new EventLog(l));
320
+ return logs
321
+ .filter((l) => {
322
+ const t = Array.isArray(l && l.topics) ? l.topics[0] : null;
323
+ return typeof t === "string" && normalizeHex(t).toLowerCase() === topic0.toLowerCase();
324
+ })
325
+ .map((l) => new EventLog(l));
279
326
  }
280
327
 
281
328
  on(event, callback) {
@@ -356,5 +403,6 @@ module.exports = {
356
403
  ContractTransactionResponse,
357
404
  ContractTransactionReceipt,
358
405
  EventLog,
406
+ _sanitizeOverrides,
359
407
  };
360
408
 
@@ -1,9 +1,9 @@
1
- declare const _exports: {
2
- ContractFactory: typeof import("./contract-factory").ContractFactory;
3
- BaseContract: typeof import("./contract").BaseContract;
4
- Contract: typeof import("./contract").Contract;
5
- ContractTransactionResponse: typeof import("./contract").ContractTransactionResponse;
6
- ContractTransactionReceipt: typeof import("./contract").ContractTransactionReceipt;
7
- EventLog: typeof import("./contract").EventLog;
8
- };
9
- export = _exports;
1
+ declare const _exports: {
2
+ ContractFactory: typeof import("./contract-factory").ContractFactory;
3
+ BaseContract: typeof import("./contract").BaseContract;
4
+ Contract: typeof import("./contract").Contract;
5
+ ContractTransactionResponse: typeof import("./contract").ContractTransactionResponse;
6
+ ContractTransactionReceipt: typeof import("./contract").ContractTransactionReceipt;
7
+ EventLog: typeof import("./contract").EventLog;
8
+ };
9
+ export = _exports;
@@ -1,92 +1,92 @@
1
- export type ErrorCode = "INVALID_ARGUMENT" | "NUMERIC_FAULT" | "BUFFER_OVERRUN" | "CALL_EXCEPTION" | "UNKNOWN_ERROR" | "NOT_IMPLEMENTED";
2
- /**
3
- * @fileoverview Error helpers and error classes.
4
- *
5
- * The QuantumCoin.js SDK follows ethers.js v6 error patterns:
6
- * - errors include a machine-readable `code`
7
- * - errors include `shortMessage`
8
- * - errors may include extra fields depending on the failure
9
- */
10
- /**
11
- * @typedef {"INVALID_ARGUMENT"|"NUMERIC_FAULT"|"BUFFER_OVERRUN"|"CALL_EXCEPTION"|"UNKNOWN_ERROR"|"NOT_IMPLEMENTED"} ErrorCode
12
- */
13
- /**
14
- * Returns true if the error matches the given code.
15
- * @param {any} error
16
- * @param {string} code
17
- * @returns {boolean}
18
- */
19
- export function isError(error: any, code: string): boolean;
20
- /**
21
- * Returns true if the error is a CALL_EXCEPTION.
22
- * @param {any} error
23
- * @returns {boolean}
24
- */
25
- export function isCallException(error: any): boolean;
26
- /**
27
- * Create an Error configured like ethers emits errors.
28
- *
29
- * @param {string} message
30
- * @param {ErrorCode} code
31
- * @param {Record<string, any>=} info
32
- * @returns {Error & { code: ErrorCode, shortMessage: string }}
33
- */
34
- export function makeError(message: string, code: ErrorCode, info?: Record<string, any> | undefined): Error & {
35
- code: ErrorCode;
36
- shortMessage: string;
37
- };
38
- /**
39
- * Assert a condition, throwing an ethers-style error otherwise.
40
- * @param {any} check
41
- * @param {string} message
42
- * @param {ErrorCode} code
43
- * @param {Record<string, any>=} info
44
- */
45
- export function assert(check: any, message: string, code: ErrorCode, info?: Record<string, any> | undefined): void;
46
- /**
47
- * Assert an argument constraint.
48
- * @param {any} check
49
- * @param {string} message
50
- * @param {string} name
51
- * @param {any} value
52
- */
53
- export function assertArgument(check: any, message: string, name: string, value: any): void;
54
- /**
55
- * Provider error.
56
- */
57
- export class ProviderError extends Error {
58
- /**
59
- * @param {string} message
60
- * @param {Record<string, any>=} info
61
- */
62
- constructor(message: string, info?: Record<string, any> | undefined);
63
- /** @type {ErrorCode} */
64
- code: ErrorCode;
65
- shortMessage: string;
66
- }
67
- /**
68
- * Transaction error.
69
- */
70
- export class TransactionError extends Error {
71
- /**
72
- * @param {string} message
73
- * @param {Record<string, any>=} info
74
- */
75
- constructor(message: string, info?: Record<string, any> | undefined);
76
- /** @type {ErrorCode} */
77
- code: ErrorCode;
78
- shortMessage: string;
79
- }
80
- /**
81
- * Contract error.
82
- */
83
- export class ContractError extends Error {
84
- /**
85
- * @param {string} message
86
- * @param {Record<string, any>=} info
87
- */
88
- constructor(message: string, info?: Record<string, any> | undefined);
89
- /** @type {ErrorCode} */
90
- code: ErrorCode;
91
- shortMessage: string;
92
- }
1
+ export type ErrorCode = "INVALID_ARGUMENT" | "NUMERIC_FAULT" | "BUFFER_OVERRUN" | "CALL_EXCEPTION" | "UNKNOWN_ERROR" | "NOT_IMPLEMENTED";
2
+ /**
3
+ * @fileoverview Error helpers and error classes.
4
+ *
5
+ * The QuantumCoin.js SDK follows ethers.js v6 error patterns:
6
+ * - errors include a machine-readable `code`
7
+ * - errors include `shortMessage`
8
+ * - errors may include extra fields depending on the failure
9
+ */
10
+ /**
11
+ * @typedef {"INVALID_ARGUMENT"|"NUMERIC_FAULT"|"BUFFER_OVERRUN"|"CALL_EXCEPTION"|"UNKNOWN_ERROR"|"NOT_IMPLEMENTED"} ErrorCode
12
+ */
13
+ /**
14
+ * Returns true if the error matches the given code.
15
+ * @param {any} error
16
+ * @param {string} code
17
+ * @returns {boolean}
18
+ */
19
+ export function isError(error: any, code: string): boolean;
20
+ /**
21
+ * Returns true if the error is a CALL_EXCEPTION.
22
+ * @param {any} error
23
+ * @returns {boolean}
24
+ */
25
+ export function isCallException(error: any): boolean;
26
+ /**
27
+ * Create an Error configured like ethers emits errors.
28
+ *
29
+ * @param {string} message
30
+ * @param {ErrorCode} code
31
+ * @param {Record<string, any>=} info
32
+ * @returns {Error & { code: ErrorCode, shortMessage: string }}
33
+ */
34
+ export function makeError(message: string, code: ErrorCode, info?: Record<string, any> | undefined): Error & {
35
+ code: ErrorCode;
36
+ shortMessage: string;
37
+ };
38
+ /**
39
+ * Assert a condition, throwing an ethers-style error otherwise.
40
+ * @param {any} check
41
+ * @param {string} message
42
+ * @param {ErrorCode} code
43
+ * @param {Record<string, any>=} info
44
+ */
45
+ export function assert(check: any, message: string, code: ErrorCode, info?: Record<string, any> | undefined): void;
46
+ /**
47
+ * Assert an argument constraint.
48
+ * @param {any} check
49
+ * @param {string} message
50
+ * @param {string} name
51
+ * @param {any} value
52
+ */
53
+ export function assertArgument(check: any, message: string, name: string, value: any): void;
54
+ /**
55
+ * Provider error.
56
+ */
57
+ export class ProviderError extends Error {
58
+ /**
59
+ * @param {string} message
60
+ * @param {Record<string, any>=} info
61
+ */
62
+ constructor(message: string, info?: Record<string, any> | undefined);
63
+ /** @type {ErrorCode} */
64
+ code: ErrorCode;
65
+ shortMessage: string;
66
+ }
67
+ /**
68
+ * Transaction error.
69
+ */
70
+ export class TransactionError extends Error {
71
+ /**
72
+ * @param {string} message
73
+ * @param {Record<string, any>=} info
74
+ */
75
+ constructor(message: string, info?: Record<string, any> | undefined);
76
+ /** @type {ErrorCode} */
77
+ code: ErrorCode;
78
+ shortMessage: string;
79
+ }
80
+ /**
81
+ * Contract error.
82
+ */
83
+ export class ContractError extends Error {
84
+ /**
85
+ * @param {string} message
86
+ * @param {Record<string, any>=} info
87
+ */
88
+ constructor(message: string, info?: Record<string, any> | undefined);
89
+ /** @type {ErrorCode} */
90
+ code: ErrorCode;
91
+ shortMessage: string;
92
+ }
@@ -52,23 +52,30 @@ export function generateFromArtifacts(opts: {
52
52
  * Generate a transactional e2e test file (JavaScript) for the typed contract package.
53
53
  * The test deploys the contract with constructor args (if any) and invokes one write method.
54
54
  *
55
- * @param {{ contractName: string, abi: any[] }} opts
56
- * @returns {string}
55
+ * When `bytecode` is omitted, empty, or `"0x"` the contract is treated as an interface
56
+ * and the post-deploy `provider.getCode(...)` bytecode assertion is omitted from the
57
+ * generated test (interfaces deploy with no runtime code by design).
58
+ *
59
+ * @param opts
57
60
  */
58
61
  export function generateTransactionalTestJs(opts: {
59
62
  contractName: string;
60
63
  abi: any[];
64
+ bytecode?: string;
61
65
  }): string;
62
66
  /**
63
67
  * Generate a single transactional e2e test that deploys and invokes methods on ALL contracts.
64
68
  * Used when the package has multiple contracts so one test exercises every contract.
65
69
  *
66
- * @param {{ artifacts: Array<{ contractName: string, abi: any[] }> }} opts
67
- * @returns {string}
70
+ * Accepts `bytecode` per artifact for forward-compatibility; the multi-contract template
71
+ * currently emits no `getCode` assertion (so the value is not yet consumed).
72
+ *
73
+ * @param opts
68
74
  */
69
75
  export function generateAllContractsTransactionalTestJs(opts: {
70
76
  artifacts: Array<{
71
77
  contractName: string;
72
78
  abi: any[];
79
+ bytecode?: string;
73
80
  }>;
74
81
  }): string;