@gitmyabi-stg/gcr 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/CoinToken.d.ts +972 -0
- package/contracts/CoinToken.js +1009 -0
- package/contracts/CoinToken.ts +1299 -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,1299 @@
|
|
|
1
|
+
import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
|
|
2
|
+
import { getContract } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CoinToken ABI
|
|
6
|
+
*
|
|
7
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
8
|
+
*/
|
|
9
|
+
export const CoinTokenAbi = [
|
|
10
|
+
{
|
|
11
|
+
"constant": true,
|
|
12
|
+
"inputs": [],
|
|
13
|
+
"name": "name",
|
|
14
|
+
"outputs": [
|
|
15
|
+
{
|
|
16
|
+
"name": "",
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"payable": false,
|
|
21
|
+
"stateMutability": "view",
|
|
22
|
+
"type": "function"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"constant": false,
|
|
26
|
+
"inputs": [
|
|
27
|
+
{
|
|
28
|
+
"name": "_spender",
|
|
29
|
+
"type": "address"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "_value",
|
|
33
|
+
"type": "uint256"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"name": "approve",
|
|
37
|
+
"outputs": [
|
|
38
|
+
{
|
|
39
|
+
"name": "",
|
|
40
|
+
"type": "bool"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"payable": false,
|
|
44
|
+
"stateMutability": "nonpayable",
|
|
45
|
+
"type": "function"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"constant": true,
|
|
49
|
+
"inputs": [],
|
|
50
|
+
"name": "totalSupply",
|
|
51
|
+
"outputs": [
|
|
52
|
+
{
|
|
53
|
+
"name": "",
|
|
54
|
+
"type": "uint256"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"payable": false,
|
|
58
|
+
"stateMutability": "view",
|
|
59
|
+
"type": "function"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"constant": false,
|
|
63
|
+
"inputs": [
|
|
64
|
+
{
|
|
65
|
+
"name": "_from",
|
|
66
|
+
"type": "address"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "_to",
|
|
70
|
+
"type": "address"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "_value",
|
|
74
|
+
"type": "uint256"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"name": "transferFrom",
|
|
78
|
+
"outputs": [
|
|
79
|
+
{
|
|
80
|
+
"name": "",
|
|
81
|
+
"type": "bool"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"payable": false,
|
|
85
|
+
"stateMutability": "nonpayable",
|
|
86
|
+
"type": "function"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"constant": true,
|
|
90
|
+
"inputs": [],
|
|
91
|
+
"name": "decimals",
|
|
92
|
+
"outputs": [
|
|
93
|
+
{
|
|
94
|
+
"name": "",
|
|
95
|
+
"type": "uint256"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"payable": false,
|
|
99
|
+
"stateMutability": "view",
|
|
100
|
+
"type": "function"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"constant": false,
|
|
104
|
+
"inputs": [],
|
|
105
|
+
"name": "unpause",
|
|
106
|
+
"outputs": [],
|
|
107
|
+
"payable": false,
|
|
108
|
+
"stateMutability": "nonpayable",
|
|
109
|
+
"type": "function"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"constant": false,
|
|
113
|
+
"inputs": [
|
|
114
|
+
{
|
|
115
|
+
"name": "account",
|
|
116
|
+
"type": "address"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "amount",
|
|
120
|
+
"type": "uint256"
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"name": "mint",
|
|
124
|
+
"outputs": [],
|
|
125
|
+
"payable": false,
|
|
126
|
+
"stateMutability": "nonpayable",
|
|
127
|
+
"type": "function"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"constant": false,
|
|
131
|
+
"inputs": [
|
|
132
|
+
{
|
|
133
|
+
"name": "_value",
|
|
134
|
+
"type": "uint256"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"name": "burn",
|
|
138
|
+
"outputs": [],
|
|
139
|
+
"payable": false,
|
|
140
|
+
"stateMutability": "nonpayable",
|
|
141
|
+
"type": "function"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"constant": true,
|
|
145
|
+
"inputs": [],
|
|
146
|
+
"name": "paused",
|
|
147
|
+
"outputs": [
|
|
148
|
+
{
|
|
149
|
+
"name": "",
|
|
150
|
+
"type": "bool"
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"payable": false,
|
|
154
|
+
"stateMutability": "view",
|
|
155
|
+
"type": "function"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"constant": false,
|
|
159
|
+
"inputs": [
|
|
160
|
+
{
|
|
161
|
+
"name": "_spender",
|
|
162
|
+
"type": "address"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "_subtractedValue",
|
|
166
|
+
"type": "uint256"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"name": "decreaseApproval",
|
|
170
|
+
"outputs": [
|
|
171
|
+
{
|
|
172
|
+
"name": "success",
|
|
173
|
+
"type": "bool"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"payable": false,
|
|
177
|
+
"stateMutability": "nonpayable",
|
|
178
|
+
"type": "function"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"constant": true,
|
|
182
|
+
"inputs": [
|
|
183
|
+
{
|
|
184
|
+
"name": "_owner",
|
|
185
|
+
"type": "address"
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"name": "balanceOf",
|
|
189
|
+
"outputs": [
|
|
190
|
+
{
|
|
191
|
+
"name": "balance",
|
|
192
|
+
"type": "uint256"
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"payable": false,
|
|
196
|
+
"stateMutability": "view",
|
|
197
|
+
"type": "function"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"constant": false,
|
|
201
|
+
"inputs": [
|
|
202
|
+
{
|
|
203
|
+
"name": "listAddress",
|
|
204
|
+
"type": "address"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "isBlackListed",
|
|
208
|
+
"type": "bool"
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
"name": "blackListAddress",
|
|
212
|
+
"outputs": [
|
|
213
|
+
{
|
|
214
|
+
"name": "success",
|
|
215
|
+
"type": "bool"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"payable": false,
|
|
219
|
+
"stateMutability": "nonpayable",
|
|
220
|
+
"type": "function"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"constant": false,
|
|
224
|
+
"inputs": [],
|
|
225
|
+
"name": "pause",
|
|
226
|
+
"outputs": [],
|
|
227
|
+
"payable": false,
|
|
228
|
+
"stateMutability": "nonpayable",
|
|
229
|
+
"type": "function"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"constant": true,
|
|
233
|
+
"inputs": [],
|
|
234
|
+
"name": "owner",
|
|
235
|
+
"outputs": [
|
|
236
|
+
{
|
|
237
|
+
"name": "",
|
|
238
|
+
"type": "address"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"payable": false,
|
|
242
|
+
"stateMutability": "view",
|
|
243
|
+
"type": "function"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"constant": true,
|
|
247
|
+
"inputs": [],
|
|
248
|
+
"name": "symbol",
|
|
249
|
+
"outputs": [
|
|
250
|
+
{
|
|
251
|
+
"name": "",
|
|
252
|
+
"type": "string"
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
"payable": false,
|
|
256
|
+
"stateMutability": "view",
|
|
257
|
+
"type": "function"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"constant": false,
|
|
261
|
+
"inputs": [
|
|
262
|
+
{
|
|
263
|
+
"name": "_to",
|
|
264
|
+
"type": "address"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"name": "_value",
|
|
268
|
+
"type": "uint256"
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"name": "transfer",
|
|
272
|
+
"outputs": [
|
|
273
|
+
{
|
|
274
|
+
"name": "",
|
|
275
|
+
"type": "bool"
|
|
276
|
+
}
|
|
277
|
+
],
|
|
278
|
+
"payable": false,
|
|
279
|
+
"stateMutability": "nonpayable",
|
|
280
|
+
"type": "function"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"constant": false,
|
|
284
|
+
"inputs": [
|
|
285
|
+
{
|
|
286
|
+
"name": "_spender",
|
|
287
|
+
"type": "address"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"name": "_addedValue",
|
|
291
|
+
"type": "uint256"
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
"name": "increaseApproval",
|
|
295
|
+
"outputs": [
|
|
296
|
+
{
|
|
297
|
+
"name": "success",
|
|
298
|
+
"type": "bool"
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"payable": false,
|
|
302
|
+
"stateMutability": "nonpayable",
|
|
303
|
+
"type": "function"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"constant": true,
|
|
307
|
+
"inputs": [
|
|
308
|
+
{
|
|
309
|
+
"name": "_owner",
|
|
310
|
+
"type": "address"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"name": "_spender",
|
|
314
|
+
"type": "address"
|
|
315
|
+
}
|
|
316
|
+
],
|
|
317
|
+
"name": "allowance",
|
|
318
|
+
"outputs": [
|
|
319
|
+
{
|
|
320
|
+
"name": "",
|
|
321
|
+
"type": "uint256"
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
"payable": false,
|
|
325
|
+
"stateMutability": "view",
|
|
326
|
+
"type": "function"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"constant": false,
|
|
330
|
+
"inputs": [
|
|
331
|
+
{
|
|
332
|
+
"name": "newOwner",
|
|
333
|
+
"type": "address"
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"name": "transferOwnership",
|
|
337
|
+
"outputs": [],
|
|
338
|
+
"payable": false,
|
|
339
|
+
"stateMutability": "nonpayable",
|
|
340
|
+
"type": "function"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"inputs": [
|
|
344
|
+
{
|
|
345
|
+
"name": "_name",
|
|
346
|
+
"type": "string"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"name": "_symbol",
|
|
350
|
+
"type": "string"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"name": "_decimals",
|
|
354
|
+
"type": "uint256"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"name": "_supply",
|
|
358
|
+
"type": "uint256"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"name": "tokenOwner",
|
|
362
|
+
"type": "address"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "service",
|
|
366
|
+
"type": "address"
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
"payable": true,
|
|
370
|
+
"stateMutability": "payable",
|
|
371
|
+
"type": "constructor"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"anonymous": false,
|
|
375
|
+
"inputs": [
|
|
376
|
+
{
|
|
377
|
+
"indexed": true,
|
|
378
|
+
"name": "from",
|
|
379
|
+
"type": "address"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"indexed": true,
|
|
383
|
+
"name": "to",
|
|
384
|
+
"type": "address"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"indexed": false,
|
|
388
|
+
"name": "value",
|
|
389
|
+
"type": "uint256"
|
|
390
|
+
}
|
|
391
|
+
],
|
|
392
|
+
"name": "Mint",
|
|
393
|
+
"type": "event"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"anonymous": false,
|
|
397
|
+
"inputs": [
|
|
398
|
+
{
|
|
399
|
+
"indexed": true,
|
|
400
|
+
"name": "burner",
|
|
401
|
+
"type": "address"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"indexed": false,
|
|
405
|
+
"name": "value",
|
|
406
|
+
"type": "uint256"
|
|
407
|
+
}
|
|
408
|
+
],
|
|
409
|
+
"name": "Burn",
|
|
410
|
+
"type": "event"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"anonymous": false,
|
|
414
|
+
"inputs": [],
|
|
415
|
+
"name": "Pause",
|
|
416
|
+
"type": "event"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"anonymous": false,
|
|
420
|
+
"inputs": [],
|
|
421
|
+
"name": "Unpause",
|
|
422
|
+
"type": "event"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"anonymous": false,
|
|
426
|
+
"inputs": [
|
|
427
|
+
{
|
|
428
|
+
"indexed": true,
|
|
429
|
+
"name": "previousOwner",
|
|
430
|
+
"type": "address"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"indexed": true,
|
|
434
|
+
"name": "newOwner",
|
|
435
|
+
"type": "address"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
438
|
+
"name": "OwnershipTransferred",
|
|
439
|
+
"type": "event"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"anonymous": false,
|
|
443
|
+
"inputs": [
|
|
444
|
+
{
|
|
445
|
+
"indexed": true,
|
|
446
|
+
"name": "blackListed",
|
|
447
|
+
"type": "address"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"indexed": false,
|
|
451
|
+
"name": "value",
|
|
452
|
+
"type": "bool"
|
|
453
|
+
}
|
|
454
|
+
],
|
|
455
|
+
"name": "Blacklist",
|
|
456
|
+
"type": "event"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"anonymous": false,
|
|
460
|
+
"inputs": [
|
|
461
|
+
{
|
|
462
|
+
"indexed": true,
|
|
463
|
+
"name": "owner",
|
|
464
|
+
"type": "address"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
"indexed": true,
|
|
468
|
+
"name": "spender",
|
|
469
|
+
"type": "address"
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"indexed": false,
|
|
473
|
+
"name": "value",
|
|
474
|
+
"type": "uint256"
|
|
475
|
+
}
|
|
476
|
+
],
|
|
477
|
+
"name": "Approval",
|
|
478
|
+
"type": "event"
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
"anonymous": false,
|
|
482
|
+
"inputs": [
|
|
483
|
+
{
|
|
484
|
+
"indexed": true,
|
|
485
|
+
"name": "from",
|
|
486
|
+
"type": "address"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"indexed": true,
|
|
490
|
+
"name": "to",
|
|
491
|
+
"type": "address"
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
"indexed": false,
|
|
495
|
+
"name": "value",
|
|
496
|
+
"type": "uint256"
|
|
497
|
+
}
|
|
498
|
+
],
|
|
499
|
+
"name": "Transfer",
|
|
500
|
+
"type": "event"
|
|
501
|
+
}
|
|
502
|
+
] as const satisfies Abi;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Type-safe ABI for CoinToken
|
|
506
|
+
*/
|
|
507
|
+
export type CoinTokenAbi = typeof CoinTokenAbi;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Contract instance type for CoinToken
|
|
511
|
+
*/
|
|
512
|
+
// Use any for contract type to avoid complex viem type issues
|
|
513
|
+
// The runtime behavior is type-safe through viem's ABI typing
|
|
514
|
+
export type CoinTokenContract = any;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* CoinToken Contract Class
|
|
518
|
+
*
|
|
519
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
524
|
+
* import { mainnet } from 'viem/chains';
|
|
525
|
+
* import { CoinToken } from 'CoinToken';
|
|
526
|
+
*
|
|
527
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
528
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
529
|
+
*
|
|
530
|
+
* const contract = new CoinToken('0x...', { publicClient, walletClient });
|
|
531
|
+
*
|
|
532
|
+
* // Read functions
|
|
533
|
+
* const result = await contract.balanceOf('0x...');
|
|
534
|
+
*
|
|
535
|
+
* // Write functions
|
|
536
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
537
|
+
*
|
|
538
|
+
* // Simulate transactions (dry-run)
|
|
539
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
540
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
541
|
+
*
|
|
542
|
+
* // Watch events
|
|
543
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
544
|
+
* console.log('Transfer event:', event);
|
|
545
|
+
* });
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
export class CoinToken {
|
|
549
|
+
private contract: CoinTokenContract;
|
|
550
|
+
private contractAddress: Address;
|
|
551
|
+
private publicClient: PublicClient;
|
|
552
|
+
|
|
553
|
+
constructor(
|
|
554
|
+
address: Address,
|
|
555
|
+
clients: {
|
|
556
|
+
publicClient: PublicClient;
|
|
557
|
+
walletClient?: WalletClient;
|
|
558
|
+
}
|
|
559
|
+
) {
|
|
560
|
+
this.contractAddress = address;
|
|
561
|
+
this.publicClient = clients.publicClient;
|
|
562
|
+
this.contract = getContract({
|
|
563
|
+
address,
|
|
564
|
+
abi: CoinTokenAbi,
|
|
565
|
+
client: {
|
|
566
|
+
public: clients.publicClient,
|
|
567
|
+
wallet: clients.walletClient,
|
|
568
|
+
},
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Get the contract address
|
|
574
|
+
*/
|
|
575
|
+
get address(): Address {
|
|
576
|
+
return this.contractAddress;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Get the underlying viem contract instance.
|
|
581
|
+
*/
|
|
582
|
+
getContract(): CoinTokenContract {
|
|
583
|
+
return this.contract;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* name
|
|
588
|
+
* view
|
|
589
|
+
*/
|
|
590
|
+
async name(): Promise<string> {
|
|
591
|
+
return this.contract.read.name() as Promise<string>;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* totalSupply
|
|
596
|
+
* view
|
|
597
|
+
*/
|
|
598
|
+
async totalSupply(): Promise<bigint> {
|
|
599
|
+
return this.contract.read.totalSupply() as Promise<bigint>;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* decimals
|
|
604
|
+
* view
|
|
605
|
+
*/
|
|
606
|
+
async decimals(): Promise<bigint> {
|
|
607
|
+
return this.contract.read.decimals() as Promise<bigint>;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* paused
|
|
612
|
+
* view
|
|
613
|
+
*/
|
|
614
|
+
async paused(): Promise<boolean> {
|
|
615
|
+
return this.contract.read.paused() as Promise<boolean>;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* balanceOf
|
|
620
|
+
* view
|
|
621
|
+
*/
|
|
622
|
+
async balanceOf(_owner: `0x${string}`): Promise<bigint> {
|
|
623
|
+
return this.contract.read.balanceOf([_owner] as const) as Promise<bigint>;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* owner
|
|
628
|
+
* view
|
|
629
|
+
*/
|
|
630
|
+
async owner(): Promise<`0x${string}`> {
|
|
631
|
+
return this.contract.read.owner() as Promise<`0x${string}`>;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* symbol
|
|
636
|
+
* view
|
|
637
|
+
*/
|
|
638
|
+
async symbol(): Promise<string> {
|
|
639
|
+
return this.contract.read.symbol() as Promise<string>;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* allowance
|
|
644
|
+
* view
|
|
645
|
+
*/
|
|
646
|
+
async allowance(_owner: `0x${string}`, _spender: `0x${string}`): Promise<bigint> {
|
|
647
|
+
return this.contract.read.allowance([_owner, _spender] as const) as Promise<bigint>;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* approve
|
|
652
|
+
* nonpayable
|
|
653
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
654
|
+
*/
|
|
655
|
+
async approve(_spender: `0x${string}`, _value: bigint, options?: {
|
|
656
|
+
accessList?: import('viem').AccessList;
|
|
657
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
658
|
+
chain?: import('viem').Chain | null;
|
|
659
|
+
dataSuffix?: `0x${string}`;
|
|
660
|
+
gas?: bigint;
|
|
661
|
+
gasPrice?: bigint;
|
|
662
|
+
maxFeePerGas?: bigint;
|
|
663
|
+
maxPriorityFeePerGas?: bigint;
|
|
664
|
+
nonce?: number;
|
|
665
|
+
value?: bigint;
|
|
666
|
+
}): Promise<`0x${string}`> {
|
|
667
|
+
if (!this.contract.write) {
|
|
668
|
+
throw new Error('Wallet client is required for write operations');
|
|
669
|
+
}
|
|
670
|
+
return this.contract.write.approve([_spender, _value] as const, options) as Promise<`0x${string}`>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* transferFrom
|
|
675
|
+
* nonpayable
|
|
676
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
677
|
+
*/
|
|
678
|
+
async transferFrom(_from: `0x${string}`, _to: `0x${string}`, _value: bigint, options?: {
|
|
679
|
+
accessList?: import('viem').AccessList;
|
|
680
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
681
|
+
chain?: import('viem').Chain | null;
|
|
682
|
+
dataSuffix?: `0x${string}`;
|
|
683
|
+
gas?: bigint;
|
|
684
|
+
gasPrice?: bigint;
|
|
685
|
+
maxFeePerGas?: bigint;
|
|
686
|
+
maxPriorityFeePerGas?: bigint;
|
|
687
|
+
nonce?: number;
|
|
688
|
+
value?: bigint;
|
|
689
|
+
}): Promise<`0x${string}`> {
|
|
690
|
+
if (!this.contract.write) {
|
|
691
|
+
throw new Error('Wallet client is required for write operations');
|
|
692
|
+
}
|
|
693
|
+
return this.contract.write.transferFrom([_from, _to, _value] as const, options) as Promise<`0x${string}`>;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* unpause
|
|
698
|
+
* nonpayable
|
|
699
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
700
|
+
*/
|
|
701
|
+
async unpause(options?: {
|
|
702
|
+
accessList?: import('viem').AccessList;
|
|
703
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
704
|
+
chain?: import('viem').Chain | null;
|
|
705
|
+
dataSuffix?: `0x${string}`;
|
|
706
|
+
gas?: bigint;
|
|
707
|
+
gasPrice?: bigint;
|
|
708
|
+
maxFeePerGas?: bigint;
|
|
709
|
+
maxPriorityFeePerGas?: bigint;
|
|
710
|
+
nonce?: number;
|
|
711
|
+
value?: bigint;
|
|
712
|
+
}): Promise<`0x${string}`> {
|
|
713
|
+
if (!this.contract.write) {
|
|
714
|
+
throw new Error('Wallet client is required for write operations');
|
|
715
|
+
}
|
|
716
|
+
return this.contract.write.unpause(options) as Promise<`0x${string}`>;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* mint
|
|
721
|
+
* nonpayable
|
|
722
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
723
|
+
*/
|
|
724
|
+
async mint(account: `0x${string}`, amount: bigint, options?: {
|
|
725
|
+
accessList?: import('viem').AccessList;
|
|
726
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
727
|
+
chain?: import('viem').Chain | null;
|
|
728
|
+
dataSuffix?: `0x${string}`;
|
|
729
|
+
gas?: bigint;
|
|
730
|
+
gasPrice?: bigint;
|
|
731
|
+
maxFeePerGas?: bigint;
|
|
732
|
+
maxPriorityFeePerGas?: bigint;
|
|
733
|
+
nonce?: number;
|
|
734
|
+
value?: bigint;
|
|
735
|
+
}): Promise<`0x${string}`> {
|
|
736
|
+
if (!this.contract.write) {
|
|
737
|
+
throw new Error('Wallet client is required for write operations');
|
|
738
|
+
}
|
|
739
|
+
return this.contract.write.mint([account, amount] as const, options) as Promise<`0x${string}`>;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* burn
|
|
744
|
+
* nonpayable
|
|
745
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
746
|
+
*/
|
|
747
|
+
async burn(_value: bigint, options?: {
|
|
748
|
+
accessList?: import('viem').AccessList;
|
|
749
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
750
|
+
chain?: import('viem').Chain | null;
|
|
751
|
+
dataSuffix?: `0x${string}`;
|
|
752
|
+
gas?: bigint;
|
|
753
|
+
gasPrice?: bigint;
|
|
754
|
+
maxFeePerGas?: bigint;
|
|
755
|
+
maxPriorityFeePerGas?: bigint;
|
|
756
|
+
nonce?: number;
|
|
757
|
+
value?: bigint;
|
|
758
|
+
}): Promise<`0x${string}`> {
|
|
759
|
+
if (!this.contract.write) {
|
|
760
|
+
throw new Error('Wallet client is required for write operations');
|
|
761
|
+
}
|
|
762
|
+
return this.contract.write.burn([_value] as const, options) as Promise<`0x${string}`>;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* decreaseApproval
|
|
767
|
+
* nonpayable
|
|
768
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
769
|
+
*/
|
|
770
|
+
async decreaseApproval(_spender: `0x${string}`, _subtractedValue: bigint, options?: {
|
|
771
|
+
accessList?: import('viem').AccessList;
|
|
772
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
773
|
+
chain?: import('viem').Chain | null;
|
|
774
|
+
dataSuffix?: `0x${string}`;
|
|
775
|
+
gas?: bigint;
|
|
776
|
+
gasPrice?: bigint;
|
|
777
|
+
maxFeePerGas?: bigint;
|
|
778
|
+
maxPriorityFeePerGas?: bigint;
|
|
779
|
+
nonce?: number;
|
|
780
|
+
value?: bigint;
|
|
781
|
+
}): Promise<`0x${string}`> {
|
|
782
|
+
if (!this.contract.write) {
|
|
783
|
+
throw new Error('Wallet client is required for write operations');
|
|
784
|
+
}
|
|
785
|
+
return this.contract.write.decreaseApproval([_spender, _subtractedValue] as const, options) as Promise<`0x${string}`>;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* blackListAddress
|
|
790
|
+
* nonpayable
|
|
791
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
792
|
+
*/
|
|
793
|
+
async blackListAddress(listAddress: `0x${string}`, isBlackListed: boolean, options?: {
|
|
794
|
+
accessList?: import('viem').AccessList;
|
|
795
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
796
|
+
chain?: import('viem').Chain | null;
|
|
797
|
+
dataSuffix?: `0x${string}`;
|
|
798
|
+
gas?: bigint;
|
|
799
|
+
gasPrice?: bigint;
|
|
800
|
+
maxFeePerGas?: bigint;
|
|
801
|
+
maxPriorityFeePerGas?: bigint;
|
|
802
|
+
nonce?: number;
|
|
803
|
+
value?: bigint;
|
|
804
|
+
}): Promise<`0x${string}`> {
|
|
805
|
+
if (!this.contract.write) {
|
|
806
|
+
throw new Error('Wallet client is required for write operations');
|
|
807
|
+
}
|
|
808
|
+
return this.contract.write.blackListAddress([listAddress, isBlackListed] as const, options) as Promise<`0x${string}`>;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* pause
|
|
813
|
+
* nonpayable
|
|
814
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
815
|
+
*/
|
|
816
|
+
async pause(options?: {
|
|
817
|
+
accessList?: import('viem').AccessList;
|
|
818
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
819
|
+
chain?: import('viem').Chain | null;
|
|
820
|
+
dataSuffix?: `0x${string}`;
|
|
821
|
+
gas?: bigint;
|
|
822
|
+
gasPrice?: bigint;
|
|
823
|
+
maxFeePerGas?: bigint;
|
|
824
|
+
maxPriorityFeePerGas?: bigint;
|
|
825
|
+
nonce?: number;
|
|
826
|
+
value?: bigint;
|
|
827
|
+
}): Promise<`0x${string}`> {
|
|
828
|
+
if (!this.contract.write) {
|
|
829
|
+
throw new Error('Wallet client is required for write operations');
|
|
830
|
+
}
|
|
831
|
+
return this.contract.write.pause(options) as Promise<`0x${string}`>;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* transfer
|
|
836
|
+
* nonpayable
|
|
837
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
838
|
+
*/
|
|
839
|
+
async transfer(_to: `0x${string}`, _value: bigint, options?: {
|
|
840
|
+
accessList?: import('viem').AccessList;
|
|
841
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
842
|
+
chain?: import('viem').Chain | null;
|
|
843
|
+
dataSuffix?: `0x${string}`;
|
|
844
|
+
gas?: bigint;
|
|
845
|
+
gasPrice?: bigint;
|
|
846
|
+
maxFeePerGas?: bigint;
|
|
847
|
+
maxPriorityFeePerGas?: bigint;
|
|
848
|
+
nonce?: number;
|
|
849
|
+
value?: bigint;
|
|
850
|
+
}): Promise<`0x${string}`> {
|
|
851
|
+
if (!this.contract.write) {
|
|
852
|
+
throw new Error('Wallet client is required for write operations');
|
|
853
|
+
}
|
|
854
|
+
return this.contract.write.transfer([_to, _value] as const, options) as Promise<`0x${string}`>;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* increaseApproval
|
|
859
|
+
* nonpayable
|
|
860
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
861
|
+
*/
|
|
862
|
+
async increaseApproval(_spender: `0x${string}`, _addedValue: bigint, options?: {
|
|
863
|
+
accessList?: import('viem').AccessList;
|
|
864
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
865
|
+
chain?: import('viem').Chain | null;
|
|
866
|
+
dataSuffix?: `0x${string}`;
|
|
867
|
+
gas?: bigint;
|
|
868
|
+
gasPrice?: bigint;
|
|
869
|
+
maxFeePerGas?: bigint;
|
|
870
|
+
maxPriorityFeePerGas?: bigint;
|
|
871
|
+
nonce?: number;
|
|
872
|
+
value?: bigint;
|
|
873
|
+
}): Promise<`0x${string}`> {
|
|
874
|
+
if (!this.contract.write) {
|
|
875
|
+
throw new Error('Wallet client is required for write operations');
|
|
876
|
+
}
|
|
877
|
+
return this.contract.write.increaseApproval([_spender, _addedValue] as const, options) as Promise<`0x${string}`>;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* transferOwnership
|
|
882
|
+
* nonpayable
|
|
883
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
884
|
+
*/
|
|
885
|
+
async transferOwnership(newOwner: `0x${string}`, options?: {
|
|
886
|
+
accessList?: import('viem').AccessList;
|
|
887
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
888
|
+
chain?: import('viem').Chain | null;
|
|
889
|
+
dataSuffix?: `0x${string}`;
|
|
890
|
+
gas?: bigint;
|
|
891
|
+
gasPrice?: bigint;
|
|
892
|
+
maxFeePerGas?: bigint;
|
|
893
|
+
maxPriorityFeePerGas?: bigint;
|
|
894
|
+
nonce?: number;
|
|
895
|
+
value?: bigint;
|
|
896
|
+
}): Promise<`0x${string}`> {
|
|
897
|
+
if (!this.contract.write) {
|
|
898
|
+
throw new Error('Wallet client is required for write operations');
|
|
899
|
+
}
|
|
900
|
+
return this.contract.write.transferOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
910
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
911
|
+
* console.log('Would succeed:', result.result);
|
|
912
|
+
*/
|
|
913
|
+
get simulate() {
|
|
914
|
+
const contract = this.contract;
|
|
915
|
+
if (!contract.simulate) {
|
|
916
|
+
throw new Error('Public client is required for simulation');
|
|
917
|
+
}
|
|
918
|
+
return {
|
|
919
|
+
/**
|
|
920
|
+
* Simulate approve
|
|
921
|
+
* Returns gas estimate and result without sending transaction
|
|
922
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
923
|
+
*/
|
|
924
|
+
async approve(_spender: `0x${string}`, _value: bigint, options?: {
|
|
925
|
+
accessList?: import('viem').AccessList;
|
|
926
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
927
|
+
chain?: import('viem').Chain | null;
|
|
928
|
+
dataSuffix?: `0x${string}`;
|
|
929
|
+
gas?: bigint;
|
|
930
|
+
gasPrice?: bigint;
|
|
931
|
+
maxFeePerGas?: bigint;
|
|
932
|
+
maxPriorityFeePerGas?: bigint;
|
|
933
|
+
nonce?: number;
|
|
934
|
+
value?: bigint;
|
|
935
|
+
}): Promise<boolean> {
|
|
936
|
+
return contract.simulate.approve([_spender, _value] as const, options) as Promise<boolean>;
|
|
937
|
+
},
|
|
938
|
+
/**
|
|
939
|
+
* Simulate transferFrom
|
|
940
|
+
* Returns gas estimate and result without sending transaction
|
|
941
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
942
|
+
*/
|
|
943
|
+
async transferFrom(_from: `0x${string}`, _to: `0x${string}`, _value: bigint, options?: {
|
|
944
|
+
accessList?: import('viem').AccessList;
|
|
945
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
946
|
+
chain?: import('viem').Chain | null;
|
|
947
|
+
dataSuffix?: `0x${string}`;
|
|
948
|
+
gas?: bigint;
|
|
949
|
+
gasPrice?: bigint;
|
|
950
|
+
maxFeePerGas?: bigint;
|
|
951
|
+
maxPriorityFeePerGas?: bigint;
|
|
952
|
+
nonce?: number;
|
|
953
|
+
value?: bigint;
|
|
954
|
+
}): Promise<boolean> {
|
|
955
|
+
return contract.simulate.transferFrom([_from, _to, _value] as const, options) as Promise<boolean>;
|
|
956
|
+
},
|
|
957
|
+
/**
|
|
958
|
+
* Simulate unpause
|
|
959
|
+
* Returns gas estimate and result without sending transaction
|
|
960
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
961
|
+
*/
|
|
962
|
+
async unpause(options?: {
|
|
963
|
+
accessList?: import('viem').AccessList;
|
|
964
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
965
|
+
chain?: import('viem').Chain | null;
|
|
966
|
+
dataSuffix?: `0x${string}`;
|
|
967
|
+
gas?: bigint;
|
|
968
|
+
gasPrice?: bigint;
|
|
969
|
+
maxFeePerGas?: bigint;
|
|
970
|
+
maxPriorityFeePerGas?: bigint;
|
|
971
|
+
nonce?: number;
|
|
972
|
+
value?: bigint;
|
|
973
|
+
}): Promise<void> {
|
|
974
|
+
return contract.simulate.unpause(options) as Promise<void>;
|
|
975
|
+
},
|
|
976
|
+
/**
|
|
977
|
+
* Simulate mint
|
|
978
|
+
* Returns gas estimate and result without sending transaction
|
|
979
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
980
|
+
*/
|
|
981
|
+
async mint(account: `0x${string}`, amount: bigint, options?: {
|
|
982
|
+
accessList?: import('viem').AccessList;
|
|
983
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
984
|
+
chain?: import('viem').Chain | null;
|
|
985
|
+
dataSuffix?: `0x${string}`;
|
|
986
|
+
gas?: bigint;
|
|
987
|
+
gasPrice?: bigint;
|
|
988
|
+
maxFeePerGas?: bigint;
|
|
989
|
+
maxPriorityFeePerGas?: bigint;
|
|
990
|
+
nonce?: number;
|
|
991
|
+
value?: bigint;
|
|
992
|
+
}): Promise<void> {
|
|
993
|
+
return contract.simulate.mint([account, amount] as const, options) as Promise<void>;
|
|
994
|
+
},
|
|
995
|
+
/**
|
|
996
|
+
* Simulate burn
|
|
997
|
+
* Returns gas estimate and result without sending transaction
|
|
998
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
999
|
+
*/
|
|
1000
|
+
async burn(_value: bigint, options?: {
|
|
1001
|
+
accessList?: import('viem').AccessList;
|
|
1002
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1003
|
+
chain?: import('viem').Chain | null;
|
|
1004
|
+
dataSuffix?: `0x${string}`;
|
|
1005
|
+
gas?: bigint;
|
|
1006
|
+
gasPrice?: bigint;
|
|
1007
|
+
maxFeePerGas?: bigint;
|
|
1008
|
+
maxPriorityFeePerGas?: bigint;
|
|
1009
|
+
nonce?: number;
|
|
1010
|
+
value?: bigint;
|
|
1011
|
+
}): Promise<void> {
|
|
1012
|
+
return contract.simulate.burn([_value] as const, options) as Promise<void>;
|
|
1013
|
+
},
|
|
1014
|
+
/**
|
|
1015
|
+
* Simulate decreaseApproval
|
|
1016
|
+
* Returns gas estimate and result without sending transaction
|
|
1017
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1018
|
+
*/
|
|
1019
|
+
async decreaseApproval(_spender: `0x${string}`, _subtractedValue: bigint, options?: {
|
|
1020
|
+
accessList?: import('viem').AccessList;
|
|
1021
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1022
|
+
chain?: import('viem').Chain | null;
|
|
1023
|
+
dataSuffix?: `0x${string}`;
|
|
1024
|
+
gas?: bigint;
|
|
1025
|
+
gasPrice?: bigint;
|
|
1026
|
+
maxFeePerGas?: bigint;
|
|
1027
|
+
maxPriorityFeePerGas?: bigint;
|
|
1028
|
+
nonce?: number;
|
|
1029
|
+
value?: bigint;
|
|
1030
|
+
}): Promise<boolean> {
|
|
1031
|
+
return contract.simulate.decreaseApproval([_spender, _subtractedValue] as const, options) as Promise<boolean>;
|
|
1032
|
+
},
|
|
1033
|
+
/**
|
|
1034
|
+
* Simulate blackListAddress
|
|
1035
|
+
* Returns gas estimate and result without sending transaction
|
|
1036
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1037
|
+
*/
|
|
1038
|
+
async blackListAddress(listAddress: `0x${string}`, isBlackListed: boolean, options?: {
|
|
1039
|
+
accessList?: import('viem').AccessList;
|
|
1040
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1041
|
+
chain?: import('viem').Chain | null;
|
|
1042
|
+
dataSuffix?: `0x${string}`;
|
|
1043
|
+
gas?: bigint;
|
|
1044
|
+
gasPrice?: bigint;
|
|
1045
|
+
maxFeePerGas?: bigint;
|
|
1046
|
+
maxPriorityFeePerGas?: bigint;
|
|
1047
|
+
nonce?: number;
|
|
1048
|
+
value?: bigint;
|
|
1049
|
+
}): Promise<boolean> {
|
|
1050
|
+
return contract.simulate.blackListAddress([listAddress, isBlackListed] as const, options) as Promise<boolean>;
|
|
1051
|
+
},
|
|
1052
|
+
/**
|
|
1053
|
+
* Simulate pause
|
|
1054
|
+
* Returns gas estimate and result without sending transaction
|
|
1055
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1056
|
+
*/
|
|
1057
|
+
async pause(options?: {
|
|
1058
|
+
accessList?: import('viem').AccessList;
|
|
1059
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1060
|
+
chain?: import('viem').Chain | null;
|
|
1061
|
+
dataSuffix?: `0x${string}`;
|
|
1062
|
+
gas?: bigint;
|
|
1063
|
+
gasPrice?: bigint;
|
|
1064
|
+
maxFeePerGas?: bigint;
|
|
1065
|
+
maxPriorityFeePerGas?: bigint;
|
|
1066
|
+
nonce?: number;
|
|
1067
|
+
value?: bigint;
|
|
1068
|
+
}): Promise<void> {
|
|
1069
|
+
return contract.simulate.pause(options) as Promise<void>;
|
|
1070
|
+
},
|
|
1071
|
+
/**
|
|
1072
|
+
* Simulate transfer
|
|
1073
|
+
* Returns gas estimate and result without sending transaction
|
|
1074
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1075
|
+
*/
|
|
1076
|
+
async transfer(_to: `0x${string}`, _value: bigint, options?: {
|
|
1077
|
+
accessList?: import('viem').AccessList;
|
|
1078
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1079
|
+
chain?: import('viem').Chain | null;
|
|
1080
|
+
dataSuffix?: `0x${string}`;
|
|
1081
|
+
gas?: bigint;
|
|
1082
|
+
gasPrice?: bigint;
|
|
1083
|
+
maxFeePerGas?: bigint;
|
|
1084
|
+
maxPriorityFeePerGas?: bigint;
|
|
1085
|
+
nonce?: number;
|
|
1086
|
+
value?: bigint;
|
|
1087
|
+
}): Promise<boolean> {
|
|
1088
|
+
return contract.simulate.transfer([_to, _value] as const, options) as Promise<boolean>;
|
|
1089
|
+
},
|
|
1090
|
+
/**
|
|
1091
|
+
* Simulate increaseApproval
|
|
1092
|
+
* Returns gas estimate and result without sending transaction
|
|
1093
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1094
|
+
*/
|
|
1095
|
+
async increaseApproval(_spender: `0x${string}`, _addedValue: bigint, options?: {
|
|
1096
|
+
accessList?: import('viem').AccessList;
|
|
1097
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1098
|
+
chain?: import('viem').Chain | null;
|
|
1099
|
+
dataSuffix?: `0x${string}`;
|
|
1100
|
+
gas?: bigint;
|
|
1101
|
+
gasPrice?: bigint;
|
|
1102
|
+
maxFeePerGas?: bigint;
|
|
1103
|
+
maxPriorityFeePerGas?: bigint;
|
|
1104
|
+
nonce?: number;
|
|
1105
|
+
value?: bigint;
|
|
1106
|
+
}): Promise<boolean> {
|
|
1107
|
+
return contract.simulate.increaseApproval([_spender, _addedValue] as const, options) as Promise<boolean>;
|
|
1108
|
+
},
|
|
1109
|
+
/**
|
|
1110
|
+
* Simulate transferOwnership
|
|
1111
|
+
* Returns gas estimate and result without sending transaction
|
|
1112
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1113
|
+
*/
|
|
1114
|
+
async transferOwnership(newOwner: `0x${string}`, options?: {
|
|
1115
|
+
accessList?: import('viem').AccessList;
|
|
1116
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1117
|
+
chain?: import('viem').Chain | null;
|
|
1118
|
+
dataSuffix?: `0x${string}`;
|
|
1119
|
+
gas?: bigint;
|
|
1120
|
+
gasPrice?: bigint;
|
|
1121
|
+
maxFeePerGas?: bigint;
|
|
1122
|
+
maxPriorityFeePerGas?: bigint;
|
|
1123
|
+
nonce?: number;
|
|
1124
|
+
value?: bigint;
|
|
1125
|
+
}): Promise<void> {
|
|
1126
|
+
return contract.simulate.transferOwnership([newOwner] as const, options) as Promise<void>;
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Watch contract events
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
* // Watch all Transfer events
|
|
1136
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
1137
|
+
* console.log('Transfer:', event);
|
|
1138
|
+
* });
|
|
1139
|
+
*
|
|
1140
|
+
* // Stop watching
|
|
1141
|
+
* unwatch();
|
|
1142
|
+
*/
|
|
1143
|
+
get watch() {
|
|
1144
|
+
return {
|
|
1145
|
+
/**
|
|
1146
|
+
* Watch Mint events
|
|
1147
|
+
* @param callback Function to call when event is emitted
|
|
1148
|
+
* @param filter Optional filter for indexed parameters
|
|
1149
|
+
* @returns Unwatch function to stop listening
|
|
1150
|
+
*/
|
|
1151
|
+
Mint: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from?: `0x${string}` | `0x${string}`[] | null; to?: `0x${string}` | `0x${string}`[] | null }) => {
|
|
1152
|
+
return this.publicClient.watchContractEvent({
|
|
1153
|
+
address: this.contractAddress,
|
|
1154
|
+
abi: CoinTokenAbi,
|
|
1155
|
+
eventName: 'Mint',
|
|
1156
|
+
args: filter as any,
|
|
1157
|
+
onLogs: (logs: any[]) => {
|
|
1158
|
+
logs.forEach((log: any) => {
|
|
1159
|
+
callback(log.args as any);
|
|
1160
|
+
});
|
|
1161
|
+
},
|
|
1162
|
+
}) as () => void;
|
|
1163
|
+
},
|
|
1164
|
+
/**
|
|
1165
|
+
* Watch Burn events
|
|
1166
|
+
* @param callback Function to call when event is emitted
|
|
1167
|
+
* @param filter Optional filter for indexed parameters
|
|
1168
|
+
* @returns Unwatch function to stop listening
|
|
1169
|
+
*/
|
|
1170
|
+
Burn: (callback: (event: { burner: `0x${string}`; value: bigint }) => void, filter?: { burner?: `0x${string}` | `0x${string}`[] | null }) => {
|
|
1171
|
+
return this.publicClient.watchContractEvent({
|
|
1172
|
+
address: this.contractAddress,
|
|
1173
|
+
abi: CoinTokenAbi,
|
|
1174
|
+
eventName: 'Burn',
|
|
1175
|
+
args: filter as any,
|
|
1176
|
+
onLogs: (logs: any[]) => {
|
|
1177
|
+
logs.forEach((log: any) => {
|
|
1178
|
+
callback(log.args as any);
|
|
1179
|
+
});
|
|
1180
|
+
},
|
|
1181
|
+
}) as () => void;
|
|
1182
|
+
},
|
|
1183
|
+
/**
|
|
1184
|
+
* Watch Pause events
|
|
1185
|
+
* @param callback Function to call when event is emitted
|
|
1186
|
+
* @param filter Optional filter for indexed parameters
|
|
1187
|
+
* @returns Unwatch function to stop listening
|
|
1188
|
+
*/
|
|
1189
|
+
Pause: (callback: (event: { }) => void) => {
|
|
1190
|
+
return this.publicClient.watchContractEvent({
|
|
1191
|
+
address: this.contractAddress,
|
|
1192
|
+
abi: CoinTokenAbi,
|
|
1193
|
+
eventName: 'Pause',
|
|
1194
|
+
|
|
1195
|
+
onLogs: (logs: any[]) => {
|
|
1196
|
+
logs.forEach((log: any) => {
|
|
1197
|
+
callback(log.args as any);
|
|
1198
|
+
});
|
|
1199
|
+
},
|
|
1200
|
+
}) as () => void;
|
|
1201
|
+
},
|
|
1202
|
+
/**
|
|
1203
|
+
* Watch Unpause events
|
|
1204
|
+
* @param callback Function to call when event is emitted
|
|
1205
|
+
* @param filter Optional filter for indexed parameters
|
|
1206
|
+
* @returns Unwatch function to stop listening
|
|
1207
|
+
*/
|
|
1208
|
+
Unpause: (callback: (event: { }) => void) => {
|
|
1209
|
+
return this.publicClient.watchContractEvent({
|
|
1210
|
+
address: this.contractAddress,
|
|
1211
|
+
abi: CoinTokenAbi,
|
|
1212
|
+
eventName: 'Unpause',
|
|
1213
|
+
|
|
1214
|
+
onLogs: (logs: any[]) => {
|
|
1215
|
+
logs.forEach((log: any) => {
|
|
1216
|
+
callback(log.args as any);
|
|
1217
|
+
});
|
|
1218
|
+
},
|
|
1219
|
+
}) as () => void;
|
|
1220
|
+
},
|
|
1221
|
+
/**
|
|
1222
|
+
* Watch OwnershipTransferred events
|
|
1223
|
+
* @param callback Function to call when event is emitted
|
|
1224
|
+
* @param filter Optional filter for indexed parameters
|
|
1225
|
+
* @returns Unwatch function to stop listening
|
|
1226
|
+
*/
|
|
1227
|
+
OwnershipTransferred: (callback: (event: { previousOwner: `0x${string}`; newOwner: `0x${string}` }) => void, filter?: { previousOwner?: `0x${string}` | `0x${string}`[] | null; newOwner?: `0x${string}` | `0x${string}`[] | null }) => {
|
|
1228
|
+
return this.publicClient.watchContractEvent({
|
|
1229
|
+
address: this.contractAddress,
|
|
1230
|
+
abi: CoinTokenAbi,
|
|
1231
|
+
eventName: 'OwnershipTransferred',
|
|
1232
|
+
args: filter as any,
|
|
1233
|
+
onLogs: (logs: any[]) => {
|
|
1234
|
+
logs.forEach((log: any) => {
|
|
1235
|
+
callback(log.args as any);
|
|
1236
|
+
});
|
|
1237
|
+
},
|
|
1238
|
+
}) as () => void;
|
|
1239
|
+
},
|
|
1240
|
+
/**
|
|
1241
|
+
* Watch Blacklist events
|
|
1242
|
+
* @param callback Function to call when event is emitted
|
|
1243
|
+
* @param filter Optional filter for indexed parameters
|
|
1244
|
+
* @returns Unwatch function to stop listening
|
|
1245
|
+
*/
|
|
1246
|
+
Blacklist: (callback: (event: { blackListed: `0x${string}`; value: boolean }) => void, filter?: { blackListed?: `0x${string}` | `0x${string}`[] | null }) => {
|
|
1247
|
+
return this.publicClient.watchContractEvent({
|
|
1248
|
+
address: this.contractAddress,
|
|
1249
|
+
abi: CoinTokenAbi,
|
|
1250
|
+
eventName: 'Blacklist',
|
|
1251
|
+
args: filter as any,
|
|
1252
|
+
onLogs: (logs: any[]) => {
|
|
1253
|
+
logs.forEach((log: any) => {
|
|
1254
|
+
callback(log.args as any);
|
|
1255
|
+
});
|
|
1256
|
+
},
|
|
1257
|
+
}) as () => void;
|
|
1258
|
+
},
|
|
1259
|
+
/**
|
|
1260
|
+
* Watch Approval events
|
|
1261
|
+
* @param callback Function to call when event is emitted
|
|
1262
|
+
* @param filter Optional filter for indexed parameters
|
|
1263
|
+
* @returns Unwatch function to stop listening
|
|
1264
|
+
*/
|
|
1265
|
+
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 }) => {
|
|
1266
|
+
return this.publicClient.watchContractEvent({
|
|
1267
|
+
address: this.contractAddress,
|
|
1268
|
+
abi: CoinTokenAbi,
|
|
1269
|
+
eventName: 'Approval',
|
|
1270
|
+
args: filter as any,
|
|
1271
|
+
onLogs: (logs: any[]) => {
|
|
1272
|
+
logs.forEach((log: any) => {
|
|
1273
|
+
callback(log.args as any);
|
|
1274
|
+
});
|
|
1275
|
+
},
|
|
1276
|
+
}) as () => void;
|
|
1277
|
+
},
|
|
1278
|
+
/**
|
|
1279
|
+
* Watch Transfer events
|
|
1280
|
+
* @param callback Function to call when event is emitted
|
|
1281
|
+
* @param filter Optional filter for indexed parameters
|
|
1282
|
+
* @returns Unwatch function to stop listening
|
|
1283
|
+
*/
|
|
1284
|
+
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 }) => {
|
|
1285
|
+
return this.publicClient.watchContractEvent({
|
|
1286
|
+
address: this.contractAddress,
|
|
1287
|
+
abi: CoinTokenAbi,
|
|
1288
|
+
eventName: 'Transfer',
|
|
1289
|
+
args: filter as any,
|
|
1290
|
+
onLogs: (logs: any[]) => {
|
|
1291
|
+
logs.forEach((log: any) => {
|
|
1292
|
+
callback(log.args as any);
|
|
1293
|
+
});
|
|
1294
|
+
},
|
|
1295
|
+
}) as () => void;
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
}
|