@pufferfinance/puffer-sdk 1.13.2 → 1.14.1
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/dist/api/puffer-client-helpers.cjs +1 -1
- package/dist/api/puffer-client-helpers.cjs.map +1 -1
- package/dist/api/puffer-client-helpers.js +3 -3
- package/dist/api/puffer-client-helpers.js.map +1 -1
- package/dist/api/puffer-client.cjs +1 -1
- package/dist/api/puffer-client.js +2 -2
- package/dist/{ccip-C0xwQhXU.cjs → ccip-BYEwaDSr.cjs} +2 -2
- package/dist/{ccip-C0xwQhXU.cjs.map → ccip-BYEwaDSr.cjs.map} +1 -1
- package/dist/{ccip-K-z2PL4P.js → ccip-DA_MOIPz.js} +3 -3
- package/dist/{ccip-K-z2PL4P.js.map → ccip-DA_MOIPz.js.map} +1 -1
- package/dist/chains/constants.cjs +1 -1
- package/dist/chains/constants.d.ts +4 -1
- package/dist/chains/constants.js +1 -1
- package/dist/constants-5WxIZnbu.cjs +9 -0
- package/dist/constants-5WxIZnbu.cjs.map +1 -0
- package/dist/{constants-CH7Tz5jz.js → constants-BDqMRitM.js} +924 -798
- package/dist/constants-BDqMRitM.js.map +1 -0
- package/dist/contracts/abis/mainnet/Accountant.cjs +1 -1
- package/dist/contracts/abis/mainnet/Accountant.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/Accountant.d.ts +13 -457
- package/dist/contracts/abis/mainnet/Accountant.js +12 -441
- package/dist/contracts/abis/mainnet/Accountant.js.map +1 -1
- package/dist/contracts/abis/mainnet/BoringVault.cjs +1 -1
- package/dist/contracts/abis/mainnet/BoringVault.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/BoringVault.d.ts +18 -505
- package/dist/contracts/abis/mainnet/BoringVault.js +15 -346
- package/dist/contracts/abis/mainnet/BoringVault.js.map +1 -1
- package/dist/contracts/abis/mainnet/CarrotStaker.cjs +1 -1
- package/dist/contracts/abis/mainnet/CarrotStaker.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/CarrotStaker.d.ts +2 -371
- package/dist/contracts/abis/mainnet/CarrotStaker.js +4 -295
- package/dist/contracts/abis/mainnet/CarrotStaker.js.map +1 -1
- package/dist/contracts/abis/mainnet/Distributor.cjs +1 -1
- package/dist/contracts/abis/mainnet/Distributor.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/Distributor.d.ts +0 -413
- package/dist/contracts/abis/mainnet/Distributor.js +2 -355
- package/dist/contracts/abis/mainnet/Distributor.js.map +1 -1
- package/dist/contracts/abis/mainnet/L1RewardManager.cjs +1 -1
- package/dist/contracts/abis/mainnet/L1RewardManager.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/L1RewardManager.d.ts +0 -489
- package/dist/contracts/abis/mainnet/L1RewardManager.js +0 -411
- package/dist/contracts/abis/mainnet/L1RewardManager.js.map +1 -1
- package/dist/contracts/abis/mainnet/L2RewardManager.cjs +1 -1
- package/dist/contracts/abis/mainnet/L2RewardManager.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/L2RewardManager.d.ts +23 -569
- package/dist/contracts/abis/mainnet/L2RewardManager.js +16 -484
- package/dist/contracts/abis/mainnet/L2RewardManager.js.map +1 -1
- package/dist/contracts/abis/mainnet/PufLocker.cjs +1 -1
- package/dist/contracts/abis/mainnet/PufLocker.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/PufLocker.d.ts +29 -371
- package/dist/contracts/abis/mainnet/PufLocker.js +15 -285
- package/dist/contracts/abis/mainnet/PufLocker.js.map +1 -1
- package/dist/contracts/abis/mainnet/PufferL2Depositor.cjs +1 -1
- package/dist/contracts/abis/mainnet/PufferL2Depositor.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/PufferL2Depositor.d.ts +0 -325
- package/dist/contracts/abis/mainnet/PufferL2Depositor.js +0 -270
- package/dist/contracts/abis/mainnet/PufferL2Depositor.js.map +1 -1
- package/dist/contracts/abis/mainnet/PufferVaultV2.cjs +1 -1
- package/dist/contracts/abis/mainnet/PufferVaultV2.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/PufferVaultV2.d.ts +35 -1289
- package/dist/contracts/abis/mainnet/PufferVaultV2.js +45 -1681
- package/dist/contracts/abis/mainnet/PufferVaultV2.js.map +1 -1
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.cjs +1 -1
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.d.ts +3 -426
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.js +5 -552
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.js.map +1 -1
- package/dist/contracts/abis/mainnet/Teller.cjs +1 -1
- package/dist/contracts/abis/mainnet/Teller.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/Teller.d.ts +18 -444
- package/dist/contracts/abis/mainnet/Teller.js +15 -390
- package/dist/contracts/abis/mainnet/Teller.js.map +1 -1
- package/dist/contracts/abis/mainnet/mtwCARROT.cjs +1 -1
- package/dist/contracts/abis/mainnet/mtwCARROT.cjs.map +1 -1
- package/dist/contracts/abis/mainnet/mtwCARROT.d.ts +69 -399
- package/dist/contracts/abis/mainnet/mtwCARROT.js +43 -346
- package/dist/contracts/abis/mainnet/mtwCARROT.js.map +1 -1
- package/dist/contracts/addresses.cjs +1 -1
- package/dist/contracts/addresses.cjs.map +1 -1
- package/dist/contracts/addresses.js +4 -1
- package/dist/contracts/addresses.js.map +1 -1
- package/dist/contracts/handlers/carrot-staking-handler.cjs +1 -1
- package/dist/contracts/handlers/carrot-staking-handler.d.ts +1652 -0
- package/dist/contracts/handlers/carrot-staking-handler.js +2 -2
- package/dist/contracts/handlers/distributor-handler.cjs +1 -1
- package/dist/contracts/handlers/distributor-handler.cjs.map +1 -1
- package/dist/contracts/handlers/distributor-handler.d.ts +8762 -0
- package/dist/contracts/handlers/distributor-handler.js +13 -127
- package/dist/contracts/handlers/distributor-handler.js.map +1 -1
- package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
- package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
- package/dist/contracts/handlers/erc20-permit-handler.d.ts +4 -4
- package/dist/contracts/handlers/erc20-permit-handler.js +14 -14
- package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
- package/dist/contracts/handlers/l1-reward-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/l1-reward-manager-handler.cjs.map +1 -1
- package/dist/contracts/handlers/l1-reward-manager-handler.d.ts +339 -0
- package/dist/contracts/handlers/l1-reward-manager-handler.js +14 -14
- package/dist/contracts/handlers/l1-reward-manager-handler.js.map +1 -1
- package/dist/contracts/handlers/l2-reward-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/l2-reward-manager-handler.cjs.map +1 -1
- package/dist/contracts/handlers/l2-reward-manager-handler.d.ts +2423 -0
- package/dist/contracts/handlers/l2-reward-manager-handler.js +6 -6
- package/dist/contracts/handlers/l2-reward-manager-handler.js.map +1 -1
- package/dist/contracts/handlers/mtw-carrot-handler.cjs +1 -1
- package/dist/contracts/handlers/mtw-carrot-handler.d.ts +14333 -0
- package/dist/contracts/handlers/mtw-carrot-handler.js +2 -2
- package/dist/contracts/handlers/nucleus-accountant-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-accountant-handler.cjs.map +1 -1
- package/dist/contracts/handlers/nucleus-accountant-handler.d.ts +620 -0
- package/dist/contracts/handlers/nucleus-accountant-handler.js +8 -8
- package/dist/contracts/handlers/nucleus-accountant-handler.js.map +1 -1
- package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs.map +1 -1
- package/dist/contracts/handlers/nucleus-atomic-queue-handler.js +9 -9
- package/dist/contracts/handlers/nucleus-atomic-queue-handler.js.map +1 -1
- package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs.map +1 -1
- package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +3917 -0
- package/dist/contracts/handlers/nucleus-boring-vault-handler.js +24 -24
- package/dist/contracts/handlers/nucleus-boring-vault-handler.js.map +1 -1
- package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-teller-handler.cjs.map +1 -1
- package/dist/contracts/handlers/nucleus-teller-handler.d.ts +2209 -0
- package/dist/contracts/handlers/nucleus-teller-handler.js +14 -14
- package/dist/contracts/handlers/nucleus-teller-handler.js.map +1 -1
- package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
- package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puf-locker-handler.d.ts +2389 -0
- package/dist/contracts/handlers/puf-locker-handler.js +12 -12
- package/dist/contracts/handlers/puf-locker-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-depositor-handler.d.ts +100 -100
- package/dist/contracts/handlers/puffer-depositor-handler.js +19 -19
- package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-l2-depositor-handler.d.ts +471 -0
- package/dist/contracts/handlers/puffer-l2-depositor-handler.js +17 -17
- package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-vault-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-vault-handler.d.ts +4657 -0
- package/dist/contracts/handlers/puffer-vault-handler.js +4 -4
- package/dist/contracts/handlers/puffer-vault-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.d.ts +1882 -0
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +10 -10
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
- package/dist/contracts/tokens.cjs +1 -1
- package/dist/contracts/tokens.cjs.map +1 -1
- package/dist/contracts/tokens.d.ts +3 -1
- package/dist/contracts/tokens.js +71 -60
- package/dist/contracts/tokens.js.map +1 -1
- package/dist/contracts/vaults-addresses.cjs +1 -1
- package/dist/contracts/vaults-addresses.d.ts +5 -4
- package/dist/contracts/vaults-addresses.js +1 -1
- package/dist/{createWalletClient-DNLhBkOd.js → createWalletClient-DMXR-Bug.js} +4 -4
- package/dist/{createWalletClient-DNLhBkOd.js.map → createWalletClient-DMXR-Bug.js.map} +1 -1
- package/dist/{createWalletClient-Di5of07E.cjs → createWalletClient-L7tR5Gda.cjs} +2 -2
- package/dist/{createWalletClient-Di5of07E.cjs.map → createWalletClient-L7tR5Gda.cjs.map} +1 -1
- package/dist/{getContract-ChPFzc5y.cjs → getContract-Bt9GsQBq.cjs} +2 -2
- package/dist/{getContract-ChPFzc5y.cjs.map → getContract-Bt9GsQBq.cjs.map} +1 -1
- package/dist/{getContract-6ajhFbP2.js → getContract-DXPZJOBy.js} +2 -2
- package/dist/{getContract-6ajhFbP2.js.map → getContract-DXPZJOBy.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +1 -1
- package/dist/{secp256k1-Ev0s9Yr6.js → secp256k1-D02y6Pc-.js} +2 -2
- package/dist/{secp256k1-Ev0s9Yr6.js.map → secp256k1-D02y6Pc-.js.map} +1 -1
- package/dist/{secp256k1-B8plqpXf.cjs → secp256k1-q_akf6f-.cjs} +2 -2
- package/dist/{secp256k1-B8plqpXf.cjs.map → secp256k1-q_akf6f-.cjs.map} +1 -1
- package/dist/utils/version.cjs +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/{writeContract-CjcOEtWX.js → writeContract-BsrMQkg5.js} +4 -4
- package/dist/{writeContract-CjcOEtWX.js.map → writeContract-BsrMQkg5.js.map} +1 -1
- package/dist/{writeContract-BatuNuTe.cjs → writeContract-Cbrw62uO.cjs} +3 -3
- package/dist/{writeContract-BatuNuTe.cjs.map → writeContract-Cbrw62uO.cjs.map} +1 -1
- package/package.json +2 -2
- package/dist/constants-BcPRVxdH.cjs +0 -9
- package/dist/constants-BcPRVxdH.cjs.map +0 -1
- package/dist/constants-CH7Tz5jz.js.map +0 -1
- package/dist/contracts/abis/holesky/PufferDepositor.cjs +0 -2
- package/dist/contracts/abis/holesky/PufferDepositor.cjs.map +0 -1
- package/dist/contracts/abis/holesky/PufferDepositor.d.ts +0 -283
- package/dist/contracts/abis/holesky/PufferDepositor.js +0 -377
- package/dist/contracts/abis/holesky/PufferDepositor.js.map +0 -1
- package/dist/contracts/abis/holesky/PufferVaultV2.cjs +0 -2
- package/dist/contracts/abis/holesky/PufferVaultV2.cjs.map +0 -1
- package/dist/contracts/abis/holesky/PufferVaultV2.d.ts +0 -1361
- package/dist/contracts/abis/holesky/PufferVaultV2.js +0 -1787
- package/dist/contracts/abis/holesky/PufferVaultV2.js.map +0 -1
- package/dist/contracts/abis/l1-reward-manager-abis.cjs +0 -2
- package/dist/contracts/abis/l1-reward-manager-abis.cjs.map +0 -1
- package/dist/contracts/abis/l1-reward-manager-abis.d.ts +0 -527
- package/dist/contracts/abis/l1-reward-manager-abis.js +0 -10
- package/dist/contracts/abis/l1-reward-manager-abis.js.map +0 -1
- package/dist/contracts/abis/l2-reward-manager-abis.cjs +0 -2
- package/dist/contracts/abis/l2-reward-manager-abis.cjs.map +0 -1
- package/dist/contracts/abis/l2-reward-manager-abis.d.ts +0 -709
- package/dist/contracts/abis/l2-reward-manager-abis.js +0 -11
- package/dist/contracts/abis/l2-reward-manager-abis.js.map +0 -1
- package/dist/contracts/abis/nucleus-accountant-abis.cjs +0 -2
- package/dist/contracts/abis/nucleus-accountant-abis.cjs.map +0 -1
- package/dist/contracts/abis/nucleus-accountant-abis.d.ts +0 -525
- package/dist/contracts/abis/nucleus-accountant-abis.js +0 -9
- package/dist/contracts/abis/nucleus-accountant-abis.js.map +0 -1
- package/dist/contracts/abis/nucleus-atomic-queue-abis.cjs +0 -2
- package/dist/contracts/abis/nucleus-atomic-queue-abis.cjs.map +0 -1
- package/dist/contracts/abis/nucleus-atomic-queue-abis.d.ts +0 -332
- package/dist/contracts/abis/nucleus-atomic-queue-abis.js +0 -9
- package/dist/contracts/abis/nucleus-atomic-queue-abis.js.map +0 -1
- package/dist/contracts/abis/nucleus-boring-vault-abis.cjs +0 -2
- package/dist/contracts/abis/nucleus-boring-vault-abis.cjs.map +0 -1
- package/dist/contracts/abis/nucleus-boring-vault-abis.d.ts +0 -626
- package/dist/contracts/abis/nucleus-boring-vault-abis.js +0 -9
- package/dist/contracts/abis/nucleus-boring-vault-abis.js.map +0 -1
- package/dist/contracts/abis/nucleus-teller-abis.cjs +0 -2
- package/dist/contracts/abis/nucleus-teller-abis.cjs.map +0 -1
- package/dist/contracts/abis/nucleus-teller-abis.d.ts +0 -545
- package/dist/contracts/abis/nucleus-teller-abis.js +0 -9
- package/dist/contracts/abis/nucleus-teller-abis.js.map +0 -1
- package/dist/contracts/abis/puf-locker-abis.cjs +0 -2
- package/dist/contracts/abis/puf-locker-abis.cjs.map +0 -1
- package/dist/contracts/abis/puf-locker-abis.d.ts +0 -484
- package/dist/contracts/abis/puf-locker-abis.js +0 -10
- package/dist/contracts/abis/puf-locker-abis.js.map +0 -1
- package/dist/contracts/abis/puffer-depositor-abis.cjs +0 -2
- package/dist/contracts/abis/puffer-depositor-abis.cjs.map +0 -1
- package/dist/contracts/abis/puffer-depositor-abis.d.ts +0 -664
- package/dist/contracts/abis/puffer-depositor-abis.js +0 -20
- package/dist/contracts/abis/puffer-depositor-abis.js.map +0 -1
- package/dist/contracts/abis/puffer-vault-abis.cjs +0 -2
- package/dist/contracts/abis/puffer-vault-abis.cjs.map +0 -1
- package/dist/contracts/abis/puffer-vault-abis.d.ts +0 -2787
- package/dist/contracts/abis/puffer-vault-abis.js +0 -15
- package/dist/contracts/abis/puffer-vault-abis.js.map +0 -1
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.cjs +0 -2
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.cjs.map +0 -1
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.d.ts +0 -514
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.js +0 -10
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.js.map +0 -1
- package/dist/contracts/abis/tokens-abis.cjs +0 -2
- package/dist/contracts/abis/tokens-abis.cjs.map +0 -1
- package/dist/contracts/abis/tokens-abis.d.ts +0 -396
- package/dist/contracts/abis/tokens-abis.js +0 -6
- package/dist/contracts/abis/tokens-abis.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { V as
|
|
5
|
-
import { CONTRACT_ADDRESSES as
|
|
6
|
-
import { Distributor as
|
|
7
|
-
import { g as
|
|
8
|
-
class
|
|
1
|
+
var s = Object.defineProperty;
|
|
2
|
+
var c = (i, t, e) => t in i ? s(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var o = (i, t, e) => c(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { V as h } from "../../constants-BDqMRitM.js";
|
|
5
|
+
import { CONTRACT_ADDRESSES as l } from "../addresses.js";
|
|
6
|
+
import { Distributor as u } from "../abis/mainnet/Distributor.js";
|
|
7
|
+
import { g as C } from "../../getContract-DXPZJOBy.js";
|
|
8
|
+
class O {
|
|
9
9
|
/**
|
|
10
10
|
* Create the handler for the Distributor contract exposing
|
|
11
11
|
* methods to interact with the contract.
|
|
@@ -15,8 +15,8 @@ class w {
|
|
|
15
15
|
* @param publicClient The public client to use for public interactions.
|
|
16
16
|
*/
|
|
17
17
|
constructor(t, e, r) {
|
|
18
|
-
|
|
19
|
-
this.chain = t, this.walletClient = e, this.publicClient = r, this.viemChain =
|
|
18
|
+
o(this, "viemChain");
|
|
19
|
+
this.chain = t, this.walletClient = e, this.publicClient = r, this.viemChain = h[t];
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Get the contract.
|
|
@@ -24,17 +24,8 @@ class w {
|
|
|
24
24
|
* @returns The viem contract.
|
|
25
25
|
*/
|
|
26
26
|
getContract() {
|
|
27
|
-
const t =
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Check if an address can update the merkle root.
|
|
32
|
-
*
|
|
33
|
-
* @param address The address to check.
|
|
34
|
-
* @returns Whether the address can update the merkle root.
|
|
35
|
-
*/
|
|
36
|
-
canUpdateMerkleRoot(t) {
|
|
37
|
-
return this.getContract().read.canUpdateMerkleRoot([t]);
|
|
27
|
+
const t = l[this.chain].Distributor, e = u, r = { public: this.publicClient, wallet: this.walletClient };
|
|
28
|
+
return C({ address: t, abi: e, client: r });
|
|
38
29
|
}
|
|
39
30
|
/**
|
|
40
31
|
* Claim tokens for multiple users.
|
|
@@ -154,98 +145,6 @@ class w {
|
|
|
154
145
|
onlyOperatorCanClaim(t) {
|
|
155
146
|
return this.getContract().read.onlyOperatorCanClaim([t]);
|
|
156
147
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Check if an address is an operator for a user.
|
|
159
|
-
*
|
|
160
|
-
* @param user The user address.
|
|
161
|
-
* @param operator The operator address.
|
|
162
|
-
* @returns Whether the address is an operator.
|
|
163
|
-
*/
|
|
164
|
-
operators(t, e) {
|
|
165
|
-
return this.getContract().read.operators([t, e]);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Recover ERC20 tokens sent to the contract.
|
|
169
|
-
*
|
|
170
|
-
* @param account The account recovering the tokens.
|
|
171
|
-
* @param tokenAddress The token address to recover.
|
|
172
|
-
* @param to The address to send recovered tokens to.
|
|
173
|
-
* @param amountToRecover The amount to recover.
|
|
174
|
-
* @returns A promise that resolves to the transaction hash.
|
|
175
|
-
*/
|
|
176
|
-
recoverERC20(t, e, r, a) {
|
|
177
|
-
return this.getContract().write.recoverERC20(
|
|
178
|
-
[e, r, a],
|
|
179
|
-
{
|
|
180
|
-
account: t,
|
|
181
|
-
chain: this.viemChain
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Resolve a dispute.
|
|
187
|
-
*
|
|
188
|
-
* @param account The account resolving the dispute.
|
|
189
|
-
* @param valid Whether the disputed tree is valid.
|
|
190
|
-
* @returns A promise that resolves to the transaction hash.
|
|
191
|
-
*/
|
|
192
|
-
resolveDispute(t, e) {
|
|
193
|
-
return this.getContract().write.resolveDispute([e], {
|
|
194
|
-
account: t,
|
|
195
|
-
chain: this.viemChain
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Revoke the current tree.
|
|
200
|
-
*
|
|
201
|
-
* @param account The account revoking the tree.
|
|
202
|
-
* @returns A promise that resolves to the transaction hash.
|
|
203
|
-
*/
|
|
204
|
-
revokeTree(t) {
|
|
205
|
-
return this.getContract().write.revokeTree({
|
|
206
|
-
account: t,
|
|
207
|
-
chain: this.viemChain
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Set the dispute amount.
|
|
212
|
-
*
|
|
213
|
-
* @param account The account setting the dispute amount.
|
|
214
|
-
* @param disputeAmount The new dispute amount.
|
|
215
|
-
* @returns A promise that resolves to the transaction hash.
|
|
216
|
-
*/
|
|
217
|
-
setDisputeAmount(t, e) {
|
|
218
|
-
return this.getContract().write.setDisputeAmount([e], {
|
|
219
|
-
account: t,
|
|
220
|
-
chain: this.viemChain
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Set the dispute period.
|
|
225
|
-
*
|
|
226
|
-
* @param account The account setting the dispute period.
|
|
227
|
-
* @param disputePeriod The new dispute period in seconds.
|
|
228
|
-
* @returns A promise that resolves to the transaction hash.
|
|
229
|
-
*/
|
|
230
|
-
setDisputePeriod(t, e) {
|
|
231
|
-
return this.getContract().write.setDisputePeriod([e], {
|
|
232
|
-
account: t,
|
|
233
|
-
chain: this.viemChain
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Set the dispute token.
|
|
238
|
-
*
|
|
239
|
-
* @param account The account setting the dispute token.
|
|
240
|
-
* @param disputeToken The new dispute token address.
|
|
241
|
-
* @returns A promise that resolves to the transaction hash.
|
|
242
|
-
*/
|
|
243
|
-
setDisputeToken(t, e) {
|
|
244
|
-
return this.getContract().write.setDisputeToken([e], {
|
|
245
|
-
account: t,
|
|
246
|
-
chain: this.viemChain
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
148
|
/**
|
|
250
149
|
* Toggle whether only operators can claim for a user.
|
|
251
150
|
*
|
|
@@ -298,21 +197,8 @@ class w {
|
|
|
298
197
|
ipfsHash: e
|
|
299
198
|
};
|
|
300
199
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Update the merkle tree.
|
|
303
|
-
*
|
|
304
|
-
* @param account The account updating the tree.
|
|
305
|
-
* @param tree The new tree information.
|
|
306
|
-
* @returns A promise that resolves to the transaction hash.
|
|
307
|
-
*/
|
|
308
|
-
updateTree(t, e) {
|
|
309
|
-
return this.getContract().write.updateTree([e], {
|
|
310
|
-
account: t,
|
|
311
|
-
chain: this.viemChain
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
200
|
}
|
|
315
201
|
export {
|
|
316
|
-
|
|
202
|
+
O as DistributorHandler
|
|
317
203
|
};
|
|
318
204
|
//# sourceMappingURL=distributor-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distributor-handler.js","sources":["../../../lib/contracts/handlers/distributor-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { Distributor } from '../abis/mainnet/Distributor';\n\ninterface ContractAddressesWithDistributor {\n Distributor: Address;\n}\n\nexport interface MerkleTree {\n merkleRoot: `0x${string}`;\n ipfsHash: `0x${string}`;\n}\n\nexport interface ClaimInfo {\n amount: bigint;\n timestamp: bigint;\n merkleRoot: `0x${string}`;\n}\n\nexport interface ClaimParams {\n users: Address[];\n tokens: Address[];\n amounts: bigint[];\n proofs: `0x${string}`[][];\n}\n\n/**\n * Handler for the Merkle Distributor contract, for claiming rewards, e.g. mtwCARROT.\n */\nexport class DistributorHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the Distributor contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet interactions.\n * @param publicClient The public client to use for public interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n }\n\n /**\n * Get the contract.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = (\n CONTRACT_ADDRESSES[\n this.chain\n ] as unknown as ContractAddressesWithDistributor\n ).Distributor;\n const abi = Distributor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Check if an address can update the merkle root.\n *\n * @param address The address to check.\n * @returns Whether the address can update the merkle root.\n */\n public canUpdateMerkleRoot(address: Address) {\n return this.getContract().read.canUpdateMerkleRoot([address]);\n }\n\n /**\n * Claim tokens for multiple users.\n *\n * @param account The account making the claim.\n * @param params The claim parameters.\n * @returns A promise that resolves to the transaction hash.\n */\n public claim(\n account: Address,\n { users, tokens, amounts, proofs }: ClaimParams,\n ) {\n return this.getContract().write.claim([users, tokens, amounts, proofs], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get claim information for a user and token.\n *\n * @param user The user address.\n * @param token The token address.\n * @returns The claim information.\n */\n public async claimed(user: Address, token: Address): Promise<ClaimInfo> {\n const [amount, timestamp, merkleRoot] =\n await this.getContract().read.claimed([user, token]);\n return {\n amount,\n timestamp: BigInt(timestamp),\n merkleRoot,\n };\n }\n\n /**\n * Get the core contract address.\n *\n * @returns The core contract address.\n */\n public core() {\n return this.getContract().read.core();\n }\n\n /**\n * Get the dispute amount.\n *\n * @returns The dispute amount.\n */\n public disputeAmount() {\n return this.getContract().read.disputeAmount();\n }\n\n /**\n * Get the dispute period.\n *\n * @returns The dispute period in seconds.\n */\n public disputePeriod() {\n return this.getContract().read.disputePeriod();\n }\n\n /**\n * Get the dispute token address.\n *\n * @returns The dispute token address.\n */\n public disputeToken() {\n return this.getContract().read.disputeToken();\n }\n\n /**\n * Dispute the current tree.\n *\n * @param account The account disputing the tree.\n * @param reason The reason for the dispute.\n * @returns A promise that resolves to the transaction hash.\n */\n public disputeTree(account: Address, reason: string) {\n return this.getContract().write.disputeTree([reason], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the current disputer address.\n *\n * @returns The disputer address.\n */\n public disputer() {\n return this.getContract().read.disputer();\n }\n\n /**\n * Get the end of the dispute period.\n *\n * @returns The timestamp when the dispute period ends.\n */\n public endOfDisputePeriod() {\n return this.getContract().read.endOfDisputePeriod();\n }\n\n /**\n * Get the current merkle root.\n *\n * @returns The current merkle root.\n */\n public getMerkleRoot() {\n return this.getContract().read.getMerkleRoot();\n }\n\n /**\n * Get the last tree information.\n *\n * @returns The last tree information.\n */\n public async lastTree(): Promise<MerkleTree> {\n const [merkleRoot, ipfsHash] = await this.getContract().read.lastTree();\n return {\n merkleRoot,\n ipfsHash,\n };\n }\n\n /**\n * Check if only operators can claim for a user.\n *\n * @param user The user address to check.\n * @returns Whether only operators can claim for the user.\n */\n public onlyOperatorCanClaim(user: Address) {\n return this.getContract().read.onlyOperatorCanClaim([user]);\n }\n\n /**\n * Check if an address is an operator for a user.\n *\n * @param user The user address.\n * @param operator The operator address.\n * @returns Whether the address is an operator.\n */\n public operators(user: Address, operator: Address) {\n return this.getContract().read.operators([user, operator]);\n }\n\n /**\n * Recover ERC20 tokens sent to the contract.\n *\n * @param account The account recovering the tokens.\n * @param tokenAddress The token address to recover.\n * @param to The address to send recovered tokens to.\n * @param amountToRecover The amount to recover.\n * @returns A promise that resolves to the transaction hash.\n */\n public recoverERC20(\n account: Address,\n tokenAddress: Address,\n to: Address,\n amountToRecover: bigint,\n ) {\n return this.getContract().write.recoverERC20(\n [tokenAddress, to, amountToRecover],\n {\n account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Resolve a dispute.\n *\n * @param account The account resolving the dispute.\n * @param valid Whether the disputed tree is valid.\n * @returns A promise that resolves to the transaction hash.\n */\n public resolveDispute(account: Address, valid: boolean) {\n return this.getContract().write.resolveDispute([valid], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Revoke the current tree.\n *\n * @param account The account revoking the tree.\n * @returns A promise that resolves to the transaction hash.\n */\n public revokeTree(account: Address) {\n return this.getContract().write.revokeTree({\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the dispute amount.\n *\n * @param account The account setting the dispute amount.\n * @param disputeAmount The new dispute amount.\n * @returns A promise that resolves to the transaction hash.\n */\n public setDisputeAmount(account: Address, disputeAmount: bigint) {\n return this.getContract().write.setDisputeAmount([disputeAmount], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the dispute period.\n *\n * @param account The account setting the dispute period.\n * @param disputePeriod The new dispute period in seconds.\n * @returns A promise that resolves to the transaction hash.\n */\n public setDisputePeriod(account: Address, disputePeriod: number) {\n return this.getContract().write.setDisputePeriod([disputePeriod], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the dispute token.\n *\n * @param account The account setting the dispute token.\n * @param disputeToken The new dispute token address.\n * @returns A promise that resolves to the transaction hash.\n */\n public setDisputeToken(account: Address, disputeToken: Address) {\n return this.getContract().write.setDisputeToken([disputeToken], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Toggle whether only operators can claim for a user.\n *\n * @param account The account toggling the setting.\n * @param user The user address to toggle for.\n * @returns A promise that resolves to the transaction hash.\n */\n public toggleOnlyOperatorCanClaim(account: Address, user: Address) {\n return this.getContract().write.toggleOnlyOperatorCanClaim([user], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Toggle an operator for a user.\n *\n * @param account The account toggling the operator.\n * @param user The user address.\n * @param operator The operator address to toggle.\n * @returns A promise that resolves to the transaction hash.\n */\n public toggleOperator(account: Address, user: Address, operator: Address) {\n return this.getContract().write.toggleOperator([user, operator], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Toggle whether an address is trusted.\n *\n * @param account The account toggling the trusted status.\n * @param eoa The address to toggle trust for.\n * @returns A promise that resolves to the transaction hash.\n */\n public toggleTrusted(account: Address, eoa: Address) {\n return this.getContract().write.toggleTrusted([eoa], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the current tree information.\n *\n * @returns The current tree information.\n */\n public async tree(): Promise<MerkleTree> {\n const [merkleRoot, ipfsHash] = await this.getContract().read.tree();\n return {\n merkleRoot,\n ipfsHash,\n };\n }\n\n /**\n * Update the merkle tree.\n *\n * @param account The account updating the tree.\n * @param tree The new tree information.\n * @returns A promise that resolves to the transaction hash.\n */\n public updateTree(account: Address, tree: MerkleTree) {\n return this.getContract().write.updateTree([tree], {\n account,\n chain: this.viemChain,\n });\n }\n}\n"],"names":["DistributorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","Distributor","client","getContract","account","users","tokens","amounts","proofs","user","token","amount","timestamp","merkleRoot","reason","ipfsHash","operator","tokenAddress","to","amountToRecover","valid","disputeAmount","disputePeriod","disputeToken","eoa","tree"],"mappings":";;;;;;;AAoCO,MAAMA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { Distributor } from '../abis/mainnet/Distributor';\n\nexport interface MerkleTree {\n merkleRoot: Address;\n ipfsHash: Address;\n}\n\nexport interface ClaimInfo {\n amount: bigint;\n timestamp: bigint;\n merkleRoot: Address;\n}\n\nexport interface ClaimParams {\n users: Address[];\n tokens: Address[];\n amounts: bigint[];\n proofs: Address[][];\n}\n\n/**\n * Handler for the Merkle Distributor contract, for claiming rewards, e.g. mtwCARROT.\n */\nexport class DistributorHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the Distributor contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet interactions.\n * @param publicClient The public client to use for public interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n }\n\n /**\n * Get the contract.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].Distributor as Address;\n const abi = Distributor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Claim tokens for multiple users.\n *\n * @param account The account making the claim.\n * @param params The claim parameters.\n * @returns A promise that resolves to the transaction hash.\n */\n public claim(\n account: Address,\n { users, tokens, amounts, proofs }: ClaimParams,\n ) {\n return this.getContract().write.claim([users, tokens, amounts, proofs], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get claim information for a user and token.\n *\n * @param user The user address.\n * @param token The token address.\n * @returns The claim information.\n */\n public async claimed(user: Address, token: Address): Promise<ClaimInfo> {\n const [amount, timestamp, merkleRoot] =\n await this.getContract().read.claimed([user, token]);\n return {\n amount,\n timestamp: BigInt(timestamp),\n merkleRoot,\n };\n }\n\n /**\n * Get the core contract address.\n *\n * @returns The core contract address.\n */\n public core() {\n return this.getContract().read.core();\n }\n\n /**\n * Get the dispute amount.\n *\n * @returns The dispute amount.\n */\n public disputeAmount() {\n return this.getContract().read.disputeAmount();\n }\n\n /**\n * Get the dispute period.\n *\n * @returns The dispute period in seconds.\n */\n public disputePeriod() {\n return this.getContract().read.disputePeriod();\n }\n\n /**\n * Get the dispute token address.\n *\n * @returns The dispute token address.\n */\n public disputeToken() {\n return this.getContract().read.disputeToken();\n }\n\n /**\n * Dispute the current tree.\n *\n * @param account The account disputing the tree.\n * @param reason The reason for the dispute.\n * @returns A promise that resolves to the transaction hash.\n */\n public disputeTree(account: Address, reason: string) {\n return this.getContract().write.disputeTree([reason], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the current disputer address.\n *\n * @returns The disputer address.\n */\n public disputer() {\n return this.getContract().read.disputer();\n }\n\n /**\n * Get the end of the dispute period.\n *\n * @returns The timestamp when the dispute period ends.\n */\n public endOfDisputePeriod() {\n return this.getContract().read.endOfDisputePeriod();\n }\n\n /**\n * Get the current merkle root.\n *\n * @returns The current merkle root.\n */\n public getMerkleRoot() {\n return this.getContract().read.getMerkleRoot();\n }\n\n /**\n * Get the last tree information.\n *\n * @returns The last tree information.\n */\n public async lastTree(): Promise<MerkleTree> {\n const [merkleRoot, ipfsHash] = await this.getContract().read.lastTree();\n return {\n merkleRoot,\n ipfsHash,\n };\n }\n\n /**\n * Check if only operators can claim for a user.\n *\n * @param user The user address to check.\n * @returns Whether only operators can claim for the user.\n */\n public onlyOperatorCanClaim(user: Address) {\n return this.getContract().read.onlyOperatorCanClaim([user]);\n }\n\n /**\n * Toggle whether only operators can claim for a user.\n *\n * @param account The account toggling the setting.\n * @param user The user address to toggle for.\n * @returns A promise that resolves to the transaction hash.\n */\n public toggleOnlyOperatorCanClaim(account: Address, user: Address) {\n return this.getContract().write.toggleOnlyOperatorCanClaim([user], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Toggle an operator for a user.\n *\n * @param account The account toggling the operator.\n * @param user The user address.\n * @param operator The operator address to toggle.\n * @returns A promise that resolves to the transaction hash.\n */\n public toggleOperator(account: Address, user: Address, operator: Address) {\n return this.getContract().write.toggleOperator([user, operator], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Toggle whether an address is trusted.\n *\n * @param account The account toggling the trusted status.\n * @param eoa The address to toggle trust for.\n * @returns A promise that resolves to the transaction hash.\n */\n public toggleTrusted(account: Address, eoa: Address) {\n return this.getContract().write.toggleTrusted([eoa], {\n account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the current tree information.\n *\n * @returns The current tree information.\n */\n public async tree(): Promise<MerkleTree> {\n const [merkleRoot, ipfsHash] = await this.getContract().read.tree();\n return {\n merkleRoot,\n ipfsHash,\n };\n }\n}\n"],"names":["DistributorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","Distributor","client","getContract","account","users","tokens","amounts","proofs","user","token","amount","timestamp","merkleRoot","reason","ipfsHash","operator","eoa"],"mappings":";;;;;;;AAgCO,MAAMA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW9B,YACUC,GACAC,GACAC,GACR;AAdM,IAAAC,EAAA;AAWE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,cAAc;AACnB,UAAMK,IAAUC,EAAmB,KAAK,KAAK,EAAE,aACzCC,IAAMC,GACNC,IAAS,EAAE,QAAQ,KAAK,cAAc,QAAQ,KAAK,aAAa;AAEtE,WAAOC,EAAY,EAAE,SAAAL,GAAS,KAAAE,GAAK,QAAAE,GAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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H,MAAa,OAA4B;AACjC,UAAA,CAACS,GAAYE,CAAQ,IAAI,MAAM,KAAK,YAAc,EAAA,KAAK,KAAK;AAC3D,WAAA;AAAA,MACL,YAAAF;AAAA,MACA,UAAAE;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var d=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var c=(i,t,e)=>d(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../constants-
|
|
1
|
+
"use strict";var p=Object.defineProperty;var d=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var c=(i,t,e)=>d(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../constants-5WxIZnbu.cjs"),s=require("../tokens.cjs"),g=require("../../utils/time.cjs"),S=require("../abis/mainnet/ERC20Permit.cjs"),y=require("../../getContract-Bt9GsQBq.cjs"),C=require("../../secp256k1-q_akf6f-.cjs");function E(i){const{r:t,s:e}=C.secp256k1.Signature.fromCompact(i.slice(2,130)),n=+`0x${i.slice(130)}`,[r,o]=(()=>{if(n===0||n===1)return[void 0,n];if(n===27)return[BigInt(n),0];if(n===28)return[BigInt(n),1];throw new Error("Invalid yParityOrV value")})();return typeof r<"u"?{r:a.numberToHex(t,{size:32}),s:a.numberToHex(e,{size:32}),v:r,yParity:o}:{r:a.numberToHex(t,{size:32}),s:a.numberToHex(e,{size:32}),yParity:o}}class T{constructor(t,e,n){c(this,"viemChain");c(this,"token");this.chain=t,this.walletClient=e,this.publicClient=n,this.viemChain=a.VIEM_CHAINS[t],this.token=s.Token.WETH}withToken(t){return this.token=t,this}getContract(){const t=s.TOKENS_ADDRESSES[this.token][this.chain],e=S.ERC20Permit,n={public:this.publicClient,wallet:this.walletClient};return y.getContract({address:t,abi:e,client:n})}async getPermitSignature(t,e,n){const r=this.getContract(),o=await r.read.nonces([t]),m={name:await r.read.name(),version:this.getPermitVersion(this.token),chainId:this.chain,verifyingContract:s.TOKENS_ADDRESSES[this.token][this.chain],salt:this.getPermitSalt(this.token)},h={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u=BigInt(g.getTimestampInSeconds()+60*60*2),l=await this.walletClient.signTypedData({account:t,domain:m,types:h,primaryType:"Permit",message:{owner:t,spender:e,value:n,nonce:o,deadline:u}});return{...E(l),deadline:u}}approve(t,e,n){return this.getContract().write.approve([e,n],{account:t,chain:this.viemChain})}getPermitVersion(t){return s.TOKENS_PERMIT_VERSION[t]}getPermitSalt(t){var e,n;return(n=(e=s.TOKENS_SALT)==null?void 0:e[t])==null?void 0:n[this.chain]}}exports.ERC20PermitHandler=T;
|
|
2
2
|
//# sourceMappingURL=erc20-permit-handler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20-permit-handler.cjs","sources":["../../../node_modules/.pnpm/viem@2.23.6_typescript@5.
|
|
1
|
+
{"version":3,"file":"erc20-permit-handler.cjs","sources":["../../../node_modules/.pnpm/viem@2.23.6_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await contract.read.nonces([ownerAddress]);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","TOKENS_SALT"],"mappings":"oeAYO,SAASA,EAAeC,EAAc,CACzC,KAAM,CAAE,EAAAC,EAAG,EAAAC,CAAG,EAAGC,YAAU,UAAU,YAAYH,EAAa,MAAM,EAAG,GAAG,CAAC,EACrEI,EAAa,CAAO,KAAKJ,EAAa,MAAM,GAAG,CAAC,GAChD,CAACK,EAAGC,CAAO,GAAK,IAAM,CACxB,GAAIF,IAAe,GAAKA,IAAe,EACnC,MAAO,CAAC,OAAWA,CAAU,EACjC,GAAIA,IAAe,GACf,MAAO,CAAC,OAAOA,CAAU,EAAG,CAAC,EACjC,GAAIA,IAAe,GACf,MAAO,CAAC,OAAOA,CAAU,EAAG,CAAC,EACjC,MAAM,IAAI,MAAM,0BAA0B,CAClD,GAAQ,EACJ,OAAI,OAAOC,EAAM,IACN,CACH,EAAGE,EAAAA,YAAYN,EAAG,CAAE,KAAM,EAAE,CAAE,EAC9B,EAAGM,EAAAA,YAAYL,EAAG,CAAE,KAAM,EAAE,CAAE,EAC9B,EAAAG,EACA,QAAAC,CACH,EACE,CACH,EAAGC,EAAAA,YAAYN,EAAG,CAAE,KAAM,EAAE,CAAE,EAC9B,EAAGM,EAAAA,YAAYL,EAAG,CAAE,KAAM,EAAE,CAAE,EAC9B,QAAAI,CACH,CACL,CCdO,MAAME,CAAmB,CAa9B,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBACAA,EAAA,cAYE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,MAAQK,EAAAA,MAAM,IAA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,QAASF,EACT,MAAO,KAAK,SAAA,CACb,CAAA,CAGK,iBAAiBP,EAAyB,CAChD,OAAOiB,EAAAA,sBAAsBjB,CAAK,CAAA,CAG5B,cAAcA,EAAiB,SACrC,OAAOkB,GAAAA,EAAAA,gBAAAA,YAAAA,EAAclB,KAAdkB,YAAAA,EAAuB,KAAK,MAAK,CAE5C","x_google_ignoreList":[0]}
|
|
@@ -827,7 +827,7 @@ export declare class ERC20PermitHandler {
|
|
|
827
827
|
readonly internalType: "string";
|
|
828
828
|
}];
|
|
829
829
|
}], "name", readonly []>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<string>;
|
|
830
|
-
|
|
830
|
+
balanceOf: (args: readonly [`0x${string}`], options?: import('viem').Prettify<import('viem').UnionOmit<import('viem').ReadContractParameters<readonly [{
|
|
831
831
|
readonly type: "function";
|
|
832
832
|
readonly name: "DOMAIN_SEPARATOR";
|
|
833
833
|
readonly inputs: readonly [];
|
|
@@ -1222,7 +1222,7 @@ export declare class ERC20PermitHandler {
|
|
|
1222
1222
|
readonly type: "string";
|
|
1223
1223
|
readonly internalType: "string";
|
|
1224
1224
|
}];
|
|
1225
|
-
}], "
|
|
1225
|
+
}], "balanceOf", readonly [`0x${string}`]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
1226
1226
|
allowance: (args: readonly [`0x${string}`, `0x${string}`], options?: import('viem').Prettify<import('viem').UnionOmit<import('viem').ReadContractParameters<readonly [{
|
|
1227
1227
|
readonly type: "function";
|
|
1228
1228
|
readonly name: "DOMAIN_SEPARATOR";
|
|
@@ -1619,7 +1619,7 @@ export declare class ERC20PermitHandler {
|
|
|
1619
1619
|
readonly internalType: "string";
|
|
1620
1620
|
}];
|
|
1621
1621
|
}], "allowance", readonly [`0x${string}`, `0x${string}`]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
1622
|
-
|
|
1622
|
+
DOMAIN_SEPARATOR: (options?: import('viem').Prettify<import('viem').UnionOmit<import('viem').ReadContractParameters<readonly [{
|
|
1623
1623
|
readonly type: "function";
|
|
1624
1624
|
readonly name: "DOMAIN_SEPARATOR";
|
|
1625
1625
|
readonly inputs: readonly [];
|
|
@@ -2014,7 +2014,7 @@ export declare class ERC20PermitHandler {
|
|
|
2014
2014
|
readonly type: "string";
|
|
2015
2015
|
readonly internalType: "string";
|
|
2016
2016
|
}];
|
|
2017
|
-
}], "
|
|
2017
|
+
}], "DOMAIN_SEPARATOR", readonly []>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<`0x${string}`>;
|
|
2018
2018
|
decimals: (options?: import('viem').Prettify<import('viem').UnionOmit<import('viem').ReadContractParameters<readonly [{
|
|
2019
2019
|
readonly type: "function";
|
|
2020
2020
|
readonly name: "DOMAIN_SEPARATOR";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var l = Object.defineProperty;
|
|
2
2
|
var d = (i, t, e) => t in i ? l(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
3
|
var o = (i, t, e) => d(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { n as s, V as g } from "../../constants-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { g as
|
|
9
|
-
import { secp256k1 as T } from "../../secp256k1-
|
|
10
|
-
function
|
|
4
|
+
import { n as s, V as g } from "../../constants-BDqMRitM.js";
|
|
5
|
+
import { Token as y, TOKENS_ADDRESSES as m, TOKENS_PERMIT_VERSION as C, TOKENS_SALT as f } from "../tokens.js";
|
|
6
|
+
import { getTimestampInSeconds as S } from "../../utils/time.js";
|
|
7
|
+
import { ERC20Permit as P } from "../abis/mainnet/ERC20Permit.js";
|
|
8
|
+
import { g as E } from "../../getContract-DXPZJOBy.js";
|
|
9
|
+
import { secp256k1 as T } from "../../secp256k1-D02y6Pc-.js";
|
|
10
|
+
function v(i) {
|
|
11
11
|
const { r: t, s: e } = T.Signature.fromCompact(i.slice(2, 130)), n = +`0x${i.slice(130)}`, [r, a] = (() => {
|
|
12
12
|
if (n === 0 || n === 1)
|
|
13
13
|
return [void 0, n];
|
|
@@ -41,7 +41,7 @@ class _ {
|
|
|
41
41
|
constructor(t, e, n) {
|
|
42
42
|
o(this, "viemChain");
|
|
43
43
|
o(this, "token");
|
|
44
|
-
this.chain = t, this.walletClient = e, this.publicClient = n, this.viemChain = g[t], this.token =
|
|
44
|
+
this.chain = t, this.walletClient = e, this.publicClient = n, this.viemChain = g[t], this.token = y.WETH;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Set the token to use for executing transactions on the contract.
|
|
@@ -59,8 +59,8 @@ class _ {
|
|
|
59
59
|
* @returns The viem contract.
|
|
60
60
|
*/
|
|
61
61
|
getContract() {
|
|
62
|
-
const t = m[this.token][this.chain], e =
|
|
63
|
-
return
|
|
62
|
+
const t = m[this.token][this.chain], e = P, n = { public: this.publicClient, wallet: this.walletClient };
|
|
63
|
+
return E({ address: t, abi: e, client: n });
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Process and get permit signature for the given token to perform
|
|
@@ -86,7 +86,7 @@ class _ {
|
|
|
86
86
|
{ name: "nonce", type: "uint256" },
|
|
87
87
|
{ name: "deadline", type: "uint256" }
|
|
88
88
|
]
|
|
89
|
-
}, c = BigInt(
|
|
89
|
+
}, c = BigInt(S() + 60 * 60 * 2), u = await this.walletClient.signTypedData({
|
|
90
90
|
account: t,
|
|
91
91
|
domain: h,
|
|
92
92
|
types: p,
|
|
@@ -99,7 +99,7 @@ class _ {
|
|
|
99
99
|
deadline: c
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
-
return { ...
|
|
102
|
+
return { ...v(u), deadline: c };
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* Approve transaction for the spender to spend the owner's tokens.
|
|
@@ -116,11 +116,11 @@ class _ {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
getPermitVersion(t) {
|
|
119
|
-
return
|
|
119
|
+
return C[t];
|
|
120
120
|
}
|
|
121
121
|
getPermitSalt(t) {
|
|
122
122
|
var e, n;
|
|
123
|
-
return (n = (e =
|
|
123
|
+
return (n = (e = f) == null ? void 0 : e[t]) == null ? void 0 : n[this.chain];
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.23.6_typescript@5.
|
|
1
|
+
{"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.23.6_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await contract.read.nonces([ownerAddress]);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","_b","_a","TOKENS_SALT"],"mappings":";;;;;;;;;AAYO,SAASA,EAAeC,GAAc;AACzC,QAAM,EAAE,GAAAC,GAAG,GAAAC,EAAG,IAAGC,EAAU,UAAU,YAAYH,EAAa,MAAM,GAAG,GAAG,CAAC,GACrEI,IAAa,CAAO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,CAACD,GAAgBC,CAAK,GAAG;AAAA,MAC/D,SAASF;AAAA,MACT,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EAAA;AAAA,EAGK,iBAAiBP,GAAyB;AAChD,WAAOiB,EAAsBjB,CAAK;AAAA,EAAA;AAAA,EAG5B,cAAcA,GAAiB;;AACrC,YAAOkB,KAAAC,IAAAC,MAAA,gBAAAD,EAAcnB,OAAd,gBAAAkB,EAAuB,KAAK;AAAA,EAAK;AAE5C;","x_google_ignoreList":[0]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=(a,t,e)=>t in a?i(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var n=(a,t,e)=>s(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../constants-5WxIZnbu.cjs"),o=require("../addresses.cjs"),l=require("../abis/mainnet/L1RewardManager.cjs"),C=require("../../getContract-Bt9GsQBq.cjs");class d{constructor(t,e,r){n(this,"viemChain");this.chain=t,this.walletClient=e,this.publicClient=r,this.viemChain=c.VIEM_CHAINS[t]}getContract(){const t=o.CONTRACT_ADDRESSES[this.chain].L1RewardManager,e=l.L1RewardManager,r={public:this.publicClient,wallet:this.walletClient};return C.getContract({address:t,abi:e,client:r})}getBridge(t){return this.getContract().read.getBridge([t])}setL2RewardClaimer(t,e,r){return{transact:()=>this.getContract().write.setL2RewardClaimer([e,r],{chain:this.viemChain,account:t}),estimate:()=>this.getContract().estimateGas.setL2RewardClaimer([e,r],{account:t})}}}exports.L1RewardManagerHandler=d;
|
|
2
2
|
//# sourceMappingURL=l1-reward-manager-handler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l1-reward-manager-handler.cjs","sources":["../../../lib/contracts/handlers/l1-reward-manager-handler.ts"],"sourcesContent":["import {\n Address,\n getContract,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport {
|
|
1
|
+
{"version":3,"file":"l1-reward-manager-handler.cjs","sources":["../../../lib/contracts/handlers/l1-reward-manager-handler.ts"],"sourcesContent":["import {\n Address,\n getContract,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { L1RewardManager } from '../abis/mainnet/L1RewardManager';\n\n/**\n * Handler for the `L1RewardManager` contract.\n */\nexport class L1RewardManagerHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the `L1RewardManager` contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].L1RewardManager as Address;\n const abi = L1RewardManager;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get the bridge data for the given bridge address.\n *\n * @param bridgeAddress Address of the bridge.\n * @returns The bridge data.\n */\n public getBridge(bridgeAddress: Address) {\n return this.getContract().read.getBridge([bridgeAddress]);\n }\n\n /**\n * Sets the rewards claimer on L2. Smart contracts might not be able\n * to to own the same address on L2. This function allows to set a\n * different address as the claimer.\n *\n * @param account The account to make the transaction with.\n * @param bridge Address of the bridge.\n * @param claimer Address of the new claimer.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public setL2RewardClaimer(\n account: Address,\n bridge: Address,\n claimer: Address,\n ) {\n const transact = () =>\n this.getContract().write.setL2RewardClaimer([bridge, claimer], {\n chain: this.viemChain,\n account,\n });\n const estimate = () =>\n this.getContract().estimateGas.setL2RewardClaimer([bridge, claimer], {\n account,\n });\n\n return { transact, estimate };\n }\n}\n"],"names":["L1RewardManagerHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","L1RewardManager","client","getContract","bridgeAddress","account","bridge","claimer"],"mappings":"+ZAcO,MAAMA,CAAuB,CAalC,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,CAAA,CAS7B,aAAc,CACnB,MAAMK,EAAUC,EAAA,mBAAmB,KAAK,KAAK,EAAE,gBACzCC,EAAMC,EAAA,gBACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CAatC,UAAUE,EAAwB,CACvC,OAAO,KAAK,YAAY,EAAE,KAAK,UAAU,CAACA,CAAa,CAAC,CAAA,CAiBnD,mBACLC,EACAC,EACAC,EACA,CAWO,MAAA,CAAE,SAVQ,IACf,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAACD,EAAQC,CAAO,EAAG,CAC7D,MAAO,KAAK,UACZ,QAAAF,CAAA,CACD,EAMgB,SALF,IACf,KAAK,YAAY,EAAE,YAAY,mBAAmB,CAACC,EAAQC,CAAO,EAAG,CACnE,QAAAF,CAAA,CACD,CAEyB,CAAA,CAEhC"}
|