quantumcoin 7.0.11 → 7.0.13

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 (324) hide show
  1. package/README-SDK.md +828 -807
  2. package/README.md +17 -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/package-lock.json +1 -1
  42. package/examples/sdk-generator-erc20.inline.json +251 -251
  43. package/generate-sdk.js +1825 -1823
  44. package/package.json +1 -1
  45. package/src/abi/fragments.d.ts +42 -42
  46. package/src/abi/index.d.ts +13 -13
  47. package/src/contract/index.d.ts +9 -9
  48. package/src/errors/index.d.ts +92 -92
  49. package/src/generator/index.d.ts +11 -4
  50. package/src/generator/index.js +33 -5
  51. package/src/internal/hex.d.ts +68 -61
  52. package/src/internal/hex.js +36 -0
  53. package/src/providers/json-rpc-provider.d.ts +12 -12
  54. package/src/providers/provider.js +3 -3
  55. package/src/utils/address.d.ts +58 -58
  56. package/src/utils/encoding.d.ts +120 -120
  57. package/src/utils/hashing.js +298 -298
  58. package/src/utils/index.d.ts +63 -63
  59. package/src/utils/index.js +14 -14
  60. package/src/utils/result.d.ts +57 -57
  61. package/src/utils/rlp.d.ts +12 -12
  62. package/src/utils/units.d.ts +29 -29
  63. package/src/wallet/index.d.ts +10 -10
  64. package/src/wallet/wallet.d.ts +192 -187
  65. package/src/wallet/wallet.js +630 -610
  66. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/README.md +83 -0
  67. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.abi.json +12544 -0
  68. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.bin +1 -0
  69. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.js +17 -0
  70. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.ts +10 -0
  71. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.js +41 -0
  72. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.ts +41 -0
  73. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.js +36 -0
  74. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.ts +36 -0
  75. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.js +82 -0
  76. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.ts +80 -0
  77. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.js +46 -0
  78. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.ts +44 -0
  79. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.js +44 -0
  80. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.ts +44 -0
  81. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.d.ts +1 -0
  82. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.js +21 -0
  83. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package-lock.json +597 -0
  84. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package.json +25 -0
  85. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.d.ts +1280 -0
  86. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.js +14021 -0
  87. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.d.ts +11 -0
  88. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.js +29 -0
  89. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.d.ts +4 -0
  90. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.js +5 -0
  91. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/quantumcoin-shims.d.ts +25 -0
  92. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.d.ts +3 -0
  93. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.js +3 -0
  94. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.e2e.test.js +77 -0
  95. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.extra.test.js +195 -0
  96. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/README.md +83 -0
  97. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.abi.json +12544 -0
  98. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.bin +1 -0
  99. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.js +17 -0
  100. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.ts +10 -0
  101. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.js +41 -0
  102. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.ts +41 -0
  103. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.js +36 -0
  104. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.ts +36 -0
  105. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.js +82 -0
  106. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.ts +80 -0
  107. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.js +46 -0
  108. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.ts +44 -0
  109. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.js +44 -0
  110. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.ts +44 -0
  111. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.d.ts +1 -0
  112. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.js +21 -0
  113. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package-lock.json +597 -0
  114. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package.json +26 -0
  115. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes.ts +13940 -0
  116. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes__factory.ts +29 -0
  117. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/index.ts +4 -0
  118. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/quantumcoin-shims.d.ts +25 -0
  119. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/types.ts +4 -0
  120. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.e2e.test.js +77 -0
  121. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.extra.test.js +195 -0
  122. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/tsconfig.json +18 -0
  123. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/README.md +74 -0
  124. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.abi.json +245 -0
  125. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.bin +1 -0
  126. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.js +17 -0
  127. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.ts +10 -0
  128. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.js +41 -0
  129. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.ts +41 -0
  130. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.js +36 -0
  131. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.ts +36 -0
  132. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.js +82 -0
  133. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.ts +80 -0
  134. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.js +46 -0
  135. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.ts +44 -0
  136. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.js +44 -0
  137. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.ts +44 -0
  138. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.d.ts +1 -0
  139. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.js +16 -0
  140. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package-lock.json +597 -0
  141. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package.json +25 -0
  142. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.d.ts +24 -0
  143. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.js +372 -0
  144. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.d.ts +10 -0
  145. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.js +29 -0
  146. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.d.ts +4 -0
  147. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.js +5 -0
  148. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/quantumcoin-shims.d.ts +25 -0
  149. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.d.ts +3 -0
  150. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.js +3 -0
  151. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/test/e2e/SimpleERC20.e2e.test.js +90 -0
  152. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/README.md +74 -0
  153. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.abi.json +245 -0
  154. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.bin +1 -0
  155. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.js +17 -0
  156. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.ts +10 -0
  157. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.js +41 -0
  158. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.ts +41 -0
  159. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.js +36 -0
  160. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.ts +36 -0
  161. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.js +82 -0
  162. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.ts +80 -0
  163. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.js +46 -0
  164. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.ts +44 -0
  165. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.js +44 -0
  166. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.ts +44 -0
  167. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.d.ts +1 -0
  168. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.js +16 -0
  169. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package-lock.json +597 -0
  170. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package.json +26 -0
  171. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20.ts +355 -0
  172. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20__factory.ts +28 -0
  173. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/index.ts +4 -0
  174. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/quantumcoin-shims.d.ts +25 -0
  175. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/types.ts +4 -0
  176. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/test/e2e/SimpleERC20.e2e.test.js +90 -0
  177. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/tsconfig.json +18 -0
  178. package/test/e2e/generator-interface.e2e.test.js +163 -0
  179. package/test/e2e/generator-interface.e2e.test.ts +158 -0
  180. package/test/e2e/signing-context-and-fee.e2e.test.js +141 -141
  181. package/test/e2e/signing-context-and-fee.e2e.test.ts +128 -128
  182. package/test/integration/provider.test.js +88 -88
  183. package/test/unit/address-wallet.test.js +892 -751
  184. package/test/unit/address-wallet.test.ts +877 -736
  185. package/test/unit/generator.test.js +48 -1
  186. package/test/unit/generator.test.ts +48 -1
  187. package/test/unit/hashing.test.js +64 -64
  188. package/test/unit/hashing.test.ts +63 -63
  189. package/test/unit/internal-hex.test.js +32 -1
  190. package/test/unit/internal-hex.test.ts +32 -1
  191. package/test/unit/providers.test.js +51 -1
  192. package/test/unit/providers.test.ts +53 -0
  193. package/SPEC.md +0 -3784
  194. package/examples/node_modules/.bin/esbuild +0 -16
  195. package/examples/node_modules/.bin/esbuild.cmd +0 -17
  196. package/examples/node_modules/.bin/esbuild.ps1 +0 -28
  197. package/examples/node_modules/.bin/sdkgen +0 -16
  198. package/examples/node_modules/.bin/sdkgen.cmd +0 -17
  199. package/examples/node_modules/.bin/sdkgen.ps1 +0 -28
  200. package/examples/node_modules/.bin/tsx +0 -16
  201. package/examples/node_modules/.bin/tsx.cmd +0 -17
  202. package/examples/node_modules/.bin/tsx.ps1 +0 -28
  203. package/examples/node_modules/.package-lock.json +0 -235
  204. package/examples/node_modules/@esbuild/win32-x64/README.md +0 -3
  205. package/examples/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
  206. package/examples/node_modules/@esbuild/win32-x64/package.json +0 -20
  207. package/examples/node_modules/esbuild/LICENSE.md +0 -21
  208. package/examples/node_modules/esbuild/README.md +0 -3
  209. package/examples/node_modules/esbuild/bin/esbuild +0 -223
  210. package/examples/node_modules/esbuild/install.js +0 -289
  211. package/examples/node_modules/esbuild/lib/main.d.ts +0 -716
  212. package/examples/node_modules/esbuild/lib/main.js +0 -2532
  213. package/examples/node_modules/esbuild/package.json +0 -49
  214. package/examples/node_modules/get-tsconfig/LICENSE +0 -21
  215. package/examples/node_modules/get-tsconfig/README.md +0 -235
  216. package/examples/node_modules/get-tsconfig/dist/index.cjs +0 -7
  217. package/examples/node_modules/get-tsconfig/dist/index.d.cts +0 -2088
  218. package/examples/node_modules/get-tsconfig/dist/index.d.mts +0 -2088
  219. package/examples/node_modules/get-tsconfig/dist/index.mjs +0 -7
  220. package/examples/node_modules/get-tsconfig/package.json +0 -46
  221. package/examples/node_modules/quantum-coin-js-sdk/.github/workflows/publish-npmjs.yaml +0 -22
  222. package/examples/node_modules/quantum-coin-js-sdk/LICENSE +0 -21
  223. package/examples/node_modules/quantum-coin-js-sdk/LICENSE-wasm_exec.js.txt +0 -30
  224. package/examples/node_modules/quantum-coin-js-sdk/README.md +0 -1665
  225. package/examples/node_modules/quantum-coin-js-sdk/example/README.md +0 -14
  226. package/examples/node_modules/quantum-coin-js-sdk/example/conversion-example.js +0 -19
  227. package/examples/node_modules/quantum-coin-js-sdk/example/example-create-contract.js +0 -396
  228. package/examples/node_modules/quantum-coin-js-sdk/example/example-encode-decode-rlp.js +0 -225
  229. package/examples/node_modules/quantum-coin-js-sdk/example/example-event-pack-unpack.js +0 -391
  230. package/examples/node_modules/quantum-coin-js-sdk/example/example-misc.js +0 -101
  231. package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send-signRawTransaction.js +0 -318
  232. package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send.js +0 -116
  233. package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +0 -70
  234. package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +0 -961
  235. package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +0 -35
  236. package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet.js +0 -43
  237. package/examples/node_modules/quantum-coin-js-sdk/example/example.js +0 -405
  238. package/examples/node_modules/quantum-coin-js-sdk/example/package-lock.json +0 -134
  239. package/examples/node_modules/quantum-coin-js-sdk/example/package.json +0 -15
  240. package/examples/node_modules/quantum-coin-js-sdk/index.d.ts +0 -1024
  241. package/examples/node_modules/quantum-coin-js-sdk/index.js +0 -3062
  242. package/examples/node_modules/quantum-coin-js-sdk/package.json +0 -34
  243. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-32.json +0 -1
  244. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-36.json +0 -1
  245. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-48.json +0 -1
  246. package/examples/node_modules/quantum-coin-js-sdk/tests/generate-verify-vectors.js +0 -91
  247. package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.preinit.test.js +0 -41
  248. package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.test.js +0 -686
  249. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-keytype5-context-null.test.js +0 -107
  250. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-transaction.test.js +0 -196
  251. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-verify.test.js +0 -311
  252. package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.relay.test.js +0 -131
  253. package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.rpc.test.js +0 -103
  254. package/examples/node_modules/quantum-coin-js-sdk/tests/verify-vectors.json +0 -95035
  255. package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.d.ts +0 -9
  256. package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.js +0 -16
  257. package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.d.ts +0 -0
  258. package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.js +0 -587
  259. package/examples/node_modules/resolve-pkg-maps/LICENSE +0 -21
  260. package/examples/node_modules/resolve-pkg-maps/README.md +0 -216
  261. package/examples/node_modules/resolve-pkg-maps/dist/index.cjs +0 -1
  262. package/examples/node_modules/resolve-pkg-maps/dist/index.d.cts +0 -11
  263. package/examples/node_modules/resolve-pkg-maps/dist/index.d.mts +0 -11
  264. package/examples/node_modules/resolve-pkg-maps/dist/index.mjs +0 -1
  265. package/examples/node_modules/resolve-pkg-maps/package.json +0 -42
  266. package/examples/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
  267. package/examples/node_modules/seed-words/BUILD.md +0 -7
  268. package/examples/node_modules/seed-words/LICENSE +0 -121
  269. package/examples/node_modules/seed-words/README.md +0 -67
  270. package/examples/node_modules/seed-words/dist/seedwords.d.ts +0 -39
  271. package/examples/node_modules/seed-words/package.json +0 -27
  272. package/examples/node_modules/seed-words/seedwords.js +0 -315
  273. package/examples/node_modules/seed-words/seedwords.txt +0 -65536
  274. package/examples/node_modules/seed-words/tsconfig.json +0 -21
  275. package/examples/node_modules/tsx/LICENSE +0 -21
  276. package/examples/node_modules/tsx/README.md +0 -32
  277. package/examples/node_modules/tsx/dist/cjs/api/index.cjs +0 -1
  278. package/examples/node_modules/tsx/dist/cjs/api/index.d.cts +0 -35
  279. package/examples/node_modules/tsx/dist/cjs/api/index.d.mts +0 -35
  280. package/examples/node_modules/tsx/dist/cjs/api/index.mjs +0 -1
  281. package/examples/node_modules/tsx/dist/cjs/index.cjs +0 -1
  282. package/examples/node_modules/tsx/dist/cjs/index.mjs +0 -1
  283. package/examples/node_modules/tsx/dist/cli.cjs +0 -54
  284. package/examples/node_modules/tsx/dist/cli.mjs +0 -55
  285. package/examples/node_modules/tsx/dist/client-BQVF1NaW.mjs +0 -1
  286. package/examples/node_modules/tsx/dist/client-D6NvIMSC.cjs +0 -1
  287. package/examples/node_modules/tsx/dist/esm/api/index.cjs +0 -1
  288. package/examples/node_modules/tsx/dist/esm/api/index.d.cts +0 -35
  289. package/examples/node_modules/tsx/dist/esm/api/index.d.mts +0 -35
  290. package/examples/node_modules/tsx/dist/esm/api/index.mjs +0 -1
  291. package/examples/node_modules/tsx/dist/esm/index.cjs +0 -2
  292. package/examples/node_modules/tsx/dist/esm/index.mjs +0 -2
  293. package/examples/node_modules/tsx/dist/get-pipe-path-BHW2eJdv.mjs +0 -1
  294. package/examples/node_modules/tsx/dist/get-pipe-path-BoR10qr8.cjs +0 -1
  295. package/examples/node_modules/tsx/dist/index-7AaEi15b.mjs +0 -14
  296. package/examples/node_modules/tsx/dist/index-BWFBUo6r.cjs +0 -1
  297. package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +0 -1
  298. package/examples/node_modules/tsx/dist/index-gckBtVBf.cjs +0 -14
  299. package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +0 -3
  300. package/examples/node_modules/tsx/dist/lexer-DgIbo0BU.cjs +0 -3
  301. package/examples/node_modules/tsx/dist/loader.cjs +0 -1
  302. package/examples/node_modules/tsx/dist/loader.mjs +0 -1
  303. package/examples/node_modules/tsx/dist/node-features-_8ZFwP_x.mjs +0 -1
  304. package/examples/node_modules/tsx/dist/node-features-roYmp9jK.cjs +0 -1
  305. package/examples/node_modules/tsx/dist/package-CeBgXWuR.mjs +0 -1
  306. package/examples/node_modules/tsx/dist/package-Dxt5kIHw.cjs +0 -1
  307. package/examples/node_modules/tsx/dist/patch-repl.cjs +0 -1
  308. package/examples/node_modules/tsx/dist/patch-repl.mjs +0 -1
  309. package/examples/node_modules/tsx/dist/preflight.cjs +0 -1
  310. package/examples/node_modules/tsx/dist/preflight.mjs +0 -1
  311. package/examples/node_modules/tsx/dist/register-2sWVXuRQ.cjs +0 -1
  312. package/examples/node_modules/tsx/dist/register-B7jrtLTO.mjs +0 -1
  313. package/examples/node_modules/tsx/dist/register-CFH5oNdT.mjs +0 -4
  314. package/examples/node_modules/tsx/dist/register-D46fvsV_.cjs +0 -4
  315. package/examples/node_modules/tsx/dist/repl.cjs +0 -3
  316. package/examples/node_modules/tsx/dist/repl.mjs +0 -3
  317. package/examples/node_modules/tsx/dist/require-D4F1Lv60.cjs +0 -1
  318. package/examples/node_modules/tsx/dist/require-DQxpCAr4.mjs +0 -1
  319. package/examples/node_modules/tsx/dist/suppress-warnings.cjs +0 -1
  320. package/examples/node_modules/tsx/dist/suppress-warnings.mjs +0 -1
  321. package/examples/node_modules/tsx/dist/temporary-directory-B83uKxJF.cjs +0 -1
  322. package/examples/node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs +0 -1
  323. package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +0 -5
  324. package/examples/node_modules/tsx/package.json +0 -68
