quantumswap 0.0.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 (77) hide show
  1. package/.github/workflows/publish-npmjs.yaml +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +287 -0
  4. package/examples/_test-wallet.js +17 -0
  5. package/examples/deploy-IERC20.js +23 -0
  6. package/examples/deploy-QuantumSwapV2ERC20.js +23 -0
  7. package/examples/deploy-QuantumSwapV2Factory.js +23 -0
  8. package/examples/deploy-QuantumSwapV2Pair.js +23 -0
  9. package/examples/deploy-QuantumSwapV2Router02.js +23 -0
  10. package/examples/deploy-WQ.js +23 -0
  11. package/examples/events-IERC20.js +20 -0
  12. package/examples/events-QuantumSwapV2ERC20.js +20 -0
  13. package/examples/events-QuantumSwapV2Factory.js +20 -0
  14. package/examples/events-QuantumSwapV2Pair.js +20 -0
  15. package/examples/events-QuantumSwapV2Router02.js +20 -0
  16. package/examples/events-WQ.js +20 -0
  17. package/examples/offline-signing-IERC20.js +29 -0
  18. package/examples/offline-signing-QuantumSwapV2ERC20.js +29 -0
  19. package/examples/offline-signing-QuantumSwapV2Factory.js +29 -0
  20. package/examples/offline-signing-QuantumSwapV2Pair.js +29 -0
  21. package/examples/offline-signing-QuantumSwapV2Router02.js +29 -0
  22. package/examples/offline-signing-WQ.js +29 -0
  23. package/examples/read-operations-IERC20.js +19 -0
  24. package/examples/read-operations-QuantumSwapV2ERC20.js +19 -0
  25. package/examples/read-operations-QuantumSwapV2Factory.js +19 -0
  26. package/examples/read-operations-QuantumSwapV2Pair.js +19 -0
  27. package/examples/read-operations-QuantumSwapV2Router02.js +19 -0
  28. package/examples/read-operations-WQ.js +19 -0
  29. package/examples/walkthrough-dex-full-flow.js +226 -0
  30. package/examples/walkthrough-dex-full-flow.ts +231 -0
  31. package/examples/write-operations-IERC20.js +22 -0
  32. package/examples/write-operations-QuantumSwapV2ERC20.js +22 -0
  33. package/examples/write-operations-QuantumSwapV2Factory.js +22 -0
  34. package/examples/write-operations-QuantumSwapV2Pair.js +22 -0
  35. package/examples/write-operations-QuantumSwapV2Router02.js +22 -0
  36. package/examples/write-operations-WQ.js +22 -0
  37. package/index.d.ts +1 -0
  38. package/index.js +45 -0
  39. package/package.json +35 -0
  40. package/src/IERC20.d.ts +24 -0
  41. package/src/IERC20.js +348 -0
  42. package/src/IERC20__factory.d.ts +10 -0
  43. package/src/IERC20__factory.js +29 -0
  44. package/src/QuantumSwapV2ERC20.d.ts +24 -0
  45. package/src/QuantumSwapV2ERC20.js +353 -0
  46. package/src/QuantumSwapV2ERC20__factory.d.ts +10 -0
  47. package/src/QuantumSwapV2ERC20__factory.js +29 -0
  48. package/src/QuantumSwapV2Factory.d.ts +24 -0
  49. package/src/QuantumSwapV2Factory.js +310 -0
  50. package/src/QuantumSwapV2Factory__factory.d.ts +10 -0
  51. package/src/QuantumSwapV2Factory__factory.js +29 -0
  52. package/src/QuantumSwapV2Pair.d.ts +44 -0
  53. package/src/QuantumSwapV2Pair.js +847 -0
  54. package/src/QuantumSwapV2Pair__factory.d.ts +10 -0
  55. package/src/QuantumSwapV2Pair__factory.js +29 -0
  56. package/src/QuantumSwapV2Router02.d.ts +47 -0
  57. package/src/QuantumSwapV2Router02.js +1109 -0
  58. package/src/QuantumSwapV2Router02__factory.d.ts +10 -0
  59. package/src/QuantumSwapV2Router02__factory.js +29 -0
  60. package/src/WQ.d.ts +28 -0
  61. package/src/WQ.js +435 -0
  62. package/src/WQ__factory.d.ts +10 -0
  63. package/src/WQ__factory.js +29 -0
  64. package/src/index.d.ts +14 -0
  65. package/src/index.js +15 -0
  66. package/src/quantumcoin-shims.d.ts +25 -0
  67. package/src/types.d.ts +3 -0
  68. package/src/types.js +3 -0
  69. package/test/e2e/IERC20.e2e.test.js +79 -0
  70. package/test/e2e/QuantumSwapV2ERC20.e2e.test.js +79 -0
  71. package/test/e2e/QuantumSwapV2Factory.e2e.test.js +79 -0
  72. package/test/e2e/QuantumSwapV2Pair.e2e.test.js +79 -0
  73. package/test/e2e/QuantumSwapV2Router02.e2e.test.js +79 -0
  74. package/test/e2e/WQ.e2e.test.js +79 -0
  75. package/test/e2e/all-contracts.e2e.test.js +103 -0
  76. package/test/e2e/dex-full-flow.e2e.test.js +353 -0
  77. package/tsconfig.json +14 -0
