quantumcoin 7.0.1 → 7.0.2

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 (36) hide show
  1. package/.gitignore +3 -0
  2. package/README-SDK.md +62 -6
  3. package/README.md +25 -0
  4. package/SPEC.md +3845 -0
  5. package/examples/AllSolidityTypes.sol +184 -0
  6. package/examples/SimpleIERC20.sol +74 -0
  7. package/examples/example-generator-sdk-js.js +95 -0
  8. package/examples/example-generator-sdk-ts.js +95 -0
  9. package/examples/example.js +2 -2
  10. package/examples/package-lock.json +10 -1103
  11. package/examples/package.json +1 -2
  12. package/examples/read-operations.js +1 -2
  13. package/examples/sdk-generator-erc20.inline.json +251 -0
  14. package/examples/solidity-types.ts +43 -0
  15. package/generate-sdk.js +579 -84
  16. package/package.json +27 -6
  17. package/src/abi/interface.d.ts +18 -0
  18. package/src/abi/interface.js +247 -9
  19. package/src/abi/js-abi-coder.js +474 -0
  20. package/src/contract/contract-factory.d.ts +1 -1
  21. package/src/contract/contract-factory.js +14 -2
  22. package/src/contract/contract.d.ts +1 -1
  23. package/src/generator/index.js +834 -59
  24. package/src/index.d.ts +16 -0
  25. package/src/providers/provider.d.ts +13 -11
  26. package/src/types/index.d.ts +462 -0
  27. package/src/types/index.js +9 -0
  28. package/test/e2e/all-solidity-types.dynamic.test.js +200 -0
  29. package/test/e2e/all-solidity-types.fixtures.js +231 -0
  30. package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +361 -0
  31. package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +144 -0
  32. package/test/e2e/typed-generator.e2e.test.js +6 -6
  33. package/test/unit/generate-contract-cli.test.js +1 -0
  34. package/test/unit/generate-sdk-artifacts-json.test.js +45 -0
  35. package/test/unit/solidity-types.test.js +46 -0
  36. package/test/unit/utils.test.js +1 -1
package/src/index.d.ts CHANGED
@@ -109,3 +109,19 @@ declare const _exports: {
109
109
  };
110
110
  export = _exports;
111
111
  import errors = require("./errors");
