quantum-coin-js-sdk 2.0.1 → 2.1.1

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 (233) hide show
  1. package/README.md +13 -0
  2. package/index.d.ts +9 -0
  3. package/index.js +37 -4
  4. package/package.json +12 -4
  5. package/wasmBase64.js +3 -2
  6. package/.gitignore +0 -4
  7. package/.idea/.name +0 -1
  8. package/.idea/modules.xml +0 -8
  9. package/.idea/quantum-coin-js-sdk.iml +0 -12
  10. package/.idea/vcs.xml +0 -6
  11. package/.vs/ProjectSettings.json +0 -3
  12. package/.vs/VSWorkspaceState.json +0 -8
  13. package/.vs/quantum-coin-js-sdk/FileContentIndex/a9d6de82-cfc3-4c22-ac38-06d706ff3673.vsidx +0 -0
  14. package/.vs/quantum-coin-js-sdk/FileContentIndex/fdc816df-1898-4153-99f2-c69ef4c2283b.vsidx +0 -0
  15. package/.vs/quantum-coin-js-sdk/config/applicationhost.config +0 -1011
  16. package/.vs/quantum-coin-js-sdk/v17/.wsuo +0 -0
  17. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.backup.json +0 -39
  18. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.json +0 -57
  19. package/.vs/slnx.sqlite +0 -0
  20. package/example/README.md +0 -14
  21. package/example/conversion-example.js +0 -19
  22. package/example/example-create-contract.js +0 -396
  23. package/example/example-encode-decode-rlp.js +0 -225
  24. package/example/example-event-pack-unpack.js +0 -391
  25. package/example/example-misc.js +0 -96
  26. package/example/example-token-pack-unpack.js +0 -960
  27. package/example/example-wallet-version4.js +0 -34
  28. package/example/example-wallet.js +0 -39
  29. package/example/example.js +0 -115
  30. package/example/node_modules/.bin/sdkgen +0 -16
  31. package/example/node_modules/.bin/sdkgen.cmd +0 -17
  32. package/example/node_modules/.bin/sdkgen.ps1 +0 -28
  33. package/example/node_modules/.package-lock.json +0 -51
  34. package/example/node_modules/quantumcoin/.github/workflows/publish-npmjs.yaml +0 -22
  35. package/example/node_modules/quantumcoin/LICENSE +0 -21
  36. package/example/node_modules/quantumcoin/README-SDK.md +0 -828
  37. package/example/node_modules/quantumcoin/README.md +0 -197
  38. package/example/node_modules/quantumcoin/config.d.ts +0 -50
  39. package/example/node_modules/quantumcoin/config.js +0 -123
  40. package/example/node_modules/quantumcoin/examples/AllSolidityTypes.sol +0 -184
  41. package/example/node_modules/quantumcoin/examples/SimpleIERC20.sol +0 -74
  42. package/example/node_modules/quantumcoin/examples/events.js +0 -41
  43. package/example/node_modules/quantumcoin/examples/events.ts +0 -35
  44. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.js +0 -100
  45. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.ts +0 -77
  46. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.js +0 -100
  47. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.ts +0 -77
  48. package/example/node_modules/quantumcoin/examples/example.js +0 -67
  49. package/example/node_modules/quantumcoin/examples/example.ts +0 -56
  50. package/example/node_modules/quantumcoin/examples/offline-signing.js +0 -77
  51. package/example/node_modules/quantumcoin/examples/offline-signing.ts +0 -65
  52. package/example/node_modules/quantumcoin/examples/package-lock.json +0 -596
  53. package/example/node_modules/quantumcoin/examples/package.json +0 -32
  54. package/example/node_modules/quantumcoin/examples/read-operations.js +0 -32
  55. package/example/node_modules/quantumcoin/examples/read-operations.ts +0 -31
  56. package/example/node_modules/quantumcoin/examples/sdk-generator-erc20.inline.json +0 -251
  57. package/example/node_modules/quantumcoin/examples/solidity-types.ts +0 -43
  58. package/example/node_modules/quantumcoin/examples/wallet-offline.js +0 -36
  59. package/example/node_modules/quantumcoin/examples/wallet-offline.ts +0 -26
  60. package/example/node_modules/quantumcoin/generate-sdk.js +0 -1846
  61. package/example/node_modules/quantumcoin/index.js +0 -12
  62. package/example/node_modules/quantumcoin/package.json +0 -95
  63. package/example/node_modules/quantumcoin/scripts/copy-declarations.js +0 -31
  64. package/example/node_modules/quantumcoin/scripts/run-all-one-by-one.js +0 -151
  65. package/example/node_modules/quantumcoin/src/abi/fragments.d.ts +0 -42
  66. package/example/node_modules/quantumcoin/src/abi/fragments.js +0 -63
  67. package/example/node_modules/quantumcoin/src/abi/index.d.ts +0 -13
  68. package/example/node_modules/quantumcoin/src/abi/index.js +0 -9
  69. package/example/node_modules/quantumcoin/src/abi/interface.d.ts +0 -128
  70. package/example/node_modules/quantumcoin/src/abi/interface.js +0 -605
  71. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.d.ts +0 -8
  72. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.js +0 -538
  73. package/example/node_modules/quantumcoin/src/constants.d.ts +0 -61
  74. package/example/node_modules/quantumcoin/src/constants.js +0 -94
  75. package/example/node_modules/quantumcoin/src/contract/contract-factory.d.ts +0 -28
  76. package/example/node_modules/quantumcoin/src/contract/contract-factory.js +0 -111
  77. package/example/node_modules/quantumcoin/src/contract/contract.d.ts +0 -113
  78. package/example/node_modules/quantumcoin/src/contract/contract.js +0 -408
  79. package/example/node_modules/quantumcoin/src/contract/index.d.ts +0 -9
  80. package/example/node_modules/quantumcoin/src/contract/index.js +0 -9
  81. package/example/node_modules/quantumcoin/src/errors/index.d.ts +0 -92
  82. package/example/node_modules/quantumcoin/src/errors/index.js +0 -200
  83. package/example/node_modules/quantumcoin/src/generator/index.d.ts +0 -81
  84. package/example/node_modules/quantumcoin/src/generator/index.js +0 -1571
  85. package/example/node_modules/quantumcoin/src/index.d.ts +0 -122
  86. package/example/node_modules/quantumcoin/src/index.js +0 -41
  87. package/example/node_modules/quantumcoin/src/internal/hex.d.ts +0 -68
  88. package/example/node_modules/quantumcoin/src/internal/hex.js +0 -180
  89. package/example/node_modules/quantumcoin/src/providers/extra-providers.d.ts +0 -139
  90. package/example/node_modules/quantumcoin/src/providers/extra-providers.js +0 -614
  91. package/example/node_modules/quantumcoin/src/providers/index.d.ts +0 -17
  92. package/example/node_modules/quantumcoin/src/providers/index.js +0 -10
  93. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.d.ts +0 -12
  94. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.js +0 -89
  95. package/example/node_modules/quantumcoin/src/providers/provider.d.ts +0 -206
  96. package/example/node_modules/quantumcoin/src/providers/provider.js +0 -524
  97. package/example/node_modules/quantumcoin/src/types/index.d.ts +0 -214
  98. package/example/node_modules/quantumcoin/src/types/index.js +0 -9
  99. package/example/node_modules/quantumcoin/src/utils/address.d.ts +0 -58
  100. package/example/node_modules/quantumcoin/src/utils/address.js +0 -144
  101. package/example/node_modules/quantumcoin/src/utils/encoding.d.ts +0 -120
  102. package/example/node_modules/quantumcoin/src/utils/encoding.js +0 -306
  103. package/example/node_modules/quantumcoin/src/utils/fixednumber.d.ts +0 -57
  104. package/example/node_modules/quantumcoin/src/utils/fixednumber.js +0 -366
  105. package/example/node_modules/quantumcoin/src/utils/hashing.d.ts +0 -76
  106. package/example/node_modules/quantumcoin/src/utils/hashing.js +0 -298
  107. package/example/node_modules/quantumcoin/src/utils/index.d.ts +0 -63
  108. package/example/node_modules/quantumcoin/src/utils/index.js +0 -14
  109. package/example/node_modules/quantumcoin/src/utils/result.d.ts +0 -57
  110. package/example/node_modules/quantumcoin/src/utils/result.js +0 -128
  111. package/example/node_modules/quantumcoin/src/utils/rlp.d.ts +0 -12
  112. package/example/node_modules/quantumcoin/src/utils/rlp.js +0 -215
  113. package/example/node_modules/quantumcoin/src/utils/units.d.ts +0 -29
  114. package/example/node_modules/quantumcoin/src/utils/units.js +0 -107
  115. package/example/node_modules/quantumcoin/src/wallet/index.d.ts +0 -10
  116. package/example/node_modules/quantumcoin/src/wallet/index.js +0 -8
  117. package/example/node_modules/quantumcoin/src/wallet/wallet.d.ts +0 -192
  118. package/example/node_modules/quantumcoin/src/wallet/wallet.js +0 -713
  119. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.js +0 -207
  120. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
  121. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.fixtures.js +0 -231
  122. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
  123. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
  124. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.js +0 -165
  125. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.ts +0 -160
  126. package/example/node_modules/quantumcoin/test/e2e/helpers.js +0 -59
  127. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
  128. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
  129. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
  130. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
  131. package/example/node_modules/quantumcoin/test/e2e/transactional.test.js +0 -245
  132. package/example/node_modules/quantumcoin/test/e2e/transactional.test.ts +0 -208
  133. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.js +0 -407
  134. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.ts +0 -337
  135. package/example/node_modules/quantumcoin/test/fixtures/ConstructorParam.sol +0 -23
  136. package/example/node_modules/quantumcoin/test/fixtures/MultiContracts.sol +0 -37
  137. package/example/node_modules/quantumcoin/test/fixtures/SimpleStorage.sol +0 -18
  138. package/example/node_modules/quantumcoin/test/fixtures/StakingContract.abi.json +0 -1
  139. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.js +0 -49
  140. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.ts +0 -44
  141. package/example/node_modules/quantumcoin/test/integration/provider.test.js +0 -88
  142. package/example/node_modules/quantumcoin/test/integration/provider.test.ts +0 -85
  143. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.js +0 -41
  144. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.ts +0 -38
  145. package/example/node_modules/quantumcoin/test/security/abi-decoder-bounds.test.js +0 -122
  146. package/example/node_modules/quantumcoin/test/security/contract-overrides.test.js +0 -112
  147. package/example/node_modules/quantumcoin/test/security/generator-injection.test.js +0 -195
  148. package/example/node_modules/quantumcoin/test/security/malformed-input.test.js +0 -330
  149. package/example/node_modules/quantumcoin/test/security/malformed-input.test.ts +0 -35
  150. package/example/node_modules/quantumcoin/test/security/rpc-numeric-bounds.test.js +0 -81
  151. package/example/node_modules/quantumcoin/test/security/rpc-trust.test.js +0 -202
  152. package/example/node_modules/quantumcoin/test/unit/_encrypted-output.txt +0 -6
  153. package/example/node_modules/quantumcoin/test/unit/_log-encrypted-jsons.js +0 -45
  154. package/example/node_modules/quantumcoin/test/unit/_write-keystore-fixture.js +0 -16
  155. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.js +0 -110
  156. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.ts +0 -109
  157. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.js +0 -923
  158. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.ts +0 -877
  159. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.js +0 -85
  160. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.ts +0 -79
  161. package/example/node_modules/quantumcoin/test/unit/contract.test.js +0 -85
  162. package/example/node_modules/quantumcoin/test/unit/contract.test.ts +0 -83
  163. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.js +0 -127
  164. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.ts +0 -91
  165. package/example/node_modules/quantumcoin/test/unit/errors.test.js +0 -77
  166. package/example/node_modules/quantumcoin/test/unit/errors.test.ts +0 -76
  167. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.js +0 -55
  168. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.ts +0 -54
  169. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.js +0 -656
  170. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.ts +0 -660
  171. package/example/node_modules/quantumcoin/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
  172. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.js +0 -42
  173. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.ts +0 -41
  174. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.js +0 -113
  175. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
  176. package/example/node_modules/quantumcoin/test/unit/generator.test.js +0 -149
  177. package/example/node_modules/quantumcoin/test/unit/generator.test.ts +0 -148
  178. package/example/node_modules/quantumcoin/test/unit/hashing.test.js +0 -64
  179. package/example/node_modules/quantumcoin/test/unit/hashing.test.ts +0 -63
  180. package/example/node_modules/quantumcoin/test/unit/init.test.js +0 -39
  181. package/example/node_modules/quantumcoin/test/unit/init.test.ts +0 -38
  182. package/example/node_modules/quantumcoin/test/unit/interface.test.js +0 -56
  183. package/example/node_modules/quantumcoin/test/unit/interface.test.ts +0 -54
  184. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.js +0 -81
  185. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.ts +0 -80
  186. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.js +0 -98
  187. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.ts +0 -64
  188. package/example/node_modules/quantumcoin/test/unit/providers.test.js +0 -252
  189. package/example/node_modules/quantumcoin/test/unit/providers.test.ts +0 -251
  190. package/example/node_modules/quantumcoin/test/unit/result.test.js +0 -80
  191. package/example/node_modules/quantumcoin/test/unit/result.test.ts +0 -79
  192. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.js +0 -49
  193. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.ts +0 -39
  194. package/example/node_modules/quantumcoin/test/unit/utils.test.js +0 -57
  195. package/example/node_modules/quantumcoin/test/unit/utils.test.ts +0 -56
  196. package/example/node_modules/quantumcoin/test/verbose-logger.js +0 -74
  197. package/example/node_modules/quantumcoin/tsconfig.build.json +0 -14
  198. package/example/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
  199. package/example/node_modules/seed-words/BUILD.md +0 -7
  200. package/example/node_modules/seed-words/LICENSE +0 -121
  201. package/example/node_modules/seed-words/README.md +0 -67
  202. package/example/node_modules/seed-words/dist/seedwords.d.ts +0 -39
  203. package/example/node_modules/seed-words/package.json +0 -27
  204. package/example/node_modules/seed-words/seedwords.js +0 -315
  205. package/example/node_modules/seed-words/seedwords.txt +0 -65536
  206. package/example/node_modules/seed-words/tsconfig.json +0 -21
  207. package/example/package-lock.json +0 -60
  208. package/example/package.json +0 -15
  209. package/scripts/build-browser-tests.js +0 -29
  210. package/scripts/build-wasm.js +0 -85
  211. package/tests/browser/bundle.js +0 -97643
  212. package/tests/browser/entry.js +0 -57
  213. package/tests/browser/harness.html +0 -20
  214. package/tests/browser/run-browser.js +0 -50
  215. package/tests/encrypted-32.json +0 -1
  216. package/tests/encrypted-36.json +0 -1
  217. package/tests/encrypted-48.json +0 -1
  218. package/tests/generate-verify-vectors.js +0 -88
  219. package/tests/get-gas-price.test.js +0 -59
  220. package/tests/hashing.test.js +0 -34
  221. package/tests/non-transactional.preinit.test.js +0 -33
  222. package/tests/non-transactional.test.js +0 -1318
  223. package/tests/sign-raw-keytype5-context-null.test.js +0 -105
  224. package/tests/sign-raw-transaction.test.js +0 -194
  225. package/tests/sign-verify.test.js +0 -308
  226. package/tests/specs/assert.js +0 -74
  227. package/tests/specs/crypto.spec.js +0 -104
  228. package/tests/specs/hex.js +0 -31
  229. package/tests/specs/preinit.spec.js +0 -19
  230. package/tests/specs/sign.spec.js +0 -90
  231. package/tests/specs/wallet.spec.js +0 -98
  232. package/tests/transactional.rpc.test.js +0 -102
  233. package/tests/verify-vectors.json +0 -95035
