@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.
Files changed (65) hide show
  1. package/dist/api/puffer-client.cjs +1 -1
  2. package/dist/api/puffer-client.cjs.map +1 -1
  3. package/dist/api/puffer-client.d.ts +3 -0
  4. package/dist/api/puffer-client.js +28 -21
  5. package/dist/api/puffer-client.js.map +1 -1
  6. package/dist/contracts/abis/mainnet/vlPUFFER.cjs +2 -0
  7. package/dist/contracts/abis/mainnet/vlPUFFER.cjs.map +1 -0
  8. package/dist/contracts/abis/mainnet/vlPUFFER.d.ts +437 -0
  9. package/dist/contracts/abis/mainnet/vlPUFFER.js +269 -0
  10. package/dist/contracts/abis/mainnet/vlPUFFER.js.map +1 -0
  11. package/dist/contracts/common/lib/types.cjs +2 -0
  12. package/dist/contracts/common/lib/types.cjs.map +1 -0
  13. package/dist/contracts/common/lib/types.d.ts +8 -0
  14. package/dist/contracts/common/lib/types.js +2 -0
  15. package/dist/contracts/common/lib/types.js.map +1 -0
  16. package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
  17. package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
  18. package/dist/contracts/handlers/erc20-permit-handler.d.ts +10 -0
  19. package/dist/contracts/handlers/erc20-permit-handler.js +56 -40
  20. package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
  21. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
  22. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs.map +1 -1
  23. package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +2 -6
  24. package/dist/contracts/handlers/nucleus-boring-vault-handler.js +17 -17
  25. package/dist/contracts/handlers/nucleus-boring-vault-handler.js.map +1 -1
  26. package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
  27. package/dist/contracts/handlers/nucleus-teller-handler.cjs.map +1 -1
  28. package/dist/contracts/handlers/nucleus-teller-handler.d.ts +2 -6
  29. package/dist/contracts/handlers/nucleus-teller-handler.js +11 -20
  30. package/dist/contracts/handlers/nucleus-teller-handler.js.map +1 -1
  31. package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
  32. package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -1
  33. package/dist/contracts/handlers/puf-locker-handler.js +31 -40
  34. package/dist/contracts/handlers/puf-locker-handler.js.map +1 -1
  35. package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
  36. package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -1
  37. package/dist/contracts/handlers/puffer-depositor-handler.js +26 -38
  38. package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -1
  39. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
  40. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -1
  41. package/dist/contracts/handlers/puffer-l2-depositor-handler.js +28 -37
  42. package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
  43. package/dist/contracts/handlers/puffer-protocol-handler.cjs.map +1 -1
  44. package/dist/contracts/handlers/puffer-protocol-handler.d.ts +49 -55
  45. package/dist/contracts/handlers/puffer-protocol-handler.js.map +1 -1
  46. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
  47. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -1
  48. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +21 -27
  49. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
  50. package/dist/contracts/handlers/validator-ticket-handler.cjs.map +1 -1
  51. package/dist/contracts/handlers/validator-ticket-handler.d.ts +1 -7
  52. package/dist/contracts/handlers/validator-ticket-handler.js.map +1 -1
  53. package/dist/contracts/handlers/vl-puffer-handler.cjs +2 -0
  54. package/dist/contracts/handlers/vl-puffer-handler.cjs.map +1 -0
  55. package/dist/contracts/handlers/vl-puffer-handler.d.ts +14802 -0
  56. package/dist/contracts/handlers/vl-puffer-handler.js +357 -0
  57. package/dist/contracts/handlers/vl-puffer-handler.js.map +1 -0
  58. package/dist/contracts/tokens.cjs +1 -1
  59. package/dist/contracts/tokens.cjs.map +1 -1
  60. package/dist/contracts/tokens.d.ts +2 -1
  61. package/dist/contracts/tokens.js +6 -2
  62. package/dist/contracts/tokens.js.map +1 -1
  63. package/dist/utils/version.cjs +1 -1
  64. package/dist/utils/version.js +1 -1
  65. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vlPUFFER.js","sources":["../../../../lib/contracts/abis/mainnet/vlPUFFER.ts"],"sourcesContent":["export const vlPUFFER = <const>[\n {\n type: 'function',\n name: 'PUFFER',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'address', name: '', simpleType: 'address' }],\n },\n {\n type: 'function',\n name: 'decimals',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'uint8', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'delegates',\n stateMutability: 'view',\n inputs: [{ type: 'address', name: 'account', simpleType: 'address' }],\n outputs: [{ type: 'address', name: '', simpleType: 'address' }],\n },\n {\n type: 'function',\n name: 'owner',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'address', name: '', simpleType: 'address' }],\n },\n {\n type: 'function',\n name: 'allowance',\n stateMutability: 'view',\n inputs: [\n { type: 'address', name: 'owner', simpleType: 'address' },\n { type: 'address', name: 'spender', simpleType: 'address' },\n ],\n outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'transferFrom',\n stateMutability: 'nonpayable',\n inputs: [\n { type: 'address', name: 'from', simpleType: 'address' },\n { type: 'address', name: 'to', simpleType: 'address' },\n { type: 'uint256', name: 'value', simpleType: 'uint' },\n ],\n outputs: [{ type: 'bool', name: '', simpleType: 'bool' }],\n },\n {\n type: 'function',\n name: 'totalSupply',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'createLock',\n stateMutability: 'nonpayable',\n inputs: [\n { type: 'uint256', name: 'amount', simpleType: 'uint' },\n { type: 'uint256', name: 'multiplier', simpleType: 'uint' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'symbol',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'string', name: '', simpleType: 'string' }],\n },\n {\n type: 'function',\n name: 'paused',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'bool', name: '', simpleType: 'bool' }],\n },\n {\n type: 'function',\n name: 'lockInfos',\n stateMutability: 'view',\n inputs: [{ type: 'address', name: 'user', simpleType: 'address' }],\n outputs: [\n { type: 'uint256', name: 'pufferAmount', simpleType: 'uint' },\n { type: 'uint256', name: 'unlockTime', simpleType: 'uint' },\n ],\n },\n {\n type: 'function',\n name: 'getPastTotalSupply',\n stateMutability: 'view',\n inputs: [{ type: 'uint256', name: 'timepoint', simpleType: 'uint' }],\n outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'balanceOf',\n stateMutability: 'view',\n inputs: [{ type: 'address', name: 'account', simpleType: 'address' }],\n outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'nonces',\n stateMutability: 'view',\n inputs: [{ type: 'address', name: 'owner', simpleType: 'address' }],\n outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'getVotes',\n stateMutability: 'view',\n inputs: [{ type: 'address', name: 'account', simpleType: 'address' }],\n outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'delegateBySig',\n stateMutability: 'nonpayable',\n inputs: [\n { type: 'address', name: 'delegatee', simpleType: 'address' },\n { type: 'uint256', name: 'nonce', simpleType: 'uint' },\n { type: 'uint256', name: 'expiry', simpleType: 'uint' },\n { type: 'uint8', name: 'v', simpleType: 'uint' },\n { type: 'bytes32', name: 'r', simpleType: 'bytes' },\n { type: 'bytes32', name: 's', simpleType: 'bytes' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'pause',\n stateMutability: 'nonpayable',\n inputs: [],\n outputs: [],\n },\n {\n type: 'function',\n name: 'transfer',\n stateMutability: 'nonpayable',\n inputs: [\n { type: 'address', name: 'to', simpleType: 'address' },\n { type: 'uint256', name: 'value', simpleType: 'uint' },\n ],\n outputs: [{ type: 'bool', name: '', simpleType: 'bool' }],\n },\n {\n type: 'function',\n name: 'CLOCK_MODE',\n stateMutability: 'pure',\n inputs: [],\n outputs: [{ type: 'string', name: '', simpleType: 'string' }],\n },\n {\n type: 'function',\n name: 'numCheckpoints',\n stateMutability: 'view',\n inputs: [{ type: 'address', name: 'account', simpleType: 'address' }],\n outputs: [{ type: 'uint32', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'approve',\n stateMutability: 'nonpayable',\n inputs: [\n { type: 'address', name: 'spender', simpleType: 'address' },\n { type: 'uint256', name: 'value', simpleType: 'uint' },\n ],\n outputs: [{ type: 'bool', name: '', simpleType: 'bool' }],\n },\n {\n type: 'function',\n name: 'reLock',\n stateMutability: 'nonpayable',\n inputs: [\n { type: 'uint256', name: 'amount', simpleType: 'uint' },\n { type: 'uint256', name: 'multiplier', simpleType: 'uint' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'getPastVotes',\n stateMutability: 'view',\n inputs: [\n { type: 'address', name: 'account', simpleType: 'address' },\n { type: 'uint256', name: 'timepoint', simpleType: 'uint' },\n ],\n outputs: [{ type: 'uint256', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'checkpoints',\n stateMutability: 'view',\n inputs: [\n { type: 'address', name: 'account', simpleType: 'address' },\n { type: 'uint32', name: 'pos', simpleType: 'uint' },\n ],\n outputs: [\n {\n type: 'tuple',\n name: '',\n simpleType: 'tuple',\n components: [\n { type: 'uint48', name: '_key', simpleType: 'uint' },\n { type: 'uint208', name: '_value', simpleType: 'uint' },\n ],\n },\n ],\n },\n {\n type: 'function',\n name: 'name',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'string', name: '', simpleType: 'string' }],\n },\n {\n type: 'function',\n name: 'createLockWithPermit',\n stateMutability: 'nonpayable',\n inputs: [\n { type: 'uint256', name: 'value', simpleType: 'uint' },\n { type: 'uint256', name: 'multiplier', simpleType: 'uint' },\n {\n type: 'tuple',\n name: 'permitData',\n simpleType: 'tuple',\n components: [\n { type: 'uint256', name: 'deadline', simpleType: 'uint' },\n { type: 'uint256', name: 'amount', simpleType: 'uint' },\n { type: 'uint8', name: 'v', simpleType: 'uint' },\n { type: 'bytes32', name: 'r', simpleType: 'bytes' },\n { type: 'bytes32', name: 's', simpleType: 'bytes' },\n ],\n },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'clock',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'uint48', name: '', simpleType: 'uint' }],\n },\n {\n type: 'function',\n name: 'withdraw',\n stateMutability: 'nonpayable',\n inputs: [{ type: 'address', name: 'recipient', simpleType: 'address' }],\n outputs: [],\n },\n {\n type: 'function',\n name: 'delegate',\n stateMutability: 'nonpayable',\n inputs: [{ type: 'address', name: 'delegatee', simpleType: 'address' }],\n outputs: [],\n },\n];\n"],"names":["vlPUFFER"],"mappings":"AAAO,MAAMA,IAAkB;AAAA,EAC7B;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ,CAAC;AAAA,IACT,SAAS,CAAC,EAAE,MAAM,WAAW,MAAM,IAAI,YAAY,UAAW,CAAA;AAAA,EAChE;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ,CAAC;AAAA,IACT,SAAS,CAAC,EAAE,MAAM,SAAS,MAAM,IAAI,YAAY,OAAQ,CAAA;AAAA,EAC3D;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM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AAA,MACpD;AAAA,IAEJ;AAAA,IACA,SAAS,CAAA;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ,CAAC;AAAA,IACT,SAAS,CAAC,EAAE,MAAM,UAAU,MAAM,IAAI,YAAY,OAAQ,CAAA;AAAA,EAC5D;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ,CAAC,EAAE,MAAM,WAAW,MAAM,aAAa,YAAY,WAAW;AAAA,IACtE,SAAS,CAAA;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ,CAAC,EAAE,MAAM,WAAW,MAAM,aAAa,YAAY,WAAW;AAAA,IACtE,SAAS,CAAA;AAAA,EAAC;AAEd;"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { Address } from 'viem';
2
+ export type PermitData = {
3
+ deadline: bigint;
4
+ amount: bigint;
5
+ v: number;
6
+ r: Address;
7
+ s: Address;
8
+ };
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var d=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var c=(i,t,e)=>d(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../constants-CxSgz27h.cjs"),s=require("../tokens.cjs"),g=require("../../utils/time.cjs"),S=require("../abis/mainnet/ERC20Permit.cjs"),y=require("../../getContract-DUA3M2pm.cjs"),C=require("../../secp256k1-YUzyTLhP.cjs");function E(i){const{r:t,s:e}=C.secp256k1.Signature.fromCompact(i.slice(2,130)),n=+`0x${i.slice(130)}`,[r,o]=(()=>{if(n===0||n===1)return[void 0,n];if(n===27)return[BigInt(n),0];if(n===28)return[BigInt(n),1];throw new Error("Invalid yParityOrV value")})();return typeof r<"u"?{r:a.numberToHex(t,{size:32}),s:a.numberToHex(e,{size:32}),v:r,yParity:o}:{r:a.numberToHex(t,{size:32}),s:a.numberToHex(e,{size:32}),yParity:o}}class T{constructor(t,e,n){c(this,"viemChain");c(this,"token");this.chain=t,this.walletClient=e,this.publicClient=n,this.viemChain=a.VIEM_CHAINS[t],this.token=s.Token.WETH}withToken(t){return this.token=t,this}getContract(){const t=s.TOKENS_ADDRESSES[this.token][this.chain],e=S.ERC20Permit,n={public:this.publicClient,wallet:this.walletClient};return y.getContract({address:t,abi:e,client:n})}async getPermitSignature(t,e,n){const r=this.getContract(),o=await r.read.nonces([t]),m={name:await r.read.name(),version:this.getPermitVersion(this.token),chainId:this.chain,verifyingContract:s.TOKENS_ADDRESSES[this.token][this.chain],salt:this.getPermitSalt(this.token)},h={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u=BigInt(g.getTimestampInSeconds()+60*60*2),l=await this.walletClient.signTypedData({account:t,domain:m,types:h,primaryType:"Permit",message:{owner:t,spender:e,value:n,nonce:o,deadline:u}});return{...E(l),deadline:u}}approve(t,e,n){return this.getContract().write.approve([e,n],{account:t,chain:this.viemChain})}getPermitVersion(t){return s.TOKENS_PERMIT_VERSION[t]}getPermitSalt(t){var e,n;return(n=(e=s.TOKENS_SALT)==null?void 0:e[t])==null?void 0:n[this.chain]}}exports.ERC20PermitHandler=T;
1
+ "use strict";var d=Object.defineProperty;var g=(i,t,n)=>t in i?d(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var m=(i,t,n)=>g(i,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../constants-CxSgz27h.cjs"),a=require("../tokens.cjs"),y=require("../../utils/time.cjs"),S=require("../abis/mainnet/ERC20Permit.cjs"),C=require("../../getContract-DUA3M2pm.cjs"),P=require("../../secp256k1-YUzyTLhP.cjs");function E(i){const{r:t,s:n}=P.secp256k1.Signature.fromCompact(i.slice(2,130)),e=+`0x${i.slice(130)}`,[r,s]=(()=>{if(e===0||e===1)return[void 0,e];if(e===27)return[BigInt(e),0];if(e===28)return[BigInt(e),1];throw new Error("Invalid yParityOrV value")})();return typeof r<"u"?{r:o.numberToHex(t,{size:32}),s:o.numberToHex(n,{size:32}),v:r,yParity:s}:{r:o.numberToHex(t,{size:32}),s:o.numberToHex(n,{size:32}),yParity:s}}class T{constructor(t,n,e){m(this,"viemChain");m(this,"token");this.chain=t,this.walletClient=n,this.publicClient=e,this.viemChain=o.VIEM_CHAINS[t],this.token=a.Token.WETH}withToken(t){return this.token=t,this}getContract(){const t=a.TOKENS_ADDRESSES[this.token][this.chain],n=S.ERC20Permit,e={public:this.publicClient,wallet:this.walletClient};return C.getContract({address:t,abi:n,client:e})}async getPermitSignature(t,n,e){const r=this.getContract(),s=await r.read.nonces([t]),c={name:await r.read.name(),version:this.getPermitVersion(this.token),chainId:this.chain,verifyingContract:a.TOKENS_ADDRESSES[this.token][this.chain],salt:this.getPermitSalt(this.token)},u={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},l=BigInt(y.getTimestampInSeconds()+60*60*2),p=await this.walletClient.signTypedData({account:t,domain:c,types:u,primaryType:"Permit",message:{owner:t,spender:n,value:e,nonce:s,deadline:l}});return{...E(p),deadline:l}}async getPermitData(t,n,e){const{r,s,v:h,yParity:c,deadline:u}=await this.getPermitSignature(t,n,e);return{r,s,v:Number(h??c),deadline:u,amount:e}}approve(t,n,e){return this.getContract().write.approve([n,e],{account:t,chain:this.viemChain})}getPermitVersion(t){return a.TOKENS_PERMIT_VERSION[t]}getPermitSalt(t){var n,e;return(e=(n=a.TOKENS_SALT)==null?void 0:n[t])==null?void 0:e[this.chain]}}exports.ERC20PermitHandler=T;
2
2
  //# sourceMappingURL=erc20-permit-handler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"erc20-permit-handler.cjs","sources":["../../../node_modules/.pnpm/viem@2.33.1_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await contract.read.nonces([ownerAddress]);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","TOKENS_SALT"],"mappings":"oeAYO,SAASA,EAAeC,EAAc,CACzC,KAAM,CAAE,EAAAC,EAAG,EAAAC,CAAG,EAAGC,YAAU,UAAU,YAAYH,EAAa,MAAM,EAAG,GAAG,CAAC,EACrEI,EAAa,CAAO,KAAKJ,EAAa,MAAM,GAAG,CAAC,GAChD,CAACK,EAAGC,CAAO,GAAK,IAAM,CAC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AK,iBAAiB,KAAK,KAAK,EACzC,QAAS,KAAK,MACd,kBAAmBR,EAAiB,iBAAA,KAAK,KAAK,EAAE,KAAK,KAAK,EAC1D,KAAM,KAAK,cAAc,KAAK,KAAK,CACrC,EACMW,EAAe,CACnB,OAAQ,CACN,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,UAAW,KAAM,SAAU,EACnC,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,WAAY,KAAM,SAAU,CAAA,CAExC,EAEMC,EAAW,OAAOC,EAAAA,sBAA0B,EAAA,GAAK,GAAK,CAAC,EAEvDC,EAAY,MAAM,KAAK,aAAa,cAAc,CACtD,QAAST,EACT,OAAAK,EACA,MAAAC,EACA,YAAa,SACb,QAAS,CACP,MAAON,EACP,QAASC,EACT,MAAAC,EACA,MAAOE,EACP,SAAAG,CAAA,CACF,CACD,EAED,MAAO,CAAE,GAAG9B,EAAegC,CAAS,EAAG,SAAAF,CAAS,CAAA,CAW3C,QACLP,EACAC,EACAC,EACA,CACO,OAAA,KAAK,cAAc,MAAM,QAAQ,CAACD,EAAgBC,CAAK,EAAG,CAC/D,QAASF,EACT,MAAO,KAAK,SAAA,CACb,CAAA,CAGK,iBAAiBP,EAAyB,CAChD,OAAOiB,EAAAA,sBAAsBjB,CAAK,CAAA,CAG5B,cAAcA,EAAiB,SACrC,OAAOkB,GAAAA,EAAAA,gBAAAA,YAAAA,EAAclB,KAAdkB,YAAAA,EAAuB,KAAK,MAAK,CAE5C","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"erc20-permit-handler.cjs","sources":["../../../node_modules/.pnpm/viem@2.33.1_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\nimport { PermitData } from '../common/lib/types';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await contract.read.nonces([ownerAddress]);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Get the permit data for the given owner, spender and value.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value/amount to be permitted.\n * @returns Permit data in the form `{ r, s, v, deadline, amount }`.\n */\n public async getPermitData(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ): Promise<PermitData> {\n const { r, s, v, yParity, deadline } = await this.getPermitSignature(\n ownerAddress,\n spenderAddress,\n value,\n );\n\n /* istanbul ignore next */\n return { r, s, v: Number(v ?? yParity), deadline, amount: value };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","TOKENS_SALT"],"mappings":"oeAYO,SAASA,EAAeC,EAAc,CACzC,KAAM,CAAE,EAAAC,EAAG,EAAAC,CAAG,EAAGC,YAAU,UAAU,YAAYH,EAAa,MAAM,EAAG,GAAG,CAAC,EACrEI,EAAa,CAAO,KAAKJ,EAAa,MAAM,GAAG,CAAC,GAChD,CAACK,EAAGC,CAAO,GAAK,IAAM,CACxB,GAAIF,IAAe,GAAKA,IAAe,EACnC,MAAO,CAAC,OAAWA,CAAU,EACjC,GAAIA,IAAe,GACf,MAAO,CAAC,OAAOA,CAAU,EAAG,CAAC,EACjC,GAAIA,I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,CACrC,EACMW,EAAe,CACnB,OAAQ,CACN,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,UAAW,KAAM,SAAU,EACnC,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,WAAY,KAAM,SAAU,CAAA,CAExC,EAEMC,EAAW,OAAOC,EAAAA,sBAA0B,EAAA,GAAK,GAAK,CAAC,EAEvDC,EAAY,MAAM,KAAK,aAAa,cAAc,CACtD,QAAST,EACT,OAAAK,EACA,MAAAC,EACA,YAAa,SACb,QAAS,CACP,MAAON,EACP,QAASC,EACT,MAAAC,EACA,MAAOE,EACP,SAAAG,CAAA,CACF,CACD,EAED,MAAO,CAAE,GAAG9B,EAAegC,CAAS,EAAG,SAAAF,CAAS,CAAA,CAWlD,MAAa,cACXP,EACAC,EACAC,EACqB,CACf,KAAA,CAAE,EAAG,EAAG,EAAAnB,EAAG,QAAAC,EAAS,SAAAuB,CAAS,EAAI,MAAM,KAAK,mBAChDP,EACAC,EACAC,CACF,EAGO,MAAA,CAAE,EAAG,EAAG,EAAG,OAAOnB,GAAKC,CAAO,EAAG,SAAAuB,EAAU,OAAQL,CAAM,CAAA,CAW3D,QACLF,EACAC,EACAC,EACA,CACO,OAAA,KAAK,cAAc,MAAM,QAAQ,CAACD,EAAgBC,CAAK,EAAG,CAC/D,QAASF,EACT,MAAO,KAAK,SAAA,CACb,CAAA,CAGK,iBAAiBP,EAAyB,CAChD,OAAOiB,EAAAA,sBAAsBjB,CAAK,CAAA,CAG5B,cAAcA,EAAiB,SACrC,OAAOkB,GAAAA,EAAAA,gBAAAA,YAAAA,EAAclB,KAAdkB,YAAAA,EAAuB,KAAK,MAAK,CAE5C","x_google_ignoreList":[0]}
@@ -1,6 +1,7 @@
1
1
  import { WalletClient, PublicClient, Address, GetContractReturnType } from 'viem';
2
2
  import { Chain, ViemChain } from '../../chains/constants';
3
3
  import { AnyToken } from '../tokens';
4
+ import { PermitData } from '../common/lib/types';
4
5
  /**
5
6
  * Handler for performing operations for and with ERC20Permit tokens.
6
7
  */
@@ -15003,6 +15004,15 @@ export declare class ERC20PermitHandler {
15003
15004
  yParity: number;
15004
15005
  v?: never;
15005
15006
  }>;
15007
+ /**
15008
+ * Get the permit data for the given owner, spender and value.
15009
+ *
15010
+ * @param ownerAddress Address of the token owner.
15011
+ * @param spenderAddress Address of the spender who needs the permit.
15012
+ * @param value Value/amount to be permitted.
15013
+ * @returns Permit data in the form `{ r, s, v, deadline, amount }`.
15014
+ */
15015
+ getPermitData(ownerAddress: Address, spenderAddress: Address, value: bigint): Promise<PermitData>;
15006
15016
  /**
15007
15017
  * Approve transaction for the spender to spend the owner's tokens.
15008
15018
  *
@@ -1,30 +1,30 @@
1
- var l = Object.defineProperty;
2
- var d = (i, t, e) => t in i ? l(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var o = (i, t, e) => d(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { n as s, V as g } from "../../constants-C9YZ6Ewc.js";
5
- import { Token as y, TOKENS_ADDRESSES as m, TOKENS_PERMIT_VERSION as C, TOKENS_SALT as f } from "../tokens.js";
1
+ var g = Object.defineProperty;
2
+ var d = (i, t, n) => t in i ? g(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
3
+ var m = (i, t, n) => d(i, typeof t != "symbol" ? t + "" : t, n);
4
+ import { n as s, V as y } from "../../constants-C9YZ6Ewc.js";
5
+ import { Token as C, TOKENS_ADDRESSES as p, TOKENS_PERMIT_VERSION as f, TOKENS_SALT as P } from "../tokens.js";
6
6
  import { getTimestampInSeconds as S } from "../../utils/time.js";
7
- import { ERC20Permit as P } from "../abis/mainnet/ERC20Permit.js";
8
- import { g as E } from "../../getContract-DEPNMZxg.js";
9
- import { secp256k1 as T } from "../../secp256k1-ClOw2ksU.js";
10
- function v(i) {
11
- const { r: t, s: e } = T.Signature.fromCompact(i.slice(2, 130)), n = +`0x${i.slice(130)}`, [r, a] = (() => {
12
- if (n === 0 || n === 1)
13
- return [void 0, n];
14
- if (n === 27)
15
- return [BigInt(n), 0];
16
- if (n === 28)
17
- return [BigInt(n), 1];
7
+ import { ERC20Permit as v } from "../abis/mainnet/ERC20Permit.js";
8
+ import { g as w } from "../../getContract-DEPNMZxg.js";
9
+ import { secp256k1 as E } from "../../secp256k1-ClOw2ksU.js";
10
+ function T(i) {
11
+ const { r: t, s: n } = E.Signature.fromCompact(i.slice(2, 130)), e = +`0x${i.slice(130)}`, [r, a] = (() => {
12
+ if (e === 0 || e === 1)
13
+ return [void 0, e];
14
+ if (e === 27)
15
+ return [BigInt(e), 0];
16
+ if (e === 28)
17
+ return [BigInt(e), 1];
18
18
  throw new Error("Invalid yParityOrV value");
19
19
  })();
20
20
  return typeof r < "u" ? {
21
21
  r: s(t, { size: 32 }),
22
- s: s(e, { size: 32 }),
22
+ s: s(n, { size: 32 }),
23
23
  v: r,
24
24
  yParity: a
25
25
  } : {
26
26
  r: s(t, { size: 32 }),
27
- s: s(e, { size: 32 }),
27
+ s: s(n, { size: 32 }),
28
28
  yParity: a
29
29
  };
30
30
  }
@@ -38,10 +38,10 @@ class _ {
38
38
  * @param publicClient The public client to use for public
39
39
  * interactions.
40
40
  */
41
- constructor(t, e, n) {
42
- o(this, "viemChain");
43
- o(this, "token");
44
- this.chain = t, this.walletClient = e, this.publicClient = n, this.viemChain = g[t], this.token = y.WETH;
41
+ constructor(t, n, e) {
42
+ m(this, "viemChain");
43
+ m(this, "token");
44
+ this.chain = t, this.walletClient = n, this.publicClient = e, this.viemChain = y[t], this.token = C.WETH;
45
45
  }
46
46
  /**
47
47
  * Set the token to use for executing transactions on the contract.
@@ -59,8 +59,8 @@ class _ {
59
59
  * @returns The viem contract.
60
60
  */
61
61
  getContract() {
62
- const t = m[this.token][this.chain], e = P, n = { public: this.publicClient, wallet: this.walletClient };
63
- return E({ address: t, abi: e, client: n });
62
+ const t = p[this.token][this.chain], n = v, e = { public: this.publicClient, wallet: this.walletClient };
63
+ return w({ address: t, abi: n, client: e });
64
64
  }
65
65
  /**
66
66
  * Process and get permit signature for the given token to perform
@@ -71,14 +71,14 @@ class _ {
71
71
  * @param value Value of the transaction.
72
72
  * @returns Permit signature in the form `{ r, s, v?, yParity }`.
73
73
  */
74
- async getPermitSignature(t, e, n) {
75
- const r = this.getContract(), a = await r.read.nonces([t]), h = {
74
+ async getPermitSignature(t, n, e) {
75
+ const r = this.getContract(), a = await r.read.nonces([t]), o = {
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],
79
+ verifyingContract: p[this.token][this.chain],
80
80
  salt: this.getPermitSalt(this.token)
81
- }, p = {
81
+ }, c = {
82
82
  Permit: [
83
83
  { name: "owner", type: "address" },
84
84
  { name: "spender", type: "address" },
@@ -86,20 +86,36 @@ class _ {
86
86
  { name: "nonce", type: "uint256" },
87
87
  { name: "deadline", type: "uint256" }
88
88
  ]
89
- }, c = BigInt(S() + 60 * 60 * 2), u = await this.walletClient.signTypedData({
89
+ }, u = BigInt(S() + 60 * 60 * 2), l = await this.walletClient.signTypedData({
90
90
  account: t,
91
- domain: h,
92
- types: p,
91
+ domain: o,
92
+ types: c,
93
93
  primaryType: "Permit",
94
94
  message: {
95
95
  owner: t,
96
- spender: e,
97
- value: n,
96
+ spender: n,
97
+ value: e,
98
98
  nonce: a,
99
- deadline: c
99
+ deadline: u
100
100
  }
101
101
  });
102
- return { ...v(u), deadline: c };
102
+ return { ...T(l), deadline: u };
103
+ }
104
+ /**
105
+ * Get the permit data for the given owner, spender and value.
106
+ *
107
+ * @param ownerAddress Address of the token owner.
108
+ * @param spenderAddress Address of the spender who needs the permit.
109
+ * @param value Value/amount to be permitted.
110
+ * @returns Permit data in the form `{ r, s, v, deadline, amount }`.
111
+ */
112
+ async getPermitData(t, n, e) {
113
+ const { r, s: a, v: h, yParity: o, deadline: c } = await this.getPermitSignature(
114
+ t,
115
+ n,
116
+ e
117
+ );
118
+ return { r, s: a, v: Number(h ?? o), deadline: c, amount: e };
103
119
  }
104
120
  /**
105
121
  * Approve transaction for the spender to spend the owner's tokens.
@@ -109,18 +125,18 @@ class _ {
109
125
  * @param value Value to approve for the spender.
110
126
  * @returns Hash of the transaction.
111
127
  */
112
- approve(t, e, n) {
113
- return this.getContract().write.approve([e, n], {
128
+ approve(t, n, e) {
129
+ return this.getContract().write.approve([n, e], {
114
130
  account: t,
115
131
  chain: this.viemChain
116
132
  });
117
133
  }
118
134
  getPermitVersion(t) {
119
- return C[t];
135
+ return f[t];
120
136
  }
121
137
  getPermitSalt(t) {
122
- var e, n;
123
- return (n = (e = f) == null ? void 0 : e[t]) == null ? void 0 : n[this.chain];
138
+ var n, e;
139
+ return (e = (n = P) == null ? void 0 : n[t]) == null ? void 0 : e[this.chain];
124
140
  }
125
141
  }
126
142
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.33.1_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await contract.read.nonces([ownerAddress]);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","_b","_a","TOKENS_SALT"],"mappings":";;;;;;;;;AAYO,SAASA,EAAeC,GAAc;AACzC,QAAM,EAAE,GAAAC,GAAG,GAAAC,EAAG,IAAGC,EAAU,UAAU,YAAYH,EAAa,MAAM,GAAG,GAAG,CAAC,GACrEI,IAAa,CAAO,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,GAAQ;AACJ,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,EACH,IACE;AAAA,IACH,GAAGC,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,SAAAI;AAAA,EACH;AACL;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,QAAQK,EAAM;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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T,OAAAC;AAAA,QACA,OAAOE;AAAA,QACP,UAAAG;AAAA,MAAA;AAAA,IACF,CACD;AAED,WAAO,EAAE,GAAG9B,EAAegC,CAAS,GAAG,UAAAF,EAAS;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW3C,QACLP,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,EAAA;AAAA,EAGK,iBAAiBP,GAAyB;AAChD,WAAOiB,EAAsBjB,CAAK;AAAA,EAAA;AAAA,EAG5B,cAAcA,GAAiB;;AACrC,YAAOkB,KAAAC,IAAAC,MAAA,gBAAAD,EAAcnB,OAAd,gBAAAkB,EAAuB,KAAK;AAAA,EAAK;AAE5C;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.33.1_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\nimport { PermitData } from '../common/lib/types';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await contract.read.nonces([ownerAddress]);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Get the permit data for the given owner, spender and value.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value/amount to be permitted.\n * @returns Permit data in the form `{ r, s, v, deadline, amount }`.\n */\n public async getPermitData(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ): Promise<PermitData> {\n const { r, s, v, yParity, deadline } = await this.getPermitSignature(\n ownerAddress,\n spenderAddress,\n value,\n );\n\n /* istanbul ignore next */\n return { r, s, v: Number(v ?? yParity), deadline, amount: value };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","_b","_a","TOKENS_SALT"],"mappings":";;;;;;;;;AAYO,SAASA,EAAeC,GAAc;AACzC,QAAM,EAAE,GAAAC,GAAG,GAAAC,EAAG,IAAGC,EAAU,UAAU,YAAYH,EAAa,MAAM,GAAG,GAAG,CAAC,GACrEI,IAAa,CAAO,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,GAAQ;AACJ,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,EACH,IACE;AAAA,IACH,GAAGC,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE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EAAuB,KAAK;AAAA,EAAK;AAE5C;","x_google_ignoreList":[0]}
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var C=(a,t,e)=>t in a?l(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var c=(a,t,e)=>C(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../constants-CxSgz27h.cjs"),g=require("../vaults-addresses.cjs"),p=require("../tokens.cjs"),f=require("../abis/mainnet/BoringVault.cjs"),v=require("../../getContract-DUA3M2pm.cjs");class b{constructor(t,e,n){c(this,"viemChain");c(this,"token");this.chain=t,this.walletClient=e,this.publicClient=n,this.viemChain=m.VIEM_CHAINS[t],this.token=p.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=g.VAULTS_ADDRESSES[this.token][this.chain].NucleusBoringVault,e=f.BoringVault,n={public:this.publicClient,wallet:this.walletClient};return v.getContract({address:t,abi:e,client:n})}getAllowance(t,e){return this.getContract().read.allowance([t,e])}balanceOf(t){return this.getContract().read.balanceOf([t])}totalSupply(){return this.getContract().read.totalSupply()}approve(t,e,n){return this.getContract().write.approve([e,n],{account:t,chain:this.viemChain})}transfer(t,e,n){return{transact:()=>this.getContract().write.transfer([e,n],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transfer([e,n],{account:t})}}transferFrom(t,e,n,i){return{transact:()=>this.getContract().write.transferFrom([e,n,i],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transferFrom([e,n,i],{account:t})}}permit(t){const{account:e,owner:n,spender:i,value:r,deadline:s,v:o,r:u,s:h}=t;return{transact:()=>this.getContract().write.permit([n,i,r,s,o,u,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.permit([n,i,r,s,o,u,h],{account:e})}}}exports.NucleusBoringVaultHandler=b;
1
+ "use strict";var l=Object.defineProperty;var C=(a,t,e)=>t in a?l(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var c=(a,t,e)=>C(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../constants-CxSgz27h.cjs"),g=require("../vaults-addresses.cjs"),p=require("../tokens.cjs"),f=require("../abis/mainnet/BoringVault.cjs"),b=require("../../getContract-DUA3M2pm.cjs");class v{constructor(t,e,n){c(this,"viemChain");c(this,"token");this.chain=t,this.walletClient=e,this.publicClient=n,this.viemChain=m.VIEM_CHAINS[t],this.token=p.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=g.VAULTS_ADDRESSES[this.token][this.chain].NucleusBoringVault,e=f.BoringVault,n={public:this.publicClient,wallet:this.walletClient};return b.getContract({address:t,abi:e,client:n})}getAllowance(t,e){return this.getContract().read.allowance([t,e])}balanceOf(t){return this.getContract().read.balanceOf([t])}totalSupply(){return this.getContract().read.totalSupply()}approve(t,e,n){return this.getContract().write.approve([e,n],{account:t,chain:this.viemChain})}transfer(t,e,n){return{transact:()=>this.getContract().write.transfer([e,n],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transfer([e,n],{account:t})}}transferFrom(t,e,n,i){return{transact:()=>this.getContract().write.transferFrom([e,n,i],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transferFrom([e,n,i],{account:t})}}permit(t){const{account:e,owner:n,spender:i,amount:r,deadline:s,v:o,r:u,s:h}=t;return{transact:()=>this.getContract().write.permit([n,i,r,s,o,u,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.permit([n,i,r,s,o,u,h],{account:e})}}}exports.NucleusBoringVaultHandler=v;
2
2
  //# sourceMappingURL=nucleus-boring-vault-handler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nucleus-boring-vault-handler.cjs","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\nimport { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\n\nexport type PermitParams = {\n account: Address;\n owner: Address;\n spender: Address;\n value: bigint;\n deadline: bigint;\n v: number;\n r: Address;\n s: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = UnifiToken.unifiETH;\n }\n\n /**\n * Set the UniFi token to use for executing transactions on the\n * contract.\n *\n * @param token UniFi token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: UnifiToken) {\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 = VAULTS_ADDRESSES[this.token][this.chain]\n .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\n * @param params.deadline Deadline for the permit.\n * @param params.v v value of the permit.\n * @param params.r r value of the permit.\n * @param params.s s value of the permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public permit(params: PermitParams) {\n const { account, owner, spender, value, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, value, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, value, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","deadline","v","r","s"],"mappings":"6bA6BO,MAAMA,CAA0B,CAarC,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBACAA,EAAA,cAYE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,MAAQK,EAAAA,WAAW,QAAA,CAUnB,UAAUC,EAAmB,CAClC,YAAK,MAAQA,EACN,IAAA,CASF,aAAc,CACnB,MAAMC,EAAUC,EAAAA,iBAAiB,KAAK,KAAK,EAAE,KAAK,KAAK,EACpD,mBACGC,EAAMC,EAAA,YACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CActC,aAAaE,EAAgBC,EAAkB,CAC7C,OAAA,KAAK,cAAc,KAAK,UAAU,CAACD,EAAOC,CAAO,CAAC,CAAA,CASpD,UAAUC,EAAwB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,QAAAJ,CAAQ,CACZ,CAE0B,CAAA,CAEhC"}
1
+ {"version":3,"file":"nucleus-boring-vault-handler.cjs","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\nimport { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\nimport { PermitData } from '../common/lib/types';\n\nexport type PermitParams = PermitData & {\n account: Address;\n owner: Address;\n spender: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = UnifiToken.unifiETH;\n }\n\n /**\n * Set the UniFi token to use for executing transactions on the\n * contract.\n *\n * @param token UniFi token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: UnifiToken) {\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 = VAULTS_ADDRESSES[this.token][this.chain]\n .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\n * @param params.deadline Deadline for the permit.\n * @param params.v v value of the permit.\n * @param params.r r value of the permit.\n * @param params.s s value of the permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public permit(params: PermitParams) {\n const { account, owner, spender, amount, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","amount","deadline","v","r","s"],"mappings":"6bAyBO,MAAMA,CAA0B,CAarC,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBACAA,EAAA,cAYE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,MAAQK,EAAAA,WAAW,QAAA,CAUnB,UAAUC,EAAmB,CAClC,YAAK,MAAQA,EACN,IAAA,CASF,aAAc,CACnB,MAAMC,EAAUC,EAAAA,iBAAiB,KAAK,KAAK,EAAE,KAAK,KAAK,EACpD,mBACGC,EAAMC,EAAA,YACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,O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AAQC,EAAUC,EAAGC,EAAGC,CAAC,EAC1C,CAAE,QAAAL,EAAS,MAAO,KAAK,SAAU,CACnC,EAOiB,SANF,IACf,KAAK,cAAc,YAAY,OAC7B,CAACR,EAAOC,EAASQ,EAAQC,EAAUC,EAAGC,EAAGC,CAAC,EAC1C,CAAE,QAAAL,CAAQ,CACZ,CAE0B,CAAA,CAEhC"}
@@ -1,15 +1,11 @@
1
1
  import { WalletClient, PublicClient, Address, GetContractReturnType } from 'viem';
2
2
  import { Chain, ViemChain } from '../../chains/constants';
3
3
  import { UnifiToken } from '../tokens';
4
- export type PermitParams = {
4
+ import { PermitData } from '../common/lib/types';
5
+ export type PermitParams = PermitData & {
5
6
  account: Address;
6
7
  owner: Address;
7
8
  spender: Address;
8
- value: bigint;
9
- deadline: bigint;
10
- v: number;
11
- r: Address;
12
- s: Address;
13
9
  };
14
10
  /**
15
11
  * Handler for the `BoringVault` contract for a given token exposing
@@ -1,6 +1,6 @@
1
1
  var u = Object.defineProperty;
2
- var l = (a, t, n) => t in a ? u(a, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[t] = n;
3
- var c = (a, t, n) => l(a, typeof t != "symbol" ? t + "" : t, n);
2
+ var l = (e, t, n) => t in e ? u(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var c = (e, t, n) => l(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { V as C } from "../../constants-C9YZ6Ewc.js";
5
5
  import { VAULTS_ADDRESSES as p } from "../vaults-addresses.js";
6
6
  import { UnifiToken as g } from "../tokens.js";
@@ -16,10 +16,10 @@ class F {
16
16
  * @param publicClient The public client to use for public
17
17
  * interactions.
18
18
  */
19
- constructor(t, n, e) {
19
+ constructor(t, n, a) {
20
20
  c(this, "viemChain");
21
21
  c(this, "token");
22
- this.chain = t, this.walletClient = n, this.publicClient = e, this.viemChain = C[t], this.token = g.unifiETH;
22
+ this.chain = t, this.walletClient = n, this.publicClient = a, this.viemChain = C[t], this.token = g.unifiETH;
23
23
  }
24
24
  /**
25
25
  * Set the UniFi token to use for executing transactions on the
@@ -38,8 +38,8 @@ class F {
38
38
  * @returns The viem contract.
39
39
  */
40
40
  getContract() {
41
- const t = p[this.token][this.chain].NucleusBoringVault, n = f, e = { public: this.publicClient, wallet: this.walletClient };
42
- return w({ address: t, abi: n, client: e });
41
+ const t = p[this.token][this.chain].NucleusBoringVault, n = f, a = { public: this.publicClient, wallet: this.walletClient };
42
+ return w({ address: t, abi: n, client: a });
43
43
  }
44
44
  /**
45
45
  * Get the allowance for the given owner and spender.
@@ -76,8 +76,8 @@ class F {
76
76
  * @param value Value to approve for the spender.
77
77
  * @returns Hash of the transaction.
78
78
  */
79
- approve(t, n, e) {
80
- return this.getContract().write.approve([n, e], {
79
+ approve(t, n, a) {
80
+ return this.getContract().write.approve([n, a], {
81
81
  account: t,
82
82
  chain: this.viemChain
83
83
  });
@@ -94,11 +94,11 @@ class F {
94
94
  * `estimate: () => Promise<bigint>` - Gas estimate of the
95
95
  * transaction.
96
96
  */
97
- transfer(t, n, e) {
98
- return { transact: () => this.getContract().write.transfer([n, e], {
97
+ transfer(t, n, a) {
98
+ return { transact: () => this.getContract().write.transfer([n, a], {
99
99
  account: t,
100
100
  chain: this.viemChain
101
- }), estimate: () => this.getContract().estimateGas.transfer([n, e], {
101
+ }), estimate: () => this.getContract().estimateGas.transfer([n, a], {
102
102
  account: t
103
103
  }) };
104
104
  }
@@ -115,12 +115,12 @@ class F {
115
115
  * `estimate: () => Promise<bigint>` - Gas estimate of the
116
116
  * transaction.
117
117
  */
118
- transferFrom(t, n, e, i) {
119
- return { transact: () => this.getContract().write.transferFrom([n, e, i], {
118
+ transferFrom(t, n, a, i) {
119
+ return { transact: () => this.getContract().write.transferFrom([n, a, i], {
120
120
  account: t,
121
121
  chain: this.viemChain
122
122
  }), estimate: () => this.getContract().estimateGas.transferFrom(
123
- [n, e, i],
123
+ [n, a, i],
124
124
  { account: t }
125
125
  ) };
126
126
  }
@@ -143,12 +143,12 @@ class F {
143
143
  * transaction.
144
144
  */
145
145
  permit(t) {
146
- const { account: n, owner: e, spender: i, value: r, deadline: s, v: o, r: h, s: m } = t;
146
+ const { account: n, owner: a, spender: i, amount: r, deadline: s, v: o, r: h, s: m } = t;
147
147
  return { transact: () => this.getContract().write.permit(
148
- [e, i, r, s, o, h, m],
148
+ [a, i, r, s, o, h, m],
149
149
  { account: n, chain: this.viemChain }
150
150
  ), estimate: () => this.getContract().estimateGas.permit(
151
- [e, i, r, s, o, h, m],
151
+ [a, i, r, s, o, h, m],
152
152
  { account: n }
153
153
  ) };
154
154
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nucleus-boring-vault-handler.js","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\nimport { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\n\nexport type PermitParams = {\n account: Address;\n owner: Address;\n spender: Address;\n value: bigint;\n deadline: bigint;\n v: number;\n r: Address;\n s: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = UnifiToken.unifiETH;\n }\n\n /**\n * Set the UniFi token to use for executing transactions on the\n * contract.\n *\n * @param token UniFi token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: UnifiToken) {\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 = VAULTS_ADDRESSES[this.token][this.chain]\n .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\n * @param params.deadline Deadline for the permit.\n * @param params.v v value of the permit.\n * @param params.r r value of the permit.\n * @param params.s s value of the permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public permit(params: PermitParams) {\n const { account, owner, spender, value, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, value, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, value, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","deadline","v","r","s"],"mappings":";;;;;;;;AA6BO,MAAMA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAA,MAC7B,CAACR,GAAOC,GAASG,GAAOK,GAAUC,GAAGC,GAAGC,CAAC;AAAA,MACzC,EAAE,SAAAJ,EAAQ;AAAA,IACZ,EAE0B;AAAA,EAAA;AAEhC;"}
1
+ {"version":3,"file":"nucleus-boring-vault-handler.js","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\nimport { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\nimport { PermitData } from '../common/lib/types';\n\nexport type PermitParams = PermitData & {\n account: Address;\n owner: Address;\n spender: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = UnifiToken.unifiETH;\n }\n\n /**\n * Set the UniFi token to use for executing transactions on the\n * contract.\n *\n * @param token UniFi token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: UnifiToken) {\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 = VAULTS_ADDRESSES[this.token][this.chain]\n .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\n * @param params.deadline Deadline for the permit.\n * @param params.v v value of the permit.\n * @param params.r r value of the permit.\n * @param params.s s value of the permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public permit(params: PermitParams) {\n const { account, owner, spender, amount, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","amount","deadline","v","r","s"],"mappings":";;;;;;;;AAyBO,MAAMA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarC,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,QAAQK,EAAW;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,E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,e)=>p(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../constants-CxSgz27h.cjs"),T=require("../vaults-addresses.cjs"),l=require("../tokens.cjs"),k=require("./erc20-permit-handler.cjs"),v=require("../abis/mainnet/Teller.cjs"),_=require("../../getContract-DUA3M2pm.cjs");class E{constructor(t,e,i){u(this,"viemChain");u(this,"erc20PermitHandler");u(this,"token");this.chain=t,this.walletClient=e,this.publicClient=i,this.viemChain=S.VIEM_CHAINS[t],this.erc20PermitHandler=new k.ERC20PermitHandler(t,e,i),this.token=l.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=T.VAULTS_ADDRESSES[this.token][this.chain].NucleusTeller,e=v.Teller,i={public:this.publicClient,wallet:this.walletClient};return _.getContract({address:t,abi:e,client:i})}accountant(){return this.getContract().read.accountant()}vault(){return this.getContract().read.vault()}shareLockPeriod(){return this.getContract().read.shareLockPeriod()}shareUnlockTime(t){return this.getContract().read.shareUnlockTime([t])}isPaused(){return this.getContract().read.isPaused()}async deposit(t){const{token:e,unifiToken:i,account:s,amount:n,minimumMint:a,isPreapproved:o=!1}=t,c=l.TOKENS_ADDRESSES[e][this.chain];if(o)return{transact:()=>this.getContract().write.deposit([c,n,a],{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit([c,n,a],{account:s})};const{r:h,s:d,v:m,deadline:g}=await this.erc20PermitHandler.withToken(e).getPermitSignature(s,l.TOKENS_ADDRESSES[i][this.chain],n),C=[c,n,a,g,Number(m),h,d];return{transact:()=>this.getContract().write.depositWithPermit(C,{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit(C,{account:s})}}depositWithPermit(t){const{account:e,depositAsset:i,depositAmount:s,minimumMint:n,deadline:a,v:o,r:c,s:h}=t;return{transact:()=>this.getContract().write.depositWithPermit([i,s,n,a,o,c,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit([i,s,n,a,o,c,h],{account:e})}}}exports.NucleusTellerHandler=E;
1
+ "use strict";var P=Object.defineProperty;var T=(r,t,e)=>t in r?P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>T(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../constants-CxSgz27h.cjs"),p=require("../vaults-addresses.cjs"),l=require("../tokens.cjs"),S=require("./erc20-permit-handler.cjs"),v=require("../abis/mainnet/Teller.cjs"),_=require("../../getContract-DUA3M2pm.cjs");class E{constructor(t,e,i){u(this,"viemChain");u(this,"erc20PermitHandler");u(this,"token");this.chain=t,this.walletClient=e,this.publicClient=i,this.viemChain=k.VIEM_CHAINS[t],this.erc20PermitHandler=new S.ERC20PermitHandler(t,e,i),this.token=l.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=p.VAULTS_ADDRESSES[this.token][this.chain].NucleusTeller,e=v.Teller,i={public:this.publicClient,wallet:this.walletClient};return _.getContract({address:t,abi:e,client:i})}accountant(){return this.getContract().read.accountant()}vault(){return this.getContract().read.vault()}shareLockPeriod(){return this.getContract().read.shareLockPeriod()}shareUnlockTime(t){return this.getContract().read.shareUnlockTime([t])}isPaused(){return this.getContract().read.isPaused()}async deposit(t){const{token:e,unifiToken:i,account:s,amount:n,minimumMint:a,isPreapproved:o=!1}=t,c=l.TOKENS_ADDRESSES[e][this.chain];if(o)return{transact:()=>this.getContract().write.deposit([c,n,a],{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit([c,n,a],{account:s})};const{r:h,s:d,v:m,deadline:g}=await this.erc20PermitHandler.withToken(e).getPermitData(s,l.TOKENS_ADDRESSES[i][this.chain],n),C=[c,n,a,g,m,h,d];return{transact:()=>this.getContract().write.depositWithPermit(C,{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit(C,{account:s})}}depositWithPermit(t){const{account:e,depositAsset:i,amount:s,minimumMint:n,deadline:a,v:o,r:c,s:h}=t;return{transact:()=>this.getContract().write.depositWithPermit([i,s,n,a,o,c,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit([i,s,n,a,o,c,h],{account:e})}}}exports.NucleusTellerHandler=E;
2
2
  //# sourceMappingURL=nucleus-teller-handler.cjs.map