quantum-coin-js-sdk 1.0.39 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/.gitignore +2 -1
  2. package/README.md +109 -768
  3. package/index.d.ts +76 -545
  4. package/index.js +319 -1194
  5. package/package.json +20 -5
  6. package/wasmBase64.js +7 -16
  7. package/wasm_exec.js +575 -587
  8. package/.idea/.name +0 -1
  9. package/.idea/modules.xml +0 -8
  10. package/.idea/quantum-coin-js-sdk.iml +0 -12
  11. package/.idea/vcs.xml +0 -6
  12. package/.vs/ProjectSettings.json +0 -3
  13. package/.vs/VSWorkspaceState.json +0 -8
  14. package/.vs/quantum-coin-js-sdk/FileContentIndex/a9d6de82-cfc3-4c22-ac38-06d706ff3673.vsidx +0 -0
  15. package/.vs/quantum-coin-js-sdk/FileContentIndex/fdc816df-1898-4153-99f2-c69ef4c2283b.vsidx +0 -0
  16. package/.vs/quantum-coin-js-sdk/config/applicationhost.config +0 -1011
  17. package/.vs/quantum-coin-js-sdk/v17/.wsuo +0 -0
  18. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.backup.json +0 -39
  19. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.json +0 -57
  20. package/.vs/slnx.sqlite +0 -0
  21. package/example/README.md +0 -14
  22. package/example/conversion-example.js +0 -19
  23. package/example/example-create-contract.js +0 -396
  24. package/example/example-encode-decode-rlp.js +0 -225
  25. package/example/example-event-pack-unpack.js +0 -391
  26. package/example/example-misc.js +0 -100
  27. package/example/example-rpc-send-signRawTransaction.js +0 -318
  28. package/example/example-rpc-send.js +0 -115
  29. package/example/example-send.js +0 -69
  30. package/example/example-token-pack-unpack.js +0 -960
  31. package/example/example-wallet-version4.js +0 -34
  32. package/example/example-wallet.js +0 -43
  33. package/example/example.js +0 -405
  34. package/example/node_modules/.bin/sdkgen +0 -16
  35. package/example/node_modules/.bin/sdkgen.cmd +0 -17
  36. package/example/node_modules/.bin/sdkgen.ps1 +0 -28
  37. package/example/node_modules/.package-lock.json +0 -47
  38. package/example/node_modules/quantumcoin/.github/workflows/publish-npmjs.yaml +0 -22
  39. package/example/node_modules/quantumcoin/LICENSE +0 -21
  40. package/example/node_modules/quantumcoin/README-SDK.md +0 -828
  41. package/example/node_modules/quantumcoin/README.md +0 -197
  42. package/example/node_modules/quantumcoin/config.d.ts +0 -50
  43. package/example/node_modules/quantumcoin/config.js +0 -123
  44. package/example/node_modules/quantumcoin/examples/AllSolidityTypes.sol +0 -184
  45. package/example/node_modules/quantumcoin/examples/SimpleIERC20.sol +0 -74
  46. package/example/node_modules/quantumcoin/examples/events.js +0 -41
  47. package/example/node_modules/quantumcoin/examples/events.ts +0 -35
  48. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.js +0 -100
  49. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.ts +0 -77
  50. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.js +0 -100
  51. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.ts +0 -77
  52. package/example/node_modules/quantumcoin/examples/example.js +0 -67
  53. package/example/node_modules/quantumcoin/examples/example.ts +0 -56
  54. package/example/node_modules/quantumcoin/examples/offline-signing.js +0 -77
  55. package/example/node_modules/quantumcoin/examples/offline-signing.ts +0 -65
  56. package/example/node_modules/quantumcoin/examples/package-lock.json +0 -596
  57. package/example/node_modules/quantumcoin/examples/package.json +0 -32
  58. package/example/node_modules/quantumcoin/examples/read-operations.js +0 -32
  59. package/example/node_modules/quantumcoin/examples/read-operations.ts +0 -31
  60. package/example/node_modules/quantumcoin/examples/sdk-generator-erc20.inline.json +0 -251
  61. package/example/node_modules/quantumcoin/examples/solidity-types.ts +0 -43
  62. package/example/node_modules/quantumcoin/examples/wallet-offline.js +0 -36
  63. package/example/node_modules/quantumcoin/examples/wallet-offline.ts +0 -26
  64. package/example/node_modules/quantumcoin/generate-sdk.js +0 -1846
  65. package/example/node_modules/quantumcoin/index.js +0 -12
  66. package/example/node_modules/quantumcoin/package.json +0 -95
  67. package/example/node_modules/quantumcoin/scripts/copy-declarations.js +0 -31
  68. package/example/node_modules/quantumcoin/scripts/run-all-one-by-one.js +0 -151
  69. package/example/node_modules/quantumcoin/src/abi/fragments.d.ts +0 -42
  70. package/example/node_modules/quantumcoin/src/abi/fragments.js +0 -63
  71. package/example/node_modules/quantumcoin/src/abi/index.d.ts +0 -13
  72. package/example/node_modules/quantumcoin/src/abi/index.js +0 -9
  73. package/example/node_modules/quantumcoin/src/abi/interface.d.ts +0 -128
  74. package/example/node_modules/quantumcoin/src/abi/interface.js +0 -605
  75. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.d.ts +0 -8
  76. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.js +0 -538
  77. package/example/node_modules/quantumcoin/src/constants.d.ts +0 -61
  78. package/example/node_modules/quantumcoin/src/constants.js +0 -94
  79. package/example/node_modules/quantumcoin/src/contract/contract-factory.d.ts +0 -28
  80. package/example/node_modules/quantumcoin/src/contract/contract-factory.js +0 -111
  81. package/example/node_modules/quantumcoin/src/contract/contract.d.ts +0 -113
  82. package/example/node_modules/quantumcoin/src/contract/contract.js +0 -408
  83. package/example/node_modules/quantumcoin/src/contract/index.d.ts +0 -9
  84. package/example/node_modules/quantumcoin/src/contract/index.js +0 -9
  85. package/example/node_modules/quantumcoin/src/errors/index.d.ts +0 -92
  86. package/example/node_modules/quantumcoin/src/errors/index.js +0 -200
  87. package/example/node_modules/quantumcoin/src/generator/index.d.ts +0 -81
  88. package/example/node_modules/quantumcoin/src/generator/index.js +0 -1571
  89. package/example/node_modules/quantumcoin/src/index.d.ts +0 -122
  90. package/example/node_modules/quantumcoin/src/index.js +0 -41
  91. package/example/node_modules/quantumcoin/src/internal/hex.d.ts +0 -68
  92. package/example/node_modules/quantumcoin/src/internal/hex.js +0 -180
  93. package/example/node_modules/quantumcoin/src/providers/extra-providers.d.ts +0 -139
  94. package/example/node_modules/quantumcoin/src/providers/extra-providers.js +0 -614
  95. package/example/node_modules/quantumcoin/src/providers/index.d.ts +0 -17
  96. package/example/node_modules/quantumcoin/src/providers/index.js +0 -10
  97. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.d.ts +0 -12
  98. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.js +0 -89
  99. package/example/node_modules/quantumcoin/src/providers/provider.d.ts +0 -206
  100. package/example/node_modules/quantumcoin/src/providers/provider.js +0 -524
  101. package/example/node_modules/quantumcoin/src/types/index.d.ts +0 -214
  102. package/example/node_modules/quantumcoin/src/types/index.js +0 -9
  103. package/example/node_modules/quantumcoin/src/utils/address.d.ts +0 -58
  104. package/example/node_modules/quantumcoin/src/utils/address.js +0 -144
  105. package/example/node_modules/quantumcoin/src/utils/encoding.d.ts +0 -120
  106. package/example/node_modules/quantumcoin/src/utils/encoding.js +0 -306
  107. package/example/node_modules/quantumcoin/src/utils/fixednumber.d.ts +0 -57
  108. package/example/node_modules/quantumcoin/src/utils/fixednumber.js +0 -366
  109. package/example/node_modules/quantumcoin/src/utils/hashing.d.ts +0 -76
  110. package/example/node_modules/quantumcoin/src/utils/hashing.js +0 -298
  111. package/example/node_modules/quantumcoin/src/utils/index.d.ts +0 -63
  112. package/example/node_modules/quantumcoin/src/utils/index.js +0 -14
  113. package/example/node_modules/quantumcoin/src/utils/result.d.ts +0 -57
  114. package/example/node_modules/quantumcoin/src/utils/result.js +0 -128
  115. package/example/node_modules/quantumcoin/src/utils/rlp.d.ts +0 -12
  116. package/example/node_modules/quantumcoin/src/utils/rlp.js +0 -215
  117. package/example/node_modules/quantumcoin/src/utils/units.d.ts +0 -29
  118. package/example/node_modules/quantumcoin/src/utils/units.js +0 -107
  119. package/example/node_modules/quantumcoin/src/wallet/index.d.ts +0 -10
  120. package/example/node_modules/quantumcoin/src/wallet/index.js +0 -8
  121. package/example/node_modules/quantumcoin/src/wallet/wallet.d.ts +0 -192
  122. package/example/node_modules/quantumcoin/src/wallet/wallet.js +0 -713
  123. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.js +0 -207
  124. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
  125. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.fixtures.js +0 -231
  126. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
  127. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
  128. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.js +0 -165
  129. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.ts +0 -160
  130. package/example/node_modules/quantumcoin/test/e2e/helpers.js +0 -59
  131. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
  132. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
  133. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
  134. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
  135. package/example/node_modules/quantumcoin/test/e2e/transactional.test.js +0 -245
  136. package/example/node_modules/quantumcoin/test/e2e/transactional.test.ts +0 -208
  137. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.js +0 -407
  138. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.ts +0 -337
  139. package/example/node_modules/quantumcoin/test/fixtures/ConstructorParam.sol +0 -23
  140. package/example/node_modules/quantumcoin/test/fixtures/MultiContracts.sol +0 -37
  141. package/example/node_modules/quantumcoin/test/fixtures/SimpleStorage.sol +0 -18
  142. package/example/node_modules/quantumcoin/test/fixtures/StakingContract.abi.json +0 -1
  143. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.js +0 -49
  144. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.ts +0 -44
  145. package/example/node_modules/quantumcoin/test/integration/provider.test.js +0 -88
  146. package/example/node_modules/quantumcoin/test/integration/provider.test.ts +0 -85
  147. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.js +0 -41
  148. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.ts +0 -38
  149. package/example/node_modules/quantumcoin/test/security/abi-decoder-bounds.test.js +0 -122
  150. package/example/node_modules/quantumcoin/test/security/contract-overrides.test.js +0 -112
  151. package/example/node_modules/quantumcoin/test/security/generator-injection.test.js +0 -195
  152. package/example/node_modules/quantumcoin/test/security/malformed-input.test.js +0 -330
  153. package/example/node_modules/quantumcoin/test/security/malformed-input.test.ts +0 -35
  154. package/example/node_modules/quantumcoin/test/security/rpc-numeric-bounds.test.js +0 -81
  155. package/example/node_modules/quantumcoin/test/security/rpc-trust.test.js +0 -202
  156. package/example/node_modules/quantumcoin/test/unit/_encrypted-output.txt +0 -6
  157. package/example/node_modules/quantumcoin/test/unit/_log-encrypted-jsons.js +0 -45
  158. package/example/node_modules/quantumcoin/test/unit/_write-keystore-fixture.js +0 -16
  159. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.js +0 -110
  160. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.ts +0 -109
  161. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.js +0 -923
  162. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.ts +0 -877
  163. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.js +0 -85
  164. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.ts +0 -79
  165. package/example/node_modules/quantumcoin/test/unit/contract.test.js +0 -85
  166. package/example/node_modules/quantumcoin/test/unit/contract.test.ts +0 -83
  167. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.js +0 -127
  168. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.ts +0 -91
  169. package/example/node_modules/quantumcoin/test/unit/errors.test.js +0 -77
  170. package/example/node_modules/quantumcoin/test/unit/errors.test.ts +0 -76
  171. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.js +0 -55
  172. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.ts +0 -54
  173. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.js +0 -656
  174. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.ts +0 -660
  175. package/example/node_modules/quantumcoin/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
  176. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.js +0 -42
  177. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.ts +0 -41
  178. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.js +0 -113
  179. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
  180. package/example/node_modules/quantumcoin/test/unit/generator.test.js +0 -149
  181. package/example/node_modules/quantumcoin/test/unit/generator.test.ts +0 -148
  182. package/example/node_modules/quantumcoin/test/unit/hashing.test.js +0 -64
  183. package/example/node_modules/quantumcoin/test/unit/hashing.test.ts +0 -63
  184. package/example/node_modules/quantumcoin/test/unit/init.test.js +0 -39
  185. package/example/node_modules/quantumcoin/test/unit/init.test.ts +0 -38
  186. package/example/node_modules/quantumcoin/test/unit/interface.test.js +0 -56
  187. package/example/node_modules/quantumcoin/test/unit/interface.test.ts +0 -54
  188. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.js +0 -81
  189. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.ts +0 -80
  190. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.js +0 -98
  191. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.ts +0 -64
  192. package/example/node_modules/quantumcoin/test/unit/providers.test.js +0 -252
  193. package/example/node_modules/quantumcoin/test/unit/providers.test.ts +0 -251
  194. package/example/node_modules/quantumcoin/test/unit/result.test.js +0 -80
  195. package/example/node_modules/quantumcoin/test/unit/result.test.ts +0 -79
  196. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.js +0 -49
  197. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.ts +0 -39
  198. package/example/node_modules/quantumcoin/test/unit/utils.test.js +0 -57
  199. package/example/node_modules/quantumcoin/test/unit/utils.test.ts +0 -56
  200. package/example/node_modules/quantumcoin/test/verbose-logger.js +0 -74
  201. package/example/node_modules/quantumcoin/tsconfig.build.json +0 -14
  202. package/example/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
  203. package/example/node_modules/seed-words/BUILD.md +0 -7
  204. package/example/node_modules/seed-words/LICENSE +0 -121
  205. package/example/node_modules/seed-words/README.md +0 -67
  206. package/example/node_modules/seed-words/dist/seedwords.d.ts +0 -39
  207. package/example/node_modules/seed-words/package.json +0 -27
  208. package/example/node_modules/seed-words/seedwords.js +0 -315
  209. package/example/node_modules/seed-words/seedwords.txt +0 -65536
  210. package/example/node_modules/seed-words/tsconfig.json +0 -21
  211. package/example/package-lock.json +0 -56
  212. package/example/package.json +0 -15
  213. package/tests/encrypted-32.json +0 -1
  214. package/tests/encrypted-36.json +0 -1
  215. package/tests/encrypted-48.json +0 -1
  216. package/tests/generate-verify-vectors.js +0 -91
  217. package/tests/get-gas-price.test.js +0 -59
  218. package/tests/non-transactional.preinit.test.js +0 -41
  219. package/tests/non-transactional.test.js +0 -1389
  220. package/tests/scrypt.test.js +0 -128
  221. package/tests/sign-raw-keytype5-context-null.test.js +0 -107
  222. package/tests/sign-raw-transaction.test.js +0 -196
  223. package/tests/sign-verify.test.js +0 -311
  224. package/tests/transactional.relay.test.js +0 -131
  225. package/tests/transactional.rpc.test.js +0 -103
  226. package/tests/verify-vectors.json +0 -95035
