@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.
@@ -0,0 +1,590 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BuyBackBurn_json = exports.BuyBackBurn_jsonAbi = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * BuyBackBurn_json ABI
7
+ *
8
+ * This ABI is typed using viem's type system for full type safety.
9
+ */
10
+ exports.BuyBackBurn_jsonAbi = [
11
+ {
12
+ "anonymous": false,
13
+ "inputs": [
14
+ {
15
+ "indexed": false,
16
+ "internalType": "address",
17
+ "name": "router",
18
+ "type": "address"
19
+ }
20
+ ],
21
+ "name": "ChangeRouter",
22
+ "type": "event"
23
+ },
24
+ {
25
+ "anonymous": false,
26
+ "inputs": [
27
+ {
28
+ "indexed": false,
29
+ "internalType": "address",
30
+ "name": "token",
31
+ "type": "address"
32
+ }
33
+ ],
34
+ "name": "ChangeSFMAddress",
35
+ "type": "event"
36
+ },
37
+ {
38
+ "anonymous": false,
39
+ "inputs": [
40
+ {
41
+ "indexed": false,
42
+ "internalType": "uint256",
43
+ "name": "amount",
44
+ "type": "uint256"
45
+ }
46
+ ],
47
+ "name": "ChangeThreshold",
48
+ "type": "event"
49
+ },
50
+ {
51
+ "anonymous": false,
52
+ "inputs": [
53
+ {
54
+ "indexed": false,
55
+ "internalType": "uint8",
56
+ "name": "version",
57
+ "type": "uint8"
58
+ }
59
+ ],
60
+ "name": "Initialized",
61
+ "type": "event"
62
+ },
63
+ {
64
+ "anonymous": false,
65
+ "inputs": [
66
+ {
67
+ "indexed": true,
68
+ "internalType": "address",
69
+ "name": "previousOwner",
70
+ "type": "address"
71
+ },
72
+ {
73
+ "indexed": true,
74
+ "internalType": "address",
75
+ "name": "newOwner",
76
+ "type": "address"
77
+ }
78
+ ],
79
+ "name": "OwnershipTransferred",
80
+ "type": "event"
81
+ },
82
+ {
83
+ "inputs": [],
84
+ "name": "buyBackAndBurn",
85
+ "outputs": [],
86
+ "stateMutability": "payable",
87
+ "type": "function"
88
+ },
89
+ {
90
+ "inputs": [
91
+ {
92
+ "internalType": "address",
93
+ "name": "_tradeRouter",
94
+ "type": "address"
95
+ }
96
+ ],
97
+ "name": "changeRouter",
98
+ "outputs": [],
99
+ "stateMutability": "nonpayable",
100
+ "type": "function"
101
+ },
102
+ {
103
+ "inputs": [
104
+ {
105
+ "internalType": "address",
106
+ "name": "_token",
107
+ "type": "address"
108
+ }
109
+ ],
110
+ "name": "changeSFMToken",
111
+ "outputs": [],
112
+ "stateMutability": "nonpayable",
113
+ "type": "function"
114
+ },
115
+ {
116
+ "inputs": [
117
+ {
118
+ "internalType": "uint256",
119
+ "name": "_threshold",
120
+ "type": "uint256"
121
+ }
122
+ ],
123
+ "name": "changeThreshold",
124
+ "outputs": [],
125
+ "stateMutability": "nonpayable",
126
+ "type": "function"
127
+ },
128
+ {
129
+ "inputs": [],
130
+ "name": "factory",
131
+ "outputs": [
132
+ {
133
+ "internalType": "address",
134
+ "name": "",
135
+ "type": "address"
136
+ }
137
+ ],
138
+ "stateMutability": "view",
139
+ "type": "function"
140
+ },
141
+ {
142
+ "inputs": [
143
+ {
144
+ "internalType": "uint256",
145
+ "name": "_threshold",
146
+ "type": "uint256"
147
+ },
148
+ {
149
+ "internalType": "address",
150
+ "name": "_tradeRouter",
151
+ "type": "address"
152
+ },
153
+ {
154
+ "internalType": "address",
155
+ "name": "_sfmToken",
156
+ "type": "address"
157
+ }
158
+ ],
159
+ "name": "initialize",
160
+ "outputs": [],
161
+ "stateMutability": "nonpayable",
162
+ "type": "function"
163
+ },
164
+ {
165
+ "inputs": [],
166
+ "name": "owner",
167
+ "outputs": [
168
+ {
169
+ "internalType": "address",
170
+ "name": "",
171
+ "type": "address"
172
+ }
173
+ ],
174
+ "stateMutability": "view",
175
+ "type": "function"
176
+ },
177
+ {
178
+ "inputs": [],
179
+ "name": "renounceOwnership",
180
+ "outputs": [],
181
+ "stateMutability": "nonpayable",
182
+ "type": "function"
183
+ },
184
+ {
185
+ "inputs": [],
186
+ "name": "sfmTokenAddress",
187
+ "outputs": [
188
+ {
189
+ "internalType": "address",
190
+ "name": "",
191
+ "type": "address"
192
+ }
193
+ ],
194
+ "stateMutability": "view",
195
+ "type": "function"
196
+ },
197
+ {
198
+ "inputs": [],
199
+ "name": "threshold",
200
+ "outputs": [
201
+ {
202
+ "internalType": "uint256",
203
+ "name": "",
204
+ "type": "uint256"
205
+ }
206
+ ],
207
+ "stateMutability": "view",
208
+ "type": "function"
209
+ },
210
+ {
211
+ "inputs": [],
212
+ "name": "tradeRouter",
213
+ "outputs": [
214
+ {
215
+ "internalType": "address",
216
+ "name": "",
217
+ "type": "address"
218
+ }
219
+ ],
220
+ "stateMutability": "view",
221
+ "type": "function"
222
+ },
223
+ {
224
+ "inputs": [
225
+ {
226
+ "internalType": "address",
227
+ "name": "newOwner",
228
+ "type": "address"
229
+ }
230
+ ],
231
+ "name": "transferOwnership",
232
+ "outputs": [],
233
+ "stateMutability": "nonpayable",
234
+ "type": "function"
235
+ },
236
+ {
237
+ "stateMutability": "payable",
238
+ "type": "receive"
239
+ }
240
+ ];
241
+ /**
242
+ * BuyBackBurn_json Contract Class
243
+ *
244
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * import { createPublicClient, createWalletClient, http } from 'viem';
249
+ * import { mainnet } from 'viem/chains';
250
+ * import { BuyBackBurn_json } from 'BuyBackBurn_json';
251
+ *
252
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
253
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
254
+ *
255
+ * const contract = new BuyBackBurn_json('0x...', { publicClient, walletClient });
256
+ *
257
+ * // Read functions
258
+ * const result = await contract.balanceOf('0x...');
259
+ *
260
+ * // Write functions
261
+ * const hash = await contract.transfer('0x...', 1000n);
262
+ *
263
+ * // Simulate transactions (dry-run)
264
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
265
+ * console.log('Gas estimate:', simulation.request.gas);
266
+ *
267
+ * // Watch events
268
+ * const unwatch = contract.watch.Transfer((event) => {
269
+ * console.log('Transfer event:', event);
270
+ * });
271
+ * ```
272
+ */
273
+ class BuyBackBurn_json {
274
+ constructor(address, clients) {
275
+ this.contractAddress = address;
276
+ this.publicClient = clients.publicClient;
277
+ this.contract = (0, viem_1.getContract)({
278
+ address,
279
+ abi: exports.BuyBackBurn_jsonAbi,
280
+ client: {
281
+ public: clients.publicClient,
282
+ wallet: clients.walletClient,
283
+ },
284
+ });
285
+ }
286
+ /**
287
+ * Get the contract address
288
+ */
289
+ get address() {
290
+ return this.contractAddress;
291
+ }
292
+ /**
293
+ * Get the underlying viem contract instance
294
+ */
295
+ getContract() {
296
+ return this.contract;
297
+ }
298
+ /**
299
+ * factory
300
+ * view
301
+ */
302
+ async factory() {
303
+ return this.contract.read.factory();
304
+ }
305
+ /**
306
+ * owner
307
+ * view
308
+ */
309
+ async owner() {
310
+ return this.contract.read.owner();
311
+ }
312
+ /**
313
+ * sfmTokenAddress
314
+ * view
315
+ */
316
+ async sfmTokenAddress() {
317
+ return this.contract.read.sfmTokenAddress();
318
+ }
319
+ /**
320
+ * threshold
321
+ * view
322
+ */
323
+ async threshold() {
324
+ return this.contract.read.threshold();
325
+ }
326
+ /**
327
+ * tradeRouter
328
+ * view
329
+ */
330
+ async tradeRouter() {
331
+ return this.contract.read.tradeRouter();
332
+ }
333
+ /**
334
+ * buyBackAndBurn
335
+ * payable
336
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
337
+ */
338
+ async buyBackAndBurn(options) {
339
+ if (!this.contract.write) {
340
+ throw new Error('Wallet client is required for write operations');
341
+ }
342
+ return this.contract.write.buyBackAndBurn(options);
343
+ }
344
+ /**
345
+ * changeRouter
346
+ * nonpayable
347
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
348
+ */
349
+ async changeRouter(_tradeRouter, options) {
350
+ if (!this.contract.write) {
351
+ throw new Error('Wallet client is required for write operations');
352
+ }
353
+ return this.contract.write.changeRouter([_tradeRouter], options);
354
+ }
355
+ /**
356
+ * changeSFMToken
357
+ * nonpayable
358
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
359
+ */
360
+ async changeSFMToken(_token, options) {
361
+ if (!this.contract.write) {
362
+ throw new Error('Wallet client is required for write operations');
363
+ }
364
+ return this.contract.write.changeSFMToken([_token], options);
365
+ }
366
+ /**
367
+ * changeThreshold
368
+ * nonpayable
369
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
370
+ */
371
+ async changeThreshold(_threshold, options) {
372
+ if (!this.contract.write) {
373
+ throw new Error('Wallet client is required for write operations');
374
+ }
375
+ return this.contract.write.changeThreshold([_threshold], options);
376
+ }
377
+ /**
378
+ * initialize
379
+ * nonpayable
380
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
381
+ */
382
+ async initialize(_threshold, _tradeRouter, _sfmToken, options) {
383
+ if (!this.contract.write) {
384
+ throw new Error('Wallet client is required for write operations');
385
+ }
386
+ return this.contract.write.initialize([_threshold, _tradeRouter, _sfmToken], options);
387
+ }
388
+ /**
389
+ * renounceOwnership
390
+ * nonpayable
391
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
392
+ */
393
+ async renounceOwnership(options) {
394
+ if (!this.contract.write) {
395
+ throw new Error('Wallet client is required for write operations');
396
+ }
397
+ return this.contract.write.renounceOwnership(options);
398
+ }
399
+ /**
400
+ * transferOwnership
401
+ * nonpayable
402
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
403
+ */
404
+ async transferOwnership(newOwner, options) {
405
+ if (!this.contract.write) {
406
+ throw new Error('Wallet client is required for write operations');
407
+ }
408
+ return this.contract.write.transferOwnership([newOwner], options);
409
+ }
410
+ /**
411
+ * Simulate contract write operations (dry-run without sending transaction)
412
+ *
413
+ * @example
414
+ * const result = await contract.simulate.transfer('0x...', 1000n);
415
+ * console.log('Gas estimate:', result.request.gas);
416
+ * console.log('Would succeed:', result.result);
417
+ */
418
+ get simulate() {
419
+ const contract = this.contract;
420
+ if (!contract.simulate) {
421
+ throw new Error('Public client is required for simulation');
422
+ }
423
+ return {
424
+ /**
425
+ * Simulate buyBackAndBurn
426
+ * Returns gas estimate and result without sending transaction
427
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
428
+ */
429
+ async buyBackAndBurn(options) {
430
+ return contract.simulate.buyBackAndBurn(options);
431
+ },
432
+ /**
433
+ * Simulate changeRouter
434
+ * Returns gas estimate and result without sending transaction
435
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
436
+ */
437
+ async changeRouter(_tradeRouter, options) {
438
+ return contract.simulate.changeRouter([_tradeRouter], options);
439
+ },
440
+ /**
441
+ * Simulate changeSFMToken
442
+ * Returns gas estimate and result without sending transaction
443
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
444
+ */
445
+ async changeSFMToken(_token, options) {
446
+ return contract.simulate.changeSFMToken([_token], options);
447
+ },
448
+ /**
449
+ * Simulate changeThreshold
450
+ * Returns gas estimate and result without sending transaction
451
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
452
+ */
453
+ async changeThreshold(_threshold, options) {
454
+ return contract.simulate.changeThreshold([_threshold], options);
455
+ },
456
+ /**
457
+ * Simulate initialize
458
+ * Returns gas estimate and result without sending transaction
459
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
460
+ */
461
+ async initialize(_threshold, _tradeRouter, _sfmToken, options) {
462
+ return contract.simulate.initialize([_threshold, _tradeRouter, _sfmToken], options);
463
+ },
464
+ /**
465
+ * Simulate renounceOwnership
466
+ * Returns gas estimate and result without sending transaction
467
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
468
+ */
469
+ async renounceOwnership(options) {
470
+ return contract.simulate.renounceOwnership(options);
471
+ },
472
+ /**
473
+ * Simulate transferOwnership
474
+ * Returns gas estimate and result without sending transaction
475
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
476
+ */
477
+ async transferOwnership(newOwner, options) {
478
+ return contract.simulate.transferOwnership([newOwner], options);
479
+ }
480
+ };
481
+ }
482
+ /**
483
+ * Watch contract events
484
+ *
485
+ * @example
486
+ * // Watch all Transfer events
487
+ * const unwatch = contract.watch.Transfer((event) => {
488
+ * console.log('Transfer:', event);
489
+ * });
490
+ *
491
+ * // Stop watching
492
+ * unwatch();
493
+ */
494
+ get watch() {
495
+ return {
496
+ /**
497
+ * Watch ChangeRouter events
498
+ * @param callback Function to call when event is emitted
499
+ * @param filter Optional filter for indexed parameters
500
+ * @returns Unwatch function to stop listening
501
+ */
502
+ ChangeRouter: (callback) => {
503
+ return this.publicClient.watchContractEvent({
504
+ address: this.contractAddress,
505
+ abi: exports.BuyBackBurn_jsonAbi,
506
+ eventName: 'ChangeRouter',
507
+ onLogs: (logs) => {
508
+ logs.forEach((log) => {
509
+ callback(log.args);
510
+ });
511
+ },
512
+ });
513
+ },
514
+ /**
515
+ * Watch ChangeSFMAddress events
516
+ * @param callback Function to call when event is emitted
517
+ * @param filter Optional filter for indexed parameters
518
+ * @returns Unwatch function to stop listening
519
+ */
520
+ ChangeSFMAddress: (callback) => {
521
+ return this.publicClient.watchContractEvent({
522
+ address: this.contractAddress,
523
+ abi: exports.BuyBackBurn_jsonAbi,
524
+ eventName: 'ChangeSFMAddress',
525
+ onLogs: (logs) => {
526
+ logs.forEach((log) => {
527
+ callback(log.args);
528
+ });
529
+ },
530
+ });
531
+ },
532
+ /**
533
+ * Watch ChangeThreshold events
534
+ * @param callback Function to call when event is emitted
535
+ * @param filter Optional filter for indexed parameters
536
+ * @returns Unwatch function to stop listening
537
+ */
538
+ ChangeThreshold: (callback) => {
539
+ return this.publicClient.watchContractEvent({
540
+ address: this.contractAddress,
541
+ abi: exports.BuyBackBurn_jsonAbi,
542
+ eventName: 'ChangeThreshold',
543
+ onLogs: (logs) => {
544
+ logs.forEach((log) => {
545
+ callback(log.args);
546
+ });
547
+ },
548
+ });
549
+ },
550
+ /**
551
+ * Watch Initialized events
552
+ * @param callback Function to call when event is emitted
553
+ * @param filter Optional filter for indexed parameters
554
+ * @returns Unwatch function to stop listening
555
+ */
556
+ Initialized: (callback) => {
557
+ return this.publicClient.watchContractEvent({
558
+ address: this.contractAddress,
559
+ abi: exports.BuyBackBurn_jsonAbi,
560
+ eventName: 'Initialized',
561
+ onLogs: (logs) => {
562
+ logs.forEach((log) => {
563
+ callback(log.args);
564
+ });
565
+ },
566
+ });
567
+ },
568
+ /**
569
+ * Watch OwnershipTransferred events
570
+ * @param callback Function to call when event is emitted
571
+ * @param filter Optional filter for indexed parameters
572
+ * @returns Unwatch function to stop listening
573
+ */
574
+ OwnershipTransferred: (callback, filter) => {
575
+ return this.publicClient.watchContractEvent({
576
+ address: this.contractAddress,
577
+ abi: exports.BuyBackBurn_jsonAbi,
578
+ eventName: 'OwnershipTransferred',
579
+ args: filter,
580
+ onLogs: (logs) => {
581
+ logs.forEach((log) => {
582
+ callback(log.args);
583
+ });
584
+ },
585
+ });
586
+ }
587
+ };
588
+ }
589
+ }
590
+ exports.BuyBackBurn_json = BuyBackBurn_json;