112
+
113
+ // ---------------------------------------------------------------------------
114
+ // Core Solidity typing exports (type-only)
115
+ // ---------------------------------------------------------------------------
116
+ declare namespace _exports {
117
+ export type AddressLike = import("./types").AddressLike;
118
+ export type BytesLike = import("./types").BytesLike;
119
+ export type Bytes32Like = import("./types").Bytes32Like;
120
+ export type BigNumberish = import("./types").BigNumberish;
121
+ export type HexString = import("./types").HexString;
122
+ export type SolidityTypeName = import("./types").SolidityTypeName;
123
+ export type SolidityInputValue<T extends SolidityTypeName> = import("./types").SolidityInputValue<T>;
124
+ export type SolidityOutputValue<T extends SolidityTypeName> = import("./types").SolidityOutputValue<T>;
125
+ export type SolidityTuple = import("./types").SolidityTuple;
126
+ export type SolidityStruct = import("./types").SolidityStruct;
127
+ }
@@ -1,11 +1,13 @@
1
- export type BytesLike = import("../utils/encoding").BytesLike;
1
+ export type BytesLike = import("../types").BytesLike;
2
+ export type AddressLike = import("../types").AddressLike;
3
+ export type BigNumberish = import("../types").BigNumberish;
2
4
  export type TransactionRequest = {
3
- to?: string | undefined;
4
- from?: string | undefined;
5
- value?: (bigint | string | number) | undefined;
6
- data?: string | undefined;
7
- gasLimit?: (bigint | string | number) | undefined;
8
- gasPrice?: (bigint | string | number) | undefined;
5
+ to?: AddressLike | undefined;
6
+ from?: AddressLike | undefined;
7
+ value?: BigNumberish | undefined;
8
+ data?: BytesLike | undefined;
9
+ gasLimit?: BigNumberish | undefined;
10
+ gasPrice?: BigNumberish | undefined;
9
11
  nonce?: number | undefined;
10
12
  chainId?: number | undefined;
11
13
  /**
@@ -56,13 +58,13 @@ export class AbstractProvider extends Provider {
56
58
  * @param {string} address
57
59
  * @returns {Promise<bigint>}
58
60
  */
59
- getBalance(address: string): Promise<bigint>;
61
+ getBalance(address: AddressLike): Promise<bigint>;
60
62
  /**
61
63
  * @param {string} address
62
64
  * @param {string=} blockTag
63
65
  * @returns {Promise<number>}
64
66
  */
65
- getTransactionCount(address: string, blockTag?: string | undefined): Promise<number>;
67
+ getTransactionCount(address: AddressLike, blockTag?: string | undefined): Promise<number>;
66
68
  /**
67
69
  * Broadcasts a signed transaction.
68
70
  * @param {TransactionRequest|string} tx
@@ -87,14 +89,14 @@ export class AbstractProvider extends Provider {
87
89
  * @param {string=} blockTag
88
90
  * @returns {Promise<string>}
89
91
  */
90
- getCode(address: string, blockTag?: string | undefined): Promise<string>;
92
+ getCode(address: AddressLike, blockTag?: string | undefined): Promise<string>;
91
93
  /**
92
94
  * @param {string} address
93
95
  * @param {bigint} position
94
96
  * @param {string=} blockTag
95
97
  * @returns {Promise<string>}
96
98
  */
97
- getStorageAt(address: string, position: bigint, blockTag?: string | undefined): Promise<string>;
99
+ getStorageAt(address: AddressLike, position: bigint, blockTag?: string | undefined): Promise<string>;
98
100
  /**
99
101
  * @param {Filter} filter
100
102
  * @returns {Promise<Log[]>}
@@ -0,0 +1,462 @@
1
+ /**
2
+ * @fileoverview Core Solidity typing helpers for QuantumCoin.js.
3
+ *
4
+ * These types model common Solidity ABI value shapes (inputs and outputs).
5
+ *
6
+ * Notes:
7
+ * - QuantumCoin addresses are 32 bytes (0x + 64 hex chars), but are represented as strings.
8
+ * - For uint/int inputs, use BigNumberish (string | number | bigint) for compatibility.
9
+ * - For uint/int outputs, QuantumCoin.js typically returns bigint (ethers v6 style).
10
+ */
11
+
12
+ export type BytesLike = import("../utils/encoding").BytesLike;
13
+ export type BigNumberish = import("../utils/units").BigNumberish;
14
+
15
+ /**
16
+ * A value that can be resolved to an address string.
17
+ *
18
+ * This mirrors the common "AddressLike" concept from ethers.js:
19
+ * - raw string
20
+ * - Addressable objects with getAddress()
21
+ */
22
+ export type AddressLike =
23
+ | string;
24
+
25
+ /**
26
+ * Generic "hex string" alias (e.g. "0x..." or raw hex depending on context).
27
+ */
28
+ export type HexString = string;
29
+
30
+ /**
31
+ * Represents a 32-byte value input (bytes32).
32
+ */
33
+ export type Bytes32Like = BytesLike;
34
+
35
+ /**
36
+ * ---------------------------------------------------------------------------
37
+ * Top-level Solidity value types (language-level)
38
+ * ---------------------------------------------------------------------------
39
+ * These are convenience aliases to describe Solidity types in TypeScript.
40
+ * They are primarily useful for:
41
+ * - ABI inputs/outputs
42
+ * - generated typed contract wrappers
43
+ * - dynamic ABI coding helpers
44
+ *
45
+ * Notes:
46
+ * - Fixed point types and function types are intentionally omitted.
47
+ * - Solidity mappings are not part of the ABI; they are modeled as nominal types.
48
+ */
49
+
50
+ export type SolBool = boolean;
51
+ export type SolString = string;
52
+ export type SolBytes = BytesLike;
53
+
54
+ // Solidity address types (ABI uses "address" for both address and address payable)
55
+ export type SolAddress = AddressLike;
56
+ export type SolAddressPayable = AddressLike;
57
+
58
+ // Contract types are represented as addresses in the ABI.
59
+ export type SolContract = AddressLike;
60
+
61
+ // Enums are ABI-exposed as an integer type (usually uint8/uint16/uint256).
62
+ export type SolEnum<T extends number = number> = T;
63
+
64
+ // Arrays
65
+ export type SolArray<T> = readonly T[] | T[];
66
+ export type SolFixedArray<T, N extends number> = readonly T[] | T[]; // length is not enforced at runtime
67
+
68
+ // Tuples / structs (ABI tuples)
69
+ export type SolTuple<T extends readonly unknown[] = readonly unknown[]> = T;
70
+ export type SolStruct<TFields extends Record<string, unknown> = Record<string, unknown>> = TFields;
71
+
72
+ // Mappings are not part of the ABI; this is a nominal placeholder.
73
+ export type SolMapping<TKey, TValue> = {
74
+ readonly __solMappingKey: TKey;
75
+ readonly __solMappingValue: TValue;
76
+ };
77
+
78
+ /**
79
+ * ---------------------------------------------------------------------------
80
+ * Fixed-size bytes (explicit, static definitions)
81
+ * ---------------------------------------------------------------------------
82
+ */
83
+
84
+ export type Bytes1Like = BytesLike;
85
+ export type Bytes2Like = BytesLike;
86
+ export type Bytes3Like = BytesLike;
87
+ export type Bytes4Like = BytesLike;
88
+ export type Bytes5Like = BytesLike;
89
+ export type Bytes6Like = BytesLike;
90
+ export type Bytes7Like = BytesLike;
91
+ export type Bytes8Like = BytesLike;
92
+ export type Bytes9Like = BytesLike;
93
+ export type Bytes10Like = BytesLike;
94
+ export type Bytes11Like = BytesLike;
95
+ export type Bytes12Like = BytesLike;
96
+ export type Bytes13Like = BytesLike;
97
+ export type Bytes14Like = BytesLike;
98
+ export type Bytes15Like = BytesLike;
99
+ export type Bytes16Like = BytesLike;
100
+ export type Bytes17Like = BytesLike;
101
+ export type Bytes18Like = BytesLike;
102
+ export type Bytes19Like = BytesLike;
103
+ export type Bytes20Like = BytesLike;
104
+ export type Bytes21Like = BytesLike;
105
+ export type Bytes22Like = BytesLike;
106
+ export type Bytes23Like = BytesLike;
107
+ export type Bytes24Like = BytesLike;
108
+ export type Bytes25Like = BytesLike;
109
+ export type Bytes26Like = BytesLike;
110
+ export type Bytes27Like = BytesLike;
111
+ export type Bytes28Like = BytesLike;
112
+ export type Bytes29Like = BytesLike;
113
+ export type Bytes30Like = BytesLike;
114
+ export type Bytes31Like = BytesLike;
115
+ export type Bytes32FixedLike = Bytes32Like;
116
+
117
+ export type Bytes1 = string;
118
+ export type Bytes2 = string;
119
+ export type Bytes3 = string;
120
+ export type Bytes4 = string;
121
+ export type Bytes5 = string;
122
+ export type Bytes6 = string;
123
+ export type Bytes7 = string;
124
+ export type Bytes8 = string;
125
+ export type Bytes9 = string;
126
+ export type Bytes10 = string;
127
+ export type Bytes11 = string;
128
+ export type Bytes12 = string;
129
+ export type Bytes13 = string;
130
+ export type Bytes14 = string;
131
+ export type Bytes15 = string;
132
+ export type Bytes16 = string;
133
+ export type Bytes17 = string;
134
+ export type Bytes18 = string;
135
+ export type Bytes19 = string;
136
+ export type Bytes20 = string;
137
+ export type Bytes21 = string;
138
+ export type Bytes22 = string;
139
+ export type Bytes23 = string;
140
+ export type Bytes24 = string;
141
+ export type Bytes25 = string;
142
+ export type Bytes26 = string;
143
+ export type Bytes27 = string;
144
+ export type Bytes28 = string;
145
+ export type Bytes29 = string;
146
+ export type Bytes30 = string;
147
+ export type Bytes31 = string;
148
+ export type Bytes32 = string;
149
+
150
+ /**
151
+ * ---------------------------------------------------------------------------
152
+ * Integers (explicit width aliases)
153
+ * ---------------------------------------------------------------------------
154
+ */
155
+
156
+ export type Int8Like = BigNumberish;
157
+ export type Int16Like = BigNumberish;
158
+ export type Int24Like = BigNumberish;
159
+ export type Int32Like = BigNumberish;
160
+ export type Int40Like = BigNumberish;
161
+ export type Int48Like = BigNumberish;
162
+ export type Int56Like = BigNumberish;
163
+ export type Int64Like = BigNumberish;
164
+ export type Int72Like = BigNumberish;
165
+ export type Int80Like = BigNumberish;
166
+ export type Int88Like = BigNumberish;
167
+ export type Int96Like = BigNumberish;
168
+ export type Int104Like = BigNumberish;
169
+ export type Int112Like = BigNumberish;
170
+ export type Int120Like = BigNumberish;
171
+ export type Int128Like = BigNumberish;
172
+ export type Int136Like = BigNumberish;
173
+ export type Int144Like = BigNumberish;
174
+ export type Int152Like = BigNumberish;
175
+ export type Int160Like = BigNumberish;
176
+ export type Int168Like = BigNumberish;
177
+ export type Int176Like = BigNumberish;
178
+ export type Int184Like = BigNumberish;
179
+ export type Int192Like = BigNumberish;
180
+ export type Int200Like = BigNumberish;
181
+ export type Int208Like = BigNumberish;
182
+ export type Int216Like = BigNumberish;
183
+ export type Int224Like = BigNumberish;
184
+ export type Int232Like = BigNumberish;
185
+ export type Int240Like = BigNumberish;
186
+ export type Int248Like = BigNumberish;
187
+ export type Int256Like = BigNumberish;
188
+
189
+ export type Uint8Like = BigNumberish;
190
+ export type Uint16Like = BigNumberish;
191
+ export type Uint24Like = BigNumberish;
192
+ export type Uint32Like = BigNumberish;
193
+ export type Uint40Like = BigNumberish;
194
+ export type Uint48Like = BigNumberish;
195
+ export type Uint56Like = BigNumberish;
196
+ export type Uint64Like = BigNumberish;
197
+ export type Uint72Like = BigNumberish;
198
+ export type Uint80Like = BigNumberish;
199
+ export type Uint88Like = BigNumberish;
200
+ export type Uint96Like = BigNumberish;
201
+ export type Uint104Like = BigNumberish;
202
+ export type Uint112Like = BigNumberish;
203
+ export type Uint120Like = BigNumberish;
204
+ export type Uint128Like = BigNumberish;
205
+ export type Uint136Like = BigNumberish;
206
+ export type Uint144Like = BigNumberish;
207
+ export type Uint152Like = BigNumberish;
208
+ export type Uint160Like = BigNumberish;
209
+ export type Uint168Like = BigNumberish;
210
+ export type Uint176Like = BigNumberish;
211
+ export type Uint184Like = BigNumberish;
212
+ export type Uint192Like = BigNumberish;
213
+ export type Uint200Like = BigNumberish;
214
+ export type Uint208Like = BigNumberish;
215
+ export type Uint216Like = BigNumberish;
216
+ export type Uint224Like = BigNumberish;
217
+ export type Uint232Like = BigNumberish;
218
+ export type Uint240Like = BigNumberish;
219
+ export type Uint248Like = BigNumberish;
220
+ export type Uint256Like = BigNumberish;
221
+
222
+ export type Int8 = bigint;
223
+ export type Int16 = bigint;
224
+ export type Int24 = bigint;
225
+ export type Int32 = bigint;
226
+ export type Int40 = bigint;
227
+ export type Int48 = bigint;
228
+ export type Int56 = bigint;
229
+ export type Int64 = bigint;
230
+ export type Int72 = bigint;
231
+ export type Int80 = bigint;
232
+ export type Int88 = bigint;
233
+ export type Int96 = bigint;
234
+ export type Int104 = bigint;
235
+ export type Int112 = bigint;
236
+ export type Int120 = bigint;
237
+ export type Int128 = bigint;
238
+ export type Int136 = bigint;
239
+ export type Int144 = bigint;
240
+ export type Int152 = bigint;
241
+ export type Int160 = bigint;
242
+ export type Int168 = bigint;
243
+ export type Int176 = bigint;
244
+ export type Int184 = bigint;
245
+ export type Int192 = bigint;
246
+ export type Int200 = bigint;
247
+ export type Int208 = bigint;
248
+ export type Int216 = bigint;
249
+ export type Int224 = bigint;
250
+ export type Int232 = bigint;
251
+ export type Int240 = bigint;
252
+ export type Int248 = bigint;
253
+ export type Int256 = bigint;
254
+
255
+ export type Uint8 = bigint;
256
+ export type Uint16 = bigint;
257
+ export type Uint24 = bigint;
258
+ export type Uint32 = bigint;
259
+ export type Uint40 = bigint;
260
+ export type Uint48 = bigint;
261
+ export type Uint56 = bigint;
262
+ export type Uint64 = bigint;
263
+ export type Uint72 = bigint;
264
+ export type Uint80 = bigint;
265
+ export type Uint88 = bigint;
266
+ export type Uint96 = bigint;
267
+ export type Uint104 = bigint;
268
+ export type Uint112 = bigint;
269
+ export type Uint120 = bigint;
270
+ export type Uint128 = bigint;
271
+ export type Uint136 = bigint;
272
+ export type Uint144 = bigint;
273
+ export type Uint152 = bigint;
274
+ export type Uint160 = bigint;
275
+ export type Uint168 = bigint;
276
+ export type Uint176 = bigint;
277
+ export type Uint184 = bigint;
278
+ export type Uint192 = bigint;
279
+ export type Uint200 = bigint;
280
+ export type Uint208 = bigint;
281
+ export type Uint216 = bigint;
282
+ export type Uint224 = bigint;
283
+ export type Uint232 = bigint;
284
+ export type Uint240 = bigint;
285
+ export type Uint248 = bigint;
286
+ export type Uint256 = bigint;
287
+
288
+ /**
289
+ * ---------------------------------------------------------------------------
290
+ * ABI type names + value mapping (ABI specification)
291
+ * ---------------------------------------------------------------------------
292
+ */
293
+
294
+ export type SolidityFixedBytesTypeName =
295
+ | "bytes1"
296
+ | "bytes2"
297
+ | "bytes3"
298
+ | "bytes4"
299
+ | "bytes5"
300
+ | "bytes6"
301
+ | "bytes7"
302
+ | "bytes8"
303
+ | "bytes9"
304
+ | "bytes10"
305
+ | "bytes11"
306
+ | "bytes12"
307
+ | "bytes13"
308
+ | "bytes14"
309
+ | "bytes15"
310
+ | "bytes16"
311
+ | "bytes17"
312
+ | "bytes18"
313
+ | "bytes19"
314
+ | "bytes20"
315
+ | "bytes21"
316
+ | "bytes22"
317
+ | "bytes23"
318
+ | "bytes24"
319
+ | "bytes25"
320
+ | "bytes26"
321
+ | "bytes27"
322
+ | "bytes28"
323
+ | "bytes29"
324
+ | "bytes30"
325
+ | "bytes31"
326
+ | "bytes32";
327
+
328
+ export type SolidityIntTypeName =
329
+ | "int"
330
+ | "int8"
331
+ | "int16"
332
+ | "int24"
333
+ | "int32"
334
+ | "int40"
335
+ | "int48"
336
+ | "int56"
337
+ | "int64"
338
+ | "int72"
339
+ | "int80"
340
+ | "int88"
341
+ | "int96"
342
+ | "int104"
343
+ | "int112"
344
+ | "int120"
345
+ | "int128"
346
+ | "int136"
347
+ | "int144"
348
+ | "int152"
349
+ | "int160"
350
+ | "int168"
351
+ | "int176"
352
+ | "int184"
353
+ | "int192"
354
+ | "int200"
355
+ | "int208"
356
+ | "int216"
357
+ | "int224"
358
+ | "int232"
359
+ | "int240"
360
+ | "int248"
361
+ | "int256";
362
+
363
+ export type SolidityUintTypeName =
364
+ | "uint"
365
+ | "uint8"
366
+ | "uint16"
367
+ | "uint24"
368
+ | "uint32"
369
+ | "uint40"
370
+ | "uint48"
371
+ | "uint56"
372
+ | "uint64"
373
+ | "uint72"
374
+ | "uint80"
375
+ | "uint88"
376
+ | "uint96"
377
+ | "uint104"
378
+ | "uint112"
379
+ | "uint120"
380
+ | "uint128"
381
+ | "uint136"
382
+ | "uint144"
383
+ | "uint152"
384
+ | "uint160"
385
+ | "uint168"
386
+ | "uint176"
387
+ | "uint184"
388
+ | "uint192"
389
+ | "uint200"
390
+ | "uint208"
391
+ | "uint216"
392
+ | "uint224"
393
+ | "uint232"
394
+ | "uint240"
395
+ | "uint248"
396
+ | "uint256";
397
+
398
+ export type SolidityElementaryTypeName =
399
+ | "address"
400
+ | "bool"
401
+ | "string"
402
+ | "bytes"
403
+ | SolidityFixedBytesTypeName
404
+ | SolidityIntTypeName
405
+ | SolidityUintTypeName
406
+ | "tuple";
407
+
408
+ /**
409
+ * Solidity ABI type string (commonly used in ABI coder APIs).
410
+ *
411
+ * This is intentionally broad, but still provides useful narrowing for common types.
412
+ */
413
+ export type SolidityTypeName =
414
+ | SolidityElementaryTypeName
415
+ | `${SolidityTypeName}[]`
416
+ | `${SolidityTypeName}[${number}]`;
417
+
418
+ /**
419
+ * Values accepted as ABI *inputs* for a given Solidity type.
420
+ */
421
+ export type SolidityInputValue<T extends SolidityTypeName> = T extends `${infer Inner}[]`
422
+ ? SolidityInputValue<Extract<Inner, SolidityTypeName>>[]
423
+ : T extends `${infer Inner}[${number}]`
424
+ ? SolidityInputValue<Extract<Inner, SolidityTypeName>>[]
425
+ : T extends "address"
426
+ ? AddressLike
427
+ : T extends "bool"
428
+ ? boolean
429
+ : T extends "string"
430
+ ? string
431
+ : T extends "bytes" | SolidityFixedBytesTypeName
432
+ ? BytesLike
433
+ : T extends SolidityUintTypeName | SolidityIntTypeName
434
+ ? BigNumberish
435
+ : any;
436
+
437
+ /**
438
+ * Values returned as ABI *outputs* for a given Solidity type.
439
+ */
440
+ export type SolidityOutputValue<T extends SolidityTypeName> = T extends `${infer Inner}[]`
441
+ ? SolidityOutputValue<Extract<Inner, SolidityTypeName>>[]
442
+ : T extends `${infer Inner}[${number}]`
443
+ ? SolidityOutputValue<Extract<Inner, SolidityTypeName>>[]
444
+ : T extends "address"
445
+ ? string
446
+ : T extends "bool"
447
+ ? boolean
448
+ : T extends "string"
449
+ ? string
450
+ : T extends "bytes" | SolidityFixedBytesTypeName
451
+ ? string
452
+ : T extends SolidityUintTypeName | SolidityIntTypeName
453
+ ? bigint
454
+ : any;
455
+
456
+ /**
457
+ * Generic tuple/struct placeholders (used when the ABI contains tuples).
458
+ * Generated contract wrappers may refine these further.
459
+ */
460
+ export type SolidityTuple = SolTuple;
461
+ export type SolidityStruct = SolStruct;
462
+
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @fileoverview Runtime placeholder for `require("quantumcoin/types")`.
3
+ *
4
+ * This module is primarily for TypeScript type exports (`index.d.ts`).
5
+ * At runtime, it intentionally exports nothing.
6
+ */
7
+
8
+ module.exports = {};
9
+