@pufferfinance/puffer-sdk 1.5.3 → 1.6.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 +43 -36
- package/dist/api/puffer-client.js.map +1 -1
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.cjs +2 -0
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.cjs.map +1 -0
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.d.ts +510 -0
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.js +665 -0
- package/dist/contracts/abis/mainnet/PufferWithdrawalManager.js.map +1 -0
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.cjs +2 -0
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.cjs.map +1 -0
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.d.ts +514 -0
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.js +10 -0
- package/dist/contracts/abis/puffer-withdrawal-manager-abis.js.map +1 -0
- package/dist/contracts/addresses.cjs +1 -1
- package/dist/contracts/addresses.cjs.map +1 -1
- package/dist/contracts/addresses.d.ts +1 -0
- package/dist/contracts/addresses.js +5 -1
- package/dist/contracts/addresses.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 +1 -0
- package/dist/contracts/handlers/erc20-permit-handler.js +19 -14
- package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +2 -0
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -0
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.d.ts +6697 -0
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +116 -0
- package/dist/contracts/handlers/puffer-withdrawal-manager-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 +7 -2
- package/dist/contracts/tokens.js +11 -3
- package/dist/contracts/tokens.js.map +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +26 -23
- package/dist/main.js.map +1 -1
- package/dist/utils/version.cjs +1 -1
- package/dist/utils/version.js +1 -1
- package/package.json +1 -1
|
@@ -3,12 +3,12 @@ var d = (i, t, e) => t in i ? l(i, t, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var o = (i, t, e) => d(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { n as s, V as g } from "../../constants-rWWWhxR_.js";
|
|
5
5
|
import { ERC20PERMIT_ABI as y } from "../abis/tokens-abis.js";
|
|
6
|
-
import { Token as C, TOKENS_ADDRESSES as m, TOKENS_PERMIT_VERSION as f } from "../tokens.js";
|
|
6
|
+
import { Token as C, TOKENS_ADDRESSES as m, TOKENS_PERMIT_VERSION as f, TOKENS_SALT as S } from "../tokens.js";
|
|
7
7
|
import { getTimestampInSeconds as E } from "../../utils/time.js";
|
|
8
|
-
import { g as
|
|
9
|
-
import { s as
|
|
10
|
-
function
|
|
11
|
-
const { r: t, s: e } =
|
|
8
|
+
import { g as P } from "../../getContract-B3Spz0SO.js";
|
|
9
|
+
import { s as T } from "../../secp256k1-BLbXMlpX.js";
|
|
10
|
+
function I(i) {
|
|
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];
|
|
14
14
|
if (n === 27)
|
|
@@ -28,7 +28,7 @@ function w(i) {
|
|
|
28
28
|
yParity: a
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class _ {
|
|
32
32
|
/**
|
|
33
33
|
* Create the handler for processing tokens.
|
|
34
34
|
*
|
|
@@ -60,7 +60,7 @@ class O {
|
|
|
60
60
|
*/
|
|
61
61
|
getContract() {
|
|
62
62
|
const t = m[this.token][this.chain], e = y, n = { public: this.publicClient, wallet: this.walletClient };
|
|
63
|
-
return
|
|
63
|
+
return P({ address: t, abi: e, client: n });
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Process and get permit signature for the given token to perform
|
|
@@ -72,12 +72,13 @@ class O {
|
|
|
72
72
|
* @returns Permit signature in the form `{ r, s, v?, yParity }`.
|
|
73
73
|
*/
|
|
74
74
|
async getPermitSignature(t, e, n) {
|
|
75
|
-
const r = this.getContract(), a = await r.read.nonces([t]),
|
|
75
|
+
const r = this.getContract(), a = await r.read.nonces([t]), h = {
|
|
76
76
|
name: await r.read.name(),
|
|
77
77
|
version: this.getPermitVersion(this.token),
|
|
78
78
|
chainId: this.chain,
|
|
79
|
-
verifyingContract: m[this.token][this.chain]
|
|
80
|
-
|
|
79
|
+
verifyingContract: m[this.token][this.chain],
|
|
80
|
+
salt: this.getPermitSalt(this.token)
|
|
81
|
+
}, p = {
|
|
81
82
|
Permit: [
|
|
82
83
|
{ name: "owner", type: "address" },
|
|
83
84
|
{ name: "spender", type: "address" },
|
|
@@ -87,8 +88,8 @@ class O {
|
|
|
87
88
|
]
|
|
88
89
|
}, c = BigInt(E() + 60 * 60 * 2), u = await this.walletClient.signTypedData({
|
|
89
90
|
account: t,
|
|
90
|
-
domain:
|
|
91
|
-
types:
|
|
91
|
+
domain: h,
|
|
92
|
+
types: p,
|
|
92
93
|
primaryType: "Permit",
|
|
93
94
|
message: {
|
|
94
95
|
owner: t,
|
|
@@ -98,7 +99,7 @@ class O {
|
|
|
98
99
|
deadline: c
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
|
-
return { ...
|
|
102
|
+
return { ...I(u), deadline: c };
|
|
102
103
|
}
|
|
103
104
|
getPermitVersion(t) {
|
|
104
105
|
return f[t];
|
|
@@ -117,8 +118,12 @@ class O {
|
|
|
117
118
|
chain: this.viemChain
|
|
118
119
|
});
|
|
119
120
|
}
|
|
121
|
+
getPermitSalt(t) {
|
|
122
|
+
var e, n;
|
|
123
|
+
return (n = (e = S) == null ? void 0 : e[t]) == null ? void 0 : n[this.chain];
|
|
124
|
+
}
|
|
120
125
|
}
|
|
121
126
|
export {
|
|
122
|
-
|
|
127
|
+
_ as ERC20PermitHandler
|
|
123
128
|
};
|
|
124
129
|
//# sourceMappingURL=erc20-permit-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.18.8_typescript@5.5.4_zod@3.23.8/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 { ERC20PERMIT_ABI } from '../abis/tokens-abis';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\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_ABI;\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 through the `PufferDepositor` contract.\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 };\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 private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\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"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20PERMIT_ABI","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION"],"mappings":";;;;;;;;;AAYO,SAASA,EAAeC,GAAc;AACzC,QAAM,EAAE,GAAAC,GAAG,GAAAC,EAAG,IAAGC,EAAU,UAAU,YAAYH,EAAa,MAAM,GAAG,GAAG,CAAC,GACrEI,IAAa,CAAO,KAAKJ,EAAa,MAAM,GAAG,CAAC,IAChD,CAACK,GAAGC,CAAO,KAAK,MAAM;AACxB,QAAIF,MAAe,KAAKA,MAAe;AACnC,aAAO,CAAC,QAAWA,CAAU;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAClD;AACI,SAAI,OAAOC,IAAM,MACN;AAAA,IACH,GAAGE,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAAG;AAAA,IACA,SAAAC;AAAA,EACZ,IACW;AAAA,IACH,GAAGC,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,SAAAI;AAAA,EACR;AACA;
|
|
1
|
+
{"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.18.8_typescript@5.5.4_zod@3.23.8/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 { ERC20PERMIT_ABI } from '../abis/tokens-abis';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\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_ABI;\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 through the `PufferDepositor` contract.\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 private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\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 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_ABI","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,KAAKJ,EAAa,MAAM,GAAG,CAAC,IAChD,CAACK,GAAGC,CAAO,KAAK,MAAM;AACxB,QAAIF,MAAe,KAAKA,MAAe;AACnC,aAAO,CAAC,QAAWA,CAAU;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAClD;AACI,SAAI,OAAOC,IAAM,MACN;AAAA,IACH,GAAGE,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAAG;AAAA,IACA,SAAAC;AAAA,EACZ,IACW;AAAA,IACH,GAAGC,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,SAAAI;AAAA,EACR;AACA;ACdO,MAAME,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa9B,YACUC,GACAC,GACAC,GACR;AAhBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AAYE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK,GAClC,KAAK,QAA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AAA,MACb,SAAS;AAAA,QACP,OAAON;AAAA,QACP,SAASC;AAAA,QACT,OAAAC;AAAA,QACA,OAAOE;AAAA,QACP,UAAAG;AAAA,MACF;AAAA,IAAA,CACD;AAED,WAAO,EAAE,GAAG9B,EAAegC,CAAS,GAAG,UAAAF,EAAS;AAAA,EAClD;AAAA,EAEQ,iBAAiBd,GAAyB;AAChD,WAAOiB,EAAsBjB,CAAK;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUO,QACLO,GACAC,GACAC,GACA;AACO,WAAA,KAAK,cAAc,MAAM,QAAQ,CAACD,GAAgBC,CAAK,GAAG;AAAA,MAC/D,SAASF;AAAA,MACT,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EACH;AAAA,EAEQ,cAAcP,GAAiB;;AACrC,YAAOkB,KAAAC,IAAAC,MAAA,gBAAAD,EAAcnB,OAAd,gBAAAkB,EAAuB,KAAK;AAAA,EACrC;AACF;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var m=Object.defineProperty;var l=(i,t,a)=>t in i?m(i,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[t]=a;var n=(i,t,a)=>l(i,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../addresses.cjs"),C=require("../../constants-BvU-JhfL.cjs"),g=require("./erc20-permit-handler.cjs"),w=require("../abis/puffer-withdrawal-manager-abis.cjs"),W=require("../tokens.cjs"),d=require("../../getContract-MrPLx6gp.cjs");class P{constructor(t,a,e){n(this,"viemChain");n(this,"erc20PermitHandler");this.chain=t,this.walletClient=a,this.publicClient=e,this.viemChain=C.VIEM_CHAINS[t],this.erc20PermitHandler=new g.ERC20PermitHandler(t,a,e)}getContract(){const t=s.CONTRACT_ADDRESSES[this.chain].PufferWithdrawalManager,a=w.PUFFER_WITHDRAWAL_MANAGER_ABIS[this.chain].PufferWithdrawalManager,e={public:this.publicClient,wallet:this.walletClient};return d.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{r:e,s:r,v:h,yParity:o,deadline:u}=await this.erc20PermitHandler.withToken(W.Token.pufETH).getPermitSignature(t,s.CONTRACT_ADDRESSES[this.chain].PufferWithdrawalManager,a),c={r:e,s:r,v:Number(h??o),deadline:u,amount:a};return{transact:async()=>await this.getContract().write.requestWithdrawalWithPermit([c,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.requestWithdrawalWithPermit([c,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=P;
|
|
2
|
+
//# sourceMappingURL=puffer-withdrawal-manager-handler.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"puffer-withdrawal-manager-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-withdrawal-manager-handler.ts"],"sourcesContent":["import {\n Address,\n getContract,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n} from 'viem';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PUFFER_WITHDRAWAL_MANAGER_ABIS } from '../abis/puffer-withdrawal-manager-abis';\nimport { Token } from '../tokens';\n\n/**\n * Handler for the `PufferWithdrawalsManager` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferWithdrawalManagerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferWithdrawalsManager` 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.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain]\n .PufferWithdrawalManager as Address;\n const abi =\n PUFFER_WITHDRAWAL_MANAGER_ABIS[this.chain].PufferWithdrawalManager;\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 * Request a withdrawal of the given amount to the given address, with a permit.\n *\n * @param walletAddress The account address to request the withdrawal for.\n * @param amount The pufETH amount to request the withdrawal for.\n * @returns The transaction hash of the withdrawal.\n */\n public async requestWithdrawal(walletAddress: Address, amount: bigint) {\n const transact = async () =>\n await this.getContract().write.requestWithdrawal(\n [amount, walletAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n\n const estimate = async () =>\n await this.getContract().estimateGas.requestWithdrawal(\n [amount, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Request a withdrawal of the given amount to the given address.\n *\n * @param walletAddress The account address to request the withdrawal for.\n * @param amount The pufETHamount to request the withdrawal for.\n * @returns The transaction hash of the withdrawal.\n */\n public async requestWithdrawalWithPermit(\n walletAddress: Address,\n amount: bigint,\n ) {\n const { r, s, v, yParity, deadline } = await this.erc20PermitHandler\n .withToken(Token.pufETH)\n .getPermitSignature(\n walletAddress,\n CONTRACT_ADDRESSES[this.chain].PufferWithdrawalManager as Address,\n amount,\n );\n\n /* istanbul ignore next */\n const permitData = {\n r,\n s,\n v: Number(v ?? yParity),\n deadline,\n amount,\n };\n\n const transact = async () =>\n await this.getContract().write.requestWithdrawalWithPermit(\n [permitData, walletAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n\n const estimate = async () =>\n await this.getContract().estimateGas.requestWithdrawalWithPermit(\n [permitData, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Complete a withdrawal from the queue.\n *\n * @param withdrawalIdx The index of the withdrawal to complete.\n * @returns The transaction hash of the withdrawal.\n */\n public async completeQueuedWithdrawal(\n walletAddress: Address,\n withdrawalIdx: bigint,\n ) {\n const transact = async () =>\n await this.getContract().write.completeQueuedWithdrawal([withdrawalIdx], {\n account: walletAddress,\n chain: this.viemChain,\n });\n\n const estimate = async () =>\n await this.getContract().estimateGas.completeQueuedWithdrawal(\n [withdrawalIdx],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get the withdrawal at the given index.\n *\n * @param withdrawalIdx The index of the withdrawal to get.\n * @returns The withdrawal at the given index.\n */\n public async getWithdrawal(withdrawalIdx: bigint) {\n return await this.getContract().read.getWithdrawal([withdrawalIdx]);\n }\n}\n"],"names":["PufferWithdrawalManagerHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PUFFER_WITHDRAWAL_MANAGER_ABIS","client","getContract","walletAddress","amount","r","s","v","yParity","deadline","Token","permitData","withdrawalIdx"],"mappings":"yeAiBO,MAAMA,CAA+B,CAc1C,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,CAAA,CAEJ,CAOO,aAAc,CACnB,MAAMI,EAAUC,EAAA,mBAAmB,KAAK,KAAK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