@@ -1,92 +0,0 @@
1
- export type ErrorCode = "INVALID_ARGUMENT" | "NUMERIC_FAULT" | "BUFFER_OVERRUN" | "CALL_EXCEPTION" | "UNKNOWN_ERROR" | "NOT_IMPLEMENTED";
2
- /**
3
- * @fileoverview Error helpers and error classes.
4
- *
5
- * The QuantumCoin.js SDK follows ethers.js v6 error patterns:
6
- * - errors include a machine-readable `code`
7
- * - errors include `shortMessage`
8
- * - errors may include extra fields depending on the failure
9
- */
10
- /**
11
- * @typedef {"INVALID_ARGUMENT"|"NUMERIC_FAULT"|"BUFFER_OVERRUN"|"CALL_EXCEPTION"|"UNKNOWN_ERROR"|"NOT_IMPLEMENTED"} ErrorCode
12
- */
13
- /**
14
- * Returns true if the error matches the given code.
15
- * @param {any} error
16
- * @param {string} code
17
- * @returns {boolean}
18
- */
19
- export function isError(error: any, code: string): boolean;
20
- /**
21
- * Returns true if the error is a CALL_EXCEPTION.
22
- * @param {any} error
23
- * @returns {boolean}
24
- */
25
- export function isCallException(error: any): boolean;
26
- /**
27
- * Create an Error configured like ethers emits errors.
28
- *
29
- * @param {string} message
30
- * @param {ErrorCode} code
31
- * @param {Record<string, any>=} info
32
- * @returns {Error & { code: ErrorCode, shortMessage: string }}
33
- */
34
- export function makeError(message: string, code: ErrorCode, info?: Record<string, any> | undefined): Error & {
35
- code: ErrorCode;
36
- shortMessage: string;
37
- };
38
- /**
39
- * Assert a condition, throwing an ethers-style error otherwise.
40
- * @param {any} check
41
- * @param {string} message
42
- * @param {ErrorCode} code
43
- * @param {Record<string, any>=} info
44
- */
45
- export function assert(check: any, message: string, code: ErrorCode, info?: Record<string, any> | undefined): void;
46
- /**
47
- * Assert an argument constraint.
48
- * @param {any} check
49
- * @param {string} message
50
- * @param {string} name
51
- * @param {any} value
52
- */
53
- export function assertArgument(check: any, message: string, name: string, value: any): void;
54
- /**
55
- * Provider error.
56
- */
57
- export class ProviderError extends Error {
58
- /**
59
- * @param {string} message
60
- * @param {Record<string, any>=} info
61
- */
62
- constructor(message: string, info?: Record<string, any> | undefined);
63
- /** @type {ErrorCode} */
64
- code: ErrorCode;
65
- shortMessage: string;
66
- }
67
- /**
68
- * Transaction error.
69
- */
70
- export class TransactionError extends Error {
71
- /**
72
- * @param {string} message
73
- * @param {Record<string, any>=} info
74
- */
75
- constructor(message: string, info?: Record<string, any> | undefined);
76
- /** @type {ErrorCode} */
77
- code: ErrorCode;
78
- shortMessage: string;
79
- }
80
- /**
81
- * Contract error.
82
- */
83
- export class ContractError extends Error {
84
- /**
85
- * @param {string} message
86
- * @param {Record<string, any>=} info
87
- */
88
- constructor(message: string, info?: Record<string, any> | undefined);
89
- /** @type {ErrorCode} */
90
- code: ErrorCode;
91
- shortMessage: string;
92
- }
@@ -1,200 +0,0 @@
1
- /**
2
- * @fileoverview Error helpers and error classes.
3
- *
4
- * The QuantumCoin.js SDK follows ethers.js v6 error patterns:
5
- * - errors include a machine-readable `code`
6
- * - errors include `shortMessage`
7
- * - errors may include extra fields depending on the failure
8
- */
9
-
10
- /**
11
- * @typedef {"INVALID_ARGUMENT"|"NUMERIC_FAULT"|"BUFFER_OVERRUN"|"CALL_EXCEPTION"|"UNKNOWN_ERROR"|"NOT_IMPLEMENTED"} ErrorCode
12
- */
13
-
14
- /**
15
- * Returns true if the error matches the given code.
16
- * @param {any} error
17
- * @param {string} code
18
- * @returns {boolean}
19
- */
20
- function isError(error, code) {
21
- return Boolean(error && typeof error === "object" && error.code === code);
22
- }
23
-
24
- /**
25
- * Returns true if the error is a CALL_EXCEPTION.
26
- * @param {any} error
27
- * @returns {boolean}
28
- */
29
- function isCallException(error) {
30
- return isError(error, "CALL_EXCEPTION");
31
- }
32
-
33
- function _stringify(value, seen) {
34
- if (value == null) return "null";
35
- if (seen == null) seen = new Set();
36
- if (typeof value === "object") {
37
- if (seen.has(value)) return "[Circular]";
38
- seen.add(value);
39
- }
40
- if (Array.isArray(value)) return "[ " + value.map((v) => _stringify(v, seen)).join(", ") + " ]";
41
- if (value instanceof Uint8Array) return `Uint8Array(${value.length})`;
42
- if (typeof value === "object" && typeof value.toJSON === "function") return _stringify(value.toJSON(), seen);
43
- switch (typeof value) {
44
- case "boolean":
45
- case "number":
46
- case "symbol":
47
- return value.toString();
48
- case "bigint":
49
- return BigInt(value).toString();
50
- case "string":
51
- return JSON.stringify(value);
52
- case "object": {
53
- const keys = Object.keys(value).sort();
54
- return "{ " + keys.map((k) => `${_stringify(k, seen)}: ${_stringify(value[k], seen)}`).join(", ") + " }";
55
- }
56
- default:
57
- return `[ COULD NOT SERIALIZE ]`;
58
- }
59
- }
60
-
61
- /**
62
- * Create an Error configured like ethers emits errors.
63
- *
64
- * @param {string} message
65
- * @param {ErrorCode} code
66
- * @param {Record<string, any>=} info
67
- * @returns {Error & { code: ErrorCode, shortMessage: string }}
68
- */
69
- function makeError(message, code, info) {
70
- let shortMessage = message;
71
-
72
- const details = [];
73
- if (info) {
74
- if ("message" in info || "code" in info || "name" in info) {
75
- throw new Error(`value will overwrite populated values: ${_stringify(info)}`);
76
- }
77
- for (const key in info) {
78
- if (key === "shortMessage") continue;
79
- details.push(key + "=" + _stringify(info[key]));
80
- }
81
- }
82
- details.push(`code=${code}`);
83
- if (details.length) message += " (" + details.join(", ") + ")";
84
-
85
- /** @type {any} */
86
- let err;
87
- switch (code) {
88
- case "INVALID_ARGUMENT":
89
- err = new TypeError(message);
90
- break;
91
- case "NUMERIC_FAULT":
92
- case "BUFFER_OVERRUN":
93
- err = new RangeError(message);
94
- break;
95
- default:
96
- err = new Error(message);
97
- }
98
-
99
- Object.defineProperty(err, "code", { enumerable: true, value: code, writable: false });
100
- Object.defineProperty(err, "shortMessage", { enumerable: true, value: shortMessage, writable: false });
101
- if (info) Object.assign(err, info);
102
- return err;
103
- }
104
-
105
- /**
106
- * Assert a condition, throwing an ethers-style error otherwise.
107
- * @param {any} check
108
- * @param {string} message
109
- * @param {ErrorCode} code
110
- * @param {Record<string, any>=} info
111
- */
112
- function assert(check, message, code, info) {
113
- if (!check) throw makeError(message, code, info);
114
- }
115
-
116
- /**
117
- * Assert an argument constraint.
118
- * @param {any} check
119
- * @param {string} message
120
- * @param {string} name
121
- * @param {any} value
122
- */
123
- function assertArgument(check, message, name, value) {
124
- assert(check, message, "INVALID_ARGUMENT", { argument: name, value });
125
- }
126
-
127
- /**
128
- * Assert an argument constraint for sensitive material (keys, seeds, passwords).
129
- * Uses "[REDACTED]" instead of the actual value to prevent leaking secrets in logs.
130
- * @param {any} check
131
- * @param {string} message
132
- * @param {string} name
133
- */
134
- function assertSecretArgument(check, message, name) {
135
- assert(check, message, "INVALID_ARGUMENT", { argument: name, value: "[REDACTED]" });
136
- }
137
-
138
- /**
139
- * Provider error.
140
- */
141
- class ProviderError extends Error {
142
- /**
143
- * @param {string} message
144
- * @param {Record<string, any>=} info
145
- */
146
- constructor(message, info) {
147
- super(message);
148
- /** @type {ErrorCode} */
149
- this.code = "UNKNOWN_ERROR";
150
- this.shortMessage = message;
151
- if (info) Object.assign(this, info);
152
- }
153
- }
154
-
155
- /**
156
- * Transaction error.
157
- */
158
- class TransactionError extends Error {
159
- /**
160
- * @param {string} message
161
- * @param {Record<string, any>=} info
162
- */
163
- constructor(message, info) {
164
- super(message);
165
- /** @type {ErrorCode} */
166
- this.code = "UNKNOWN_ERROR";
167
- this.shortMessage = message;
168
- if (info) Object.assign(this, info);
169
- }
170
- }
171
-
172
- /**
173
- * Contract error.
174
- */
175
- class ContractError extends Error {
176
- /**
177
- * @param {string} message
178
- * @param {Record<string, any>=} info
179
- */
180
- constructor(message, info) {
181
- super(message);
182
- /** @type {ErrorCode} */
183
- this.code = "UNKNOWN_ERROR";
184
- this.shortMessage = message;
185
- if (info) Object.assign(this, info);
186
- }
187
- }
188
-
189
- module.exports = {
190
- isError,
191
- isCallException,
192
- makeError,
193
- assert,
194
- assertArgument,
195
- assertSecretArgument,
196
- ProviderError,
197
- TransactionError,
198
- ContractError,
199
- };
200
-
@@ -1,81 +0,0 @@
1
- export type GenerateOptions = {
2
- abiPath: string;
3
- binPath: string;
4
- outDir: string;
5
- contractName: string;
6
- packageName?: string | undefined;
7
- createPackage?: boolean | undefined;
8
- dependencies?: Record<string, string> | undefined;
9
- };
10
- /**
11
- * Generate typed contract files.
12
- * @param {GenerateOptions} opts
13
- * @returns {{ contractFile: string, factoryFile: string, typesFile: string, indexFile: string }}
14
- */
15
- export function generate(opts: GenerateOptions): {
16
- contractFile: string;
17
- factoryFile: string;
18
- typesFile: string;
19
- indexFile: string;
20
- };
21
- /**
22
- * @typedef {Object} GenerateOptions
23
- * @property {string} abiPath
24
- * @property {string} binPath
25
- * @property {string} outDir
26
- * @property {string} contractName
27
- * @property {string=} packageName
28
- * @property {boolean=} createPackage
29
- * @property {Record<string,string>=} dependencies
30
- */
31
- /**
32
- * Generate multiple typed contract files.
33
- * @param {{ outDir: string, artifacts: Array<{ contractName: string, abi: any[], bytecode: string }> }} opts
34
- * @returns {{ contracts: Array<{ contractFile: string, factoryFile: string }>, typesFile: string, indexFile: string }}
35
- */
36
- export function generateFromArtifacts(opts: {
37
- outDir: string;
38
- artifacts: Array<{
39
- contractName: string;
40
- abi: any[];
41
- bytecode: string;
42
- }>;
43
- }): {
44
- contracts: Array<{
45
- contractFile: string;
46
- factoryFile: string;
47
- }>;
48
- typesFile: string;
49
- indexFile: string;
50
- };
51
- /**
52
- * Generate a transactional e2e test file (JavaScript) for the typed contract package.
53
- * The test deploys the contract with constructor args (if any) and invokes one write method.
54
- *
55
- * When `bytecode` is omitted, empty, or `"0x"` the contract is treated as an interface
56
- * and the post-deploy `provider.getCode(...)` bytecode assertion is omitted from the
57
- * generated test (interfaces deploy with no runtime code by design).
58
- *
59
- * @param opts
60
- */
61
- export function generateTransactionalTestJs(opts: {
62
- contractName: string;
63
- abi: any[];
64
- bytecode?: string;
65
- }): string;
66
- /**
67
- * Generate a single transactional e2e test that deploys and invokes methods on ALL contracts.
68
- * Used when the package has multiple contracts so one test exercises every contract.
69
- *
70
- * Accepts `bytecode` per artifact for forward-compatibility; the multi-contract template
71
- * currently emits no `getCode` assertion (so the value is not yet consumed).
72
- *
73
- * @param opts
74
- */
75
- export function generateAllContractsTransactionalTestJs(opts: {
76
- artifacts: Array<{
77
- contractName: string;
78
- abi: any[];
79
- bytecode?: string;
80
- }>;
81
- }): string;