@@ -1,80 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Result utility (optional params, deep conversions)
6
- */
7
-
8
- const { describe, it } = require("node:test");
9
- const assert = require("node:assert/strict");
10
-
11
- const qc = require("../../index");
12
- const { logSuite, logTest } = require("../verbose-logger");
13
-
14
- describe("Result", () => {
15
- logSuite("Result");
16
- it("constructor supports items omitted vs provided and keys omitted vs null", () => {
17
- logTest("constructor supports items omitted vs provided and keys omitted vs null", {});
18
- const r1 = new qc.Result();
19
- const r2 = new qc.Result(undefined, undefined);
20
- const r3 = new qc.Result([], null);
21
-
22
- assert.deepEqual(r1.toArray(), []);
23
- assert.deepEqual(r2.toArray(), []);
24
- assert.deepEqual(r3.toArray(), []);
25
- assert.deepEqual(r1.toObject(), {});
26
- });
27
-
28
- it("maps named keys onto indices and supports getValue()", () => {
29
- const r = new qc.Result([1, 2], ["a", "b"]);
30
- assert.equal(r.a, 1);
31
- assert.equal(r.b, 2);
32
- assert.equal(r.getValue("a"), 1);
33
- });
34
-
35
- it("toArray/toObject support deep=true (optional param omitted vs null)", () => {
36
- const inner = new qc.Result([1], ["x"]);
37
- const outer = new qc.Result([inner], ["inner"]);
38
-
39
- assert.deepEqual(outer.toArray(), [inner]);
40
- assert.deepEqual(outer.toArray(null), [inner]); // deep omitted behavior
41
- assert.deepEqual(outer.toArray(true), [[1]]);
42
-
43
- assert.deepEqual(outer.toObject(), { inner });
44
- assert.deepEqual(outer.toObject(null), { inner }); // deep omitted behavior
45
- assert.deepEqual(outer.toObject(true), { inner: { x: 1 } });
46
- });
47
-
48
- it("fromItems creates a Result and checkResultErrors returns []", () => {
49
- const r = qc.Result.fromItems([1, 2], ["a", "b"]);
50
- assert.ok(r instanceof qc.Result);
51
- assert.deepEqual(qc.checkResultErrors(r), []);
52
- });
53
-
54
- it("checkResultErrors finds Error instances and returns paths (nested Result)", () => {
55
- const e1 = new Error("outer");
56
- const e2 = new Error("inner");
57
-
58
- const inner = new qc.Result([e2], ["x"]);
59
- const outer = new qc.Result([e1, inner], ["a", "b"]);
60
-
61
- const errs = qc.checkResultErrors(outer);
62
- assert.equal(errs.length, 2);
63
- assert.equal(errs[0].error, e1);
64
- assert.deepEqual(errs[0].path, ["a"]);
65
- assert.equal(errs[1].error, e2);
66
- assert.deepEqual(errs[1].path, ["b", "x"]);
67
- });
68
-
69
- it("checkResultErrors walks plain objects (struct-like) and is cycle-safe", () => {
70
- const e = new Error("boom");
71
- const obj = { foo: { bar: e } };
72
- obj.self = obj;
73
-
74
- const errs = qc.checkResultErrors(obj);
75
- assert.equal(errs.length, 1);
76
- assert.equal(errs[0].error, e);
77
- assert.deepEqual(errs[0].path, ["foo", "bar"]);
78
- });
79
- });
80
-
@@ -1,79 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Result utility (optional params, deep conversions)
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
-
11
- import qc from "../../index";
12
- import { logSuite, logTest } from "../verbose-logger";
13
-
14
- describe("Result", () => {
15
- logSuite("Result");
16
- it("constructor supports items omitted vs provided and keys omitted vs null", () => {
17
- logTest("constructor supports items omitted vs provided and keys omitted vs null", {});
18
- const r1 = new qc.Result();
19
- const r2 = new qc.Result(undefined, undefined);
20
- const r3 = new qc.Result([], null);
21
-
22
- assert.deepEqual(r1.toArray(), []);
23
- assert.deepEqual(r2.toArray(), []);
24
- assert.deepEqual(r3.toArray(), []);
25
- assert.deepEqual(r1.toObject(), {});
26
- });
27
-
28
- it("maps named keys onto indices and supports getValue()", () => {
29
- const r = new qc.Result([1, 2], ["a", "b"]);
30
- assert.equal(r.a, 1);
31
- assert.equal(r.b, 2);
32
- assert.equal(r.getValue("a"), 1);
33
- });
34
-
35
- it("toArray/toObject support deep=true (optional param omitted vs null)", () => {
36
- const inner = new qc.Result([1], ["x"]);
37
- const outer = new qc.Result([inner], ["inner"]);
38
-
39
- assert.deepEqual(outer.toArray(), [inner]);
40
- assert.deepEqual(outer.toArray(null), [inner]);
41
- assert.deepEqual(outer.toArray(true), [[1]]);
42
-
43
- assert.deepEqual(outer.toObject(), { inner });
44
- assert.deepEqual(outer.toObject(null), { inner });
45
- assert.deepEqual(outer.toObject(true), { inner: { x: 1 } });
46
- });
47
-
48
- it("fromItems creates a Result and checkResultErrors returns []", () => {
49
- const r = qc.Result.fromItems([1, 2], ["a", "b"]);
50
- assert.ok(r instanceof qc.Result);
51
- assert.deepEqual(qc.checkResultErrors(r), []);
52
- });
53
-
54
- it("checkResultErrors finds Error instances and returns paths (nested Result)", () => {
55
- const e1 = new Error("outer");
56
- const e2 = new Error("inner");
57
-
58
- const inner = new qc.Result([e2], ["x"]);
59
- const outer = new qc.Result([e1, inner], ["a", "b"]);
60
-
61
- const errs = qc.checkResultErrors(outer);
62
- assert.equal(errs.length, 2);
63
- assert.equal(errs[0].error, e1);
64
- assert.deepEqual(errs[0].path, ["a"]);
65
- assert.equal(errs[1].error, e2);
66
- assert.deepEqual(errs[1].path, ["b", "x"]);
67
- });
68
-
69
- it("checkResultErrors walks plain objects (struct-like) and is cycle-safe", () => {
70
- const e = new Error("boom");
71
- const obj: { foo: { bar: Error }; self?: unknown } = { foo: { bar: e } };
72
- obj.self = obj;
73
-
74
- const errs = qc.checkResultErrors(obj);
75
- assert.equal(errs.length, 1);
76
- assert.equal(errs[0].error, e);
77
- assert.deepEqual(errs[0].path, ["foo", "bar"]);
78
- });
79
- });
@@ -1,49 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Core Solidity type exports exist and are wired via package exports.
6
- */
7
-
8
- const { describe, it } = require("node:test");
9
- const assert = require("node:assert/strict");
10
- const fs = require("node:fs");
11
- const path = require("node:path");
12
- const { logSuite, logTest } = require("../verbose-logger");
13
-
14
- describe("core solidity types", () => {
15
- logSuite("core solidity types");
16
- it("has src/types/index.d.ts with expected exports", () => {
17
- logTest("has src/types/index.d.ts with expected exports", {});
18
- const repoRoot = path.resolve(__dirname, "..", "..");
19
- const dts = path.join(repoRoot, "src", "types", "index.d.ts");
20
- assert.ok(fs.existsSync(dts), "missing src/types/index.d.ts");
21
- const src = fs.readFileSync(dts, "utf8");
22
-
23
- for (const needle of [
24
- "export type AddressLike",
25
- "export type BytesLike",
26
- "export type BigNumberish",
27
- "export type SolidityTypeName",
28
- "export type SolidityInputValue",
29
- "export type SolidityOutputValue",
30
- ]) {
31
- assert.ok(src.includes(needle), `expected types module to include: ${needle}`);
32
- }
33
- });
34
-
35
- it("exports ./types via package.json exports map", () => {
36
- const repoRoot = path.resolve(__dirname, "..", "..");
37
- const pkgPath = path.join(repoRoot, "package.json");
38
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
39
-
40
- assert.equal(pkg.types, "src/index.d.ts");
41
- assert.ok(pkg.typesVersions && pkg.typesVersions["*"], "package.json missing typesVersions");
42
-
43
- assert.ok(pkg.exports, "package.json missing exports");
44
- assert.ok(pkg.exports["./types"], "package.json exports missing ./types");
45
- assert.equal(pkg.exports["./types"].types, "./src/types/index.d.ts");
46
- assert.equal(pkg.exports["./types"].default, "./src/types/index.js");
47
- });
48
- });
49
-
@@ -1,39 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Core Solidity type exports exist and are wired via package exports.
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
- import fs from "node:fs";
11
- import path from "node:path";
12
- import { logSuite, logTest } from "../verbose-logger";
13
-
14
- describe("core solidity types", () => {
15
- logSuite("core solidity types");
16
- it("has src/types/index.d.ts with expected exports", () => {
17
- logTest("has src/types/index.d.ts with expected exports", {});
18
- const repoRoot = path.resolve(__dirname, "..", "..");
19
- const dts = path.join(repoRoot, "src", "types", "index.d.ts");
20
- assert.ok(fs.existsSync(dts), "missing src/types/index.d.ts");
21
- const src = fs.readFileSync(dts, "utf8");
22
- // Types may be defined here or re-exported; at minimum the module exists and exports something.
23
- assert.ok(src.includes("export"), "expected types module to have an export");
24
- });
25
-
26
- it("exports ./types via package.json exports map", () => {
27
- const repoRoot = path.resolve(__dirname, "..", "..");
28
- const pkgPath = path.join(repoRoot, "package.json");
29
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
30
-
31
- assert.equal(pkg.types, "src/index.d.ts");
32
- assert.ok(pkg.typesVersions && pkg.typesVersions["*"], "package.json missing typesVersions");
33
-
34
- assert.ok(pkg.exports, "package.json missing exports");
35
- assert.ok(pkg.exports["./types"], "package.json exports missing ./types");
36
- assert.equal(pkg.exports["./types"].types, "./src/types/index.d.ts");
37
- assert.equal(pkg.exports["./types"].default, "./src/types/index.js");
38
- });
39
- });
@@ -1,57 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Utility helpers (units, encoding, hashing, rlp, abi coder)
6
- */
7
-
8
- const { describe, it } = require("node:test");
9
- const assert = require("node:assert/strict");
10
-
11
- const { Initialize } = require("../../config");
12
- const qc = require("../../index");
13
- const { logSuite, logTest } = require("../verbose-logger");
14
-
15
- describe("Utils", () => {
16
- logSuite("Utils");
17
- it("parseEther/formatEther roundtrip", () => {
18
- logTest("parseEther/formatEther roundtrip", {});
19
- const wei = qc.parseEther("1.5");
20
- assert.equal(wei, 1500000000000000000n);
21
- assert.equal(qc.formatEther(wei), "1.5");
22
- });
23
-
24
- it("encodeBytes32String/decodeBytes32String roundtrip", () => {
25
- const hex = qc.encodeBytes32String("hello");
26
- assert.equal(hex.length, 66);
27
- assert.equal(qc.decodeBytes32String(hex), "hello");
28
- });
29
-
30
- it("base58 encode/decode roundtrip", () => {
31
- const bytes = qc.toUtf8Bytes("hello world");
32
- const b58 = qc.encodeBase58(bytes);
33
- const out = qc.decodeBase58(b58);
34
- assert.equal(qc.toUtf8String(out), "hello world");
35
- });
36
-
37
- it("RLP encode/decode roundtrip (hex bytes)", () => {
38
- const value = ["0x68656c6c6f", "0x7b", "0x01"];
39
- const encoded = qc.encodeRlp(value);
40
- assert.ok(typeof encoded === "string" && encoded.startsWith("0x"));
41
- const decoded = qc.decodeRlp(encoded);
42
- assert.deepEqual(decoded, value);
43
- });
44
-
45
- it("AbiCoder encode/decode roundtrip", async () => {
46
- await Initialize(null);
47
- const coder = new qc.AbiCoder();
48
- const data = coder.encode(["uint256", "bool", "string"], [123n, true, "hello"]);
49
- assert.ok(typeof data === "string" && data.startsWith("0x"));
50
- const decoded = coder.decode(["uint256", "bool", "string"], data);
51
- // qcsdk returns JSON array, so we accept array-like output
52
- assert.equal(decoded[0].toString(), "123");
53
- assert.equal(Boolean(decoded[1]), true);
54
- assert.equal(decoded[2], "hello");
55
- });
56
- });
57
-
@@ -1,56 +0,0 @@
1
- /**
2
- * @testCategory unit
3
- * @blockchainRequired false
4
- * @transactional false
5
- * @description Utility helpers (units, encoding, hashing, rlp, abi coder)
6
- */
7
-
8
- import { describe, it } from "node:test";
9
- import assert from "node:assert/strict";
10
-
11
- import { Initialize } from "../../config";
12
- import qc from "../../index";
13
- import { logSuite, logTest } from "../verbose-logger";
14
-
15
- describe("Utils", () => {
16
- logSuite("Utils");
17
- it("parseEther/formatEther roundtrip", () => {
18
- logTest("parseEther/formatEther roundtrip", {});
19
- const wei = qc.parseEther("1.5");
20
- assert.equal(wei, 1500000000000000000n);
21
- assert.equal(qc.formatEther(wei), "1.5");
22
- });
23
-
24
- it("encodeBytes32String/decodeBytes32String roundtrip", () => {
25
- const hex = qc.encodeBytes32String("hello");
26
- assert.equal(hex.length, 66);
27
- assert.equal(qc.decodeBytes32String(hex), "hello");
28
- });
29
-
30
- it("base58 encode/decode roundtrip", () => {
31
- const bytes = qc.toUtf8Bytes("hello world");
32
- const b58 = qc.encodeBase58(bytes);
33
- const out = qc.decodeBase58(b58);
34
- assert.equal(qc.toUtf8String(out), "hello world");
35
- });
36
-
37
- it("RLP encode/decode roundtrip (hex bytes)", () => {
38
- const value = ["0x68656c6c6f", "0x7b", "0x01"];
39
- const encoded = qc.encodeRlp(value);
40
- assert.ok(typeof encoded === "string" && encoded.startsWith("0x"));
41
- const decoded = qc.decodeRlp(encoded);
42
- assert.deepEqual(decoded, value);
43
- });
44
-
45
- it("AbiCoder encode/decode roundtrip", async () => {
46
- await Initialize(null);
47
- const coder = new qc.AbiCoder();
48
- const data = coder.encode(["uint256", "bool", "string"], [123n, true, "hello"]);
49
- assert.ok(typeof data === "string" && data.startsWith("0x"));
50
- const decoded = coder.decode(["uint256", "bool", "string"], data);
51
- // qcsdk returns JSON array, so we accept array-like output
52
- assert.equal(decoded[0].toString(), "123");
53
- assert.equal(Boolean(decoded[1]), true);
54
- assert.equal(decoded[2], "hello");
55
- });
56
- });
@@ -1,74 +0,0 @@
1
- /**
2
- * Verbose logging for tests and examples.
3
- * Enable with: VERBOSE=1 or QC_VERBOSE=1 (e.g. VERBOSE=1 npm test, VERBOSE=1 node examples/example.js)
4
- */
5
-
6
- function isVerbose() {
7
- const v = process.env.QC_VERBOSE || process.env.VERBOSE;
8
- return v === "1" || v === "true" || v === "yes";
9
- }
10
-
11
- function ts() {
12
- return new Date().toISOString();
13
- }
14
-
15
- function log(section, message, data) {
16
- if (!isVerbose()) return;
17
- const prefix = `[${ts()}] [${section}]`;
18
- if (data !== undefined && data !== null && typeof data === "object" && Object.keys(data).length > 0) {
19
- try {
20
- console.log(prefix, message, JSON.stringify(data));
21
- } catch {
22
- console.log(prefix, message, String(data));
23
- }
24
- } else {
25
- console.log(prefix, message);
26
- }
27
- }
28
-
29
- function logSuite(suiteName) {
30
- if (!isVerbose()) return;
31
- console.log(`[${ts()}] [suite] ${suiteName}`);
32
- }
33
-
34
- function logTest(testName, data) {
35
- if (!isVerbose()) return;
36
- const payload = { test: testName, ...data };
37
- console.log(`[${ts()}] [test] ${testName}`, JSON.stringify(payload));
38
- }
39
-
40
- function logTxn(txHash, data) {
41
- if (!isVerbose()) return;
42
- const hash = typeof txHash === "string" ? txHash : (txHash && txHash.hash) || String(txHash);
43
- console.log(`[${ts()}] [txn] hash=${hash}`, data ? JSON.stringify(data) : "");
44
- }
45
-
46
- function logAddress(label, address) {
47
- if (!isVerbose()) return;
48
- const addr = typeof address === "string" ? address : (address && address.address) || String(address);
49
- console.log(`[${ts()}] [address] ${label}=${addr}`);
50
- }
51
-
52
- function logExample(exampleName, message, data) {
53
- if (!isVerbose()) return;
54
- const prefix = `[${ts()}] [example:${exampleName}]`;
55
- if (data !== undefined && data !== null && typeof data === "object" && Object.keys(data).length > 0) {
56
- try {
57
- console.log(prefix, message, JSON.stringify(data));
58
- } catch {
59
- console.log(prefix, message, String(data));
60
- }
61
- } else {
62
- console.log(prefix, message);
63
- }
64
- }
65
-
66
- module.exports = {
67
- isVerbose,
68
- log,
69
- logSuite,
70
- logTest,
71
- logTxn,
72
- logAddress,
73
- logExample,
74
- };
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "emitDeclarationOnly": true,
5
- "allowJs": true,
6
- "lib": ["ES2015"],
7
- "skipLibCheck": true,
8
- "noEmit": false,
9
- "rootDir": "src",
10
- "outDir": "dist"
11
- },
12
- "include": ["src/**/*.js"],
13
- "exclude": ["node_modules"]
14
- }
@@ -1,22 +0,0 @@
1
- name: Publish Package to npmjs
2
- on:
3
- workflow_dispatch:
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- permissions:
9
- contents: read
10
- id-token: write
11
- steps:
12
- - uses: actions/checkout@v4
13
- # Setup .npmrc file to publish to npm
14
- - uses: actions/setup-node@v4
15
- with:
16
- node-version: '20.x'
17
- registry-url: 'https://registry.npmjs.org'
18
- - run: npm install
19
- - run: npm ci
20
- - run: npm publish --provenance --access public
21
- env:
22
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,7 +0,0 @@
1
- ## Generating Typescript Definitions
2
-
3
- npx -p typescript tsc seedwords.js --declaration --allowJs --emitDeclarationOnly --outDir dist
4
-
5
- ## Generating README.md
6
-
7
- jsdoc2md seedwords.js >README.md
@@ -1,121 +0,0 @@
1
- Creative Commons Legal Code
2
-
3
- CC0 1.0 Universal
4
-
5
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
- HEREUNDER.
13
-
14
- Statement of Purpose
15
-
16
- The laws of most jurisdictions throughout the world automatically confer
17
- exclusive Copyright and Related Rights (defined below) upon the creator
18
- and subsequent owner(s) (each and all, an "owner") of an original work of
19
- authorship and/or a database (each, a "Work").
20
-
21
- Certain owners wish to permanently relinquish those rights to a Work for
22
- the purpose of contributing to a commons of creative, cultural and
23
- scientific works ("Commons") that the public can reliably and without fear
24
- of later claims of infringement build upon, modify, incorporate in other
25
- works, reuse and redistribute as freely as possible in any form whatsoever
26
- and for any purposes, including without limitation commercial purposes.
27
- These owners may contribute to the Commons to promote the ideal of a free
28
- culture and the further production of creative, cultural and scientific
29
- works, or to gain reputation or greater distribution for their Work in
30
- part through the use and efforts of others.
31
-
32
- For these and/or other purposes and motivations, and without any
33
- expectation of additional consideration or compensation, the person
34
- associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
- is an owner of Copyright and Related Rights in the Work, voluntarily
36
- elects to apply CC0 to the Work and publicly distribute the Work under its
37
- terms, with knowledge of his or her Copyright and Related Rights in the
38
- Work and the meaning and intended legal effect of CC0 on those rights.
39
-
40
- 1. Copyright and Related Rights. A Work made available under CC0 may be
41
- protected by copyright and related or neighboring rights ("Copyright and
42
- Related Rights"). Copyright and Related Rights include, but are not
43
- limited to, the following:
44
-
45
- i. the right to reproduce, adapt, distribute, perform, display,
46
- communicate, and translate a Work;
47
- ii. moral rights retained by the original author(s) and/or performer(s);
48
- iii. publicity and privacy rights pertaining to a person's image or
49
- likeness depicted in a Work;
50
- iv. rights protecting against unfair competition in regards to a Work,
51
- subject to the limitations in paragraph 4(a), below;
52
- v. rights protecting the extraction, dissemination, use and reuse of data
53
- in a Work;
54
- vi. database rights (such as those arising under Directive 96/9/EC of the
55
- European Parliament and of the Council of 11 March 1996 on the legal
56
- protection of databases, and under any national implementation
57
- thereof, including any amended or successor version of such
58
- directive); and
59
- vii. other similar, equivalent or corresponding rights throughout the
60
- world based on applicable law or treaty, and any national
61
- implementations thereof.
62
-
63
- 2. Waiver. To the greatest extent permitted by, but not in contravention
64
- of, applicable law, Affirmer hereby overtly, fully, permanently,
65
- irrevocably and unconditionally waives, abandons, and surrenders all of
66
- Affirmer's Copyright and Related Rights and associated claims and causes
67
- of action, whether now known or unknown (including existing as well as
68
- future claims and causes of action), in the Work (i) in all territories
69
- worldwide, (ii) for the maximum duration provided by applicable law or
70
- treaty (including future time extensions), (iii) in any current or future
71
- medium and for any number of copies, and (iv) for any purpose whatsoever,
72
- including without limitation commercial, advertising or promotional
73
- purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
- member of the public at large and to the detriment of Affirmer's heirs and
75
- successors, fully intending that such Waiver shall not be subject to
76
- revocation, rescission, cancellation, termination, or any other legal or
77
- equitable action to disrupt the quiet enjoyment of the Work by the public
78
- as contemplated by Affirmer's express Statement of Purpose.
79
-
80
- 3. Public License Fallback. Should any part of the Waiver for any reason
81
- be judged legally invalid or ineffective under applicable law, then the
82
- Waiver shall be preserved to the maximum extent permitted taking into
83
- account Affirmer's express Statement of Purpose. In addition, to the
84
- extent the Waiver is so judged Affirmer hereby grants to each affected
85
- person a royalty-free, non transferable, non sublicensable, non exclusive,
86
- irrevocable and unconditional license to exercise Affirmer's Copyright and
87
- Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
- maximum duration provided by applicable law or treaty (including future
89
- time extensions), (iii) in any current or future medium and for any number
90
- of copies, and (iv) for any purpose whatsoever, including without
91
- limitation commercial, advertising or promotional purposes (the
92
- "License"). The License shall be deemed effective as of the date CC0 was
93
- applied by Affirmer to the Work. Should any part of the License for any
94
- reason be judged legally invalid or ineffective under applicable law, such
95
- partial invalidity or ineffectiveness shall not invalidate the remainder
96
- of the License, and in such case Affirmer hereby affirms that he or she
97
- will not (i) exercise any of his or her remaining Copyright and Related
98
- Rights in the Work or (ii) assert any associated claims and causes of
99
- action with respect to the Work, in either case contrary to Affirmer's
100
- express Statement of Purpose.
101
-
102
- 4. Limitations and Disclaimers.
103
-
104
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
- surrendered, licensed or otherwise affected by this document.
106
- b. Affirmer offers the Work as-is and makes no representations or
107
- warranties of any kind concerning the Work, express, implied,
108
- statutory or otherwise, including without limitation warranties of
109
- title, merchantability, fitness for a particular purpose, non
110
- infringement, or the absence of latent or other defects, accuracy, or
111
- the present or absence of errors, whether or not discoverable, all to
112
- the greatest extent permissible under applicable law.
113
- c. Affirmer disclaims responsibility for clearing rights of other persons
114
- that may apply to the Work or any use thereof, including without
115
- limitation any person's Copyright and Related Rights in the Work.
116
- Further, Affirmer disclaims responsibility for obtaining any necessary
117
- consents, permissions or other rights required for any use of the
118
- Work.
119
- d. Affirmer understands and acknowledges that Creative Commons is not a
120
- party to this document and has no duty or obligation with respect to
121
- this CC0 or use of the Work.