@@ -11,7 +11,7 @@ const fs = require("node:fs");
11
11
  const os = require("node:os");
12
12
  const path = require("node:path");
13
13
 
14
- const { generate, generateFromArtifacts } = require("../../src/generator");
14
+ const { generate, generateFromArtifacts, generateTransactionalTestJs } = require("../../src/generator");
15
15
  const { logSuite, logTest } = require("../verbose-logger");
16
16
 
17
17
  describe("typed contract generator", () => {
@@ -62,6 +62,53 @@ describe("typed contract generator", () => {
62
62
  assert.ok(factorySrc.includes("export class TestToken__factory"));
63
63
  });
64
64
 
65
+ it("generated test for a concrete contract (with bytecode) contains the provider.getCode bytecode assertion", () => {
66
+ logTest("generated test for a concrete contract contains the bytecode assertion", {});
67
+ const src = generateTransactionalTestJs({
68
+ contractName: "ConcreteToken",
69
+ abi: [{ type: "constructor", inputs: [], stateMutability: "nonpayable" }],
70
+ bytecode: "0x6080604052",
71
+ });
72
+ assert.ok(src.includes("provider.getCode(contract.target"));
73
+ assert.ok(src.includes('assert.ok(code && code !== "0x")'));
74
+ assert.ok(!src.includes("Skipping bytecode check"));
75
+ });
76
+
77
+ it("generated test for an interface (bytecode '0x') omits the provider.getCode bytecode assertion", () => {
78
+ logTest("generated test for an interface omits the bytecode assertion", {});
79
+ const src = generateTransactionalTestJs({
80
+ contractName: "IThing",
81
+ abi: [{
82
+ type: "function", name: "doThing",
83
+ inputs: [], outputs: [], stateMutability: "nonpayable",
84
+ }],
85
+ bytecode: "0x",
86
+ });
87
+ assert.ok(!src.includes("provider.getCode(contract.target"));
88
+ assert.ok(!src.includes('assert.ok(code && code !== "0x")'));
89
+ assert.ok(src.includes("Skipping bytecode check"));
90
+ assert.ok(src.includes("IThing is an interface"));
91
+ });
92
+
93
+ it("empty/undefined/null/'0X' bytecode variants are all treated as interface", () => {
94
+ logTest("empty bytecode variants are all treated as interface", {});
95
+ for (const bc of [undefined, null, "", "0x", "0X", " 0x "]) {
96
+ const src = generateTransactionalTestJs({
97
+ contractName: "IThing",
98
+ abi: [],
99
+ bytecode: bc,
100
+ });
101
+ assert.ok(
102
+ !src.includes("provider.getCode(contract.target"),
103
+ `bytecode=${JSON.stringify(bc)} should be treated as interface (no getCode assertion)`,
104
+ );
105
+ assert.ok(
106
+ src.includes("Skipping bytecode check"),
107
+ `bytecode=${JSON.stringify(bc)} should emit skip comment`,
108
+ );
109
+ }
110
+ });
111
+
65
112
  it("includes injected docs in generated TypeScript", () => {
66
113
  const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-docs-"));
67
114
  const outDir = path.join(tmp, "out");
@@ -11,7 +11,7 @@ import fs from "node:fs";
11
11
  import os from "node:os";
12
12
  import path from "node:path";
13
13
 
14
- import { generate, generateFromArtifacts } from "../../src/generator";
14
+ import { generate, generateFromArtifacts, generateTransactionalTestJs } from "../../src/generator";
15
15
  import { logSuite, logTest } from "../verbose-logger";
16
16
 
17
17
  describe("typed contract generator", () => {
@@ -62,6 +62,53 @@ describe("typed contract generator", () => {
62
62
  assert.ok(factorySrc.includes("export class TestToken__factory"));
63
63
  });
64
64
 
65
+ it("generated test for a concrete contract (with bytecode) contains the provider.getCode bytecode assertion", () => {
66
+ logTest("generated test for a concrete contract contains the bytecode assertion", {});
67
+ const src = generateTransactionalTestJs({
68
+ contractName: "ConcreteToken",
69
+ abi: [{ type: "constructor", inputs: [], stateMutability: "nonpayable" }],
70
+ bytecode: "0x6080604052",
71
+ });
72
+ assert.ok(src.includes("provider.getCode(contract.target"));
73
+ assert.ok(src.includes('assert.ok(code && code !== "0x")'));
74
+ assert.ok(!src.includes("Skipping bytecode check"));
75
+ });
76
+
77
+ it("generated test for an interface (bytecode '0x') omits the provider.getCode bytecode assertion", () => {
78
+ logTest("generated test for an interface omits the bytecode assertion", {});
79
+ const src = generateTransactionalTestJs({
80
+ contractName: "IThing",
81
+ abi: [{
82
+ type: "function", name: "doThing",
83
+ inputs: [], outputs: [], stateMutability: "nonpayable",
84
+ }],
85
+ bytecode: "0x",
86
+ });
87
+ assert.ok(!src.includes("provider.getCode(contract.target"));
88
+ assert.ok(!src.includes('assert.ok(code && code !== "0x")'));
89
+ assert.ok(src.includes("Skipping bytecode check"));
90
+ assert.ok(src.includes("IThing is an interface"));
91
+ });
92
+
93
+ it("empty/undefined/null/'0X' bytecode variants are all treated as interface", () => {
94
+ logTest("empty bytecode variants are all treated as interface", {});
95
+ for (const bc of [undefined, null, "", "0x", "0X", " 0x "] as Array<string | null | undefined>) {
96
+ const src = generateTransactionalTestJs({
97
+ contractName: "IThing",
98
+ abi: [],
99
+ bytecode: bc as unknown as string,
100
+ });
101
+ assert.ok(
102
+ !src.includes("provider.getCode(contract.target"),
103
+ `bytecode=${JSON.stringify(bc)} should be treated as interface (no getCode assertion)`,
104
+ );
105
+ assert.ok(
106
+ src.includes("Skipping bytecode check"),
107
+ `bytecode=${JSON.stringify(bc)} should emit skip comment`,
108
+ );
109
+ }
110
+ });
111
+
65
112
  it("includes injected docs in generated TypeScript", () => {
66
113
  const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "qcgen-docs-"));
67
114
  const outDir = path.join(tmp, "out");
@@ -1,64 +1,64 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Hashing helpers (optional params, deterministic behavior)
6
- */
7
-
8
- const { describe, it } = require("node:test");
9
- const assert = require("node:assert/strict");
10
-
11
- const qc = require("../../index");
12
- const { logSuite, logTest } = require("../verbose-logger");
13
-
14
- describe("Hashing", () => {
15
- logSuite("Hashing");
16
- it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
17
- logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
18
- const out = qc.keccak256(new Uint8Array([]));
19
- assert.equal(typeof out, "string");
20
- assert.ok(out.startsWith("0x"));
21
- assert.equal(out.length, 66);
22
- });
23
-
24
- it("sha256/sha512/ripemd160 output lengths are correct", () => {
25
- const data = qc.toUtf8Bytes("hello");
26
- assert.equal(qc.sha256(data).length, 66);
27
- assert.equal(qc.sha512(data).length, 130);
28
- assert.equal(qc.ripemd160(data).length, 42);
29
- });
30
-
31
- it("randomBytes returns requested length", () => {
32
- const b = qc.randomBytes(16);
33
- assert.ok(b instanceof Uint8Array);
34
- assert.equal(b.length, 16);
35
- });
36
-
37
- it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
38
- const pw = qc.toUtf8Bytes("password");
39
- const salt = qc.toUtf8Bytes("salt");
40
-
41
- const a = qc.pbkdf2(pw, salt, 1, 32);
42
- const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
43
- const c = qc.pbkdf2(pw, salt, 1, 32, null);
44
-
45
- assert.equal(a, b);
46
- assert.equal(a, c);
47
- assert.ok(a.startsWith("0x") && a.length === 66);
48
- });
49
-
50
- it("computeHmac produces a hex string", () => {
51
- const key = qc.toUtf8Bytes("key");
52
- const data = qc.toUtf8Bytes("data");
53
- const out = qc.computeHmac("sha256", key, data);
54
- assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
55
- });
56
-
57
- it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
58
- const pw = qc.toUtf8Bytes("password");
59
- const salt = qc.toUtf8Bytes("salt");
60
- const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
61
- assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
62
- });
63
- });
64
-
1
+ /**
2
+ * @testCategory unit
3
+ * @blockchainRequired false
4
+ * @transactional false
5
+ * @description Hashing helpers (optional params, deterministic behavior)
6
+ */
7
+
8
+ const { describe, it } = require("node:test");
9
+ const assert = require("node:assert/strict");
10
+
11
+ const qc = require("../../index");
12
+ const { logSuite, logTest } = require("../verbose-logger");
13
+
14
+ describe("Hashing", () => {
15
+ logSuite("Hashing");
16
+ it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
17
+ logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
18
+ const out = qc.keccak256(new Uint8Array([]));
19
+ assert.equal(typeof out, "string");
20
+ assert.ok(out.startsWith("0x"));
21
+ assert.equal(out.length, 66);
22
+ });
23
+
24
+ it("sha256/sha512/ripemd160 output lengths are correct", () => {
25
+ const data = qc.toUtf8Bytes("hello");
26
+ assert.equal(qc.sha256(data).length, 66);
27
+ assert.equal(qc.sha512(data).length, 130);
28
+ assert.equal(qc.ripemd160(data).length, 42);
29
+ });
30
+
31
+ it("randomBytes returns requested length", () => {
32
+ const b = qc.randomBytes(16);
33
+ assert.ok(b instanceof Uint8Array);
34
+ assert.equal(b.length, 16);
35
+ });
36
+
37
+ it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
38
+ const pw = qc.toUtf8Bytes("password");
39
+ const salt = qc.toUtf8Bytes("salt");
40
+
41
+ const a = qc.pbkdf2(pw, salt, 1, 32);
42
+ const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
43
+ const c = qc.pbkdf2(pw, salt, 1, 32, null);
44
+
45
+ assert.equal(a, b);
46
+ assert.equal(a, c);
47
+ assert.ok(a.startsWith("0x") && a.length === 66);
48
+ });
49
+
50
+ it("computeHmac produces a hex string", () => {
51
+ const key = qc.toUtf8Bytes("key");
52
+ const data = qc.toUtf8Bytes("data");
53
+ const out = qc.computeHmac("sha256", key, data);
54
+ assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
55
+ });
56
+
57
+ it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
58
+ const pw = qc.toUtf8Bytes("password");
59
+ const salt = qc.toUtf8Bytes("salt");
60
+ const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
61
+ assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
62
+ });
63
+ });
64
+
@@ -1,63 +1,63 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Hashing helpers (optional params, deterministic behavior)
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
-
11
- import qc from "../../index";
12
- import { logSuite, logTest } from "../verbose-logger";
13
-
14
- describe("Hashing", () => {
15
- logSuite("Hashing");
16
- it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
17
- logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
18
- const out = qc.keccak256(new Uint8Array([]));
19
- assert.equal(typeof out, "string");
20
- assert.ok(out.startsWith("0x"));
21
- assert.equal(out.length, 66);
22
- });
23
-
24
- it("sha256/sha512/ripemd160 output lengths are correct", () => {
25
- const data = qc.toUtf8Bytes("hello");
26
- assert.equal(qc.sha256(data).length, 66);
27
- assert.equal(qc.sha512(data).length, 130);
28
- assert.equal(qc.ripemd160(data).length, 42);
29
- });
30
-
31
- it("randomBytes returns requested length", () => {
32
- const b = qc.randomBytes(16);
33
- assert.ok(b instanceof Uint8Array);
34
- assert.equal(b.length, 16);
35
- });
36
-
37
- it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
38
- const pw = qc.toUtf8Bytes("password");
39
- const salt = qc.toUtf8Bytes("salt");
40
-
41
- const a = qc.pbkdf2(pw, salt, 1, 32);
42
- const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
43
- const c = qc.pbkdf2(pw, salt, 1, 32, null);
44
-
45
- assert.equal(a, b);
46
- assert.equal(a, c);
47
- assert.ok(a.startsWith("0x") && a.length === 66);
48
- });
49
-
50
- it("computeHmac produces a hex string", () => {
51
- const key = qc.toUtf8Bytes("key");
52
- const data = qc.toUtf8Bytes("data");
53
- const out = qc.computeHmac("sha256", key, data);
54
- assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
55
- });
56
-
57
- it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
58
- const pw = qc.toUtf8Bytes("password");
59
- const salt = qc.toUtf8Bytes("salt");
60
- const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
61
- assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
62
- });
63
- });
1
+ /**
2
+ * @testCategory unit
3
+ * @blockchainRequired false
4
+ * @transactional false
5
+ * @description Hashing helpers (optional params, deterministic behavior)
6
+ */
7
+
8
+ import { describe, it } from "node:test";
9
+ import assert from "node:assert/strict";
10
+
11
+ import qc from "../../index";
12
+ import { logSuite, logTest } from "../verbose-logger";
13
+
14
+ describe("Hashing", () => {
15
+ logSuite("Hashing");
16
+ it("keccak256 returns a 32-byte hex digest for empty bytes", () => {
17
+ logTest("keccak256 returns a 32-byte hex digest for empty bytes", {});
18
+ const out = qc.keccak256(new Uint8Array([]));
19
+ assert.equal(typeof out, "string");
20
+ assert.ok(out.startsWith("0x"));
21
+ assert.equal(out.length, 66);
22
+ });
23
+
24
+ it("sha256/sha512/ripemd160 output lengths are correct", () => {
25
+ const data = qc.toUtf8Bytes("hello");
26
+ assert.equal(qc.sha256(data).length, 66);
27
+ assert.equal(qc.sha512(data).length, 130);
28
+ assert.equal(qc.ripemd160(data).length, 42);
29
+ });
30
+
31
+ it("randomBytes returns requested length", () => {
32
+ const b = qc.randomBytes(16);
33
+ assert.ok(b instanceof Uint8Array);
34
+ assert.equal(b.length, 16);
35
+ });
36
+
37
+ it("pbkdf2 algorithm defaults when omitted vs null vs explicit", () => {
38
+ const pw = qc.toUtf8Bytes("password");
39
+ const salt = qc.toUtf8Bytes("salt");
40
+
41
+ const a = qc.pbkdf2(pw, salt, 1, 32);
42
+ const b = qc.pbkdf2(pw, salt, 1, 32, "sha256");
43
+ const c = qc.pbkdf2(pw, salt, 1, 32, null);
44
+
45
+ assert.equal(a, b);
46
+ assert.equal(a, c);
47
+ assert.ok(a.startsWith("0x") && a.length === 66);
48
+ });
49
+
50
+ it("computeHmac produces a hex string", () => {
51
+ const key = qc.toUtf8Bytes("key");
52
+ const data = qc.toUtf8Bytes("data");
53
+ const out = qc.computeHmac("sha256", key, data);
54
+ assert.ok(typeof out === "string" && out.startsWith("0x") && out.length === 66);
55
+ });
56
+
57
+ it("scryptSync with N=262144, r=8, p=1 produces expected hardcoded output", () => {
58
+ const pw = qc.toUtf8Bytes("password");
59
+ const salt = qc.toUtf8Bytes("salt");
60
+ const out = qc.scryptSync(pw, salt, 262144, 8, 1, 32);
61
+ assert.equal(out, "0xd36e883d93698af49daa529419bb1d97da262bbaa225c12fcf05651268659f42");
62
+ });
63
+ });
@@ -8,7 +8,7 @@
8
8
  const { describe, it } = require("node:test");
