quantumcoin 7.0.14 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/README-SDK.md +46 -0
  2. package/README.md +1 -1
  3. package/generate-sdk.js +8 -6
  4. package/package.json +22 -4
  5. package/src/abi/interface.d.ts +133 -128
  6. package/src/abi/js-abi-coder.d.ts +8 -8
  7. package/src/constants.d.ts +61 -61
  8. package/src/contract/contract-factory.d.ts +28 -28
  9. package/src/contract/contract.d.ts +121 -113
  10. package/src/contract/index.d.ts +1 -0
  11. package/src/errors/index.d.ts +10 -2
  12. package/src/errors/index.js +1 -1
  13. package/src/generator/index.d.ts +109 -81
  14. package/src/index.d.ts +126 -122
  15. package/src/internal/event-emitter.d.ts +76 -0
  16. package/src/internal/event-emitter.js +144 -0
  17. package/src/internal/hex.d.ts +27 -4
  18. package/src/internal/hex.js +7 -3
  19. package/src/providers/extra-providers.d.ts +141 -139
  20. package/src/providers/extra-providers.js +15 -1
  21. package/src/providers/index.d.ts +18 -17
  22. package/src/providers/json-rpc-provider.d.ts +1 -0
  23. package/src/providers/provider.d.ts +233 -206
  24. package/src/providers/provider.js +41 -1
  25. package/src/utils/encoding.js +16 -4
  26. package/src/utils/fixednumber.d.ts +57 -57
  27. package/src/utils/hashing.d.ts +79 -76
  28. package/src/utils/hashing.js +68 -177
  29. package/src/utils/index.d.ts +1 -1
  30. package/src/utils/rlp.js +1 -1
  31. package/src/wallet/wallet.d.ts +54 -19
  32. package/src/wallet/wallet.js +48 -10
  33. package/.github/workflows/publish-npmjs.yaml +0 -22
  34. package/.gitignore +0 -15
  35. package/examples/AllSolidityTypes.sol +0 -184
  36. package/examples/SimpleIERC20.sol +0 -74
  37. package/examples/events.js +0 -41
  38. package/examples/events.ts +0 -35
  39. package/examples/example-generated-sdk-js/README.md +0 -65
  40. package/examples/example-generated-sdk-js/examples/_test-wallet.js +0 -17
  41. package/examples/example-generated-sdk-js/examples/deploy.js +0 -41
  42. package/examples/example-generated-sdk-js/examples/events.js +0 -36
  43. package/examples/example-generated-sdk-js/examples/read-operations.js +0 -46
  44. package/examples/example-generated-sdk-js/examples/write-operations.js +0 -44
  45. package/examples/example-generated-sdk-js/index.d.ts +0 -1
  46. package/examples/example-generated-sdk-js/index.js +0 -15
  47. package/examples/example-generated-sdk-js/package-lock.json +0 -59
  48. package/examples/example-generated-sdk-js/package.json +0 -22
  49. package/examples/example-generated-sdk-js/src/SimpleERC20.d.ts +0 -19
  50. package/examples/example-generated-sdk-js/src/SimpleERC20.js +0 -353
  51. package/examples/example-generated-sdk-js/src/SimpleERC20__factory.d.ts +0 -10
  52. package/examples/example-generated-sdk-js/src/SimpleERC20__factory.js +0 -29
  53. package/examples/example-generated-sdk-js/src/index.d.ts +0 -4
  54. package/examples/example-generated-sdk-js/src/index.js +0 -5
  55. package/examples/example-generated-sdk-js/src/quantumcoin-shims.d.ts +0 -23
  56. package/examples/example-generated-sdk-js/src/types.d.ts +0 -3
  57. package/examples/example-generated-sdk-js/src/types.js +0 -3
  58. package/examples/example-generated-sdk-js/test/e2e/SimpleERC20.e2e.test.js +0 -78
  59. package/examples/example-generated-sdk-ts/README.md +0 -65
  60. package/examples/example-generated-sdk-ts/examples/_test-wallet.js +0 -17
  61. package/examples/example-generated-sdk-ts/examples/deploy.js +0 -41
  62. package/examples/example-generated-sdk-ts/examples/events.js +0 -36
  63. package/examples/example-generated-sdk-ts/examples/read-operations.js +0 -46
  64. package/examples/example-generated-sdk-ts/examples/write-operations.js +0 -44
  65. package/examples/example-generated-sdk-ts/index.d.ts +0 -1
  66. package/examples/example-generated-sdk-ts/index.js +0 -15
  67. package/examples/example-generated-sdk-ts/package-lock.json +0 -59
  68. package/examples/example-generated-sdk-ts/package.json +0 -23
  69. package/examples/example-generated-sdk-ts/src/SimpleERC20.ts +0 -334
  70. package/examples/example-generated-sdk-ts/src/SimpleERC20__factory.ts +0 -28
  71. package/examples/example-generated-sdk-ts/src/index.ts +0 -4
  72. package/examples/example-generated-sdk-ts/src/quantumcoin-shims.d.ts +0 -23
  73. package/examples/example-generated-sdk-ts/src/types.ts +0 -4
  74. package/examples/example-generated-sdk-ts/test/e2e/SimpleERC20.e2e.test.js +0 -78
  75. package/examples/example-generated-sdk-ts/tsconfig.json +0 -14
  76. package/examples/example-generator-sdk-js.js +0 -100
  77. package/examples/example-generator-sdk-js.ts +0 -77
  78. package/examples/example-generator-sdk-ts.js +0 -100
  79. package/examples/example-generator-sdk-ts.ts +0 -77
  80. package/examples/example.js +0 -67
  81. package/examples/example.ts +0 -56
  82. package/examples/node_modules/.bin/esbuild +0 -16
  83. package/examples/node_modules/.bin/esbuild.cmd +0 -17
  84. package/examples/node_modules/.bin/esbuild.ps1 +0 -28
  85. package/examples/node_modules/.bin/sdkgen +0 -16
  86. package/examples/node_modules/.bin/sdkgen.cmd +0 -17
  87. package/examples/node_modules/.bin/sdkgen.ps1 +0 -28
  88. package/examples/node_modules/.bin/tsx +0 -16
  89. package/examples/node_modules/.bin/tsx.cmd +0 -17
  90. package/examples/node_modules/.bin/tsx.ps1 +0 -28
  91. package/examples/node_modules/.package-lock.json +0 -144
  92. package/examples/node_modules/@esbuild/win32-x64/README.md +0 -3
  93. package/examples/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
  94. package/examples/node_modules/@esbuild/win32-x64/package.json +0 -20
  95. package/examples/node_modules/esbuild/LICENSE.md +0 -21
  96. package/examples/node_modules/esbuild/README.md +0 -3
  97. package/examples/node_modules/esbuild/bin/esbuild +0 -223
  98. package/examples/node_modules/esbuild/install.js +0 -289
  99. package/examples/node_modules/esbuild/lib/main.d.ts +0 -716
  100. package/examples/node_modules/esbuild/lib/main.js +0 -2532
  101. package/examples/node_modules/esbuild/package.json +0 -49
  102. package/examples/node_modules/get-tsconfig/LICENSE +0 -21
  103. package/examples/node_modules/get-tsconfig/README.md +0 -235
  104. package/examples/node_modules/get-tsconfig/dist/index.cjs +0 -7
  105. package/examples/node_modules/get-tsconfig/dist/index.d.cts +0 -2088
  106. package/examples/node_modules/get-tsconfig/dist/index.d.mts +0 -2088
  107. package/examples/node_modules/get-tsconfig/dist/index.mjs +0 -7
  108. package/examples/node_modules/get-tsconfig/package.json +0 -46
  109. package/examples/node_modules/quantum-coin-js-sdk/LICENSE +0 -21
  110. package/examples/node_modules/quantum-coin-js-sdk/LICENSE-wasm_exec.js.txt +0 -30
  111. package/examples/node_modules/quantum-coin-js-sdk/README.md +0 -1675
  112. package/examples/node_modules/quantum-coin-js-sdk/example/README.md +0 -14
  113. package/examples/node_modules/quantum-coin-js-sdk/example/conversion-example.js +0 -19
  114. package/examples/node_modules/quantum-coin-js-sdk/example/example-create-contract.js +0 -396
  115. package/examples/node_modules/quantum-coin-js-sdk/example/example-encode-decode-rlp.js +0 -225
  116. package/examples/node_modules/quantum-coin-js-sdk/example/example-event-pack-unpack.js +0 -391
  117. package/examples/node_modules/quantum-coin-js-sdk/example/example-misc.js +0 -101
  118. package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send-signRawTransaction.js +0 -318
  119. package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send.js +0 -116
  120. package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +0 -70
  121. package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +0 -961
  122. package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +0 -35
  123. package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet.js +0 -43
  124. package/examples/node_modules/quantum-coin-js-sdk/example/example.js +0 -405
  125. package/examples/node_modules/quantum-coin-js-sdk/example/package-lock.json +0 -134
  126. package/examples/node_modules/quantum-coin-js-sdk/example/package.json +0 -15
  127. package/examples/node_modules/quantum-coin-js-sdk/index.d.ts +0 -1031
  128. package/examples/node_modules/quantum-coin-js-sdk/index.js +0 -3144
  129. package/examples/node_modules/quantum-coin-js-sdk/package.json +0 -34
  130. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-32.json +0 -1
  131. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-36.json +0 -1
  132. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-48.json +0 -1
  133. package/examples/node_modules/quantum-coin-js-sdk/tests/generate-verify-vectors.js +0 -91
  134. package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.preinit.test.js +0 -41
  135. package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.test.js +0 -1389
  136. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-keytype5-context-null.test.js +0 -107
  137. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-transaction.test.js +0 -196
  138. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-verify.test.js +0 -311
  139. package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.relay.test.js +0 -131
  140. package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.rpc.test.js +0 -103
  141. package/examples/node_modules/quantum-coin-js-sdk/tests/verify-vectors.json +0 -95035
  142. package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.d.ts +0 -9
  143. package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.js +0 -16
  144. package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.d.ts +0 -0
  145. package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.js +0 -587
  146. package/examples/node_modules/resolve-pkg-maps/LICENSE +0 -21
  147. package/examples/node_modules/resolve-pkg-maps/README.md +0 -216
  148. package/examples/node_modules/resolve-pkg-maps/dist/index.cjs +0 -1
  149. package/examples/node_modules/resolve-pkg-maps/dist/index.d.cts +0 -11
  150. package/examples/node_modules/resolve-pkg-maps/dist/index.d.mts +0 -11
  151. package/examples/node_modules/resolve-pkg-maps/dist/index.mjs +0 -1
  152. package/examples/node_modules/resolve-pkg-maps/package.json +0 -42
  153. package/examples/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
  154. package/examples/node_modules/seed-words/BUILD.md +0 -7
  155. package/examples/node_modules/seed-words/LICENSE +0 -121
  156. package/examples/node_modules/seed-words/README.md +0 -67
  157. package/examples/node_modules/seed-words/dist/seedwords.d.ts +0 -39
  158. package/examples/node_modules/seed-words/package.json +0 -27
  159. package/examples/node_modules/seed-words/seedwords.js +0 -315
  160. package/examples/node_modules/seed-words/seedwords.txt +0 -65536
  161. package/examples/node_modules/seed-words/tsconfig.json +0 -21
  162. package/examples/node_modules/tsx/LICENSE +0 -21
  163. package/examples/node_modules/tsx/README.md +0 -32
  164. package/examples/node_modules/tsx/dist/cjs/api/index.cjs +0 -1
  165. package/examples/node_modules/tsx/dist/cjs/api/index.d.cts +0 -35
  166. package/examples/node_modules/tsx/dist/cjs/api/index.d.mts +0 -35
  167. package/examples/node_modules/tsx/dist/cjs/api/index.mjs +0 -1
  168. package/examples/node_modules/tsx/dist/cjs/index.cjs +0 -1
  169. package/examples/node_modules/tsx/dist/cjs/index.mjs +0 -1
  170. package/examples/node_modules/tsx/dist/cli.cjs +0 -54
  171. package/examples/node_modules/tsx/dist/cli.mjs +0 -55
  172. package/examples/node_modules/tsx/dist/client-BQVF1NaW.mjs +0 -1
  173. package/examples/node_modules/tsx/dist/client-D6NvIMSC.cjs +0 -1
  174. package/examples/node_modules/tsx/dist/esm/api/index.cjs +0 -1
  175. package/examples/node_modules/tsx/dist/esm/api/index.d.cts +0 -35
  176. package/examples/node_modules/tsx/dist/esm/api/index.d.mts +0 -35
  177. package/examples/node_modules/tsx/dist/esm/api/index.mjs +0 -1
  178. package/examples/node_modules/tsx/dist/esm/index.cjs +0 -2
  179. package/examples/node_modules/tsx/dist/esm/index.mjs +0 -2
  180. package/examples/node_modules/tsx/dist/get-pipe-path-BHW2eJdv.mjs +0 -1
  181. package/examples/node_modules/tsx/dist/get-pipe-path-BoR10qr8.cjs +0 -1
  182. package/examples/node_modules/tsx/dist/index-7AaEi15b.mjs +0 -14
  183. package/examples/node_modules/tsx/dist/index-BWFBUo6r.cjs +0 -1
  184. package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +0 -1
  185. package/examples/node_modules/tsx/dist/index-gckBtVBf.cjs +0 -14
  186. package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +0 -3
  187. package/examples/node_modules/tsx/dist/lexer-DgIbo0BU.cjs +0 -3
  188. package/examples/node_modules/tsx/dist/loader.cjs +0 -1
  189. package/examples/node_modules/tsx/dist/loader.mjs +0 -1
  190. package/examples/node_modules/tsx/dist/node-features-_8ZFwP_x.mjs +0 -1
  191. package/examples/node_modules/tsx/dist/node-features-roYmp9jK.cjs +0 -1
  192. package/examples/node_modules/tsx/dist/package-CeBgXWuR.mjs +0 -1
  193. package/examples/node_modules/tsx/dist/package-Dxt5kIHw.cjs +0 -1
  194. package/examples/node_modules/tsx/dist/patch-repl.cjs +0 -1
  195. package/examples/node_modules/tsx/dist/patch-repl.mjs +0 -1
  196. package/examples/node_modules/tsx/dist/preflight.cjs +0 -1
  197. package/examples/node_modules/tsx/dist/preflight.mjs +0 -1
  198. package/examples/node_modules/tsx/dist/register-2sWVXuRQ.cjs +0 -1
  199. package/examples/node_modules/tsx/dist/register-B7jrtLTO.mjs +0 -1
  200. package/examples/node_modules/tsx/dist/register-CFH5oNdT.mjs +0 -4
  201. package/examples/node_modules/tsx/dist/register-D46fvsV_.cjs +0 -4
  202. package/examples/node_modules/tsx/dist/repl.cjs +0 -3
  203. package/examples/node_modules/tsx/dist/repl.mjs +0 -3
  204. package/examples/node_modules/tsx/dist/require-D4F1Lv60.cjs +0 -1
  205. package/examples/node_modules/tsx/dist/require-DQxpCAr4.mjs +0 -1
  206. package/examples/node_modules/tsx/dist/suppress-warnings.cjs +0 -1
  207. package/examples/node_modules/tsx/dist/suppress-warnings.mjs +0 -1
  208. package/examples/node_modules/tsx/dist/temporary-directory-B83uKxJF.cjs +0 -1
  209. package/examples/node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs +0 -1
  210. package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +0 -5
  211. package/examples/node_modules/tsx/package.json +0 -68
  212. package/examples/offline-signing.js +0 -77
  213. package/examples/offline-signing.ts +0 -65
  214. package/examples/package-lock.json +0 -596
  215. package/examples/package.json +0 -32
  216. package/examples/read-operations.js +0 -32
  217. package/examples/read-operations.ts +0 -31
  218. package/examples/sdk-generator-erc20.inline.json +0 -251
  219. package/examples/solidity-types.ts +0 -43
  220. package/examples/wallet-offline.js +0 -36
  221. package/examples/wallet-offline.ts +0 -26
  222. package/scripts/copy-declarations.js +0 -31
  223. package/scripts/run-all-one-by-one.js +0 -151
  224. package/test/e2e/all-solidity-types.dynamic.test.js +0 -207
  225. package/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
  226. package/test/e2e/all-solidity-types.fixtures.js +0 -231
  227. package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
  228. package/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
  229. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/README.md +0 -83
  230. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.abi.json +0 -12544
  231. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/artifacts/AllSolidityTypes.bin +0 -1
  232. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.js +0 -17
  233. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/_test-wallet.ts +0 -10
  234. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.js +0 -41
  235. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/deploy.ts +0 -41
  236. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.js +0 -36
  237. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/events.ts +0 -36
  238. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.js +0 -82
  239. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/offline-signing.ts +0 -80
  240. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.js +0 -46
  241. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/read-operations.ts +0 -44
  242. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.js +0 -44
  243. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/examples/write-operations.ts +0 -44
  244. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.d.ts +0 -1
  245. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/index.js +0 -21
  246. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package-lock.json +0 -597
  247. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/package.json +0 -25
  248. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.d.ts +0 -1280
  249. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes.js +0 -14021
  250. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.d.ts +0 -11
  251. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/AllSolidityTypes__factory.js +0 -31
  252. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.d.ts +0 -4
  253. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/index.js +0 -5
  254. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/quantumcoin-shims.d.ts +0 -25
  255. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.d.ts +0 -3
  256. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/src/types.js +0 -3
  257. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.e2e.test.js +0 -77
  258. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-js/test/e2e/AllSolidityTypes.extra.test.js +0 -195
  259. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/README.md +0 -83
  260. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.abi.json +0 -12544
  261. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/artifacts/AllSolidityTypes.bin +0 -1
  262. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.js +0 -17
  263. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/_test-wallet.ts +0 -10
  264. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.js +0 -41
  265. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/deploy.ts +0 -41
  266. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.js +0 -36
  267. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/events.ts +0 -36
  268. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.js +0 -82
  269. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/offline-signing.ts +0 -80
  270. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.js +0 -46
  271. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/read-operations.ts +0 -44
  272. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.js +0 -44
  273. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/examples/write-operations.ts +0 -44
  274. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.d.ts +0 -1
  275. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/index.js +0 -21
  276. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package-lock.json +0 -597
  277. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/package.json +0 -26
  278. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes.ts +0 -13940
  279. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/AllSolidityTypes__factory.ts +0 -31
  280. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/index.ts +0 -4
  281. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/quantumcoin-shims.d.ts +0 -25
  282. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/src/types.ts +0 -4
  283. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.e2e.test.js +0 -77
  284. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/test/e2e/AllSolidityTypes.extra.test.js +0 -195
  285. package/test/e2e/generated-sdks/all-solidity-types/all-solidity-types-ts/tsconfig.json +0 -18
  286. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/README.md +0 -74
  287. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.abi.json +0 -245
  288. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/artifacts/SimpleERC20.bin +0 -1
  289. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.js +0 -17
  290. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/_test-wallet.ts +0 -10
  291. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.js +0 -41
  292. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/deploy.ts +0 -41
  293. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.js +0 -36
  294. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/events.ts +0 -36
  295. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.js +0 -82
  296. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/offline-signing.ts +0 -80
  297. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.js +0 -46
  298. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/read-operations.ts +0 -44
  299. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.js +0 -44
  300. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/examples/write-operations.ts +0 -44
  301. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.d.ts +0 -1
  302. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/index.js +0 -16
  303. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package-lock.json +0 -597
  304. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/package.json +0 -25
  305. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.d.ts +0 -24
  306. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20.js +0 -378
  307. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.d.ts +0 -10
  308. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/SimpleERC20__factory.js +0 -31
  309. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.d.ts +0 -4
  310. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/index.js +0 -5
  311. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/quantumcoin-shims.d.ts +0 -25
  312. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.d.ts +0 -3
  313. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/src/types.js +0 -3
  314. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-js/test/e2e/SimpleERC20.e2e.test.js +0 -90
  315. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/README.md +0 -74
  316. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.abi.json +0 -245
  317. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/artifacts/SimpleERC20.bin +0 -1
  318. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.js +0 -17
  319. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/_test-wallet.ts +0 -10
  320. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.js +0 -41
  321. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/deploy.ts +0 -41
  322. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.js +0 -36
  323. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/events.ts +0 -36
  324. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.js +0 -82
  325. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/offline-signing.ts +0 -80
  326. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.js +0 -46
  327. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/read-operations.ts +0 -44
  328. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.js +0 -44
  329. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/examples/write-operations.ts +0 -44
  330. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.d.ts +0 -1
  331. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/index.js +0 -16
  332. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package-lock.json +0 -597
  333. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/package.json +0 -26
  334. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20.ts +0 -361
  335. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/SimpleERC20__factory.ts +0 -30
  336. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/index.ts +0 -4
  337. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/quantumcoin-shims.d.ts +0 -25
  338. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/src/types.ts +0 -4
  339. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/test/e2e/SimpleERC20.e2e.test.js +0 -90
  340. package/test/e2e/generated-sdks/simple-erc20/simple-erc20-ts/tsconfig.json +0 -18
  341. package/test/e2e/generator-interface.e2e.test.js +0 -165
  342. package/test/e2e/generator-interface.e2e.test.ts +0 -160
  343. package/test/e2e/helpers.js +0 -59
  344. package/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
  345. package/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
  346. package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
  347. package/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
  348. package/test/e2e/transactional.test.js +0 -245
  349. package/test/e2e/transactional.test.ts +0 -208
  350. package/test/e2e/typed-generator.e2e.test.js +0 -407
  351. package/test/e2e/typed-generator.e2e.test.ts +0 -337
  352. package/test/fixtures/ConstructorParam.sol +0 -23
  353. package/test/fixtures/MultiContracts.sol +0 -37
  354. package/test/fixtures/SimpleStorage.sol +0 -18
  355. package/test/fixtures/StakingContract.abi.json +0 -1
  356. package/test/integration/ipc-provider.test.js +0 -49
  357. package/test/integration/ipc-provider.test.ts +0 -44
  358. package/test/integration/provider.test.js +0 -88
  359. package/test/integration/provider.test.ts +0 -85
  360. package/test/integration/ws-provider.test.js +0 -41
  361. package/test/integration/ws-provider.test.ts +0 -38
  362. package/test/security/abi-decoder-bounds.test.js +0 -122
  363. package/test/security/contract-overrides.test.js +0 -112
  364. package/test/security/generator-injection.test.js +0 -195
  365. package/test/security/malformed-input.test.js +0 -330
  366. package/test/security/malformed-input.test.ts +0 -35
  367. package/test/security/rpc-numeric-bounds.test.js +0 -81
  368. package/test/security/rpc-trust.test.js +0 -202
  369. package/test/unit/_encrypted-output.txt +0 -6
  370. package/test/unit/_log-encrypted-jsons.js +0 -45
  371. package/test/unit/_write-keystore-fixture.js +0 -16
  372. package/test/unit/abi-interface.test.js +0 -110
  373. package/test/unit/abi-interface.test.ts +0 -109
  374. package/test/unit/address-wallet.test.js +0 -923
  375. package/test/unit/address-wallet.test.ts +0 -877
  376. package/test/unit/browser-provider.test.js +0 -85
  377. package/test/unit/browser-provider.test.ts +0 -79
  378. package/test/unit/contract.test.js +0 -85
  379. package/test/unit/contract.test.ts +0 -83
  380. package/test/unit/encoding-units-rlp.test.js +0 -127
  381. package/test/unit/encoding-units-rlp.test.ts +0 -91
  382. package/test/unit/errors.test.js +0 -77
  383. package/test/unit/errors.test.ts +0 -76
  384. package/test/unit/filter-by-blockhash.test.js +0 -55
  385. package/test/unit/filter-by-blockhash.test.ts +0 -54
  386. package/test/unit/fixednumber.test.js +0 -656
  387. package/test/unit/fixednumber.test.ts +0 -660
  388. package/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
  389. package/test/unit/generate-contract-cli.test.js +0 -42
  390. package/test/unit/generate-contract-cli.test.ts +0 -41
  391. package/test/unit/generate-sdk-artifacts-json.test.js +0 -113
  392. package/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
  393. package/test/unit/generator.test.js +0 -149
  394. package/test/unit/generator.test.ts +0 -148
  395. package/test/unit/hashing.test.js +0 -64
  396. package/test/unit/hashing.test.ts +0 -63
  397. package/test/unit/init.test.js +0 -39
  398. package/test/unit/init.test.ts +0 -38
  399. package/test/unit/interface.test.js +0 -56
  400. package/test/unit/interface.test.ts +0 -54
  401. package/test/unit/internal-hex.test.js +0 -81
  402. package/test/unit/internal-hex.test.ts +0 -80
  403. package/test/unit/populate-transaction.test.js +0 -98
  404. package/test/unit/populate-transaction.test.ts +0 -64
  405. package/test/unit/providers.test.js +0 -252
  406. package/test/unit/providers.test.ts +0 -251
  407. package/test/unit/result.test.js +0 -80
  408. package/test/unit/result.test.ts +0 -79
  409. package/test/unit/solidity-types.test.js +0 -49
  410. package/test/unit/solidity-types.test.ts +0 -39
  411. package/test/unit/utils.test.js +0 -57
  412. package/test/unit/utils.test.ts +0 -56
  413. package/test/verbose-logger.js +0 -74
  414. package/tsconfig.build.json +0 -14
