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