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