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