quantumcoin 7.0.1 → 7.0.3

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 (43) hide show
  1. package/.gitignore +3 -0
  2. package/README-SDK.md +64 -10
  3. package/README.md +27 -4
  4. package/SPEC.md +3843 -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/offline-signing.js +73 -0
  11. package/examples/package-lock.json +10 -1103
  12. package/examples/package.json +1 -2
  13. package/examples/read-operations.js +1 -2
  14. package/examples/sdk-generator-erc20.inline.json +251 -0
  15. package/examples/solidity-types.ts +43 -0
  16. package/generate-sdk.js +689 -87
  17. package/package.json +30 -9
  18. package/src/abi/interface.d.ts +18 -0
  19. package/src/abi/interface.js +247 -9
  20. package/src/abi/js-abi-coder.js +474 -0
  21. package/src/contract/contract-factory.d.ts +1 -1
  22. package/src/contract/contract-factory.js +14 -2
  23. package/src/contract/contract.d.ts +10 -1
  24. package/src/contract/contract.js +42 -0
  25. package/src/generator/index.js +1041 -63
  26. package/src/index.d.ts +16 -0
  27. package/src/providers/provider.d.ts +20 -11
  28. package/src/providers/provider.js +12 -0
  29. package/src/types/index.d.ts +462 -0
  30. package/src/types/index.js +9 -0
  31. package/test/e2e/all-solidity-types.dynamic.test.js +200 -0
  32. package/test/e2e/all-solidity-types.fixtures.js +231 -0
  33. package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +368 -0
  34. package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +151 -0
  35. package/test/e2e/transactional.test.js +4 -4
  36. package/test/e2e/typed-generator.e2e.test.js +8 -6
  37. package/test/integration/ws-provider.test.js +1 -1
  38. package/test/unit/generate-contract-cli.test.js +2 -1
  39. package/test/unit/generate-sdk-artifacts-json.test.js +45 -0
  40. package/test/unit/generator.test.js +1 -0
  41. package/test/unit/populate-transaction.test.js +62 -0
  42. package/test/unit/solidity-types.test.js +46 -0
  43. package/test/unit/utils.test.js +1 -1
@@ -9,8 +9,7 @@
9
9
  "author": "QuantumCoin Community",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "ethers": "^6.13.4",
13
- "quantum-coin-js-sdk": "1.0.27",
12
+ "quantum-coin-js-sdk": "^1.0.28",
14
13
  "quantum-coin-pqc-js-sdk": "^1.0.5",
15
14
  "quantumcoin": "file:.."
16
15
  }
@@ -17,8 +17,7 @@ async function readOperations() {
17
17
  const contract = new Contract(STAKING_CONTRACT, abi, provider);
18
18
 
19
19
  const total = await contract.getTotalDepositedBalance();
20
- const value = Array.isArray(total) ? total[0] : total;
21
- console.log("Total deposited balance:", String(value));
20
+ console.log("Total deposited balance:", total.toString());
22
21
  }
23
22
 
