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