9
9
  const assert = require("node:assert/strict");
10
10
 
11
- const { normalizeHex, isHexString, hexToBytes, bytesToHex, arrayify } = require("../../src/internal/hex");
11
+ const { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } = require("../../src/internal/hex");
12
12
  const { logSuite, logTest } = require("../verbose-logger");
13
13
 
14
14
  describe("internal/hex", () => {
@@ -20,6 +20,37 @@
20
20
  assert.equal(normalizeHex("0xa"), "0x0a");
21
21
  assert.equal(normalizeHex("0x0A"), "0x0a");
22
22
  });
23
+
24
+ it("toQuantityHex produces spec-compliant quantities (no leading zeros, 0x0 for zero)", () => {
25
+ logTest("toQuantityHex produces spec-compliant quantities", {});
26
+ assert.equal(toQuantityHex(0), "0x0");
27
+ assert.equal(toQuantityHex(0n), "0x0");
28
+ assert.equal(toQuantityHex(1), "0x1");
29
+ assert.equal(toQuantityHex(5), "0x5");
30
+ assert.equal(toQuantityHex(15), "0xf");
31
+ assert.equal(toQuantityHex(16), "0x10");
32
+ assert.equal(toQuantityHex(255), "0xff");
33
+ assert.equal(toQuantityHex(256), "0x100");
34
+ assert.equal(toQuantityHex(4095), "0xfff");
35
+ assert.equal(toQuantityHex(4096), "0x1000");
36
+ assert.equal(toQuantityHex(65535n), "0xffff");
37
+ assert.equal(toQuantityHex(2n ** 64n), "0x10000000000000000");
38
+
39
+ assert.equal(toQuantity, toQuantityHex);
40
+ assert.equal(toQuantity(5), "0x5");
41
+ });
42
+
43
+ it("toQuantityHex rejects invalid inputs", () => {
44
+ logTest("toQuantityHex rejects invalid inputs", {});
45
+ assert.throws(() => toQuantityHex(-1), RangeError);
46
+ assert.throws(() => toQuantityHex(-1n), RangeError);
47
+ assert.throws(() => toQuantityHex(1.5), TypeError);
48
+ assert.throws(() => toQuantityHex(NaN), TypeError);
49
+ assert.throws(() => toQuantityHex(Infinity), TypeError);
50
+ assert.throws(() => toQuantityHex("5"), TypeError);
51
+ assert.throws(() => toQuantityHex(null), TypeError);
52
+ assert.throws(() => toQuantityHex(undefined), TypeError);
53
+ });
23
54
 
