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