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