@gitmyabi-stg/qai 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.
- package/README.md +108 -0
- package/contracts/QuantixAIERC20.d.ts +629 -0
- package/contracts/QuantixAIERC20.js +690 -0
- package/contracts/QuantixAIERC20.ts +839 -0
- package/contracts/index.d.ts +2 -0
- package/contracts/index.js +7 -0
- package/contracts/index.ts +3 -0
- package/index.d.ts +1 -0
- package/index.js +19 -0
- package/package.json +43 -0
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
|
|
2
|
+
import { getContract } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* QuantixAIERC20 ABI
|
|
6
|
+
*
|
|
7
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
8
|
+
*/
|
|
9
|
+
export const QuantixAIERC20Abi = [
|
|
10
|
+
{
|
|
11
|
+
"inputs": [],
|
|
12
|
+
"stateMutability": "nonpayable",
|
|
13
|
+
"type": "constructor"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"inputs": [
|
|
17
|
+
{
|
|
18
|
+
"internalType": "address",
|
|
19
|
+
"name": "spender",
|
|
20
|
+
"type": "address"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"internalType": "uint256",
|
|
24
|
+
"name": "allowance",
|
|
25
|
+
"type": "uint256"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"internalType": "uint256",
|
|
29
|
+
"name": "needed",
|
|
30
|
+
"type": "uint256"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"name": "ERC20InsufficientAllowance",
|
|
34
|
+
"type": "error"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"inputs": [
|
|
38
|
+
{
|
|
39
|
+
"internalType": "address",
|
|
40
|
+
"name": "sender",
|
|
41
|
+
"type": "address"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"internalType": "uint256",
|
|
45
|
+
"name": "balance",
|
|
46
|
+
"type": "uint256"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"internalType": "uint256",
|
|
50
|
+
"name": "needed",
|
|
51
|
+
"type": "uint256"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"name": "ERC20InsufficientBalance",
|
|
55
|
+
"type": "error"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"inputs": [
|
|
59
|
+
{
|
|
60
|
+
"internalType": "address",
|
|
61
|
+
"name": "approver",
|
|
62
|
+
"type": "address"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"name": "ERC20InvalidApprover",
|
|
66
|
+
"type": "error"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"inputs": [
|
|
70
|
+
{
|
|
71
|
+
"internalType": "address",
|
|
72
|
+
"name": "receiver",
|
|
73
|
+
"type": "address"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"name": "ERC20InvalidReceiver",
|
|
77
|
+
"type": "error"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"inputs": [
|
|
81
|
+
{
|
|
82
|
+
"internalType": "address",
|
|
83
|
+
"name": "sender",
|
|
84
|
+
"type": "address"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"name": "ERC20InvalidSender",
|
|
88
|
+
"type": "error"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"inputs": [
|
|
92
|
+
{
|
|
93
|
+
"internalType": "address",
|
|
94
|
+
"name": "spender",
|
|
95
|
+
"type": "address"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"name": "ERC20InvalidSpender",
|
|
99
|
+
"type": "error"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"inputs": [
|
|
103
|
+
{
|
|
104
|
+
"internalType": "address",
|
|
105
|
+
"name": "owner",
|
|
106
|
+
"type": "address"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"name": "OwnableInvalidOwner",
|
|
110
|
+
"type": "error"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"inputs": [
|
|
114
|
+
{
|
|
115
|
+
"internalType": "address",
|
|
116
|
+
"name": "account",
|
|
117
|
+
"type": "address"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"name": "OwnableUnauthorizedAccount",
|
|
121
|
+
"type": "error"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"anonymous": false,
|
|
125
|
+
"inputs": [
|
|
126
|
+
{
|
|
127
|
+
"indexed": true,
|
|
128
|
+
"internalType": "address",
|
|
129
|
+
"name": "owner",
|
|
130
|
+
"type": "address"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"indexed": true,
|
|
134
|
+
"internalType": "address",
|
|
135
|
+
"name": "spender",
|
|
136
|
+
"type": "address"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"indexed": false,
|
|
140
|
+
"internalType": "uint256",
|
|
141
|
+
"name": "value",
|
|
142
|
+
"type": "uint256"
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"name": "Approval",
|
|
146
|
+
"type": "event"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"anonymous": false,
|
|
150
|
+
"inputs": [
|
|
151
|
+
{
|
|
152
|
+
"indexed": true,
|
|
153
|
+
"internalType": "address",
|
|
154
|
+
"name": "previousOwner",
|
|
155
|
+
"type": "address"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"indexed": true,
|
|
159
|
+
"internalType": "address",
|
|
160
|
+
"name": "newOwner",
|
|
161
|
+
"type": "address"
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"name": "OwnershipTransferred",
|
|
165
|
+
"type": "event"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"anonymous": false,
|
|
169
|
+
"inputs": [
|
|
170
|
+
{
|
|
171
|
+
"indexed": true,
|
|
172
|
+
"internalType": "address",
|
|
173
|
+
"name": "from",
|
|
174
|
+
"type": "address"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"indexed": true,
|
|
178
|
+
"internalType": "address",
|
|
179
|
+
"name": "to",
|
|
180
|
+
"type": "address"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"indexed": false,
|
|
184
|
+
"internalType": "uint256",
|
|
185
|
+
"name": "value",
|
|
186
|
+
"type": "uint256"
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"name": "Transfer",
|
|
190
|
+
"type": "event"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"inputs": [
|
|
194
|
+
{
|
|
195
|
+
"internalType": "address",
|
|
196
|
+
"name": "owner",
|
|
197
|
+
"type": "address"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"internalType": "address",
|
|
201
|
+
"name": "spender",
|
|
202
|
+
"type": "address"
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"name": "allowance",
|
|
206
|
+
"outputs": [
|
|
207
|
+
{
|
|
208
|
+
"internalType": "uint256",
|
|
209
|
+
"name": "",
|
|
210
|
+
"type": "uint256"
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"stateMutability": "view",
|
|
214
|
+
"type": "function"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"inputs": [
|
|
218
|
+
{
|
|
219
|
+
"internalType": "address",
|
|
220
|
+
"name": "spender",
|
|
221
|
+
"type": "address"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"internalType": "uint256",
|
|
225
|
+
"name": "value",
|
|
226
|
+
"type": "uint256"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"name": "approve",
|
|
230
|
+
"outputs": [
|
|
231
|
+
{
|
|
232
|
+
"internalType": "bool",
|
|
233
|
+
"name": "",
|
|
234
|
+
"type": "bool"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"stateMutability": "nonpayable",
|
|
238
|
+
"type": "function"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"inputs": [
|
|
242
|
+
{
|
|
243
|
+
"internalType": "address",
|
|
244
|
+
"name": "account",
|
|
245
|
+
"type": "address"
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
"name": "balanceOf",
|
|
249
|
+
"outputs": [
|
|
250
|
+
{
|
|
251
|
+
"internalType": "uint256",
|
|
252
|
+
"name": "",
|
|
253
|
+
"type": "uint256"
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
"stateMutability": "view",
|
|
257
|
+
"type": "function"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"inputs": [],
|
|
261
|
+
"name": "decimals",
|
|
262
|
+
"outputs": [
|
|
263
|
+
{
|
|
264
|
+
"internalType": "uint8",
|
|
265
|
+
"name": "",
|
|
266
|
+
"type": "uint8"
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"stateMutability": "view",
|
|
270
|
+
"type": "function"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"inputs": [],
|
|
274
|
+
"name": "name",
|
|
275
|
+
"outputs": [
|
|
276
|
+
{
|
|
277
|
+
"internalType": "string",
|
|
278
|
+
"name": "",
|
|
279
|
+
"type": "string"
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
"stateMutability": "view",
|
|
283
|
+
"type": "function"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"inputs": [],
|
|
287
|
+
"name": "owner",
|
|
288
|
+
"outputs": [
|
|
289
|
+
{
|
|
290
|
+
"internalType": "address",
|
|
291
|
+
"name": "",
|
|
292
|
+
"type": "address"
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
"stateMutability": "view",
|
|
296
|
+
"type": "function"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"inputs": [],
|
|
300
|
+
"name": "renounceOwnership",
|
|
301
|
+
"outputs": [],
|
|
302
|
+
"stateMutability": "nonpayable",
|
|
303
|
+
"type": "function"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"inputs": [],
|
|
307
|
+
"name": "symbol",
|
|
308
|
+
"outputs": [
|
|
309
|
+
{
|
|
310
|
+
"internalType": "string",
|
|
311
|
+
"name": "",
|
|
312
|
+
"type": "string"
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
"stateMutability": "view",
|
|
316
|
+
"type": "function"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"inputs": [],
|
|
320
|
+
"name": "totalSupply",
|
|
321
|
+
"outputs": [
|
|
322
|
+
{
|
|
323
|
+
"internalType": "uint256",
|
|
324
|
+
"name": "",
|
|
325
|
+
"type": "uint256"
|
|
326
|
+
}
|
|
327
|
+
],
|
|
328
|
+
"stateMutability": "view",
|
|
329
|
+
"type": "function"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"inputs": [
|
|
333
|
+
{
|
|
334
|
+
"internalType": "address",
|
|
335
|
+
"name": "to",
|
|
336
|
+
"type": "address"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"internalType": "uint256",
|
|
340
|
+
"name": "value",
|
|
341
|
+
"type": "uint256"
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
"name": "transfer",
|
|
345
|
+
"outputs": [
|
|
346
|
+
{
|
|
347
|
+
"internalType": "bool",
|
|
348
|
+
"name": "",
|
|
349
|
+
"type": "bool"
|
|
350
|
+
}
|
|
351
|
+
],
|
|
352
|
+
"stateMutability": "nonpayable",
|
|
353
|
+
"type": "function"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"inputs": [
|
|
357
|
+
{
|
|
358
|
+
"internalType": "address",
|
|
359
|
+
"name": "from",
|
|
360
|
+
"type": "address"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"internalType": "address",
|
|
364
|
+
"name": "to",
|
|
365
|
+
"type": "address"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"internalType": "uint256",
|
|
369
|
+
"name": "value",
|
|
370
|
+
"type": "uint256"
|
|
371
|
+
}
|
|
372
|
+
],
|
|
373
|
+
"name": "transferFrom",
|
|
374
|
+
"outputs": [
|
|
375
|
+
{
|
|
376
|
+
"internalType": "bool",
|
|
377
|
+
"name": "",
|
|
378
|
+
"type": "bool"
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
"stateMutability": "nonpayable",
|
|
382
|
+
"type": "function"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"inputs": [
|
|
386
|
+
{
|
|
387
|
+
"internalType": "address",
|
|
388
|
+
"name": "newOwner",
|
|
389
|
+
"type": "address"
|
|
390
|
+
}
|
|
391
|
+
],
|
|
392
|
+
"name": "transferOwnership",
|
|
393
|
+
"outputs": [],
|
|
394
|
+
"stateMutability": "nonpayable",
|
|
395
|
+
"type": "function"
|
|
396
|
+
}
|
|
397
|
+
] as const satisfies Abi;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Type-safe ABI for QuantixAIERC20
|
|
401
|
+
*/
|
|
402
|
+
export type QuantixAIERC20Abi = typeof QuantixAIERC20Abi;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Contract instance type for QuantixAIERC20
|
|
406
|
+
*/
|
|
407
|
+
// Use any for contract type to avoid complex viem type issues
|
|
408
|
+
// The runtime behavior is type-safe through viem's ABI typing
|
|
409
|
+
export type QuantixAIERC20Contract = any;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* QuantixAIERC20 Contract Class
|
|
413
|
+
*
|
|
414
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
419
|
+
* import { mainnet } from 'viem/chains';
|
|
420
|
+
* import { QuantixAIERC20 } from 'QuantixAIERC20';
|
|
421
|
+
*
|
|
422
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
423
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
424
|
+
*
|
|
425
|
+
* const contract = new QuantixAIERC20('0x...', { publicClient, walletClient });
|
|
426
|
+
*
|
|
427
|
+
* // Read functions
|
|
428
|
+
* const result = await contract.balanceOf('0x...');
|
|
429
|
+
*
|
|
430
|
+
* // Write functions
|
|
431
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
432
|
+
*
|
|
433
|
+
* // Simulate transactions (dry-run)
|
|
434
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
435
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
436
|
+
*
|
|
437
|
+
* // Watch events
|
|
438
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
439
|
+
* console.log('Transfer event:', event);
|
|
440
|
+
* });
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
export class QuantixAIERC20 {
|
|
444
|
+
private contract: QuantixAIERC20Contract;
|
|
445
|
+
private contractAddress: Address;
|
|
446
|
+
private publicClient: PublicClient;
|
|
447
|
+
|
|
448
|
+
constructor(
|
|
449
|
+
address: Address,
|
|
450
|
+
clients: {
|
|
451
|
+
publicClient: PublicClient;
|
|
452
|
+
walletClient?: WalletClient;
|
|
453
|
+
}
|
|
454
|
+
) {
|
|
455
|
+
this.contractAddress = address;
|
|
456
|
+
this.publicClient = clients.publicClient;
|
|
457
|
+
this.contract = getContract({
|
|
458
|
+
address,
|
|
459
|
+
abi: QuantixAIERC20Abi,
|
|
460
|
+
client: {
|
|
461
|
+
public: clients.publicClient,
|
|
462
|
+
wallet: clients.walletClient,
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Get the contract address
|
|
469
|
+
*/
|
|
470
|
+
get address(): Address {
|
|
471
|
+
return this.contractAddress;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Get the underlying viem contract instance.
|
|
476
|
+
*/
|
|
477
|
+
getContract(): QuantixAIERC20Contract {
|
|
478
|
+
return this.contract;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* allowance
|
|
483
|
+
* view
|
|
484
|
+
*/
|
|
485
|
+
async allowance(owner: `0x${string}`, spender: `0x${string}`): Promise<bigint> {
|
|
486
|
+
return this.contract.read.allowance([owner, spender] as const) as Promise<bigint>;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* balanceOf
|
|
491
|
+
* view
|
|
492
|
+
*/
|
|
493
|
+
async balanceOf(account: `0x${string}`): Promise<bigint> {
|
|
494
|
+
return this.contract.read.balanceOf([account] as const) as Promise<bigint>;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* decimals
|
|
499
|
+
* view
|
|
500
|
+
*/
|
|
501
|
+
async decimals(): Promise<bigint> {
|
|
502
|
+
return this.contract.read.decimals() as Promise<bigint>;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* name
|
|
507
|
+
* view
|
|
508
|
+
*/
|
|
509
|
+
async name(): Promise<string> {
|
|
510
|
+
return this.contract.read.name() as Promise<string>;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* owner
|
|
515
|
+
* view
|
|
516
|
+
*/
|
|
517
|
+
async owner(): Promise<`0x${string}`> {
|
|
518
|
+
return this.contract.read.owner() as Promise<`0x${string}`>;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* symbol
|
|
523
|
+
* view
|
|
524
|
+
*/
|
|
525
|
+
async symbol(): Promise<string> {
|
|
526
|
+
return this.contract.read.symbol() as Promise<string>;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* totalSupply
|
|
531
|
+
* view
|
|
532
|
+
*/
|
|
533
|
+
async totalSupply(): Promise<bigint> {
|
|
534
|
+
return this.contract.read.totalSupply() as Promise<bigint>;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* approve
|
|
539
|
+
* nonpayable
|
|
540
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
541
|
+
*/
|
|
542
|
+
async approve(spender: `0x${string}`, value: bigint, options?: {
|
|
543
|
+
accessList?: import('viem').AccessList;
|
|
544
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
545
|
+
chain?: import('viem').Chain | null;
|
|
546
|
+
dataSuffix?: `0x${string}`;
|
|
547
|
+
gas?: bigint;
|
|
548
|
+
gasPrice?: bigint;
|
|
549
|
+
maxFeePerGas?: bigint;
|
|
550
|
+
maxPriorityFeePerGas?: bigint;
|
|
551
|
+
nonce?: number;
|
|
552
|
+
value?: bigint;
|
|
553
|
+
}): Promise<`0x${string}`> {
|
|
554
|
+
if (!this.contract.write) {
|
|
555
|
+
throw new Error('Wallet client is required for write operations');
|
|
556
|
+
}
|
|
557
|
+
return this.contract.write.approve([spender, value] as const, options) as Promise<`0x${string}`>;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* renounceOwnership
|
|
562
|
+
* nonpayable
|
|
563
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
564
|
+
*/
|
|
565
|
+
async renounceOwnership(options?: {
|
|
566
|
+
accessList?: import('viem').AccessList;
|
|
567
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
568
|
+
chain?: import('viem').Chain | null;
|
|
569
|
+
dataSuffix?: `0x${string}`;
|
|
570
|
+
gas?: bigint;
|
|
571
|
+
gasPrice?: bigint;
|
|
572
|
+
maxFeePerGas?: bigint;
|
|
573
|
+
maxPriorityFeePerGas?: bigint;
|
|
574
|
+
nonce?: number;
|
|
575
|
+
value?: bigint;
|
|
576
|
+
}): Promise<`0x${string}`> {
|
|
577
|
+
if (!this.contract.write) {
|
|
578
|
+
throw new Error('Wallet client is required for write operations');
|
|
579
|
+
}
|
|
580
|
+
return this.contract.write.renounceOwnership(options) as Promise<`0x${string}`>;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* transfer
|
|
585
|
+
* nonpayable
|
|
586
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
587
|
+
*/
|
|
588
|
+
async transfer(to: `0x${string}`, value: bigint, options?: {
|
|
589
|
+
accessList?: import('viem').AccessList;
|
|
590
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
591
|
+
chain?: import('viem').Chain | null;
|
|
592
|
+
dataSuffix?: `0x${string}`;
|
|
593
|
+
gas?: bigint;
|
|
594
|
+
gasPrice?: bigint;
|
|
595
|
+
maxFeePerGas?: bigint;
|
|
596
|
+
maxPriorityFeePerGas?: bigint;
|
|
597
|
+
nonce?: number;
|
|
598
|
+
value?: bigint;
|
|
599
|
+
}): Promise<`0x${string}`> {
|
|
600
|
+
if (!this.contract.write) {
|
|
601
|
+
throw new Error('Wallet client is required for write operations');
|
|
602
|
+
}
|
|
603
|
+
return this.contract.write.transfer([to, value] as const, options) as Promise<`0x${string}`>;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* transferFrom
|
|
608
|
+
* nonpayable
|
|
609
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
610
|
+
*/
|
|
611
|
+
async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: {
|
|
612
|
+
accessList?: import('viem').AccessList;
|
|
613
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
614
|
+
chain?: import('viem').Chain | null;
|
|
615
|
+
dataSuffix?: `0x${string}`;
|
|
616
|
+
gas?: bigint;
|
|
617
|
+
gasPrice?: bigint;
|
|
618
|
+
maxFeePerGas?: bigint;
|
|
619
|
+
maxPriorityFeePerGas?: bigint;
|
|
620
|
+
nonce?: number;
|
|
621
|
+
value?: bigint;
|
|
622
|
+
}): Promise<`0x${string}`> {
|
|
623
|
+
if (!this.contract.write) {
|
|
624
|
+
throw new Error('Wallet client is required for write operations');
|
|
625
|
+
}
|
|
626
|
+
return this.contract.write.transferFrom([from, to, value] as const, options) as Promise<`0x${string}`>;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* transferOwnership
|
|
631
|
+
* nonpayable
|
|
632
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
633
|
+
*/
|
|
634
|
+
async transferOwnership(newOwner: `0x${string}`, options?: {
|
|
635
|
+
accessList?: import('viem').AccessList;
|
|
636
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
637
|
+
chain?: import('viem').Chain | null;
|
|
638
|
+
dataSuffix?: `0x${string}`;
|
|
639
|
+
gas?: bigint;
|
|
640
|
+
gasPrice?: bigint;
|
|
641
|
+
maxFeePerGas?: bigint;
|
|
642
|
+
maxPriorityFeePerGas?: bigint;
|
|
643
|
+
nonce?: number;
|
|
644
|
+
value?: bigint;
|
|
645
|
+
}): Promise<`0x${string}`> {
|
|
646
|
+
if (!this.contract.write) {
|
|
647
|
+
throw new Error('Wallet client is required for write operations');
|
|
648
|
+
}
|
|
649
|
+
return this.contract.write.transferOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
659
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
660
|
+
* console.log('Would succeed:', result.result);
|
|
661
|
+
*/
|
|
662
|
+
get simulate() {
|
|
663
|
+
const contract = this.contract;
|
|
664
|
+
if (!contract.simulate) {
|
|
665
|
+
throw new Error('Public client is required for simulation');
|
|
666
|
+
}
|
|
667
|
+
return {
|
|
668
|
+
/**
|
|
669
|
+
* Simulate approve
|
|
670
|
+
* Returns gas estimate and result without sending transaction
|
|
671
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
672
|
+
*/
|
|
673
|
+
async approve(spender: `0x${string}`, value: bigint, options?: {
|
|
674
|
+
accessList?: import('viem').AccessList;
|
|
675
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
676
|
+
chain?: import('viem').Chain | null;
|
|
677
|
+
dataSuffix?: `0x${string}`;
|
|
678
|
+
gas?: bigint;
|
|
679
|
+
gasPrice?: bigint;
|
|
680
|
+
maxFeePerGas?: bigint;
|
|
681
|
+
maxPriorityFeePerGas?: bigint;
|
|
682
|
+
nonce?: number;
|
|
683
|
+
value?: bigint;
|
|
684
|
+
}): Promise<boolean> {
|
|
685
|
+
return contract.simulate.approve([spender, value] as const, options) as Promise<boolean>;
|
|
686
|
+
},
|
|
687
|
+
/**
|
|
688
|
+
* Simulate renounceOwnership
|
|
689
|
+
* Returns gas estimate and result without sending transaction
|
|
690
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
691
|
+
*/
|
|
692
|
+
async renounceOwnership(options?: {
|
|
693
|
+
accessList?: import('viem').AccessList;
|
|
694
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
695
|
+
chain?: import('viem').Chain | null;
|
|
696
|
+
dataSuffix?: `0x${string}`;
|
|
697
|
+
gas?: bigint;
|
|
698
|
+
gasPrice?: bigint;
|
|
699
|
+
maxFeePerGas?: bigint;
|
|
700
|
+
maxPriorityFeePerGas?: bigint;
|
|
701
|
+
nonce?: number;
|
|
702
|
+
value?: bigint;
|
|
703
|
+
}): Promise<void> {
|
|
704
|
+
return contract.simulate.renounceOwnership(options) as Promise<void>;
|
|
705
|
+
},
|
|
706
|
+
/**
|
|
707
|
+
* Simulate transfer
|
|
708
|
+
* Returns gas estimate and result without sending transaction
|
|
709
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
710
|
+
*/
|
|
711
|
+
async transfer(to: `0x${string}`, value: bigint, options?: {
|
|
712
|
+
accessList?: import('viem').AccessList;
|
|
713
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
714
|
+
chain?: import('viem').Chain | null;
|
|
715
|
+
dataSuffix?: `0x${string}`;
|
|
716
|
+
gas?: bigint;
|
|
717
|
+
gasPrice?: bigint;
|
|
718
|
+
maxFeePerGas?: bigint;
|
|
719
|
+
maxPriorityFeePerGas?: bigint;
|
|
720
|
+
nonce?: number;
|
|
721
|
+
value?: bigint;
|
|
722
|
+
}): Promise<boolean> {
|
|
723
|
+
return contract.simulate.transfer([to, value] as const, options) as Promise<boolean>;
|
|
724
|
+
},
|
|
725
|
+
/**
|
|
726
|
+
* Simulate transferFrom
|
|
727
|
+
* Returns gas estimate and result without sending transaction
|
|
728
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
729
|
+
*/
|
|
730
|
+
async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: {
|
|
731
|
+
accessList?: import('viem').AccessList;
|
|
732
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
733
|
+
chain?: import('viem').Chain | null;
|
|
734
|
+
dataSuffix?: `0x${string}`;
|
|
735
|
+
gas?: bigint;
|
|
736
|
+
gasPrice?: bigint;
|
|
737
|
+
maxFeePerGas?: bigint;
|
|
738
|
+
maxPriorityFeePerGas?: bigint;
|
|
739
|
+
nonce?: number;
|
|
740
|
+
value?: bigint;
|
|
741
|
+
}): Promise<boolean> {
|
|
742
|
+
return contract.simulate.transferFrom([from, to, value] as const, options) as Promise<boolean>;
|
|
743
|
+
},
|
|
744
|
+
/**
|
|
745
|
+
* Simulate transferOwnership
|
|
746
|
+
* Returns gas estimate and result without sending transaction
|
|
747
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
748
|
+
*/
|
|
749
|
+
async transferOwnership(newOwner: `0x${string}`, options?: {
|
|
750
|
+
accessList?: import('viem').AccessList;
|
|
751
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
752
|
+
chain?: import('viem').Chain | null;
|
|
753
|
+
dataSuffix?: `0x${string}`;
|
|
754
|
+
gas?: bigint;
|
|
755
|
+
gasPrice?: bigint;
|
|
756
|
+
maxFeePerGas?: bigint;
|
|
757
|
+
maxPriorityFeePerGas?: bigint;
|
|
758
|
+
nonce?: number;
|
|
759
|
+
value?: bigint;
|
|
760
|
+
}): Promise<void> {
|
|
761
|
+
return contract.simulate.transferOwnership([newOwner] as const, options) as Promise<void>;
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Watch contract events
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* // Watch all Transfer events
|
|
771
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
772
|
+
* console.log('Transfer:', event);
|
|
773
|
+
* });
|
|
774
|
+
*
|
|
775
|
+
* // Stop watching
|
|
776
|
+
* unwatch();
|
|
777
|
+
*/
|
|
778
|
+
get watch() {
|
|
779
|
+
return {
|
|
780
|
+
/**
|
|
781
|
+
* Watch Approval events
|
|
782
|
+
* @param callback Function to call when event is emitted
|
|
783
|
+
* @param filter Optional filter for indexed parameters
|
|
784
|
+
* @returns Unwatch function to stop listening
|
|
785
|
+
*/
|
|
786
|
+
Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner?: `0x${string}` | `0x${string}`[] | null; spender?: `0x${string}` | `0x${string}`[] | null }) => {
|
|
787
|
+
return this.publicClient.watchContractEvent({
|
|
788
|
+
address: this.contractAddress,
|
|
789
|
+
abi: QuantixAIERC20Abi,
|
|
790
|
+
eventName: 'Approval',
|
|
791
|
+
args: filter as any,
|
|
792
|
+
onLogs: (logs: any[]) => {
|
|
793
|
+
logs.forEach((log: any) => {
|
|
794
|
+
callback(log.args as any);
|
|
795
|
+
});
|
|
796
|
+
},
|
|
797
|
+
}) as () => void;
|
|
798
|
+
},
|
|
799
|
+
/**
|
|
800
|
+
* Watch OwnershipTransferred events
|
|
801
|
+
* @param callback Function to call when event is emitted
|
|
802
|
+
* @param filter Optional filter for indexed parameters
|
|
803
|
+
* @returns Unwatch function to stop listening
|
|
804
|
+
*/
|
|
805
|
+
OwnershipTransferred: (callback: (event: { previousOwner: `0x${string}`; newOwner: `0x${string}` }) => void, filter?: { previousOwner?: `0x${string}` | `0x${string}`[] | null; newOwner?: `0x${string}` | `0x${string}`[] | null }) => {
|
|
806
|
+
return this.publicClient.watchContractEvent({
|
|
807
|
+
address: this.contractAddress,
|
|
808
|
+
abi: QuantixAIERC20Abi,
|
|
809
|
+
eventName: 'OwnershipTransferred',
|
|
810
|
+
args: filter as any,
|
|
811
|
+
onLogs: (logs: any[]) => {
|
|
812
|
+
logs.forEach((log: any) => {
|
|
813
|
+
callback(log.args as any);
|
|
814
|
+
});
|
|
815
|
+
},
|
|
816
|
+
}) as () => void;
|
|
817
|
+
},
|
|
818
|
+
/**
|
|
819
|
+
* Watch Transfer events
|
|
820
|
+
* @param callback Function to call when event is emitted
|
|
821
|
+
* @param filter Optional filter for indexed parameters
|
|
822
|
+
* @returns Unwatch function to stop listening
|
|
823
|
+
*/
|
|
824
|
+
Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from?: `0x${string}` | `0x${string}`[] | null; to?: `0x${string}` | `0x${string}`[] | null }) => {
|
|
825
|
+
return this.publicClient.watchContractEvent({
|
|
826
|
+
address: this.contractAddress,
|
|
827
|
+
abi: QuantixAIERC20Abi,
|
|
828
|
+
eventName: 'Transfer',
|
|
829
|
+
args: filter as any,
|
|
830
|
+
onLogs: (logs: any[]) => {
|
|
831
|
+
logs.forEach((log: any) => {
|
|
832
|
+
callback(log.args as any);
|
|
833
|
+
});
|
|
834
|
+
},
|
|
835
|
+
}) as () => void;
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
}
|