@@ -1,961 +0,0 @@
1
- const qcsdk = require('quantum-coin-js-sdk');
2
- const ethers = require('ethers');
3
-
4
- /**
5
- * Example: Token Pack/Unpack Operations
6
- *
7
- * This example demonstrates how to use packMethodData and unpackMethodData
8
- * to interact with ERC20 tokens and Router contracts.
9
- */
10
-
11
- // Configuration
12
- var clientConfigVal = new qcsdk.Config("https://sdk.readrelay.quantumcoinapi.com", "https://sdk.writerelay.quantumcoinapi.com", 123123, "", ""); //Mainnet
13
- //Mainnet Block Explorer: https://scan.quantumcoin.org
14
-
15
- // RPC endpoint for making contract calls
16
- const rpcEndpointUrl = 'https://public.rpc.quantumcoinapi.com';
17
-
18
- // Contract addresses
19
- const SWAP_ROUTER_ADDRESS = "0x41323EF72662185f44a03ea0ad8094a0C9e925aB1102679D8e957e838054aac5";
20
- const FACTORY_ADDRESS = "0xbbF45a1B60044669793B444eD01Eb33e03Bb8cf3c5b6ae7887B218D05C5Cbf1d"; // Replace with actual Factory contract address
21
- const TOKEN_A_ADDRESS = "0x1Bd75060B22686a9f32Af80BC02348c1BAeDBba06f47ad723885c92a6566B65d";
22
- const TOKEN_B_ADDRESS = "0x12b803EC8529b26deEa8D7ff37B9457Ea15C05bD3fD0Ba2F3A4b95D53c82403a";
23
- const ACCOUNT_HOLDER_ADDRESS = "0xd51773b5dde3f8e4d29ae42b5046510e2a11fd0c8e4175853d6227896eb445c6";
24
-
25
- // ERC20 Token Standard ABI
26
- const erc20ABI = [
27
- {
28
- "name": "balanceOf",
29
- "type": "function",
30
- "inputs": [
31
- {"name": "account", "type": "address"}
32
- ],
33
- "outputs": [
34
- {"name": "", "type": "uint256"}
35
- ],
36
- "stateMutability": "view"
37
- },
38
- {
39
- "name": "name",
40
- "type": "function",
41
- "inputs": [],
42
- "outputs": [
43
- {"name": "", "type": "string"}
44
- ],
45
- "stateMutability": "view"
46
- },
47
- {
48
- "name": "symbol",
49
- "type": "function",
50
- "inputs": [],
51
- "outputs": [
52
- {"name": "", "type": "string"}
53
- ],
54
- "stateMutability": "view"
55
- },
56
- {
57
- "name": "decimals",
58
- "type": "function",
59
- "inputs": [],
60
- "outputs": [
61
- {"name": "", "type": "uint8"}
62
- ],
63
- "stateMutability": "view"
64
- },
65
- {
66
- "name": "totalSupply",
67
- "type": "function",
68
- "inputs": [],
69
- "outputs": [
70
- {"name": "", "type": "uint256"}
71
- ],
72
- "stateMutability": "view"
73
- },
74
- {
75
- "name": "owner",
76
- "type": "function",
77
- "inputs": [],
78
- "outputs": [
79
- {"name": "", "type": "address"}
80
- ],
81
- "stateMutability": "view"
82
- }
83
- ];
84
-
85
- // QuantumSwap Router ABI
86
- const quantumswapV2RouterABI = [
87
- {
88
- "name": "getAmountsIn",
89
- "type": "function",
90
- "inputs": [
91
- {"name": "amountOut", "type": "uint256"},
92
- {"name": "path", "type": "address[]"}
93
- ],
94
- "outputs": [
95
- {"name": "amounts", "type": "uint256[]"}
96
- ],
97
- "stateMutability": "view"
98
- },
99
- {
100
- "name": "getAmountsOut",
101
- "type": "function",
102
- "inputs": [
103
- {"name": "amountIn", "type": "uint256"},
104
- {"name": "path", "type": "address[]"}
105
- ],
106
- "outputs": [
107
- {"name": "amounts", "type": "uint256[]"}
108
- ],
109
- "stateMutability": "view"
110
- },
111
- {
112
- "name": "swapExactTokensForTokens",
113
- "type": "function",
114
- "inputs": [
115
- {"name": "amountIn", "type": "uint256"},
116
- {"name": "amountOutMin", "type": "uint256"},
117
- {"name": "path", "type": "address[]"},
118
- {"name": "to", "type": "address"},
119
- {"name": "deadline", "type": "uint256"}
120
- ],
121
- "outputs": [
122
- {"name": "amounts", "type": "uint256[]"}
123
- ],
124
- "stateMutability": "nonpayable"
125
- },
126
- {
127
- "name": "swapTokensForExactTokens",
128
- "type": "function",
129
- "inputs": [
130
- {"name": "amountOut", "type": "uint256"},
131
- {"name": "amountInMax", "type": "uint256"},
132
- {"name": "path", "type": "address[]"},
133
- {"name": "to", "type": "address"},
134
- {"name": "deadline", "type": "uint256"}
135
- ],
136
- "outputs": [
137
- {"name": "amounts", "type": "uint256[]"}
138
- ],
139
- "stateMutability": "nonpayable"
140
- }
141
- ];
142
-
143
- // Factory Contract ABI (for getting pair addresses)
144
- const factoryABI = [
145
- {
146
- "name": "getPair",
147
- "type": "function",
148
- "inputs": [
149
- {"name": "tokenA", "type": "address"},
150
- {"name": "tokenB", "type": "address"}
151
- ],
152
- "outputs": [
153
- {"name": "pair", "type": "address"}
154
- ],
155
- "stateMutability": "view"
156
- },
157
- {
158
- "name": "allPairs",
159
- "type": "function",
160
- "inputs": [
161
- {"name": "", "type": "uint256"}
162
- ],
163
- "outputs": [
164
- {"name": "", "type": "address"}
165
- ],
166
- "stateMutability": "view"
167
- },
168
- {
169
- "name": "allPairsLength",
170
- "type": "function",
171
- "inputs": [],
172
- "outputs": [
173
- {"name": "", "type": "uint256"}
174
- ],
175
- "stateMutability": "view"
176
- }
177
- ];
178
-
179
- /**
180
- * Helper function to make RPC calls
181
- */
182
- async function rpcCall(method, params) {
183
- try {
184
- const response = await fetch(rpcEndpointUrl, {
185
- method: 'POST',
186
- headers: {
187
- 'Content-Type': 'application/json',
188
- },
189
- body: JSON.stringify({
190
- jsonrpc: '2.0',
191
- id: 1,
192
- method: method,
193
- params: params,
194
- }),
195
- });
196
-
197
- if (!response.ok) {
198
- throw new Error(`HTTP error! status: ${response.status}`);
199
- }
200
-
201
- const result = await response.json();
202
- return result;
203
- } catch (error) {
204
- console.error('RPC call failed:', error);
205
- throw error;
206
- }
207
- }
208
-
209
- /**
210
- * Helper function to get transaction count (nonce) for an address
211
- */
212
- async function getTransactionCount(address) {
213
- const result = await rpcCall("eth_getTransactionCount", [address, "latest"]);
214
- if (result.error) {
215
- throw new Error(`Failed to get transaction count: ${result.error.message}`);
216
- }
217
- return parseInt(result.result, 16);
218
- }
219
-
220
- /**
221
- * Helper function to send raw transaction
222
- */
223
- async function sendRawTransaction(signedTxData) {
224
- const result = await rpcCall("eth_sendRawTransaction", [signedTxData]);
225
- if (result.error) {
226
- throw new Error(`Failed to send transaction: ${result.error.message}`);
227
- }
228
- return result.result; // Returns transaction hash
229
- }
230
-
231
- /**
232
- * Helper function to convert wei to coins (ETH equivalent)
233
- */
234
- function weiToCoins(wei) {
235
- const oneCoinInWei = BigInt("1000000000000000000");
236
- const coins = Number(wei) / Number(oneCoinInWei);
237
- return coins;
238
- }
239
-
240
- /**
241
- * Example 1: Get token balance of an address
242
- */
243
- async function example1_GetTokenBalance() {
244
- console.log('\n=== Example 1: Get Token Balance ===\n');
245
-
246
- // Token contract address
247
- const tokenAddress = TOKEN_A_ADDRESS;
248
- // User address
249
- const userAddress = ACCOUNT_HOLDER_ADDRESS;
250
-
251
- const abiJSON = JSON.stringify(erc20ABI);
252
-
253
- // Pack the balanceOf method call
254
- const packResult = qcsdk.packMethodData(abiJSON, "balanceOf", userAddress);
255
-
256
- if (packResult.error) {
257
- console.error("Error packing balanceOf:", packResult.error);
258
- return;
259
- }
260
-
261
- console.log("Packed data (hex):", packResult.result);
262
-
263
- // Make RPC call to get the balance
264
- const rpcResult = await rpcCall("eth_call", [
265
- {
266
- to: tokenAddress,
267
- data: packResult.result
268
- },
269
- "latest"
270
- ]);
271
-
272
- if (rpcResult.error) {
273
- console.error("RPC error:", rpcResult.error);
274
- return;
275
- }
276
-
277
- const returnData = rpcResult.result;
278
- console.log("Return data (hex):", returnData);
279
-
280
- // Unpack the return value
281
- const unpackResult = qcsdk.unpackMethodData(abiJSON, "balanceOf", returnData);
282
-
283
- if (unpackResult.error) {
284
- console.error("Error unpacking balanceOf:", unpackResult.error);
285
- return;
286
- }
287
-
288
- // Parse the JSON result
289
- const balance = JSON.parse(unpackResult.result)[0];
290
- const balanceWei = BigInt(balance);
291
- const balanceCoins = weiToCoins(balanceWei);
292
- console.log("Token Contract Address:", TOKEN_A_ADDRESS);
293
- console.log("ACCOUNT_HOLDER_ADDRESS:", ACCOUNT_HOLDER_ADDRESS);
294
- console.log("Token balance (wei):", balance);
295
- console.log("Token balance (coins):", balanceCoins.toFixed(9));
296
- }
297
-
298
- /**
299
- * Example 2: Get token name, totalSupply, decimals, owner, and symbol
300
- */
301
- async function example2_GetTokenInfo() {
302
- console.log('\n=== Example 2: Get Token Information ===\n');
303
-
304
- // Token contract address
305
- const tokenAddress = TOKEN_A_ADDRESS;
306
- const abiJSON = JSON.stringify(erc20ABI);
307
-
308
- // Helper function to call a view function
309
- async function callViewFunction(methodName, ...args) {
310
- const packResult = qcsdk.packMethodData(abiJSON, methodName, ...args);
311
-
312
- if (packResult.error) {
313
- console.error(`Error packing ${methodName}:`, packResult.error);
314
- return null;
315
- }
316
-
317
- const rpcResult = await rpcCall("eth_call", [
318
- {
319
- to: tokenAddress,
320
- data: packResult.result
321
- },
322
- "latest"
323
- ]);
324
-
325
- if (rpcResult.error) {
326
- console.error(`RPC error for ${methodName}:`, rpcResult.error);
327
- return null;
328
- }
329
-
330
- const unpackResult = qcsdk.unpackMethodData(abiJSON, methodName, rpcResult.result);
331
-
332
- if (unpackResult.error) {
333
- console.error(`Error unpacking ${methodName}:`, unpackResult.error);
334
- return null;
335
- }
336
-
337
- return JSON.parse(unpackResult.result);
338
- }
339
-
340
- // Get token name
341
- console.log("Getting token name...");
342
- const nameResult = await callViewFunction("name");
343
- if (nameResult) {
344
- console.log("Token name:", nameResult[0]);
345
- }
346
-
347
- // Get token symbol
348
- console.log("Getting token symbol...");
349
- const symbolResult = await callViewFunction("symbol");
350
- if (symbolResult) {
351
- console.log("Token symbol:", symbolResult[0]);
352
- }
353
-
354
- // Get token decimals
355
- console.log("Getting token decimals...");
356
- const decimalsResult = await callViewFunction("decimals");
357
- if (decimalsResult) {
358
- console.log("Token decimals:", parseInt(decimalsResult[0], 10));
359
- }
360
-
361
- // Get total supply
362
- console.log("Getting total supply...");
363
- const totalSupplyResult = await callViewFunction("totalSupply");
364
- if (totalSupplyResult) {
365
- const totalSupply = totalSupplyResult[0];
366
- const totalSupplyWei = BigInt(totalSupply);
367
- const totalSupplyCoins = weiToCoins(totalSupplyWei);
368
- console.log("Total supply (wei):", totalSupply);
369
- console.log("Total supply (coins):", totalSupplyCoins.toFixed(9));
370
- }
371
-
372
- // Get owner
373
- console.log("Getting token owner...");
374
- const ownerResult = await callViewFunction("owner");
375
- if (ownerResult) {
376
- console.log("Token owner:", ownerResult[0]);
377
- }
378
- }
379
-
380
- /**
381
- * Example 3: Get pair address for two tokens
382
- */
383
- async function example3_GetPairAddress() {
384
- console.log('\n=== Example 3: Get Pair Address for Two Tokens ===\n');
385
-
386
- // Factory contract address
387
- const factoryAddress = FACTORY_ADDRESS;
388
- const abiJSON = JSON.stringify(factoryABI);
389
-
390
- // Token addresses
391
- const tokenA = TOKEN_A_ADDRESS;
392
- const tokenB = TOKEN_B_ADDRESS;
393
-
394
- console.log("Token A:", tokenA);
395
- console.log("Token B:", tokenB);
396
- console.log("Factory Address:", factoryAddress);
397
-
398
- // Pack the getPair method call
399
- const packResult = qcsdk.packMethodData(abiJSON, "getPair", tokenA, tokenB);
400
-
401
- if (packResult.error) {
402
- console.error("Error packing getPair:", packResult.error);
403
- return;
404
- }
405
-
406
- console.log("Packed data (hex):", packResult.result);
407
-
408
- // Make RPC call
409
- const rpcResult = await rpcCall("eth_call", [
410
- {
411
- to: factoryAddress,
412
- data: packResult.result
413
- },
414
- "latest"
415
- ]);
416
-
417
- if (rpcResult.error) {
418
- console.error("RPC error:", rpcResult.error);
419
- return;
420
- }
421
-
422
- console.log("RPC result (raw):", rpcResult.result);
423
-
424
- // Check if result is empty or indicates a revert
425
- if (!rpcResult.result || rpcResult.result === "0x" || rpcResult.result === "") {
426
- console.error("\n❌ Error: Empty result returned from Factory contract.");
427
- console.error("Possible reasons:");
428
- console.error(" 1. Factory contract address does not exist or is incorrect");
429
- console.error(" 2. Contract execution reverted (contract may not have getPair function)");
430
- console.error(" 3. Factory contract is not deployed at the specified address");
431
- console.error("\nPlease verify the Factory contract address:", factoryAddress);
432
- return null;
433
- }
434
-
435
- // Check for revert indicator (some RPCs return "0x" for reverts, others may have specific error data)
436
- // If the result is just "0x" or very short, it might be a revert
437
- if (rpcResult.result.length <= 2) {
438
- console.error("\n❌ Error: Contract execution likely reverted.");
439
- console.error("The Factory contract may not have the getPair function or the contract address is incorrect.");
440
- return null;
441
- }
442
-
443
- // Unpack the return value
444
- const unpackResult = qcsdk.unpackMethodData(abiJSON, "getPair", rpcResult.result);
445
-
446
- if (unpackResult.error) {
447
- console.error("\n❌ Error unpacking getPair:", unpackResult.error);
448
- console.error("This usually means:");
449
- console.error(" 1. The Factory contract address is incorrect");
450
- console.error(" 2. The contract doesn't have the getPair function");
451
- console.error(" 3. The execution reverted (empty string returned)");
452
- console.error("\nPlease verify the Factory contract address:", factoryAddress);
453
- return null;
454
- }
455
-
456
- // Parse the JSON result
457
- const parsed = JSON.parse(unpackResult.result);
458
- const pairAddress = parsed[0];
459
-
460
- console.log("\n✅ Pair Address:", pairAddress);
461
-
462
- if (pairAddress === "0x0000000000000000000000000000000000000000000000000000000000000000" ||
463
- pairAddress === null ||
464
- pairAddress === undefined) {
465
- console.log("⚠️ Note: Pair does not exist yet. It will be created when liquidity is first added.");
466
- } else {
467
- console.log("✅ Pair exists at the address above.");
468
- }
469
-
470
- return pairAddress;
471
- }
472
-
473
- /**
474
- * Example 3a: Get amount in using QuantumSwap Router
475
- */
476
- async function example3a_GetAmountIn() {
477
- console.log('\n=== Example 3a: Get Amount In (QuantumSwapV2 Router) ===\n');
478
-
479
- // QuantumSwapV2 Router contract address
480
- const routerAddress = SWAP_ROUTER_ADDRESS;
481
- const abiJSON = JSON.stringify(quantumswapV2RouterABI);
482
-
483
- // Example: Want 1 token out, calculate how much token in needed
484
- // amountOut: 1 token (with 18 decimals) = 1000000000000000000 wei
485
- const amountOut = "1000000000000000000";
486
- const amountOutWei = BigInt(amountOut);
487
- const amountOutCoins = weiToCoins(amountOutWei);
488
-
489
- // Swap path: TokenA -> TokenB
490
- const path = [TOKEN_A_ADDRESS, TOKEN_B_ADDRESS];
491
-
492
- // Pack the getAmountsIn method call
493
- const packResult = qcsdk.packMethodData(abiJSON, "getAmountsIn", amountOut, path);
494
-
495
- if (packResult.error) {
496
- console.error("Error packing getAmountsIn:", packResult.error);
497
- return;
498
- }
499
-
500
- console.log("Packed data (hex):", packResult.result);
501
- console.log("Amount out desired (wei):", amountOut);
502
- console.log("Amount out desired (coins):", amountOutCoins.toFixed(9));
503
- console.log("Swap path:", path);
504
-
505
- // Make RPC call
506
- const rpcResult = await rpcCall("eth_call", [
507
- {
508
- to: routerAddress,
509
- data: packResult.result
510
- },
511
- "latest"
512
- ]);
513
-
514
- if (rpcResult.error) {
515
- console.error("RPC error:", rpcResult.error);
516
- return;
517
- }
518
-
519
- // Unpack the return value
520
- const unpackResult = qcsdk.unpackMethodData(abiJSON, "getAmountsIn", rpcResult.result);
521
-
522
- if (unpackResult.error) {
523
- console.error("Error unpacking getAmountsIn:", unpackResult.error);
524
- return;
525
- }
526
-
527
- // Parse the JSON result (array of amounts)
528
- const parsed = JSON.parse(unpackResult.result);
529
- console.log("Parsed result:", parsed);
530
- const amounts = parsed[0];
531
- console.log("Amounts array:", amounts);
532
- console.log("Amounts array type:", typeof amounts, Array.isArray(amounts));
533
-
534
- // Handle case where amounts might be a string or already an array
535
- let amountsArray;
536
- if (typeof amounts === 'string') {
537
- // If it's a string, try to parse it again
538
- try {
539
- amountsArray = JSON.parse(amounts);
540
- } catch (e) {
541
- console.error("Failed to parse amounts string:", amounts);
542
- return;
543
- }
544
- } else if (Array.isArray(amounts)) {
545
- amountsArray = amounts;
546
- } else {
547
- console.error("Unexpected amounts type:", typeof amounts, amounts);
548
- return;
549
- }
550
-
551
- const amountInWei = BigInt(amountsArray[0]);
552
- const amountInCoins = weiToCoins(amountInWei);
553
- const amountOutResultWei = BigInt(amountsArray[1]);
554
- const amountOutResultCoins = weiToCoins(amountOutResultWei);
555
- console.log("Amount in needed (wei):", amountsArray[0]);
556
- console.log("Amount in needed (coins):", amountInCoins.toFixed(9));
557
- console.log("Amount out (wei):", amountsArray[1]);
558
- console.log("Amount out (coins):", amountOutResultCoins.toFixed(9));
559
-
560
- return amounts;
561
- }
562
-
563
- /**
564
- * Example 3b: Get amount out using QuantumSwapV2 Router
565
- */
566
- async function example3b_GetAmountOut() {
567
- console.log('\n=== Example 3b: Get Amount Out (QuantumSwapV2 Router) ===\n');
568
-
569
- // QuantumSwapV2 Router contract address
570
- const routerAddress = SWAP_ROUTER_ADDRESS;
571
- const abiJSON = JSON.stringify(quantumswapV2RouterABI);
572
-
573
- // Example: Put in 1 token, calculate how much token out received
574
- // amountIn: 1 token (with 18 decimals) = 1000000000000000000 wei
575
- const amountIn = "1000000000000000000";
576
- const amountInInputWei = BigInt(amountIn);
577
- const amountInInputCoins = weiToCoins(amountInInputWei);
578
-
579
- // Swap path: TokenA -> TokenB
580
- const path = [TOKEN_A_ADDRESS, TOKEN_B_ADDRESS];
581
-
582
- // Pack the getAmountsOut method call
583
- const packResult = qcsdk.packMethodData(abiJSON, "getAmountsOut", amountIn, path);
584
-
585
- if (packResult.error) {
586
- console.error("Error packing getAmountsOut:", packResult.error);
587
- return;
588
- }
589
-
590
- console.log("Packed data (hex):", packResult.result);
591
- console.log("Amount in (wei):", amountIn);
592
- console.log("Amount in (coins):", amountInInputCoins.toFixed(9));
593
- console.log("Swap path:", path);
594
-
595
- // Make RPC call
596
- const rpcResult = await rpcCall("eth_call", [
597
- {
598
- to: routerAddress,
599
- data: packResult.result
600
- },
601
- "latest"
602
- ]);
603
-
604
- if (rpcResult.error) {
605
- console.error("RPC error:", rpcResult.error);
606
- return;
607
- }
608
-
609
- // Unpack the return value
610
- const unpackResult = qcsdk.unpackMethodData(abiJSON, "getAmountsOut", rpcResult.result);
611
-
612
- if (unpackResult.error) {
613
- console.error("Error unpacking getAmountsOut:", unpackResult.error);
614
- return;
615
- }
616
-
617
- // Parse the JSON result (array of amounts)
618
- const parsed = JSON.parse(unpackResult.result);
619
- console.log("Parsed result:", parsed);
620
- const amounts = parsed[0];
621
- console.log("Amounts array:", amounts);
622
- console.log("Amounts array type:", typeof amounts, Array.isArray(amounts));
623
-
624
- // Handle case where amounts might be a string or already an array
625
- let amountsArray;
626
- if (typeof amounts === 'string') {
627
- // If it's a string, try to parse it again
628
- try {
629
- amountsArray = JSON.parse(amounts);
630
- } catch (e) {
631
- console.error("Failed to parse amounts string:", amounts);
632
- return;
633
- }
634
- } else if (Array.isArray(amounts)) {
635
- amountsArray = amounts;
636
- } else {
637
- console.error("Unexpected amounts type:", typeof amounts, amounts);
638
- return;
639
- }
640
-
641
- const amountInWei = BigInt(amountsArray[0]);
642
- const amountInCoins = weiToCoins(amountInWei);
643
- const amountOutWei = BigInt(amountsArray[1]);
644
- const amountOutCoins = weiToCoins(amountOutWei);
645
- console.log("Amount in (wei):", amountsArray[0]);
646
- console.log("Amount in (coins):", amountInCoins.toFixed(9));
647
- console.log("Amount out received (wei):", amountsArray[1]);
648
- console.log("Amount out received (coins):", amountOutCoins.toFixed(9));
649
-
650
- return amountsArray;
651
- }
652
-
653
- /**
654
- * Example 4a: Swap exact tokens for tokens (using getAmountOut output)
655
- * This example uses the output from getAmountOut to perform a swap
656
- */
657
- async function example4a_SwapExactTokensForTokens() {
658
- console.log('\n=== Example 4a: Swap Exact Tokens For Tokens (using getAmountOut) ===\n');
659
-
660
- // Step 1: Create a new wallet
661
- console.log("Step 1: Creating a new wallet...");
662
- const wallet = qcsdk.newWallet();
663
- if (wallet === null) {
664
- console.error("Failed to create wallet");
665
- return;
666
- }
667
- console.log("Wallet address:", wallet.address);
668
-
669
- // Step 2: Get the expected amount out
670
- console.log("\nStep 2: Getting expected amount out...");
671
- const amountsOut = await example3b_GetAmountOut();
672
-
673
- if (!amountsOut || amountsOut.length < 2) {
674
- console.error("Failed to get amount out");
675
- return;
676
- }
677
-
678
- const amountIn = "1000000000000000000"; // 1 token
679
- const amountInWei = BigInt(amountIn);
680
- const amountInCoins = weiToCoins(amountInWei);
681
- const amountOutMin = amountsOut[1]; // Use the amount out from getAmountsOut (with some slippage tolerance)
682
-
683
- // Apply 1% slippage tolerance (multiply by 99/100)
684
- const slippageTolerance = BigInt(amountOutMin) * BigInt(99) / BigInt(100);
685
- const amountOutMinWithSlippage = slippageTolerance.toString();
686
- const amountOutMinWei = BigInt(amountOutMin);
687
- const amountOutMinCoins = weiToCoins(amountOutMinWei);
688
- const amountOutMinWithSlippageWei = BigInt(amountOutMinWithSlippage);
689
- const amountOutMinWithSlippageCoins = weiToCoins(amountOutMinWithSlippageWei);
690
-
691
- console.log("\nStep 3: Preparing swap transaction...");
692
- console.log("Amount in (wei):", amountIn);
693
- console.log("Amount in (coins):", amountInCoins.toFixed(9));
694
- console.log("Expected amount out (wei):", amountsOut[1]);
695
- console.log("Expected amount out (coins):", amountOutMinCoins.toFixed(9));
696
- console.log("Minimum amount out (with 1% slippage) (wei):", amountOutMinWithSlippage);
697
- console.log("Minimum amount out (with 1% slippage) (coins):", amountOutMinWithSlippageCoins.toFixed(9));
698
-
699
- // QuantumSwapV2 Router contract address
700
- const routerAddress = SWAP_ROUTER_ADDRESS;
701
- const abiJSON = JSON.stringify(quantumswapV2RouterABI);
702
-
703
- // Swap path
704
- const path = [TOKEN_A_ADDRESS, TOKEN_B_ADDRESS];
705
-
706
- // Recipient address (use the wallet address we created)
707
- const to = wallet.address;
708
-
709
- // Deadline: 20 minutes from now (Unix timestamp in seconds, UTC)
710
- // Date.now() already returns UTC milliseconds, so no conversion needed
711
- const deadline = Math.floor(Date.now() / 1000) + 20 * 60;
712
- const deadlineStr = deadline.toString();
713
-
714
- // Pack the swapExactTokensForTokens method call
715
- const packResult = qcsdk.packMethodData(
716
- abiJSON,
717
- "swapExactTokensForTokens",
718
- amountIn,
719
- amountOutMinWithSlippage,
720
- path,
721
- to,
722
- deadlineStr
723
- );
724
-
725
- if (packResult.error) {
726
- console.error("Error packing swapExactTokensForTokens:", packResult.error);
727
- return;
728
- }
729
-
730
- console.log("Packed swap transaction data (hex):", packResult.result);
731
-
732
- // Step 4: Get nonce for the wallet
733
- console.log("\nStep 4: Getting transaction count (nonce)...");
734
- let nonce;
735
- try {
736
- nonce = await getTransactionCount(wallet.address);
737
- console.log("Nonce:", nonce);
738
- } catch (error) {
739
- console.error("Failed to get nonce:", error.message);
740
- return;
741
- }
742
-
743
- // Step 5: Sign the transaction
744
- console.log("\nStep 5: Signing transaction...");
745
- const gasLimit = 300000; // Gas limit for swap transaction
746
- const valueInWeiHex = "0x0"; // No native token value for token swaps
747
-
748
- const transactionRequest = new qcsdk.TransactionSigningRequest(
749
- wallet,
750
- routerAddress,
751
- valueInWeiHex,
752
- nonce,
753
- packResult.result,
754
- gasLimit,
755
- null // remarks
756
- );
757
-
758
- const signResult = qcsdk.signRawTransaction(transactionRequest);
759
-
760
- if (signResult.resultCode !== 0) {
761
- console.error("Failed to sign transaction. Result code:", signResult.resultCode);
762
- return;
763
- }
764
-
765
- console.log("Transaction signed successfully");
766
- console.log("Transaction hash:", signResult.txnHash);
767
- console.log("Transaction data:", signResult.txnData);
768
-
769
- // Step 6: Send the transaction
770
- console.log("\nStep 6: Sending transaction to network...");
771
- try {
772
- const txHash = await sendRawTransaction(signResult.txnData);
773
- console.log("Transaction sent successfully!");
774
- console.log("Transaction ID (hash):", txHash);
775
- console.log("You can view this transaction on the block explorer");
776
- } catch (error) {
777
- console.error("Failed to send transaction:", error.message);
778
- }
779
- }
780
-
781
- /**
782
- * Example 4b: Swap tokens for exact tokens (using getAmountIn output)
783
- * This example uses the output from getAmountIn to perform a swap
784
- */
785
- async function example4b_SwapTokensForExactTokens() {
786
- console.log('\n=== Example 4b: Swap Tokens For Exact Tokens (using getAmountIn) ===\n');
787
-
788
- // Step 1: Create a new wallet
789
- console.log("Step 1: Creating a new wallet...");
790
- const wallet = qcsdk.newWallet();
791
- if (wallet === null) {
792
- console.error("Failed to create wallet");
793
- return;
794
- }
795
- console.log("Wallet address:", wallet.address);
796
-
797
- // Step 2: Get the required amount in
798
- console.log("\nStep 2: Getting required amount in...");
799
- const amountsIn = await example3a_GetAmountIn();
800
-
801
- if (!amountsIn || amountsIn.length < 2) {
802
- console.error("Failed to get amount in");
803
- return;
804
- }
805
-
806
- const amountOut = "1000000000000000000"; // 1 token desired out
807
- const amountOutWei = BigInt(amountOut);
808
- const amountOutCoins = weiToCoins(amountOutWei);
809
- const amountInMax = amountsIn[0]; // Use the amount in from getAmountsIn
810
-
811
- // Apply 2% slippage tolerance (multiply by 102/100)
812
- const slippageTolerance = BigInt(amountInMax) * BigInt(102) / BigInt(100);
813
- const amountInMaxWithSlippage = slippageTolerance.toString();
814
- const amountInMaxWei = BigInt(amountInMax);
815
- const amountInMaxCoins = weiToCoins(amountInMaxWei);
816
- const amountInMaxWithSlippageWei = BigInt(amountInMaxWithSlippage);
817
- const amountInMaxWithSlippageCoins = weiToCoins(amountInMaxWithSlippageWei);
818
-
819
- console.log("\nStep 3: Preparing swap transaction...");
820
- console.log("Desired amount out (wei):", amountOut);
821
- console.log("Desired amount out (coins):", amountOutCoins.toFixed(9));
822
- console.log("Required amount in (wei):", amountsIn[0]);
823
- console.log("Required amount in (coins):", amountInMaxCoins.toFixed(9));
824
- console.log("Maximum amount in (with 2% slippage) (wei):", amountInMaxWithSlippage);
825
- console.log("Maximum amount in (with 2% slippage) (coins):", amountInMaxWithSlippageCoins.toFixed(9));
826
-
827
- // QuantumSwapV2 Router contract address
828
- const routerAddress = SWAP_ROUTER_ADDRESS;
829
- const abiJSON = JSON.stringify(quantumswapV2RouterABI);
830
-
831
- // Swap path
832
- const path = [TOKEN_A_ADDRESS, TOKEN_B_ADDRESS];
833
-
834
- // Recipient address (use the wallet address we created)
835
- const to = wallet.address;
836
-
837
- // Deadline: 20 minutes from now (Unix timestamp in seconds, UTC)
838
- // Date.now() already returns UTC milliseconds, so no conversion needed
839
- const deadline = Math.floor(Date.now() / 1000) + 20 * 60;
840
- const deadlineStr = deadline.toString();
841
-
842
- // Pack the swapTokensForExactTokens method call
843
- const packResult = qcsdk.packMethodData(
844
- abiJSON,
845
- "swapTokensForExactTokens",
846
- amountOut,
847
- amountInMaxWithSlippage,
848
- path,
849
- to,
850
- deadlineStr
851
- );
852
-
853
- if (packResult.error) {
854
- console.error("Error packing swapTokensForExactTokens:", packResult.error);
855
- return;
856
- }
857
-
858
- console.log("Packed swap transaction data (hex):", packResult.result);
859
-
860
- // Step 4: Get nonce for the wallet
861
- console.log("\nStep 4: Getting transaction count (nonce)...");
862
- let nonce;
863
- try {
864
- nonce = await getTransactionCount(wallet.address);
865
- console.log("Nonce:", nonce);
866
- } catch (error) {
867
- console.error("Failed to get nonce:", error.message);
868
- return;
869
- }
870
-
871
- // Step 5: Sign the transaction
872
- console.log("\nStep 5: Signing transaction...");
873
- const gasLimit = 300000; // Gas limit for swap transaction
874
- const valueInWeiHex = "0x0"; // No native token value for token swaps
875
-
876
- const transactionRequest = new qcsdk.TransactionSigningRequest(
877
- wallet,
878
- routerAddress,
879
- valueInWeiHex,
880
- nonce,
881
- packResult.result,
882
- gasLimit,
883
- null // remarks
884
- );
885
-
886
- const signResult = qcsdk.signRawTransaction(transactionRequest);
887
-
888
- if (signResult.resultCode !== 0) {
889
- console.error("Failed to sign transaction. Result code:", signResult.resultCode);
890
- return;
891
- }
892
-
893
- console.log("Transaction signed successfully");
894
- console.log("Transaction hash:", signResult.txnHash);
895
- console.log("Transaction data:", signResult.txnData);
896
-
897
- // Step 6: Send the transaction
898
- console.log("\nStep 6: Sending transaction to network...");
899
- try {
900
- const txHash = await sendRawTransaction(signResult.txnData);
901
- console.log("Transaction sent successfully!");
902
- console.log("Transaction ID (hash):", txHash);
903
- console.log("You can view this transaction on the block explorer");
904
- } catch (error) {
905
- console.error("Failed to send transaction:", error.message);
906
- }
907
- }
908
-
909
- /**
910
- * Main execution function
911
- */
912
- async function main() {
913
- // Initialize the SDK
914
- const initResult = await qcsdk.initialize(clientConfigVal);
915
- if (initResult === false) {
916
- console.error("Initialize failed");
917
- return;
918
- }
919
- console.log("SDK initialized successfully\n");
920
-
921
- try {
922
- // Example 1: Get token balance
923
- await example1_GetTokenBalance();
924
-
925
- // Example 2: Get token information
926
- await example2_GetTokenInfo();
927
-
928
- // Example 3: Get pair address for two tokens
929
- await example3_GetPairAddress();
930
-
931
- // Example 3a: Get amount in
932
- await example3a_GetAmountIn();
933
-
934
- // Example 3b: Get amount out
935
- await example3b_GetAmountOut();
936
-
937
- // Note: Swap examples (4a and 4b) create wallets, sign transactions, and send them
938
- // Uncomment below to test swap examples:
939
- await example4a_SwapExactTokensForTokens();
940
- await example4b_SwapTokensForExactTokens();
941
-
942
- } catch (error) {
943
- console.error("Error running examples:", error);
944
- }
945
- }
946
-
947
- // Run the examples
948
- if (require.main === module) {
949
- main().catch(console.error);
950
- }
951
-
952
- module.exports = {
953
- example1_GetTokenBalance,
954
- example2_GetTokenInfo,
955
- example3_GetPairAddress,
956
- example3a_GetAmountIn,
957
- example3b_GetAmountOut,
958
- example4a_SwapExactTokensForTokens,
959
- example4b_SwapTokensForExactTokens
960
- };
961
-