@pufferfinance/puffer-sdk 1.25.4 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/puffer-client.cjs +1 -1
- package/dist/api/puffer-client.cjs.map +1 -1
- package/dist/api/puffer-client.d.ts +3 -0
- package/dist/api/puffer-client.js +28 -21
- package/dist/api/puffer-client.js.map +1 -1
- package/dist/contracts/abis/mainnet/vlPUFFER.cjs +2 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.cjs.map +1 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.d.ts +437 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.js +269 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.js.map +1 -0
- package/dist/contracts/common/lib/types.cjs +2 -0
- package/dist/contracts/common/lib/types.cjs.map +1 -0
- package/dist/contracts/common/lib/types.d.ts +8 -0
- package/dist/contracts/common/lib/types.js +2 -0
- package/dist/contracts/common/lib/types.js.map +1 -0
- 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 +10 -0
- package/dist/contracts/handlers/erc20-permit-handler.js +56 -40
- package/dist/contracts/handlers/erc20-permit-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 +2 -6
- package/dist/contracts/handlers/nucleus-boring-vault-handler.js +17 -17
- 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 +2 -6
- package/dist/contracts/handlers/nucleus-teller-handler.js +11 -20
- 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.js +31 -40
- 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.js +26 -38
- 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.js +28 -37
- package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-protocol-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-protocol-handler.d.ts +49 -55
- package/dist/contracts/handlers/puffer-protocol-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.js +21 -27
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
- package/dist/contracts/handlers/validator-ticket-handler.cjs.map +1 -1
- package/dist/contracts/handlers/validator-ticket-handler.d.ts +1 -7
- package/dist/contracts/handlers/validator-ticket-handler.js.map +1 -1
- package/dist/contracts/handlers/vl-puffer-handler.cjs +2 -0
- package/dist/contracts/handlers/vl-puffer-handler.cjs.map +1 -0
- package/dist/contracts/handlers/vl-puffer-handler.d.ts +14802 -0
- package/dist/contracts/handlers/vl-puffer-handler.js +357 -0
- package/dist/contracts/handlers/vl-puffer-handler.js.map +1 -0
- package/dist/contracts/tokens.cjs +1 -1
- package/dist/contracts/tokens.cjs.map +1 -1
- package/dist/contracts/tokens.d.ts +2 -1
- package/dist/contracts/tokens.js +6 -2
- package/dist/contracts/tokens.js.map +1 -1
- package/dist/utils/version.cjs +1 -1
- package/dist/utils/version.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-depositor-handler.js","sources":["../../../lib/contracts/handlers/puffer-depositor-handler.ts"],"sourcesContent":["import {\n Address,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n getContract,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Token } from '../tokens';\nimport { PufferDepositor } from '../abis/mainnet/PufferDepositor';\n\n/**\n * Handler for the `PufferDepositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferDepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferDepositor` 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 this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\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].PufferDepositor as Address;\n const abi = PufferDepositor;\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 * Deposit stETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the stETH to deposit.\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 async depositStETH(walletAddress: Address, value: bigint) {\n const
|
|
1
|
+
{"version":3,"file":"puffer-depositor-handler.js","sources":["../../../lib/contracts/handlers/puffer-depositor-handler.ts"],"sourcesContent":["import {\n Address,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n getContract,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Token } from '../tokens';\nimport { PufferDepositor } from '../abis/mainnet/PufferDepositor';\n\n/**\n * Handler for the `PufferDepositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferDepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferDepositor` 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 this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\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].PufferDepositor as Address;\n const abi = PufferDepositor;\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 * Deposit stETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the stETH to deposit.\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 async depositStETH(walletAddress: Address, value: bigint) {\n const permitData = await this.erc20PermitHandler\n .withToken(Token.stETH)\n .getPermitData(\n walletAddress,\n CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address,\n value,\n );\n\n const transact = async () =>\n await this.getContract().write.depositStETH([permitData, walletAddress], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = async () =>\n await this.getContract().estimateGas.depositStETH(\n [permitData, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Deposit wstETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the wstETH to deposit.\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 async depositWstETH(walletAddress: Address, value: bigint) {\n const permitData = await this.erc20PermitHandler\n .withToken(Token.wstETH)\n .getPermitData(\n walletAddress,\n CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address,\n value,\n );\n\n const transact = async () =>\n await this.getContract().write.depositWstETH(\n [permitData, walletAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n const estimate = async () =>\n await this.getContract().estimateGas.depositWstETH(\n [permitData, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["PufferDepositorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufferDepositor","client","getContract","walletAddress","value","permitData","Token"],"mappings":";;;;;;;;;AAiBO,MAAMA,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAclC,YACUC,GACAC,GACAC,GACR;AAjBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AAaE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gBK,WAAA,EAAE,UAdQ,YACf,MAAM,KAAK,cAAc,MAAM;AAAA,MAC7B,CAACC,GAAYF,CAAa;AAAA,MAC1B;AAAA,QACE,SAASA;AAAA,QACT,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhB,GAOiB,UANF,YACf,MAAM,KAAK,cAAc,YAAY;AAAA,MACnC,CAACE,GAAYF,CAAa;AAAA,MAC1B,EAAE,SAASA,EAAc;AAAA,IAC3B,EAE0B;AAAA,EAAA;AAEhC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var C=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var s=(i,t,e)=>C(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants-CxSgz27h.cjs"),l=require("../addresses.cjs"),f=require("../tokens.cjs"),m=require("./erc20-permit-handler.cjs"),P=require("../abis/mainnet/PufferL2Depositor.cjs"),D=require("../../getContract-DUA3M2pm.cjs");class S{constructor(t,e,r){s(this,"viemChain");s(this,"erc20PermitHandler");this.chain=t,this.walletClient=e,this.publicClient=r,this.viemChain=n.VIEM_CHAINS[t],this.erc20PermitHandler=new m.ERC20PermitHandler(t,e,r)}getContract(){const t=l.CONTRACT_ADDRESSES[this.chain].PufferL2Depositor,e=P.PufferL2Depositor,r={public:this.publicClient,wallet:this.walletClient};return D.getContract({address:t,abi:e,client:r})}async deposit(t){const{token:e,account:r,value:a,referralCode:d=0n,lockPeriod:h=0n,isPreapproved:u=!1}=t;let o={r:n.padHex("0x",{size:32}),s:n.padHex("0x",{size:32}),v:0,deadline:0n,amount:a};u||(o=await this.erc20PermitHandler.withToken(e).getPermitData(r,l.CONTRACT_ADDRESSES[this.chain].PufferL2Depositor,a));const c=[f.TOKENS_ADDRESSES[e][this.chain],r,o,d,h];return{transact:()=>this.getContract().write.deposit(c,{account:r,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit(c,{account:r})}}}exports.PufferL2DepositorHandler=S;
|
|
2
2
|
//# sourceMappingURL=puffer-l2-depositor-handler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-l2-depositor-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-l2-depositor-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { TOKENS_ADDRESSES, Token } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufferL2Depositor } from '../abis/mainnet/PufferL2Depositor';\n\nexport type L2DepositParams = {\n token: Token;\n account: Address;\n value: bigint;\n referralCode?: bigint;\n lockPeriod?: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufferL2Depositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferL2DepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferL2Depositor` 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 this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\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].PufferL2Depositor as Address;\n const abi = PufferL2Depositor;\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 * Deposit the given token in exchange for the wrapped PufToken. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * Note that not all token contracts support permit signatures (e.g.\n * USDC). If a token's contract doesn't support permit signatures, use\n * `Token.approve()` and be sure to set the option `isPreapproved` to\n * `true`.\n *\n * @param depositParams.token Token to deposit.\n * @param depositParams.account Wallet address to take the token from.\n * @param depositParams.value Value in wei of the token to deposit.\n * @param depositParams.referralCode Referral code for the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\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 async deposit(depositParams: L2DepositParams) {\n const {\n token,\n account,\n value,\n referralCode = 0n,\n lockPeriod = 0n,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n
|
|
1
|
+
{"version":3,"file":"puffer-l2-depositor-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-l2-depositor-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { TOKENS_ADDRESSES, Token } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufferL2Depositor } from '../abis/mainnet/PufferL2Depositor';\n\nexport type L2DepositParams = {\n token: Token;\n account: Address;\n value: bigint;\n referralCode?: bigint;\n lockPeriod?: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufferL2Depositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferL2DepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferL2Depositor` 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 this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\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].PufferL2Depositor as Address;\n const abi = PufferL2Depositor;\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 * Deposit the given token in exchange for the wrapped PufToken. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * Note that not all token contracts support permit signatures (e.g.\n * USDC). If a token's contract doesn't support permit signatures, use\n * `Token.approve()` and be sure to set the option `isPreapproved` to\n * `true`.\n *\n * @param depositParams.token Token to deposit.\n * @param depositParams.account Wallet address to take the token from.\n * @param depositParams.value Value in wei of the token to deposit.\n * @param depositParams.referralCode Referral code for the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\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 async deposit(depositParams: L2DepositParams) {\n const {\n token,\n account,\n value,\n referralCode = 0n,\n lockPeriod = 0n,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n permitData = await this.erc20PermitHandler\n .withToken(token)\n .getPermitData(\n account,\n CONTRACT_ADDRESSES[this.chain].PufferL2Depositor as Address,\n value,\n );\n }\n\n const depositArgs = <const>[\n TOKENS_ADDRESSES[token][this.chain],\n account,\n permitData,\n referralCode,\n lockPeriod,\n ];\n\n const transact = () =>\n this.getContract().write.deposit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.deposit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n}\n"],"names":["PufferL2DepositorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufferL2Depositor","client","getContract","depositParams","token","account","value","referralCode","lockPeriod","isPreapproved","permitData","padHex","depositArgs","TOKENS_ADDRESSES"],"mappings":"oeA2BO,MAAMA,CAAyB,CAcpC,YACUC,EACAC,EACAC,EACR,CAjBMC,EAAA,kBACAA,EAAA,2BAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,mBAAqB,IAAIK,EAAA,mBAC5BL,EACAC,EACAC,CACF,CAAA,CASK,aAAc,CACnB,MAAMI,EAAUC,EAAA,mBAAmB,KAAK,KAAK,EAAE,kBACzCC,EAAMC,EAAA,kBACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CA+B7C,MAAa,QAAQE,EAAgC,CAC7C,KAAA,CACJ,MAAAC,EACA,QAAAC,EACA,MAAAC,EACA,aAAAC,EAAe,GACf,WAAAC,EAAa,GACb,cAAAC,EAAgB,EAAA,EACdN,EAIJ,IAAIO,EAAa,CACf,EAAGC,EAAAA,OAAO,KAAM,CAAE,KAAM,GAAI,EAC5B,EAAGA,EAAAA,OAAO,KAAM,CAAE,KAAM,GAAI,EAC5B,EAAG,EACH,SAAU,GACV,OAAQL,CACV,EAEKG,IACHC,EAAa,MAAM,KAAK,mBACrB,UAAUN,CAAK,EACf,cACCC,EACAP,qBAAmB,KAAK,KAAK,EAAE,kBAC/BQ,CACF,GAGJ,MAAMM,EAAqB,CACzBC,EAAAA,iBAAiBT,CAAK,EAAE,KAAK,KAAK,EAClCC,EACAK,EACAH,EACAC,CACF,EAYO,MAAA,CAAE,SAVQ,IACf,KAAK,YAAc,EAAA,MAAM,QAAQI,EAAa,CAC5C,QAAAP,EACA,MAAO,KAAK,SAAA,CACb,EAMgB,SALF,IACf,KAAK,YAAc,EAAA,YAAY,QAAQO,EAAa,CAClD,QAAAP,CAAA,CACD,CAEyB,CAAA,CAEhC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { V as
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var f = (r, t, e) => t in r ? d(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var s = (r, t, e) => f(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { V as C, p as c } from "../../constants-C9YZ6Ewc.js";
|
|
5
5
|
import { CONTRACT_ADDRESSES as m } from "../addresses.js";
|
|
6
|
-
import { TOKENS_ADDRESSES as
|
|
7
|
-
import { ERC20PermitHandler as
|
|
8
|
-
import { PufferL2Depositor as
|
|
9
|
-
import { g as
|
|
10
|
-
class
|
|
6
|
+
import { TOKENS_ADDRESSES as u } from "../tokens.js";
|
|
7
|
+
import { ERC20PermitHandler as P } from "./erc20-permit-handler.js";
|
|
8
|
+
import { PufferL2Depositor as D } from "../abis/mainnet/PufferL2Depositor.js";
|
|
9
|
+
import { g as S } from "../../getContract-DEPNMZxg.js";
|
|
10
|
+
class T {
|
|
11
11
|
/**
|
|
12
12
|
* Create the handler for the `PufferL2Depositor` contract exposing
|
|
13
13
|
* methods to interact with the contract.
|
|
@@ -19,9 +19,9 @@ class _ {
|
|
|
19
19
|
* interactions.
|
|
20
20
|
*/
|
|
21
21
|
constructor(t, e, i) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.chain = t, this.walletClient = e, this.publicClient = i, this.viemChain =
|
|
22
|
+
s(this, "viemChain");
|
|
23
|
+
s(this, "erc20PermitHandler");
|
|
24
|
+
this.chain = t, this.walletClient = e, this.publicClient = i, this.viemChain = C[t], this.erc20PermitHandler = new P(
|
|
25
25
|
t,
|
|
26
26
|
e,
|
|
27
27
|
i
|
|
@@ -34,8 +34,8 @@ class _ {
|
|
|
34
34
|
* @returns The viem contract.
|
|
35
35
|
*/
|
|
36
36
|
getContract() {
|
|
37
|
-
const t = m[this.chain].PufferL2Depositor, e =
|
|
38
|
-
return
|
|
37
|
+
const t = m[this.chain].PufferL2Depositor, e = D, i = { public: this.publicClient, wallet: this.walletClient };
|
|
38
|
+
return S({ address: t, abi: e, client: i });
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Deposit the given token in exchange for the wrapped PufToken. This
|
|
@@ -65,38 +65,29 @@ class _ {
|
|
|
65
65
|
const {
|
|
66
66
|
token: e,
|
|
67
67
|
account: i,
|
|
68
|
-
value:
|
|
69
|
-
referralCode:
|
|
70
|
-
lockPeriod:
|
|
71
|
-
isPreapproved:
|
|
68
|
+
value: a,
|
|
69
|
+
referralCode: p = 0n,
|
|
70
|
+
lockPeriod: h = 0n,
|
|
71
|
+
isPreapproved: l = !1
|
|
72
72
|
} = t;
|
|
73
73
|
let o = {
|
|
74
74
|
r: c("0x", { size: 32 }),
|
|
75
75
|
s: c("0x", { size: 32 }),
|
|
76
76
|
v: 0,
|
|
77
77
|
deadline: 0n,
|
|
78
|
-
amount:
|
|
78
|
+
amount: a
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
);
|
|
86
|
-
o = {
|
|
87
|
-
r: d,
|
|
88
|
-
s: f,
|
|
89
|
-
v: Number(u ?? C),
|
|
90
|
-
deadline: P,
|
|
91
|
-
amount: s
|
|
92
|
-
};
|
|
93
|
-
}
|
|
80
|
+
l || (o = await this.erc20PermitHandler.withToken(e).getPermitData(
|
|
81
|
+
i,
|
|
82
|
+
m[this.chain].PufferL2Depositor,
|
|
83
|
+
a
|
|
84
|
+
));
|
|
94
85
|
const n = [
|
|
95
|
-
|
|
86
|
+
u[e][this.chain],
|
|
96
87
|
i,
|
|
97
88
|
o,
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
p,
|
|
90
|
+
h
|
|
100
91
|
];
|
|
101
92
|
return { transact: () => this.getContract().write.deposit(n, {
|
|
102
93
|
account: i,
|
|
@@ -107,6 +98,6 @@ class _ {
|
|
|
107
98
|
}
|
|
108
99
|
}
|
|
109
100
|
export {
|
|
110
|
-
|
|
101
|
+
T as PufferL2DepositorHandler
|
|
111
102
|
};
|
|
112
103
|
//# sourceMappingURL=puffer-l2-depositor-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-l2-depositor-handler.js","sources":["../../../lib/contracts/handlers/puffer-l2-depositor-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { TOKENS_ADDRESSES, Token } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufferL2Depositor } from '../abis/mainnet/PufferL2Depositor';\n\nexport type L2DepositParams = {\n token: Token;\n account: Address;\n value: bigint;\n referralCode?: bigint;\n lockPeriod?: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufferL2Depositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferL2DepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferL2Depositor` 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 this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\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].PufferL2Depositor as Address;\n const abi = PufferL2Depositor;\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 * Deposit the given token in exchange for the wrapped PufToken. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * Note that not all token contracts support permit signatures (e.g.\n * USDC). If a token's contract doesn't support permit signatures, use\n * `Token.approve()` and be sure to set the option `isPreapproved` to\n * `true`.\n *\n * @param depositParams.token Token to deposit.\n * @param depositParams.account Wallet address to take the token from.\n * @param depositParams.value Value in wei of the token to deposit.\n * @param depositParams.referralCode Referral code for the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\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 async deposit(depositParams: L2DepositParams) {\n const {\n token,\n account,\n value,\n referralCode = 0n,\n lockPeriod = 0n,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n
|
|
1
|
+
{"version":3,"file":"puffer-l2-depositor-handler.js","sources":["../../../lib/contracts/handlers/puffer-l2-depositor-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { TOKENS_ADDRESSES, Token } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufferL2Depositor } from '../abis/mainnet/PufferL2Depositor';\n\nexport type L2DepositParams = {\n token: Token;\n account: Address;\n value: bigint;\n referralCode?: bigint;\n lockPeriod?: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufferL2Depositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferL2DepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferL2Depositor` 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 this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\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].PufferL2Depositor as Address;\n const abi = PufferL2Depositor;\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 * Deposit the given token in exchange for the wrapped PufToken. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * Note that not all token contracts support permit signatures (e.g.\n * USDC). If a token's contract doesn't support permit signatures, use\n * `Token.approve()` and be sure to set the option `isPreapproved` to\n * `true`.\n *\n * @param depositParams.token Token to deposit.\n * @param depositParams.account Wallet address to take the token from.\n * @param depositParams.value Value in wei of the token to deposit.\n * @param depositParams.referralCode Referral code for the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\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 async deposit(depositParams: L2DepositParams) {\n const {\n token,\n account,\n value,\n referralCode = 0n,\n lockPeriod = 0n,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n permitData = await this.erc20PermitHandler\n .withToken(token)\n .getPermitData(\n account,\n CONTRACT_ADDRESSES[this.chain].PufferL2Depositor as Address,\n value,\n );\n }\n\n const depositArgs = <const>[\n TOKENS_ADDRESSES[token][this.chain],\n account,\n permitData,\n referralCode,\n lockPeriod,\n ];\n\n const transact = () =>\n this.getContract().write.deposit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.deposit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n}\n"],"names":["PufferL2DepositorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufferL2Depositor","client","getContract","depositParams","token","account","value","referralCode","lockPeriod","isPreapproved","permitData","padHex","depositArgs","TOKENS_ADDRESSES"],"mappings":";;;;;;;;;AA2BO,MAAM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F;AAGJ,UAAMM,IAAqB;AAAA,MACzBC,EAAiBT,CAAK,EAAE,KAAK,KAAK;AAAA,MAClCC;AAAA,MACAK;AAAA,MACAH;AAAA,MACAC;AAAA,IACF;AAYO,WAAA,EAAE,UAVQ,MACf,KAAK,YAAc,EAAA,MAAM,QAAQI,GAAa;AAAA,MAC5C,SAAAP;AAAA,MACA,OAAO,KAAK;AAAA,IAAA,CACb,GAMgB,UALF,MACf,KAAK,YAAc,EAAA,YAAY,QAAQO,GAAa;AAAA,MAClD,SAAAP;AAAA,IAAA,CACD,EAEyB;AAAA,EAAA;AAEhC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-protocol-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-protocol-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n Account,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { PufferProtocol } from '../abis/mainnet/PufferProtocol';\n\nexport type PermitData = {\n deadline: bigint;\n amount: bigint;\n v: number;\n r: Address;\n s: Address;\n};\n\nexport type ValidatorKeyData = {\n blsPubKey: `0x${string}`;\n signature: `0x${string}`;\n depositDataRoot: `0x${string}`;\n blsEncryptedPrivKeyShares: `0x${string}`[];\n blsPubKeySet: `0x${string}`;\n raveEvidence: `0x${string}`;\n};\n\nexport type StoppedValidatorInfo = {\n module: Address;\n startEpoch: bigint;\n endEpoch: bigint;\n wasSlashed: boolean;\n moduleName: `0x${string}`;\n pufferModuleIndex: bigint;\n withdrawalAmount: bigint;\n};\n\n/**\n * Handler for the `PufferProtocol` contract exposing methods to interact\n * with the contract.\n */\nexport class PufferProtocolHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the `PufferProtocol` 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.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferProtocol as Address;\n const abi = PufferProtocol;\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 minimum VT amount required.\n *\n * @returns The minimum VT amount.\n */\n public getMinimumVtAmount() {\n return this.getContract().read.getMinimumVtAmount();\n }\n\n /**\n * Get the VT penalty amount.\n *\n * @returns The VT penalty amount.\n */\n public getVTPenalty() {\n return this.getContract().read.getVTPenalty();\n }\n\n /**\n * Get validator tickets balance for an owner.\n *\n * @param owner The owner address.\n * @returns The validator tickets balance.\n */\n public getValidatorTicketsBalance(owner: Address) {\n return this.getContract().read.getValidatorTicketsBalance([owner]);\n }\n\n /**\n * Get module address by name.\n *\n * @param moduleName The module name.\n * @returns The module address.\n */\n public getModuleAddress(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleAddress([moduleName]);\n }\n\n /**\n * Get module weights.\n *\n * @returns The module weights.\n */\n public getModuleWeights() {\n return this.getContract().read.getModuleWeights();\n }\n\n /**\n * Get the next validator to be provisioned.\n *\n * @returns Tuple of module name and index.\n */\n public getNextValidatorToProvision() {\n return this.getContract().read.getNextValidatorToProvision();\n }\n\n /**\n * Get node information.\n *\n * @param node The node address.\n * @returns The node information.\n */\n public getNodeInfo(node: Address) {\n return this.getContract().read.getNodeInfo([node]);\n }\n\n /**\n * Get validators for a module.\n *\n * @param moduleName The module name.\n * @returns The validators array.\n */\n public getValidators(moduleName: `0x${string}`) {\n return this.getContract().read.getValidators([moduleName]);\n }\n\n /**\n * Get validator information.\n *\n * @param moduleName The module name.\n * @param pufferModuleIndex The puffer module index.\n * @returns The validator information.\n */\n public getValidatorInfo(\n moduleName: `0x${string}`,\n pufferModuleIndex: bigint,\n ) {\n return this.getContract().read.getValidatorInfo([\n moduleName,\n pufferModuleIndex,\n ]);\n }\n\n /**\n * Get module limit information.\n *\n * @param moduleName The module name.\n * @returns The module limit information.\n */\n public getModuleLimitInformation(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleLimitInformation([moduleName]);\n }\n\n /**\n * Get withdrawal credentials for a module.\n *\n * @param module The module address.\n * @returns The withdrawal credentials.\n */\n public getWithdrawalCredentials(module: Address) {\n return this.getContract().read.getWithdrawalCredentials([module]);\n }\n\n /**\n * Get deposit data root.\n *\n * @param pubKey The public key.\n * @param signature The signature.\n * @param withdrawalCredentials The withdrawal credentials.\n * @returns The deposit data root.\n */\n public getDepositDataRoot(\n pubKey: `0x${string}`,\n signature: `0x${string}`,\n withdrawalCredentials: `0x${string}`,\n ) {\n return this.getContract().read.getDepositDataRoot([\n pubKey,\n signature,\n withdrawalCredentials,\n ]);\n }\n\n /**\n * Create a new puffer module.\n *\n * @param moduleName The module name.\n * @returns The transaction.\n */\n public createPufferModule(moduleName: `0x${string}`) {\n return this.getContract().write.createPufferModule([moduleName], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Register validator key.\n *\n * @param data The validator key data.\n * @param moduleName The module name.\n * @param pufETHPermit The pufETH permit data.\n * @param vtPermit The VT permit data.\n * @returns The transaction.\n */\n public registerValidatorKey(\n data: ValidatorKeyData,\n moduleName: `0x${string}`,\n pufETHPermit: PermitData,\n vtPermit: PermitData,\n ) {\n return this.getContract().write.registerValidatorKey(\n [data, moduleName, pufETHPermit, vtPermit],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Provision a node.\n *\n * @param guardianEnclaveSignatures The guardian enclave signatures.\n * @param validatorSignature The validator signature.\n * @param depositRootHash The deposit root hash.\n * @returns The transaction.\n */\n public provisionNode(\n guardianEnclaveSignatures: `0x${string}`[],\n validatorSignature: `0x${string}`,\n depositRootHash: `0x${string}`,\n ) {\n return this.getContract().write.provisionNode(\n [guardianEnclaveSignatures, validatorSignature, depositRootHash],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Deposit validator tickets.\n *\n * @param permit The permit data.\n * @param node The node address.\n * @returns The transaction.\n */\n public depositValidatorTickets(permit: PermitData, node: Address) {\n return this.getContract().write.depositValidatorTickets([permit, node], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Withdraw validator tickets.\n *\n * @param amount The amount to withdraw.\n * @param recipient The recipient address.\n * @returns The transaction.\n */\n public withdrawValidatorTickets(amount: bigint, recipient: Address) {\n return this.getContract().write.withdrawValidatorTickets(\n [amount, recipient],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Batch handle withdrawals.\n *\n * @param validatorInfos The validator infos.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public batchHandleWithdrawals(\n validatorInfos: StoppedValidatorInfo[],\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.batchHandleWithdrawals(\n [validatorInfos, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Skip provisioning for a module.\n *\n * @param moduleName The module name.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public skipProvisioning(\n moduleName: `0x${string}`,\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.skipProvisioning(\n [moduleName, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n}\n"],"names":["PufferProtocolHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","PufferProtocol","client","getContract","owner","moduleName","node","pufferModuleIndex","module","pubKey","signature","withdrawalCredentials","data","pufETHPermit","vtPermit","guardianEnclaveSignat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,EAClC,CACE,QAAS,KAAK,aAAa,QAC3B,MAAO,KAAK,SAAA,CAEhB,CAAA,CAEJ"}
|
|
1
|
+
{"version":3,"file":"puffer-protocol-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-protocol-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n Account,\n Hex,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { PufferProtocol } from '../abis/mainnet/PufferProtocol';\nimport { PermitData } from '../common/lib/types';\n\nexport type ValidatorKeyData = {\n blsPubKey: `0x${string}`;\n signature: `0x${string}`;\n depositDataRoot: `0x${string}`;\n blsEncryptedPrivKeyShares: `0x${string}`[];\n blsPubKeySet: `0x${string}`;\n raveEvidence: `0x${string}`;\n};\n\nexport type StoppedValidatorInfo = {\n module: Address;\n startEpoch: bigint;\n endEpoch: bigint;\n wasSlashed: boolean;\n moduleName: `0x${string}`;\n pufferModuleIndex: bigint;\n withdrawalAmount: bigint;\n};\n\n/**\n * Handler for the `PufferProtocol` contract exposing methods to interact\n * with the contract.\n */\nexport class PufferProtocolHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the `PufferProtocol` 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.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferProtocol as Address;\n const abi = PufferProtocol;\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 minimum VT amount required.\n *\n * @returns The minimum VT amount.\n */\n public getMinimumVtAmount() {\n return this.getContract().read.getMinimumVtAmount();\n }\n\n /**\n * Get the VT penalty amount.\n *\n * @returns The VT penalty amount.\n */\n public getVTPenalty() {\n return this.getContract().read.getVTPenalty();\n }\n\n /**\n * Get validator tickets balance for an owner.\n *\n * @param owner The owner address.\n * @returns The validator tickets balance.\n */\n public getValidatorTicketsBalance(owner: Address) {\n return this.getContract().read.getValidatorTicketsBalance([owner]);\n }\n\n /**\n * Get module address by name.\n *\n * @param moduleName The module name.\n * @returns The module address.\n */\n public getModuleAddress(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleAddress([moduleName]);\n }\n\n /**\n * Get module weights.\n *\n * @returns The module weights.\n */\n public getModuleWeights() {\n return this.getContract().read.getModuleWeights();\n }\n\n /**\n * Get the next validator to be provisioned.\n *\n * @returns Tuple of module name and index.\n */\n public getNextValidatorToProvision() {\n return this.getContract().read.getNextValidatorToProvision();\n }\n\n /**\n * Get node information.\n *\n * @param node The node address.\n * @returns The node information.\n */\n public getNodeInfo(node: Address) {\n return this.getContract().read.getNodeInfo([node]);\n }\n\n /**\n * Get validators for a module.\n *\n * @param moduleName The module name.\n * @returns The validators array.\n */\n public getValidators(moduleName: `0x${string}`) {\n return this.getContract().read.getValidators([moduleName]);\n }\n\n /**\n * Get validator information.\n *\n * @param moduleName The module name.\n * @param pufferModuleIndex The puffer module index.\n * @returns The validator information.\n */\n public getValidatorInfo(\n moduleName: `0x${string}`,\n pufferModuleIndex: bigint,\n ) {\n return this.getContract().read.getValidatorInfo([\n moduleName,\n pufferModuleIndex,\n ]);\n }\n\n /**\n * Get module limit information.\n *\n * @param moduleName The module name.\n * @returns The module limit information.\n */\n public getModuleLimitInformation(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleLimitInformation([moduleName]);\n }\n\n /**\n * Get withdrawal credentials for a module.\n *\n * @param module The module address.\n * @returns The withdrawal credentials.\n */\n public getWithdrawalCredentials(module: Address) {\n return this.getContract().read.getWithdrawalCredentials([module]);\n }\n\n /**\n * Get deposit data root.\n *\n * @param pubKey The public key.\n * @param signature The signature.\n * @param withdrawalCredentials The withdrawal credentials.\n * @returns The deposit data root.\n */\n public getDepositDataRoot(\n pubKey: `0x${string}`,\n signature: `0x${string}`,\n withdrawalCredentials: `0x${string}`,\n ) {\n return this.getContract().read.getDepositDataRoot([\n pubKey,\n signature,\n withdrawalCredentials,\n ]);\n }\n\n /**\n * Create a new puffer module.\n *\n * @param moduleName The module name.\n * @returns The transaction.\n */\n public createPufferModule(moduleName: `0x${string}`) {\n return this.getContract().write.createPufferModule([moduleName], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Register validator key.\n *\n * @param data The validator key data.\n * @param moduleName The module name.\n * @param pufETHPermit The pufETH permit data.\n * @param vtPermit The VT permit data.\n * @returns The transaction.\n */\n public registerValidatorKey(\n data: ValidatorKeyData,\n moduleName: Hex,\n pufETHPermit: PermitData,\n vtPermit: PermitData,\n ) {\n return this.getContract().write.registerValidatorKey(\n [data, moduleName, pufETHPermit, vtPermit],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Provision a node.\n *\n * @param guardianEnclaveSignatures The guardian enclave signatures.\n * @param validatorSignature The validator signature.\n * @param depositRootHash The deposit root hash.\n * @returns The transaction.\n */\n public provisionNode(\n guardianEnclaveSignatures: `0x${string}`[],\n validatorSignature: `0x${string}`,\n depositRootHash: `0x${string}`,\n ) {\n return this.getContract().write.provisionNode(\n [guardianEnclaveSignatures, validatorSignature, depositRootHash],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Deposit validator tickets.\n *\n * @param permit The permit data.\n * @param node The node address.\n * @returns The transaction.\n */\n public depositValidatorTickets(permit: PermitData, node: Address) {\n return this.getContract().write.depositValidatorTickets([permit, node], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Withdraw validator tickets.\n *\n * @param amount The amount to withdraw.\n * @param recipient The recipient address.\n * @returns The transaction.\n */\n public withdrawValidatorTickets(amount: bigint, recipient: Address) {\n return this.getContract().write.withdrawValidatorTickets(\n [amount, recipient],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Batch handle withdrawals.\n *\n * @param validatorInfos The validator infos.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public batchHandleWithdrawals(\n validatorInfos: StoppedValidatorInfo[],\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.batchHandleWithdrawals(\n [validatorInfos, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Skip provisioning for a module.\n *\n * @param moduleName The module name.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public skipProvisioning(\n moduleName: `0x${string}`,\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.skipProvisioning(\n [moduleName, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n}\n"],"names":["PufferProtocolHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","PufferProtocol","client","getContract","owner","moduleName","node","pufferModuleIndex","module","pubKey","signature","withdrawalCredentials","data","pufETHPermit","vtPermit","guardianEnclaveSignatures","validatorSignature","depositRootHash","permit","amount","recipient","validatorInfos","guardianEOASignatures"],"mappings":"8ZAqCO,MAAMA,CAAsB,CAajC,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,CAAA,CAQ7B,aAAc,CACnB,MAAMK,EAAUC,EAAA,mBAAmB,KAAK,KAAK,EAAE,eACzCC,EAAMC,EAAA,eACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK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EACAQ,EACAC,EACA,CACO,OAAA,KAAK,cAAc,MAAM,qBAC9B,CAACF,EAAMP,EAAYQ,EAAcC,CAAQ,EACzC,CACE,QAAS,KAAK,aAAa,QAC3B,MAAO,KAAK,SAAA,CAEhB,CAAA,CAWK,cACLC,EACAC,EACAC,EACA,CACO,OAAA,KAAK,cAAc,MAAM,cAC9B,CAACF,EAA2BC,EAAoBC,CAAe,EAC/D,CACE,QAAS,KAAK,aAAa,QAC3B,MAAO,KAAK,SAAA,CAEhB,CAAA,CAUK,wBAAwBC,EAAoBZ,EAAe,CACzD,OAAA,KAAK,cAAc,MAAM,wBAAwB,CAACY,EAAQZ,CAAI,EAAG,CACtE,QAAS,KAAK,aAAa,QAC3B,MAAO,KAAK,SAAA,CACb,CAAA,CAUI,yBAAyBa,EAAgBC,EAAoB,CAC3D,OAAA,KAAK,cAAc,MAAM,yBAC9B,CAACD,EAAQC,CAAS,EAClB,CACE,QAAS,KAAK,aAAa,QAC3B,MAAO,KAAK,SAAA,CAEhB,CAAA,CAUK,uBACLC,EACAC,EACA,CACO,OAAA,KAAK,cAAc,MAAM,uBAC9B,CAACD,EAAgBC,CAAqB,EACtC,CACE,QAAS,KAAK,aAAa,QAC3B,MAAO,KAAK,SAAA,CAEhB,CAAA,CAUK,iBACLjB,EACAiB,EACA,CACO,OAAA,KAAK,cAAc,MAAM,iBAC9B,CAACjB,EAAYiB,CAAqB,EAClC,CACE,QAAS,KAAK,aAAa,QAC3B,MAAO,KAAK,SAAA,CAEhB,CAAA,CAEJ"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { WalletClient, PublicClient, Address, GetContractReturnType, Account } from 'viem';
|
|
1
|
+
import { WalletClient, PublicClient, Address, GetContractReturnType, Account, Hex } from 'viem';
|
|
2
2
|
import { Chain, ViemChain } from '../../chains/constants';
|
|
3
|
-
|
|
4
|
-
deadline: bigint;
|
|
5
|
-
amount: bigint;
|
|
6
|
-
v: number;
|
|
7
|
-
r: Address;
|
|
8
|
-
s: Address;
|
|
9
|
-
};
|
|
3
|
+
import { PermitData } from '../common/lib/types';
|
|
10
4
|
export type ValidatorKeyData = {
|
|
11
5
|
blsPubKey: `0x${string}`;
|
|
12
6
|
signature: `0x${string}`;
|
|
@@ -754,15 +748,15 @@ export declare class PufferProtocolHandler {
|
|
|
754
748
|
blobGasUsed: bigint;
|
|
755
749
|
difficulty: bigint;
|
|
756
750
|
excessBlobGas: bigint;
|
|
757
|
-
extraData:
|
|
751
|
+
extraData: Hex;
|
|
758
752
|
gasLimit: bigint;
|
|
759
753
|
gasUsed: bigint;
|
|
760
754
|
miner: Address;
|
|
761
755
|
mixHash: import('viem').Hash;
|
|
762
756
|
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
763
757
|
parentHash: import('viem').Hash;
|
|
764
|
-
receiptsRoot:
|
|
765
|
-
sealFields:
|
|
758
|
+
receiptsRoot: Hex;
|
|
759
|
+
sealFields: Hex[];
|
|
766
760
|
sha3Uncles: import('viem').Hash;
|
|
767
761
|
size: bigint;
|
|
768
762
|
stateRoot: import('viem').Hash;
|
|
@@ -777,12 +771,12 @@ export declare class PufferProtocolHandler {
|
|
|
777
771
|
from: Address;
|
|
778
772
|
gas: bigint;
|
|
779
773
|
hash: import('viem').Hash;
|
|
780
|
-
input:
|
|
774
|
+
input: Hex;
|
|
781
775
|
nonce: number;
|
|
782
|
-
r:
|
|
783
|
-
s:
|
|
776
|
+
r: Hex;
|
|
777
|
+
s: Hex;
|
|
784
778
|
to: Address | null;
|
|
785
|
-
typeHex:
|
|
779
|
+
typeHex: Hex | null;
|
|
786
780
|
v: bigint;
|
|
787
781
|
value: bigint;
|
|
788
782
|
accessList?: undefined | undefined;
|
|
@@ -802,12 +796,12 @@ export declare class PufferProtocolHandler {
|
|
|
802
796
|
from: Address;
|
|
803
797
|
gas: bigint;
|
|
804
798
|
hash: import('viem').Hash;
|
|
805
|
-
input:
|
|
799
|
+
input: Hex;
|
|
806
800
|
nonce: number;
|
|
807
|
-
r:
|
|
808
|
-
s:
|
|
801
|
+
r: Hex;
|
|
802
|
+
s: Hex;
|
|
809
803
|
to: Address | null;
|
|
810
|
-
typeHex:
|
|
804
|
+
typeHex: Hex | null;
|
|
811
805
|
v: bigint;
|
|
812
806
|
value: bigint;
|
|
813
807
|
accessList: import('viem').AccessList;
|
|
@@ -827,12 +821,12 @@ export declare class PufferProtocolHandler {
|
|
|
827
821
|
from: Address;
|
|
828
822
|
gas: bigint;
|
|
829
823
|
hash: import('viem').Hash;
|
|
830
|
-
input:
|
|
824
|
+
input: Hex;
|
|
831
825
|
nonce: number;
|
|
832
|
-
r:
|
|
833
|
-
s:
|
|
826
|
+
r: Hex;
|
|
827
|
+
s: Hex;
|
|
834
828
|
to: Address | null;
|
|
835
|
-
typeHex:
|
|
829
|
+
typeHex: Hex | null;
|
|
836
830
|
v: bigint;
|
|
837
831
|
value: bigint;
|
|
838
832
|
accessList: import('viem').AccessList;
|
|
@@ -852,17 +846,17 @@ export declare class PufferProtocolHandler {
|
|
|
852
846
|
from: Address;
|
|
853
847
|
gas: bigint;
|
|
854
848
|
hash: import('viem').Hash;
|
|
855
|
-
input:
|
|
849
|
+
input: Hex;
|
|
856
850
|
nonce: number;
|
|
857
|
-
r:
|
|
858
|
-
s:
|
|
851
|
+
r: Hex;
|
|
852
|
+
s: Hex;
|
|
859
853
|
to: Address | null;
|
|
860
|
-
typeHex:
|
|
854
|
+
typeHex: Hex | null;
|
|
861
855
|
v: bigint;
|
|
862
856
|
value: bigint;
|
|
863
857
|
accessList: import('viem').AccessList;
|
|
864
858
|
authorizationList?: undefined | undefined;
|
|
865
|
-
blobVersionedHashes: readonly
|
|
859
|
+
blobVersionedHashes: readonly Hex[];
|
|
866
860
|
chainId: number;
|
|
867
861
|
type: "eip4844";
|
|
868
862
|
gasPrice?: undefined | undefined;
|
|
@@ -877,12 +871,12 @@ export declare class PufferProtocolHandler {
|
|
|
877
871
|
from: Address;
|
|
878
872
|
gas: bigint;
|
|
879
873
|
hash: import('viem').Hash;
|
|
880
|
-
input:
|
|
874
|
+
input: Hex;
|
|
881
875
|
nonce: number;
|
|
882
|
-
r:
|
|
883
|
-
s:
|
|
876
|
+
r: Hex;
|
|
877
|
+
s: Hex;
|
|
884
878
|
to: Address | null;
|
|
885
|
-
typeHex:
|
|
879
|
+
typeHex: Hex | null;
|
|
886
880
|
v: bigint;
|
|
887
881
|
value: bigint;
|
|
888
882
|
accessList: import('viem').AccessList;
|
|
@@ -927,12 +921,12 @@ export declare class PufferProtocolHandler {
|
|
|
927
921
|
from: Address;
|
|
928
922
|
gas: bigint;
|
|
929
923
|
hash: import('viem').Hash;
|
|
930
|
-
input:
|
|
924
|
+
input: Hex;
|
|
931
925
|
nonce: number;
|
|
932
|
-
r:
|
|
933
|
-
s:
|
|
926
|
+
r: Hex;
|
|
927
|
+
s: Hex;
|
|
934
928
|
to: Address | null;
|
|
935
|
-
typeHex:
|
|
929
|
+
typeHex: Hex | null;
|
|
936
930
|
v: bigint;
|
|
937
931
|
value: bigint;
|
|
938
932
|
accessList?: undefined | undefined;
|
|
@@ -952,12 +946,12 @@ export declare class PufferProtocolHandler {
|
|
|
952
946
|
from: Address;
|
|
953
947
|
gas: bigint;
|
|
954
948
|
hash: import('viem').Hash;
|
|
955
|
-
input:
|
|
949
|
+
input: Hex;
|
|
956
950
|
nonce: number;
|
|
957
|
-
r:
|
|
958
|
-
s:
|
|
951
|
+
r: Hex;
|
|
952
|
+
s: Hex;
|
|
959
953
|
to: Address | null;
|
|
960
|
-
typeHex:
|
|
954
|
+
typeHex: Hex | null;
|
|
961
955
|
v: bigint;
|
|
962
956
|
value: bigint;
|
|
963
957
|
accessList: import('viem').AccessList;
|
|
@@ -977,12 +971,12 @@ export declare class PufferProtocolHandler {
|
|
|
977
971
|
from: Address;
|
|
978
972
|
gas: bigint;
|
|
979
973
|
hash: import('viem').Hash;
|
|
980
|
-
input:
|
|
974
|
+
input: Hex;
|
|
981
975
|
nonce: number;
|
|
982
|
-
r:
|
|
983
|
-
s:
|
|
976
|
+
r: Hex;
|
|
977
|
+
s: Hex;
|
|
984
978
|
to: Address | null;
|
|
985
|
-
typeHex:
|
|
979
|
+
typeHex: Hex | null;
|
|
986
980
|
v: bigint;
|
|
987
981
|
value: bigint;
|
|
988
982
|
accessList: import('viem').AccessList;
|
|
@@ -1002,17 +996,17 @@ export declare class PufferProtocolHandler {
|
|
|
1002
996
|
from: Address;
|
|
1003
997
|
gas: bigint;
|
|
1004
998
|
hash: import('viem').Hash;
|
|
1005
|
-
input:
|
|
999
|
+
input: Hex;
|
|
1006
1000
|
nonce: number;
|
|
1007
|
-
r:
|
|
1008
|
-
s:
|
|
1001
|
+
r: Hex;
|
|
1002
|
+
s: Hex;
|
|
1009
1003
|
to: Address | null;
|
|
1010
|
-
typeHex:
|
|
1004
|
+
typeHex: Hex | null;
|
|
1011
1005
|
v: bigint;
|
|
1012
1006
|
value: bigint;
|
|
1013
1007
|
accessList: import('viem').AccessList;
|
|
1014
1008
|
authorizationList?: undefined | undefined;
|
|
1015
|
-
blobVersionedHashes: readonly
|
|
1009
|
+
blobVersionedHashes: readonly Hex[];
|
|
1016
1010
|
chainId: number;
|
|
1017
1011
|
type: "eip4844";
|
|
1018
1012
|
gasPrice?: undefined | undefined;
|
|
@@ -1027,12 +1021,12 @@ export declare class PufferProtocolHandler {
|
|
|
1027
1021
|
from: Address;
|
|
1028
1022
|
gas: bigint;
|
|
1029
1023
|
hash: import('viem').Hash;
|
|
1030
|
-
input:
|
|
1024
|
+
input: Hex;
|
|
1031
1025
|
nonce: number;
|
|
1032
|
-
r:
|
|
1033
|
-
s:
|
|
1026
|
+
r: Hex;
|
|
1027
|
+
s: Hex;
|
|
1034
1028
|
to: Address | null;
|
|
1035
|
-
typeHex:
|
|
1029
|
+
typeHex: Hex | null;
|
|
1036
1030
|
v: bigint;
|
|
1037
1031
|
value: bigint;
|
|
1038
1032
|
accessList: import('viem').AccessList;
|
|
@@ -7573,7 +7567,7 @@ export declare class PufferProtocolHandler {
|
|
|
7573
7567
|
scheme?: string | undefined | undefined;
|
|
7574
7568
|
time?: Date | undefined;
|
|
7575
7569
|
message: string;
|
|
7576
|
-
signature:
|
|
7570
|
+
signature: Hex;
|
|
7577
7571
|
}) => Promise<boolean>;
|
|
7578
7572
|
verifyTypedData: (args: import('viem').VerifyTypedDataActionParameters) => Promise<import('viem').VerifyTypedDataActionReturnType>;
|
|
7579
7573
|
uninstallFilter: (args: import('viem').UninstallFilterParameters) => Promise<import('viem').UninstallFilterReturnType>;
|
|
@@ -15384,7 +15378,7 @@ export declare class PufferProtocolHandler {
|
|
|
15384
15378
|
* @param vtPermit The VT permit data.
|
|
15385
15379
|
* @returns The transaction.
|
|
15386
15380
|
*/
|
|
15387
|
-
registerValidatorKey(data: ValidatorKeyData, moduleName:
|
|
15381
|
+
registerValidatorKey(data: ValidatorKeyData, moduleName: Hex, pufETHPermit: PermitData, vtPermit: PermitData): Promise<`0x${string}`>;
|
|
15388
15382
|
/**
|
|
15389
15383
|
* Provision a node.
|
|
15390
15384
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-protocol-handler.js","sources":["../../../lib/contracts/handlers/puffer-protocol-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n Account,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { PufferProtocol } from '../abis/mainnet/PufferProtocol';\n\nexport type PermitData = {\n deadline: bigint;\n amount: bigint;\n v: number;\n r: Address;\n s: Address;\n};\n\nexport type ValidatorKeyData = {\n blsPubKey: `0x${string}`;\n signature: `0x${string}`;\n depositDataRoot: `0x${string}`;\n blsEncryptedPrivKeyShares: `0x${string}`[];\n blsPubKeySet: `0x${string}`;\n raveEvidence: `0x${string}`;\n};\n\nexport type StoppedValidatorInfo = {\n module: Address;\n startEpoch: bigint;\n endEpoch: bigint;\n wasSlashed: boolean;\n moduleName: `0x${string}`;\n pufferModuleIndex: bigint;\n withdrawalAmount: bigint;\n};\n\n/**\n * Handler for the `PufferProtocol` contract exposing methods to interact\n * with the contract.\n */\nexport class PufferProtocolHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the `PufferProtocol` 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.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferProtocol as Address;\n const abi = PufferProtocol;\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 minimum VT amount required.\n *\n * @returns The minimum VT amount.\n */\n public getMinimumVtAmount() {\n return this.getContract().read.getMinimumVtAmount();\n }\n\n /**\n * Get the VT penalty amount.\n *\n * @returns The VT penalty amount.\n */\n public getVTPenalty() {\n return this.getContract().read.getVTPenalty();\n }\n\n /**\n * Get validator tickets balance for an owner.\n *\n * @param owner The owner address.\n * @returns The validator tickets balance.\n */\n public getValidatorTicketsBalance(owner: Address) {\n return this.getContract().read.getValidatorTicketsBalance([owner]);\n }\n\n /**\n * Get module address by name.\n *\n * @param moduleName The module name.\n * @returns The module address.\n */\n public getModuleAddress(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleAddress([moduleName]);\n }\n\n /**\n * Get module weights.\n *\n * @returns The module weights.\n */\n public getModuleWeights() {\n return this.getContract().read.getModuleWeights();\n }\n\n /**\n * Get the next validator to be provisioned.\n *\n * @returns Tuple of module name and index.\n */\n public getNextValidatorToProvision() {\n return this.getContract().read.getNextValidatorToProvision();\n }\n\n /**\n * Get node information.\n *\n * @param node The node address.\n * @returns The node information.\n */\n public getNodeInfo(node: Address) {\n return this.getContract().read.getNodeInfo([node]);\n }\n\n /**\n * Get validators for a module.\n *\n * @param moduleName The module name.\n * @returns The validators array.\n */\n public getValidators(moduleName: `0x${string}`) {\n return this.getContract().read.getValidators([moduleName]);\n }\n\n /**\n * Get validator information.\n *\n * @param moduleName The module name.\n * @param pufferModuleIndex The puffer module index.\n * @returns The validator information.\n */\n public getValidatorInfo(\n moduleName: `0x${string}`,\n pufferModuleIndex: bigint,\n ) {\n return this.getContract().read.getValidatorInfo([\n moduleName,\n pufferModuleIndex,\n ]);\n }\n\n /**\n * Get module limit information.\n *\n * @param moduleName The module name.\n * @returns The module limit information.\n */\n public getModuleLimitInformation(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleLimitInformation([moduleName]);\n }\n\n /**\n * Get withdrawal credentials for a module.\n *\n * @param module The module address.\n * @returns The withdrawal credentials.\n */\n public getWithdrawalCredentials(module: Address) {\n return this.getContract().read.getWithdrawalCredentials([module]);\n }\n\n /**\n * Get deposit data root.\n *\n * @param pubKey The public key.\n * @param signature The signature.\n * @param withdrawalCredentials The withdrawal credentials.\n * @returns The deposit data root.\n */\n public getDepositDataRoot(\n pubKey: `0x${string}`,\n signature: `0x${string}`,\n withdrawalCredentials: `0x${string}`,\n ) {\n return this.getContract().read.getDepositDataRoot([\n pubKey,\n signature,\n withdrawalCredentials,\n ]);\n }\n\n /**\n * Create a new puffer module.\n *\n * @param moduleName The module name.\n * @returns The transaction.\n */\n public createPufferModule(moduleName: `0x${string}`) {\n return this.getContract().write.createPufferModule([moduleName], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Register validator key.\n *\n * @param data The validator key data.\n * @param moduleName The module name.\n * @param pufETHPermit The pufETH permit data.\n * @param vtPermit The VT permit data.\n * @returns The transaction.\n */\n public registerValidatorKey(\n data: ValidatorKeyData,\n moduleName: `0x${string}`,\n pufETHPermit: PermitData,\n vtPermit: PermitData,\n ) {\n return this.getContract().write.registerValidatorKey(\n [data, moduleName, pufETHPermit, vtPermit],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Provision a node.\n *\n * @param guardianEnclaveSignatures The guardian enclave signatures.\n * @param validatorSignature The validator signature.\n * @param depositRootHash The deposit root hash.\n * @returns The transaction.\n */\n public provisionNode(\n guardianEnclaveSignatures: `0x${string}`[],\n validatorSignature: `0x${string}`,\n depositRootHash: `0x${string}`,\n ) {\n return this.getContract().write.provisionNode(\n [guardianEnclaveSignatures, validatorSignature, depositRootHash],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Deposit validator tickets.\n *\n * @param permit The permit data.\n * @param node The node address.\n * @returns The transaction.\n */\n public depositValidatorTickets(permit: PermitData, node: Address) {\n return this.getContract().write.depositValidatorTickets([permit, node], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Withdraw validator tickets.\n *\n * @param amount The amount to withdraw.\n * @param recipient The recipient address.\n * @returns The transaction.\n */\n public withdrawValidatorTickets(amount: bigint, recipient: Address) {\n return this.getContract().write.withdrawValidatorTickets(\n [amount, recipient],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Batch handle withdrawals.\n *\n * @param validatorInfos The validator infos.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public batchHandleWithdrawals(\n validatorInfos: StoppedValidatorInfo[],\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.batchHandleWithdrawals(\n [validatorInfos, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Skip provisioning for a module.\n *\n * @param moduleName The module name.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public skipProvisioning(\n moduleName: `0x${string}`,\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.skipProvisioning(\n [moduleName, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n}\n"],"names":["PufferProtocolHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","PufferProtocol","client","getContract","owner","moduleName","node","pufferModuleIndex","module","pubKey","signature","withdrawalCredentials","data","pufETHPermit","vtPermit","guardianEnclaveSignatures","validatorSignature","depositRootHash","permit","amount","recipient","validatorInfos","guardianEOASignatures"],"mappings":";;;;;;;AA2CO,MAAMA,EAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAajC,YACUC,GACAC,GACAC,GACR;AAhBM,IAAAC,EAAA;AAaE,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,gBACzCC,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,EAYtC,qBAAqB;AAC1B,WAAO,KAAK,cAAc,KAAK,mBAAmB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7C,eAAe;AACpB,WAAO,KAAK,cAAc,KAAK,aAAa;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASvC,2BAA2BE,GAAgB;AAChD,WAAO,KAAK,YAAY,EAAE,KAAK,2BAA2B,CAACA,CAAK,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5D,iBAAiBC,GAA2B;AAC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BACLC,GACAC,GACA;AACO,WAAA,KAAK,cAAc,MAAM;AAAA,MAC9B,CAACD,GAAgBC,CAAqB;AAAA,MACtC;AAAA,QACE,SAAS,KAAK,aAAa;AAAA,QAC3B,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUK,iBACLjB,GACAiB,GACA;AACO,WAAA,KAAK,cAAc,MAAM;AAAA,MAC9B,CAACjB,GAAYiB,CAAqB;AAAA,MAClC;AAAA,QACE,SAAS,KAAK,aAAa;AAAA,QAC3B,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhB;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"puffer-protocol-handler.js","sources":["../../../lib/contracts/handlers/puffer-protocol-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n Account,\n Hex,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { PufferProtocol } from '../abis/mainnet/PufferProtocol';\nimport { PermitData } from '../common/lib/types';\n\nexport type ValidatorKeyData = {\n blsPubKey: `0x${string}`;\n signature: `0x${string}`;\n depositDataRoot: `0x${string}`;\n blsEncryptedPrivKeyShares: `0x${string}`[];\n blsPubKeySet: `0x${string}`;\n raveEvidence: `0x${string}`;\n};\n\nexport type StoppedValidatorInfo = {\n module: Address;\n startEpoch: bigint;\n endEpoch: bigint;\n wasSlashed: boolean;\n moduleName: `0x${string}`;\n pufferModuleIndex: bigint;\n withdrawalAmount: bigint;\n};\n\n/**\n * Handler for the `PufferProtocol` contract exposing methods to interact\n * with the contract.\n */\nexport class PufferProtocolHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the `PufferProtocol` 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.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferProtocol as Address;\n const abi = PufferProtocol;\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 minimum VT amount required.\n *\n * @returns The minimum VT amount.\n */\n public getMinimumVtAmount() {\n return this.getContract().read.getMinimumVtAmount();\n }\n\n /**\n * Get the VT penalty amount.\n *\n * @returns The VT penalty amount.\n */\n public getVTPenalty() {\n return this.getContract().read.getVTPenalty();\n }\n\n /**\n * Get validator tickets balance for an owner.\n *\n * @param owner The owner address.\n * @returns The validator tickets balance.\n */\n public getValidatorTicketsBalance(owner: Address) {\n return this.getContract().read.getValidatorTicketsBalance([owner]);\n }\n\n /**\n * Get module address by name.\n *\n * @param moduleName The module name.\n * @returns The module address.\n */\n public getModuleAddress(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleAddress([moduleName]);\n }\n\n /**\n * Get module weights.\n *\n * @returns The module weights.\n */\n public getModuleWeights() {\n return this.getContract().read.getModuleWeights();\n }\n\n /**\n * Get the next validator to be provisioned.\n *\n * @returns Tuple of module name and index.\n */\n public getNextValidatorToProvision() {\n return this.getContract().read.getNextValidatorToProvision();\n }\n\n /**\n * Get node information.\n *\n * @param node The node address.\n * @returns The node information.\n */\n public getNodeInfo(node: Address) {\n return this.getContract().read.getNodeInfo([node]);\n }\n\n /**\n * Get validators for a module.\n *\n * @param moduleName The module name.\n * @returns The validators array.\n */\n public getValidators(moduleName: `0x${string}`) {\n return this.getContract().read.getValidators([moduleName]);\n }\n\n /**\n * Get validator information.\n *\n * @param moduleName The module name.\n * @param pufferModuleIndex The puffer module index.\n * @returns The validator information.\n */\n public getValidatorInfo(\n moduleName: `0x${string}`,\n pufferModuleIndex: bigint,\n ) {\n return this.getContract().read.getValidatorInfo([\n moduleName,\n pufferModuleIndex,\n ]);\n }\n\n /**\n * Get module limit information.\n *\n * @param moduleName The module name.\n * @returns The module limit information.\n */\n public getModuleLimitInformation(moduleName: `0x${string}`) {\n return this.getContract().read.getModuleLimitInformation([moduleName]);\n }\n\n /**\n * Get withdrawal credentials for a module.\n *\n * @param module The module address.\n * @returns The withdrawal credentials.\n */\n public getWithdrawalCredentials(module: Address) {\n return this.getContract().read.getWithdrawalCredentials([module]);\n }\n\n /**\n * Get deposit data root.\n *\n * @param pubKey The public key.\n * @param signature The signature.\n * @param withdrawalCredentials The withdrawal credentials.\n * @returns The deposit data root.\n */\n public getDepositDataRoot(\n pubKey: `0x${string}`,\n signature: `0x${string}`,\n withdrawalCredentials: `0x${string}`,\n ) {\n return this.getContract().read.getDepositDataRoot([\n pubKey,\n signature,\n withdrawalCredentials,\n ]);\n }\n\n /**\n * Create a new puffer module.\n *\n * @param moduleName The module name.\n * @returns The transaction.\n */\n public createPufferModule(moduleName: `0x${string}`) {\n return this.getContract().write.createPufferModule([moduleName], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Register validator key.\n *\n * @param data The validator key data.\n * @param moduleName The module name.\n * @param pufETHPermit The pufETH permit data.\n * @param vtPermit The VT permit data.\n * @returns The transaction.\n */\n public registerValidatorKey(\n data: ValidatorKeyData,\n moduleName: Hex,\n pufETHPermit: PermitData,\n vtPermit: PermitData,\n ) {\n return this.getContract().write.registerValidatorKey(\n [data, moduleName, pufETHPermit, vtPermit],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Provision a node.\n *\n * @param guardianEnclaveSignatures The guardian enclave signatures.\n * @param validatorSignature The validator signature.\n * @param depositRootHash The deposit root hash.\n * @returns The transaction.\n */\n public provisionNode(\n guardianEnclaveSignatures: `0x${string}`[],\n validatorSignature: `0x${string}`,\n depositRootHash: `0x${string}`,\n ) {\n return this.getContract().write.provisionNode(\n [guardianEnclaveSignatures, validatorSignature, depositRootHash],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Deposit validator tickets.\n *\n * @param permit The permit data.\n * @param node The node address.\n * @returns The transaction.\n */\n public depositValidatorTickets(permit: PermitData, node: Address) {\n return this.getContract().write.depositValidatorTickets([permit, node], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Withdraw validator tickets.\n *\n * @param amount The amount to withdraw.\n * @param recipient The recipient address.\n * @returns The transaction.\n */\n public withdrawValidatorTickets(amount: bigint, recipient: Address) {\n return this.getContract().write.withdrawValidatorTickets(\n [amount, recipient],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Batch handle withdrawals.\n *\n * @param validatorInfos The validator infos.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public batchHandleWithdrawals(\n validatorInfos: StoppedValidatorInfo[],\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.batchHandleWithdrawals(\n [validatorInfos, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Skip provisioning for a module.\n *\n * @param moduleName The module name.\n * @param guardianEOASignatures The guardian EOA signatures.\n * @returns The transaction.\n */\n public skipProvisioning(\n moduleName: `0x${string}`,\n guardianEOASignatures: `0x${string}`[],\n ) {\n return this.getContract().write.skipProvisioning(\n [moduleName, guardianEOASignatures],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n}\n"],"names":["PufferProtocolHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","PufferProtocol","client","getContract","owner","moduleName","node","pufferModuleIndex","module","pubKey","signature","withdrawalCredentials","data","pufETHPermit","vtPermit","guardianEnclaveSignatures","valid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AK,cAAc,MAAM;AAAA,MAC9B,CAACjB,GAAYiB,CAAqB;AAAA,MAClC;AAAA,QACE,SAAS,KAAK,aAAa;AAAA,QAC3B,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhB;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var h=(i,t,a)=>t in i?s(i,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[t]=a;var r=(i,t,a)=>h(i,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../addresses.cjs"),o=require("../../constants-CxSgz27h.cjs"),u=require("./erc20-permit-handler.cjs"),m=require("../tokens.cjs"),l=require("../abis/mainnet/PufferWithdrawalManager.cjs"),C=require("../../getContract-DUA3M2pm.cjs");class w{constructor(t,a,e){r(this,"viemChain");r(this,"erc20PermitHandler");this.chain=t,this.walletClient=a,this.publicClient=e,this.viemChain=o.VIEM_CHAINS[t],this.erc20PermitHandler=new u.ERC20PermitHandler(t,a,e)}getContract(){const t=c.CONTRACT_ADDRESSES[this.chain].PufferWithdrawalManager,a=l.PufferWithdrawalManager,e={public:this.publicClient,wallet:this.walletClient};return C.getContract({address:t,abi:a,client:e})}async requestWithdrawal(t,a){return{transact:async()=>await this.getContract().write.requestWithdrawal([a,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.requestWithdrawal([a,t],{account:t})}}async requestWithdrawalWithPermit(t,a){const e=await this.erc20PermitHandler.withToken(m.Token.pufETH).getPermitData(t,c.CONTRACT_ADDRESSES[this.chain].PufferWithdrawalManager,a);return{transact:async()=>await this.getContract().write.requestWithdrawalWithPermit([e,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.requestWithdrawalWithPermit([e,t],{account:t})}}async completeQueuedWithdrawal(t,a){return{transact:async()=>await this.getContract().write.completeQueuedWithdrawal([a],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.completeQueuedWithdrawal([a],{account:t})}}async getWithdrawal(t){return await this.getContract().read.getWithdrawal([t])}}exports.PufferWithdrawalManagerHandler=w;
|
|
2
2
|
//# sourceMappingURL=puffer-withdrawal-manager-handler.cjs.map
|