package/src/IERC20.js ADDED
@@ -0,0 +1,348 @@
1
+ // Auto-generated by sdkgen
2
+ const { Contract } = require("quantumcoin");
3
+
4
+ /**
5
+ * IERC20 - A typed contract interface for IERC20
6
+ */
7
+ class IERC20 extends Contract {
8
+ static abi = [
9
+ {
10
+ "anonymous": false,
11
+ "inputs": [
12
+ {
13
+ "indexed": true,
14
+ "internalType": "address",
15
+ "name": "owner",
16
+ "type": "address"
17
+ },
18
+ {
19
+ "indexed": true,
20
+ "internalType": "address",
21
+ "name": "spender",
22
+ "type": "address"
23
+ },
24
+ {
25
+ "indexed": false,
26
+ "internalType": "uint256",
27
+ "name": "value",
28
+ "type": "uint256"
29
+ }
30
+ ],
31
+ "name": "Approval",
32
+ "type": "event"
33
+ },
34
+ {
35
+ "anonymous": false,
36
+ "inputs": [
37
+ {
38
+ "indexed": true,
39
+ "internalType": "address",
40
+ "name": "from",
41
+ "type": "address"
42
+ },
43
+ {
44
+ "indexed": true,
45
+ "internalType": "address",
46
+ "name": "to",
47
+ "type": "address"
48
+ },
49
+ {
50
+ "indexed": false,
51
+ "internalType": "uint256",
52
+ "name": "value",
53
+ "type": "uint256"
54
+ }
55
+ ],
56
+ "name": "Transfer",
57
+ "type": "event"
58
+ },
59
+ {
60
+ "inputs": [
61
+ {
62
+ "internalType": "address",
63
+ "name": "owner",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "internalType": "address",
68
+ "name": "spender",
69
+ "type": "address"
70
+ }
71
+ ],
72
+ "name": "allowance",
73
+ "outputs": [
74
+ {
75
+ "internalType": "uint256",
76
+ "name": "",
77
+ "type": "uint256"
78
+ }
79
+ ],
80
+ "stateMutability": "view",
81
+ "type": "function"
82
+ },
83
+ {
84
+ "inputs": [
85
+ {
86
+ "internalType": "address",
87
+ "name": "spender",
88
+ "type": "address"
89
+ },
90
+ {
91
+ "internalType": "uint256",
92
+ "name": "value",
93
+ "type": "uint256"
94
+ }
95
+ ],
96
+ "name": "approve",
97
+ "outputs": [
98
+ {
99
+ "internalType": "bool",
100
+ "name": "",
101
+ "type": "bool"
102
+ }
103
+ ],
104
+ "stateMutability": "nonpayable",
105
+ "type": "function"
106
+ },
107
+ {
108
+ "inputs": [
109
+ {
110
+ "internalType": "address",
111
+ "name": "owner",
112
+ "type": "address"
113
+ }
114
+ ],
115
+ "name": "balanceOf",
116
+ "outputs": [
117
+ {
118
+ "internalType": "uint256",
119
+ "name": "",
120
+ "type": "uint256"
121
+ }
122
+ ],
123
+ "stateMutability": "view",
124
+ "type": "function"
125
+ },
126
+ {
127
+ "inputs": [],
128
+ "name": "decimals",
129
+ "outputs": [
130
+ {
131
+ "internalType": "uint8",
132
+ "name": "",
133
+ "type": "uint8"
134
+ }
135
+ ],
136
+ "stateMutability": "view",
137
+ "type": "function"
138
+ },
139
+ {
140
+ "inputs": [],
141
+ "name": "name",
142
+ "outputs": [
143
+ {
144
+ "internalType": "string",
145
+ "name": "",
146
+ "type": "string"
147
+ }
148
+ ],
149
+ "stateMutability": "view",
150
+ "type": "function"
151
+ },
152
+ {
153
+ "inputs": [],
154
+ "name": "symbol",
155
+ "outputs": [
156
+ {
157
+ "internalType": "string",
158
+ "name": "",
159
+ "type": "string"
160
+ }
161
+ ],
162
+ "stateMutability": "view",
163
+ "type": "function"
164
+ },
165
+ {
166
+ "inputs": [],
167
+ "name": "totalSupply",
168
+ "outputs": [
169
+ {
170
+ "internalType": "uint256",
171
+ "name": "",
172
+ "type": "uint256"
173
+ }
174
+ ],
175
+ "stateMutability": "view",
176
+ "type": "function"
177
+ },
178
+ {
179
+ "inputs": [
180
+ {
181
+ "internalType": "address",
182
+ "name": "to",
183
+ "type": "address"
184
+ },
185
+ {
186
+ "internalType": "uint256",
187
+ "name": "value",
188
+ "type": "uint256"
189
+ }
190
+ ],
191
+ "name": "transfer",
192
+ "outputs": [
193
+ {
194
+ "internalType": "bool",
195
+ "name": "",
196
+ "type": "bool"
197
+ }
198
+ ],
199
+ "stateMutability": "nonpayable",
200
+ "type": "function"
201
+ },
202
+ {
203
+ "inputs": [
204
+ {
205
+ "internalType": "address",
206
+ "name": "from",
207
+ "type": "address"
208
+ },
209
+ {
210
+ "internalType": "address",
211
+ "name": "to",
212
+ "type": "address"
213
+ },
214
+ {
215
+ "internalType": "uint256",
216
+ "name": "value",
217
+ "type": "uint256"
218
+ }
219
+ ],
220
+ "name": "transferFrom",
221
+ "outputs": [
222
+ {
223
+ "internalType": "bool",
224
+ "name": "",
225
+ "type": "bool"
226
+ }
227
+ ],
228
+ "stateMutability": "nonpayable",
229
+ "type": "function"
230
+ }
231
+ ];
232
+ static bytecode = "0x";
233
+
234
+ static connect(address, runner) {
235
+ return new IERC20(address, runner);
236
+ }
237
+
238
+ constructor(address, runner, _deployTx) {
239
+ super(address, IERC20.abi, runner, IERC20.bytecode);
240
+ this._deployTx = _deployTx;
241
+
242
+ // Typed populateTransaction helpers (offline signing / sendRawTransaction flows)
243
+ this.populateTransaction = {
244
+ approve: async (spender, value, overrides) => {
245
+ const data = this.interface.encodeFunctionData("approve", [spender, value]);
246
+ return { to: this.address, data, ...(overrides || {}) };
247
+ },
248
+ transfer: async (to, value, overrides) => {
249
+ const data = this.interface.encodeFunctionData("transfer", [to, value]);
250
+ return { to: this.address, data, ...(overrides || {}) };
251
+ },
252
+ transferFrom: async (from, to, value, overrides) => {
253
+ const data = this.interface.encodeFunctionData("transferFrom", [from, to, value]);
254
+ return { to: this.address, data, ...(overrides || {}) };
255
+ },
256
+ };
257
+ }
258
+
259
+ /**
260
+ * allowance
261
+ * @param {import("quantumcoin/types").AddressLike} owner
262
+ * @param {import("quantumcoin/types").AddressLike} spender
263
+ * @returns {Promise<import("quantumcoin/types").Uint256>}
264
+ */
265
+ async allowance(owner, spender) {
266
+ const res = await this.call("allowance", [owner, spender]);
267
+ return Array.isArray(res) ? res[0] : res;
268
+ }
269
+
270
+ /**
271
+ * approve
272
+ * @param {import("quantumcoin/types").AddressLike} spender
273
+ * @param {import("quantumcoin/types").Uint256Like} value
274
+ * @returns {Promise<import("quantumcoin").ContractTransactionResponse>}
275
+ */
276
+ async approve(spender, value, overrides) {
277
+ return this.send("approve", [spender, value], overrides);
278
+ }
279
+
280
+ /**
281
+ * balanceOf
282
+ * @param {import("quantumcoin/types").AddressLike} owner
283
+ * @returns {Promise<import("quantumcoin/types").Uint256>}
284
+ */
285
+ async balanceOf(owner) {
286
+ const res = await this.call("balanceOf", [owner]);
287
+ return Array.isArray(res) ? res[0] : res;
288
+ }
289
+
290
+ /**
291
+ * decimals
292
+ * @returns {Promise<import("quantumcoin/types").Uint8>}
293
+ */
294
+ async decimals() {
295
+ const res = await this.call("decimals", []);
296
+ return Array.isArray(res) ? res[0] : res;
297
+ }
298
+
299
+ /**
300
+ * name
301
+ * @returns {Promise<string>}
302
+ */
303
+ async name() {
304
+ const res = await this.call("name", []);
305
+ return Array.isArray(res) ? res[0] : res;
306
+ }
307
+
308
+ /**
309
+ * symbol
310
+ * @returns {Promise<string>}
311
+ */
312
+ async symbol() {
313
+ const res = await this.call("symbol", []);
314
+ return Array.isArray(res) ? res[0] : res;
315
+ }
316
+
317
+ /**
318
+ * totalSupply
319
+ * @returns {Promise<import("quantumcoin/types").Uint256>}
320
+ */
321
+ async totalSupply() {
322
+ const res = await this.call("totalSupply", []);
323
+ return Array.isArray(res) ? res[0] : res;
324
+ }
325
+
326
+ /**
327
+ * transfer
328
+ * @param {import("quantumcoin/types").AddressLike} to
329
+ * @param {import("quantumcoin/types").Uint256Like} value
330
+ * @returns {Promise<import("quantumcoin").ContractTransactionResponse>}
331
+ */
332
+ async transfer(to, value, overrides) {
333
+ return this.send("transfer", [to, value], overrides);
334
+ }
335
+
336
+ /**
337
+ * transferFrom
338
+ * @param {import("quantumcoin/types").AddressLike} from
339
+ * @param {import("quantumcoin/types").AddressLike} to
340
+ * @param {import("quantumcoin/types").Uint256Like} value
341
+ * @returns {Promise<import("quantumcoin").ContractTransactionResponse>}
342
+ */
343
+ async transferFrom(from, to, value, overrides) {
344
+ return this.send("transferFrom", [from, to, value], overrides);
345
+ }
346
+ }
347
+
348
+ module.exports = { IERC20 };
@@ -0,0 +1,10 @@
1
+ // Auto-generated by sdkgen
2
+ import { ContractFactory, ContractRunner } from "quantumcoin";
3
+ import { IERC20 } from "./IERC20";
4
+ import type * as Types from "./types";
5
+
6
+ export declare class IERC20__factory extends ContractFactory {
7
+ constructor(runner: ContractRunner);
8
+ deploy(overrides?: any): Promise<IERC20>;
9
+ static connect(address: string, runner?: ContractRunner): IERC20;
10
+ }
@@ -0,0 +1,29 @@
1
+ // Auto-generated by sdkgen
2
+ const { ContractFactory, getCreateAddress } = require("quantumcoin");
3
+ const { IERC20 } = require("./IERC20");
4
+
5
+ class IERC20__factory extends ContractFactory {
6
+ constructor(runner) {
7
+ super(IERC20.abi, IERC20.bytecode, runner);
8
+ }
9
+
10
+ async deploy(overrides) {
11
+ const signer = this.signer;
12
+ if (!signer) { throw new Error("missing signer"); }
13
+ const from = signer.getAddress ? await signer.getAddress() : signer.address;
14
+ const provider = signer.provider;
15
+ if (!provider || !provider.getTransactionCount) { throw new Error("missing provider"); }
16
+ let nonce;
17
+ try { nonce = await provider.getTransactionCount(from, "pending"); } catch { nonce = await provider.getTransactionCount(from, "latest"); }
18
+ const address = getCreateAddress({ from, nonce });
19
+ const txReq = this.getDeployTransaction();
20
+ const tx = await signer.sendTransaction({ ...txReq, ...(overrides || {}), nonce });
21
+ return new IERC20(address, signer, tx);
22
+ }
23
+
24
+ static connect(address, runner) {
25
+ return IERC20.connect(address, runner);
26
+ }
27
+ }
28
+
29
+ module.exports = { IERC20__factory };
@@ -0,0 +1,24 @@
1
+ // Auto-generated by sdkgen
2
+ import { Contract, ContractRunner, ContractTransactionResponse, TransactionResponse } from "quantumcoin";
3
+ import type * as Types from "./types";
4
+
5
+ export declare class QuantumSwapV2ERC20 extends Contract {
6
+ static readonly abi: readonly any[];
7
+ static readonly bytecode: string;
8
+ static connect(address: string, runner?: ContractRunner): QuantumSwapV2ERC20;
9
+ constructor(address: string, runner?: ContractRunner, _deployTx?: TransactionResponse);
10
+ readonly populateTransaction: {
11
+ approve(spender: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
12
+ transfer(to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
13
+ transferFrom(from: Types.AddressLike, to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
14
+ };
15
+ allowance(arg0: Types.AddressLike, arg1: Types.AddressLike): Promise<Types.Uint256>;
16
+ approve(spender: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<ContractTransactionResponse>;
17
+ balanceOf(arg0: Types.AddressLike): Promise<Types.Uint256>;
18
+ decimals(): Promise<Types.Uint8>;
19
+ name(): Promise<string>;
20
+ symbol(): Promise<string>;
21
+ totalSupply(): Promise<Types.Uint256>;
22
+ transfer(to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<ContractTransactionResponse>;
23
+ transferFrom(from: Types.AddressLike, to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<ContractTransactionResponse>;
24
+ }