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