24
55
  it("isHexString validates and supports optional lengthBytes", () => {
25
56
  const h32 = "0x" + "11".repeat(32);
@@ -8,7 +8,7 @@
8
8
  import { describe, it } from "node:test";
9
9
  import assert from "node:assert/strict";
10
10
 
11
- import { normalizeHex, isHexString, hexToBytes, bytesToHex, arrayify } from "../../src/internal/hex";
11
+ import { normalizeHex, toQuantityHex, toQuantity, isHexString, hexToBytes, bytesToHex, arrayify } from "../../src/internal/hex";
12
12
  import { logSuite, logTest } from "../verbose-logger";
13
13
 
14
14
  describe("internal/hex", () => {
@@ -21,6 +21,37 @@ describe("internal/hex", () => {
21
21
  assert.equal(normalizeHex("0x0A"), "0x0a");
22
22
  });
23
23
 
24
+ it("toQuantityHex produces spec-compliant quantities (no leading zeros, 0x0 for zero)", () => {
25
+ logTest("toQuantityHex produces spec-compliant quantities", {});
26
+ assert.equal(toQuantityHex(0), "0x0");
27
+ assert.equal(toQuantityHex(0n), "0x0");
28
+ assert.equal(toQuantityHex(1), "0x1");
29
+ assert.equal(toQuantityHex(5), "0x5");
30
+ assert.equal(toQuantityHex(15), "0xf");
31
+ assert.equal(toQuantityHex(16), "0x10");
32
+ assert.equal(toQuantityHex(255), "0xff");
33
+ assert.equal(toQuantityHex(256), "0x100");
34
+ assert.equal(toQuantityHex(4095), "0xfff");
35
+ assert.equal(toQuantityHex(4096), "0x1000");
36
+ assert.equal(toQuantityHex(65535n), "0xffff");
37
+ assert.equal(toQuantityHex(2n ** 64n), "0x10000000000000000");
38
+
39
+ assert.equal(toQuantity, toQuantityHex);
40
+ assert.equal(toQuantity(5), "0x5");
41
+ });
42
+
43
+ it("toQuantityHex rejects invalid inputs", () => {
44
+ logTest("toQuantityHex rejects invalid inputs", {});
45
+ assert.throws(() => toQuantityHex(-1), RangeError);
46
+ assert.throws(() => toQuantityHex(-1n), RangeError);
47
+ assert.throws(() => toQuantityHex(1.5), TypeError);
48
+ assert.throws(() => toQuantityHex(NaN), TypeError);
49
+ assert.throws(() => toQuantityHex(Infinity), TypeError);
50
+ assert.throws(() => toQuantityHex("5" as unknown as number), TypeError);
51
+ assert.throws(() => toQuantityHex(null as unknown as number), TypeError);
52
+ assert.throws(() => toQuantityHex(undefined as unknown as number), TypeError);
53
+ });
54
+
24
55
  it("isHexString validates and supports optional lengthBytes", () => {
25
56
  const h32 = "0x" + "11".repeat(32);
26
57
  assert.equal(isHexString(h32), true);
@@ -94,7 +94,57 @@
94
94
  });
95
95
  });
96
96
 
97
- describe("TransactionResponse.wait", () => {
97
+ describe("AbstractProvider block-tag QUANTITY formatting", () => {
98
+ logSuite("AbstractProvider block-tag QUANTITY formatting");
99
+
100
+ it("getBlock encodes block numbers as spec-compliant quantities (no leading zeros)", async () => {
101
+ logTest("getBlock encodes block numbers as spec-compliant quantities", {});
102
+ class BlockStub extends qc.AbstractProvider {
103
+ constructor() { super(); this.calls = []; }
104
+ async _perform(method, params) {
105
+ this.calls.push({ method, params });
106
+ return { number: "0x5", timestamp: "0x64" };
107
+ }
108
+ }
109
+ const p = new BlockStub();
110
+ await p.getBlock(0); assert.equal(p.calls.at(-1).params[0], "0x0");
111
+ await p.getBlock(5); assert.equal(p.calls.at(-1).params[0], "0x5");
112
+ await p.getBlock(15); assert.equal(p.calls.at(-1).params[0], "0xf");
113
+ await p.getBlock(16); assert.equal(p.calls.at(-1).params[0], "0x10");
114
+ await p.getBlock(256); assert.equal(p.calls.at(-1).params[0], "0x100");
115
+ await p.getBlock(4095); assert.equal(p.calls.at(-1).params[0], "0xfff");
116
+ await p.getBlock(4096); assert.equal(p.calls.at(-1).params[0], "0x1000");
117
+ await p.getBlock("latest"); assert.equal(p.calls.at(-1).params[0], "latest");
118
+ });
119
+
120
+ it("getLogs encodes fromBlock/toBlock as spec-compliant quantities (no leading zeros)", async () => {
121
+ logTest("getLogs encodes fromBlock/toBlock as spec-compliant quantities", {});
122
+ class LogStub extends qc.AbstractProvider {
123
+ constructor() { super(); this.calls = []; }
124
+ async _perform(method, params) { this.calls.push({ method, params }); return []; }
125
+ }
126
+ const lp = new LogStub();
127
+ await lp.getLogs({ fromBlock: 5, toBlock: 256 });
128
+ assert.equal(lp.calls[0].params[0].fromBlock, "0x5");
129
+ assert.equal(lp.calls[0].params[0].toBlock, "0x100");
130
+ await lp.getLogs({ fromBlock: "latest", toBlock: "pending" });
131
+ assert.equal(lp.calls[1].params[0].fromBlock, "latest");
132
+ assert.equal(lp.calls[1].params[0].toBlock, "pending");
133
+ });
134
+
135
+ it("getBlock rejects invalid block numbers with a clear typed error", async () => {
136
+ logTest("getBlock rejects invalid block numbers", {});
137
+ class StubP extends qc.AbstractProvider {
138
+ async _perform() { return { number: "0x0" }; }
139
+ }
140
+ const p = new StubP();
141
+ await assert.rejects(() => p.getBlock(-1), (e) => e instanceof RangeError);
142
+ await assert.rejects(() => p.getBlock(1.5), (e) => e instanceof TypeError);
143
+ await assert.rejects(() => p.getBlock(NaN), (e) => e instanceof TypeError);
144
+ });
145
+ });
146
+
147
+ describe("TransactionResponse.wait", () => {
98
148
  logSuite("TransactionResponse.wait");
99
149
  it("uses default confirmations when omitted vs null", async () => {
100
150
  logTest("uses default confirmations when omitted vs null", {});
@@ -91,6 +91,59 @@ describe("AbstractProvider defaults", () => {
91
91
  });
92
92
  });
93
93
 
94
+ describe("AbstractProvider block-tag QUANTITY formatting", () => {
95
+ logSuite("AbstractProvider block-tag QUANTITY formatting");
96
+
97
+ it("getBlock encodes block numbers as spec-compliant quantities (no leading zeros)", async () => {
98
+ logTest("getBlock encodes block numbers as spec-compliant quantities", {});
99
+ class BlockStub extends qc.AbstractProvider {
100
+ calls: { method: string; params: any[] }[] = [];
101
+ async _perform(method: string, params: any[]) {
102
+ this.calls.push({ method, params });
103
+ return { number: "0x5", timestamp: "0x64" };
104
+ }
105
+ }
106
+ const p = new BlockStub();
107
+ await p.getBlock(0); assert.equal(p.calls.at(-1)!.params[0], "0x0");
108
+ await p.getBlock(5); assert.equal(p.calls.at(-1)!.params[0], "0x5");
109
+ await p.getBlock(15); assert.equal(p.calls.at(-1)!.params[0], "0xf");
110
+ await p.getBlock(16); assert.equal(p.calls.at(-1)!.params[0], "0x10");
111
+ await p.getBlock(256); assert.equal(p.calls.at(-1)!.params[0], "0x100");
112
+ await p.getBlock(4095); assert.equal(p.calls.at(-1)!.params[0], "0xfff");
113
+ await p.getBlock(4096); assert.equal(p.calls.at(-1)!.params[0], "0x1000");
114
+ await p.getBlock("latest"); assert.equal(p.calls.at(-1)!.params[0], "latest");
115
+ });
116
+
117
+ it("getLogs encodes fromBlock/toBlock as spec-compliant quantities (no leading zeros)", async () => {
118
+ logTest("getLogs encodes fromBlock/toBlock as spec-compliant quantities", {});
119
+ class LogStub extends qc.AbstractProvider {
120
+ calls: { method: string; params: any[] }[] = [];
121
+ async _perform(method: string, params: any[]) {
122
+ this.calls.push({ method, params });
123
+ return [];
124
+ }
125
+ }
126
+ const lp = new LogStub();
127
+ await lp.getLogs({ fromBlock: 5, toBlock: 256 });
128
+ assert.equal(lp.calls[0].params[0].fromBlock, "0x5");
129
+ assert.equal(lp.calls[0].params[0].toBlock, "0x100");
130
+ await lp.getLogs({ fromBlock: "latest", toBlock: "pending" });
131
+ assert.equal(lp.calls[1].params[0].fromBlock, "latest");
132
+ assert.equal(lp.calls[1].params[0].toBlock, "pending");
133
+ });
134
+
135
+ it("getBlock rejects invalid block numbers with a clear typed error", async () => {
136
+ logTest("getBlock rejects invalid block numbers", {});
137
+ class StubP extends qc.AbstractProvider {
138
+ async _perform() { return { number: "0x0" }; }
139
+ }
140
+ const p = new StubP();
141
+ await assert.rejects(() => p.getBlock(-1 as unknown as number), (e) => e instanceof RangeError);
142
+ await assert.rejects(() => p.getBlock(1.5 as unknown as number), (e) => e instanceof TypeError);
143
+ await assert.rejects(() => p.getBlock(NaN as unknown as number), (e) => e instanceof TypeError);
144
+ });
145
+ });
146
+
94
147
  describe("TransactionResponse.wait", () => {
95
148
  logSuite("TransactionResponse.wait");
96
149
  it("uses default confirmations when omitted vs null", async () => {