24
23
  readOperations().catch((e) => {
@@ -0,0 +1,251 @@
1
+ [
2
+ {
3
+ "name": "SimpleERC20",
4
+ "abi": [
5
+ {
6
+ "inputs": [
7
+ {
8
+ "internalType": "string",
9
+ "name": "_name",
10
+ "type": "string"
11
+ },
12
+ {
13
+ "internalType": "string",
14
+ "name": "_symbol",
15
+ "type": "string"
16
+ },
17
+ {
18
+ "internalType": "uint256",
19
+ "name": "_initialSupply",
20
+ "type": "uint256"
21
+ }
22
+ ],
23
+ "stateMutability": "nonpayable",
24
+ "type": "constructor"
25
+ },
26
+ {
27
+ "anonymous": false,
28
+ "inputs": [
29
+ {
30
+ "indexed": true,
31
+ "internalType": "address",
32
+ "name": "owner",
33
+ "type": "address"
34
+ },
35
+ {
36
+ "indexed": true,
37
+ "internalType": "address",
38
+ "name": "spender",
39
+ "type": "address"
40
+ },
41
+ {
42
+ "indexed": false,
43
+ "internalType": "uint256",
44
+ "name": "value",
45
+ "type": "uint256"
46
+ }
47
+ ],
48
+ "name": "Approval",
49
+ "type": "event"
50
+ },
51
+ {
52
+ "anonymous": false,
53
+ "inputs": [
54
+ {
55
+ "indexed": true,
56
+ "internalType": "address",
57
+ "name": "from",
58
+ "type": "address"
59
+ },
60
+ {
61
+ "indexed": true,
62
+ "internalType": "address",
63
+ "name": "to",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "indexed": false,
68
+ "internalType": "uint256",
69
+ "name": "value",
70
+ "type": "uint256"
71
+ }
72
+ ],
73
+ "name": "Transfer",
74
+ "type": "event"
75
+ },
76
+ {
77
+ "inputs": [
78
+ {
79
+ "internalType": "address",
80
+ "name": "",
81
+ "type": "address"
82
+ },
83
+ {
84
+ "internalType": "address",
85
+ "name": "",
86
+ "type": "address"
87
+ }
88
+ ],
89
+ "name": "allowance",
90
+ "outputs": [
91
+ {
92
+ "internalType": "uint256",
93
+ "name": "",
94
+ "type": "uint256"
95
+ }
96
+ ],
97
+ "stateMutability": "view",
98
+ "type": "function"
99
+ },
100
+ {
101
+ "inputs": [
102
+ {
103
+ "internalType": "address",
104
+ "name": "spender",
105
+ "type": "address"
106
+ },
107
+ {
108
+ "internalType": "uint256",
109
+ "name": "value",
110
+ "type": "uint256"
111
+ }
112
+ ],
113
+ "name": "approve",
114
+ "outputs": [
115
+ {
116
+ "internalType": "bool",
117
+ "name": "",
118
+ "type": "bool"
119
+ }
120
+ ],
121
+ "stateMutability": "nonpayable",
122
+ "type": "function"
123
+ },
124
+ {
125
+ "inputs": [
126
+ {
127
+ "internalType": "address",
128
+ "name": "",
129
+ "type": "address"
130
+ }
131
+ ],
132
+ "name": "balanceOf",
133
+ "outputs": [
134
+ {
135
+ "internalType": "uint256",
136
+ "name": "",
137
+ "type": "uint256"
138
+ }
139
+ ],
140
+ "stateMutability": "view",
141
+ "type": "function"
142
+ },
143
+ {
144
+ "inputs": [],
145
+ "name": "decimals",
146
+ "outputs": [
147
+ {
148
+ "internalType": "uint8",
149
+ "name": "",
150
+ "type": "uint8"
151
+ }
152
+ ],
153
+ "stateMutability": "view",
154
+ "type": "function"
155
+ },
156
+ {
157
+ "inputs": [],
158
+ "name": "name",
159
+ "outputs": [
160
+ {
161
+ "internalType": "string",
162
+ "name": "",
163
+ "type": "string"
164
+ }
165
+ ],
166
+ "stateMutability": "view",
167
+ "type": "function"
168
+ },
169
+ {
170
+ "inputs": [],
171
+ "name": "symbol",
172
+ "outputs": [
173
+ {
174
+ "internalType": "string",
175
+ "name": "",
176
+ "type": "string"
177
+ }
178
+ ],
179
+ "stateMutability": "view",
180
+ "type": "function"
181
+ },
182
+ {
183
+ "inputs": [],
184
+ "name": "totalSupply",
185
+ "outputs": [
186
+ {
187
+ "internalType": "uint256",
188
+ "name": "",
189
+ "type": "uint256"
190
+ }
191
+ ],
192
+ "stateMutability": "view",
193
+ "type": "function"
194
+ },
195
+ {
196
+ "inputs": [
197
+ {
198
+ "internalType": "address",
199
+ "name": "to",
200
+ "type": "address"
201
+ },
202
+ {
203
+ "internalType": "uint256",
204
+ "name": "value",
205
+ "type": "uint256"
206
+ }
207
+ ],
208
+ "name": "transfer",
209
+ "outputs": [
210
+ {
211
+ "internalType": "bool",
212
+ "name": "",
213
+ "type": "bool"
214
+ }
215
+ ],
216
+ "stateMutability": "nonpayable",
217
+ "type": "function"
218
+ },
219
+ {
220
+ "inputs": [
221
+ {
222
+ "internalType": "address",
223
+ "name": "from",
224
+ "type": "address"
225
+ },
226
+ {
227
+ "internalType": "address",
228
+ "name": "to",
229
+ "type": "address"
230
+ },
231
+ {
232
+ "internalType": "uint256",
233
+ "name": "value",
234
+ "type": "uint256"
235
+ }
236
+ ],
237
+ "name": "transferFrom",
238
+ "outputs": [
239
+ {
240
+ "internalType": "bool",
241
+ "name": "",
242
+ "type": "bool"
243
+ }
244
+ ],
245
+ "stateMutability": "nonpayable",
246
+ "type": "function"
247
+ }
248
+ ],
249
+ "bin": "0x608060405234801561001057600080fd5b506040516108ab3803806108ab8339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b5060405260209081015185519093506101a79250600091860190610264565b5081516101bb906001906020850190610264565b506101c633826101ce565b505050610305565b8161020f576040805162461bcd60e51b815260206004820152600c60248201526b4d494e545f544f5f5a45524f60a01b604482015290519081900360640190fd5b60028054820190556000828152600360209081526040808320805485019055805184815290518593927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef928290030190a35050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261029a57600085556102e0565b82601f106102b357805160ff19168380011785556102e0565b828001600101855582156102e0579182015b828111156102e05782518255916020019190600101906102c5565b506102ec9291506102f0565b5090565b5b808211156102ec57600081556001016102f1565b610597806103146000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce5671461018f57806370a08231146101ad57806395d89b41146101ca578063a9059cbb146101d2578063dd62ed3e146101f557610093565b806306fdde0314610098578063095ea7b31461011557806318160ddd1461014c57806323b872dd14610166575b600080fd5b6100a0610218565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100da5781810151838201526020016100c2565b50505050905090810190601f1680156101075780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101386004803603604081101561012b57600080fd5b50803590602001356102a6565b604080519115158252519081900360200190f35b610154610301565b60408051918252519081900360200190f35b6101386004803603606081101561017c57600080fd5b5080359060208101359060400135610307565b6101976103d6565b6040805160ff9092168252519081900360200190f35b610154600480360360208110156101c357600080fd5b50356103db565b6100a06103ed565b610138600480360360408110156101e857600080fd5b5080359060200135610447565b6101546004803603604081101561020b57600080fd5b508035906020013561045d565b6000805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561029e5780601f106102735761010080835404028352916020019161029e565b820191906000526020600020905b81548152906001019060200180831161028157829003601f168201915b505050505081565b3360008181526004602090815260408083208684528252808320859055805185815290519293869390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025481565b600083815260046020908152604080832033845290915281205482811015610362576040805162461bcd60e51b8152602060048201526009602482015268414c4c4f57414e434560b81b604482015290519081900360640190fd5b60001981146103c05760008581526004602090815260408083203380855290835292819020868503908190558151908152905188927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35b6103cb85858561047a565b506001949350505050565b601281565b60036020526000908152604090205481565b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561029e5780601f106102735761010080835404028352916020019161029e565b600061045433848461047a565b50600192915050565b600460209081526000928352604080842090915290825290205481565b816104b6576040805162461bcd60e51b8152602060048201526007602482015266544f5f5a45524f60c81b604482015290519081900360640190fd5b60008381526003602052604090205481811015610504576040805162461bcd60e51b815260206004820152600760248201526642414c414e434560c81b604482015290519081900360640190fd5b600084815260036020908152604080832085850390558583529182902080548501905581518481529151859287927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35050505056fea26469706673582212202ed1f601becde0e5fba43ade631c5e20fa87ca86747a7c41488643b1eb14a89664736f6c63430007060033"
250
+ }
251
+ ]
@@ -0,0 +1,43 @@
1
+ /**
2
+ * TypeScript-only example: core Solidity types.
3
+ *
4
+ * This file is intended for developers using QuantumCoin.js from TypeScript.
5
+ * It is not executed by `npm run example`.
6
+ */
7
+
8
+ import type {
9
+ AddressLike,
10
+ BigNumberish,
11
+ BytesLike,
12
+ SolidityInputValue,
13
+ SolidityOutputValue,
14
+ SolidityTypeName,
15
+ } from "quantumcoin/types";
16
+
17
+ // AddressLike is currently a string (32-byte QuantumCoin address).
18
+ const addr: AddressLike = "0x0000000000000000000000000000000000000000000000000000000000001000";
19
+
20
+ // BigNumberish is accepted for uint/int inputs (string | number | bigint).
21
+ const amount: BigNumberish = "123";
22
+
23
+ // BytesLike is a hex string or Uint8Array.
24
+ const data: BytesLike = "0x1234";
25
+
26
+ // Generic mappings for ABI input/output values:
27
+ type T1 = SolidityInputValue<"uint256">; // BigNumberish
28
+ type T2 = SolidityOutputValue<"uint256">; // bigint
29
+ type T3 = SolidityInputValue<"address">; // AddressLike
30
+ type T4 = SolidityOutputValue<"address">; // string
31
+
32
+ // Example: using SolidityTypeName
33
+ const t: SolidityTypeName = "bytes32";
34
+
35
+ void addr;
36
+ void amount;
37
+ void data;
38
+ void t;
39
+ void (null as any as T1);
40
+ void (null as any as T2);
41
+ void (null as any as T3);
42
+ void (null as any as T4);
43
+