@cowprotocol/permit-utils 0.1.1-RC.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/const.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { SupportedChainId } from '@cowprotocol/cow-sdk';
2
1
  import { Wallet } from '@ethersproject/wallet';
3
2
  export declare const PERMIT_SIGNER: Wallet;
4
- export declare const PERMIT_GAS_LIMIT_MIN: Record<SupportedChainId, number>;
3
+ export declare const DEFAULT_MIN_GAS_LIMIT = 55000;
5
4
  export declare const DEFAULT_PERMIT_GAS_LIMIT = "80000";
6
5
  export declare const DEFAULT_PERMIT_VALUE: string;
7
6
  export declare const DEFAULT_PERMIT_DURATION: number;
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@cowprotocol/cow-sdk"),O=require("@ethersproject/constants"),F=require("@ethersproject/wallet"),p=require("@1inch/permit-signed-approvals-utils"),b=require("@ethersproject/abi"),x=require("@ethersproject/bignumber"),G=require("@ethersproject/contracts"),v=require("@ethersproject/address"),q="0x4dae303b820e9878cafeb0f84edcc015e8a81b1bff510e824e4fc27544e458dd",P=new F.Wallet(q),T=55e3,K={[I.SupportedChainId.MAINNET]:T,[I.SupportedChainId.GNOSIS_CHAIN]:T,[I.SupportedChainId.SEPOLIA]:T,[I.SupportedChainId.GOERLI]:36e3},E="80000",L=O.MaxUint256.toString(),V=157788e6,B=new Set(["0x6b175474e89094c44da98b954eedeac495271d0f"]);async function j(r,t,e,a,n,o,{version:c,type:s,name:d}){const l=d||n;if(s==="unsupported")return!1;if(!l)throw new Error(`No token name for ${a}`);const m={chainId:t,tokenName:l,tokenAddress:a,callData:o,version:c};let u;if(o.startsWith(p.EIP_2612_PERMIT_SELECTOR)?u=e.recoverPermitOwnerFromCallData({...m,callData:o.replace(p.EIP_2612_PERMIT_SELECTOR,"0x")}):o.startsWith(p.DAI_PERMIT_SELECTOR)&&(u=e.recoverDaiLikePermitOwnerFromCallData({...m,callData:o.replace(p.DAI_PERMIT_SELECTOR,"0x")})),!!u)try{return(await u).toLowerCase()===r.toLowerCase()}catch(i){return console.debug(`[checkHasValidPendingPermit] Failed to check permit validity for owner ${r} with callData ${o}`,i),!1}}async function R({eip2162Utils:r,callDataParams:t}){const[e,a,n,...o]=t;return(await r.buildPermitCallData(e,a,n,...o)).replace("0x",p.EIP_2612_PERMIT_SELECTOR)}async function $({eip2162Utils:r,callDataParams:t}){return(await r.buildDaiLikePermitCallData(...t)).replace("0x",p.DAI_PERMIT_SELECTOR)}function y(){return Math.ceil((Date.now()+V)/1e3)}function M(r){return!!r&&r.type!=="unsupported"}const g={};async function W(r){const t=z(r),e=g[t];if(e)try{return await e}catch(n){console.debug("[generatePermitHookWith] cached request failed",n),delete g[t]}const a=Q(r).then(n=>(delete g[t],n));return g[t]=a,a}async function Q(r){const{inputToken:t,spender:e,chainId:a,permitInfo:n,provider:o,account:c,eip2162Utils:s,nonce:d}=r,l=t.address,m=n.name||t.name;if(!M(n))throw new Error(`Trying to generate permit hook for unsupported token: ${l}`);if(!m)throw new Error(`No token name for token: ${l}`);const u=c||P.address,i=d===void 0?await s.getTokenNonce(l,u):d,f=y(),k=L,C=n.type==="eip-2612"?await R({eip2162Utils:s,callDataParams:[{owner:u,spender:e,value:k,nonce:i,deadline:f},a,m,l,n.version]}):await $({eip2162Utils:s,callDataParams:[{holder:u,spender:e,allowed:!0,value:k,nonce:i,expiry:f},a,m,l,n.version]}),H=await Y(C,u,l,o,!!c);return{target:l,callData:C,gasLimit:H}}async function Y(r,t,e,a,n){try{const o=await a.estimateGas({data:r,from:t,to:e}),c=n?o:o.add(o.div(10));return c.gt(E)?c.toString():E}catch(o){return console.debug("[calculatePermitGasLimit] Failed to estimateGas, using default",o),E}}function z(r){const{inputToken:t,chainId:e,account:a}=r;return`${t.address.toLowerCase()}-${e}${a?`-${a.toLowerCase()}`:""}`}function w(r,t,e){return new G.Contract(r,t,e)}class J{constructor(t,e){this.provider=t,this.walletSigner=e}contractEncodeABI(t,e,a,n){return w(e||"",t,this.provider).interface.encodeFunctionData(a,n)}signTypedData(t,e,a){const n=Object.keys(e.types).reduce((c,s)=>(s!=="EIP712Domain"&&(c[s]=e.types[s]),c),{});return(this.walletSigner||this.provider.getSigner())._signTypedData(e.domain,n,e.message)}ethCall(t,e){return this.provider.call({to:t,data:e})}decodeABIParameter(t,e){return b.defaultAbiCoder.decode([t],e)[0]}decodeABIParameters(t,e){const a=b.defaultAbiCoder.decode(t,e);if(a&&typeof a=="object"){const n={};return Object.keys(a).forEach(o=>{const c=a[o];x.BigNumber.isBigNumber(c)?n[o]=c.toHexString():n[o]=c}),n}return a}}const _=new Map,A=new Map;function N(r,t,e){const a=_.get(r);if(!e&&a)return a;const n=`${r}-${e}`,o=A.get(n);if(o)return o;const c=new J(t,e?void 0:P),s=new p.Eip2612PermitUtils(c);return e?(console.log(`[getPermitUtilsInstance] Set cached provider utils for chain ${r}-${e}`,s),A.set(n,s)):(console.log(`[getPermitUtilsInstance] Set cached chain utils for chain ${r}`,s),_.set(r,s)),s}const U=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];async function X(r,t,e){const a=v.getAddress(r),o=await w(a,U,e).callStatic.eip712Domain();return Z(o,t,r)}async function Z(r,t,e){const{extensions:a,...n}=r;if(a.length>0)throw Error("Extensions not implemented");if(n.chainId&&t!==parseInt(n.chainId,16))throw Error(`ChainId mismatch. Received: '${n.chainId}', expected: '${t}'`);if(n.verifyingContract&&e.toLowerCase()!==n.verifyingContract.toLowerCase())throw Error(`Address mismatch. Received: '${n.verifyingContract}', expected: '${e}'`);return te(n)}const ee=["name","version","chainId","verifyingContract","salt"];function te(r){const t=parseInt(r.fields,16);return ee.reduce((e,a,n)=>(t&1<<n&&(e[a]=r[a]),e),{})}async function ne(r,t,e){const a=v.getAddress(r);return w(a,U,e).callStatic.name()}const re={value:L,nonce:0,deadline:y()},ae={allowed:!0,nonce:0,expiry:y()},S={},h={type:"unsupported"};async function oe(r){const{tokenAddress:t,chainId:e}=r,a=`${e}-${t.toLowerCase()}`,n=S[a];if(n)return n;const o=ie(r);return S[a]=o,o}async function ie(r){const{spender:t,tokenAddress:e,chainId:a,provider:n}=r,o=N(a,n),c=P.address;let s;try{s=await X(e,a,n)}catch(i){console.debug(`[checkTokenIsPermittable] Couldn't fetch eip712domain for token ${e}`,i)}let d=s==null?void 0:s.name;try{d||(d=await ne(e,a,n))}catch(i){if(/ETIMEDOUT/.test(i)&&!d)return{error:"Failed to fetch token name from contract. RPC connection error"};console.debug(`[checkTokenIsPermittable] Couldn't fetch token name from the contract for token ${e}, using provided '${d}'`,i)}if(!d)return{error:`Token name could not be determined for ${e}`};let l;try{l=await o.getTokenNonce(e,c)}catch(i){return i==="nonce not supported"||i.message==="nonce is NaN"?(console.debug(`[checkTokenIsPermittable] Not a permittable token ${e} - ${d}`,(i==null?void 0:i.message)||i),{...h,name:d}):(console.debug(`[checkTokenIsPermittable] Failed to get nonce for ${e} - ${d}`,i),{error:i.message||i.toString()})}let m=s==null?void 0:s.version;if(!B.has(e)&&m===void 0)try{m=await o.getTokenVersion(e)}catch(i){console.debug(`[checkTokenIsPermittable] Failed to get version for ${e} - ${d}`,i)}const u={chainId:a,eip2612PermitUtils:o,nonce:l,spender:t,tokenAddress:e,tokenName:d,walletAddress:c,version:m};try{return await D({...u,type:"eip-2612",provider:n})}catch(i){try{return await ce(e,o)?await D({...u,type:"dai-like",provider:n}):/invalid signature/.test(i)||(i==null?void 0:i.code)==="UNPREDICTABLE_GAS_LIMIT"?(console.debug(`[checkTokenIsPermittable] Token ${e} - ${d} might be permittable, but it's not supported for now. Reason:`,i==null?void 0:i.reason),{...h,name:d}):(console.debug(`[checkTokenIsPermittable] Failed to estimate eip-2612 permit for ${e} - ${d}`,i),{error:i.message||i.toString()})}catch(f){return console.debug(`[checkTokenIsPermittable] Failed to estimate dai-like permit for ${e} - ${d}`,f),{error:f.message||f.toString()}}}}async function D(r){const{provider:t,chainId:e,walletAddress:a,tokenAddress:n,tokenName:o,type:c,version:s}=r,l=await(c==="eip-2612"?se:de)(r);return l?(await t.estimateGas({data:l,from:a,to:n})).toNumber()>K[e]?{type:c,version:s,name:o}:{...h,name:o}:{...h,name:o}}async function se(r){const{eip2612PermitUtils:t,walletAddress:e,spender:a,nonce:n,chainId:o,tokenName:c,tokenAddress:s,version:d}=r;return R({eip2162Utils:t,callDataParams:[{...re,owner:e,spender:a,nonce:n},+o,c,s,d]})}async function ce(r,t){return await t.getPermitTypeHash(r)===p.DAI_LIKE_PERMIT_TYPEHASH}async function de(r){const{eip2612PermitUtils:t,tokenAddress:e,walletAddress:a,spender:n,nonce:o,chainId:c,tokenName:s,version:d}=r;return await t.getPermitTypeHash(e)===p.DAI_LIKE_PERMIT_TYPEHASH?$({eip2162Utils:t,callDataParams:[{...ae,holder:a,spender:n,nonce:o},c,s,e,d]}):!1}exports.PERMIT_SIGNER=P;exports.checkIsCallDataAValidPermit=j;exports.generatePermitHook=W;exports.getPermitUtilsInstance=N;exports.getTokenPermitInfo=oe;exports.isSupportedPermitInfo=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("@ethersproject/constants"),O=require("@ethersproject/wallet"),p=require("@1inch/permit-signed-approvals-utils"),k=require("@ethersproject/abi"),F=require("@ethersproject/bignumber"),x=require("@ethersproject/contracts"),D=require("@ethersproject/address"),G="0x1b80501ea68b883241ac5b9f92e8635aa3df23c89b7bbb87e762be65b8c6eb75",h=new O.Wallet(G),v=55e3,T="80000",S=H.MaxUint256.toString(),q=157788e6,K=new Set(["0x6b175474e89094c44da98b954eedeac495271d0f"]);async function V(r,n,e,a,t,o,{version:c,type:l,name:d}){const s=d||t;if(l==="unsupported")return!1;if(!s)throw new Error(`No token name for ${a}`);const m={chainId:n,tokenName:s,tokenAddress:a,callData:o,version:c};let u;if(o.startsWith(p.EIP_2612_PERMIT_SELECTOR)?u=e.recoverPermitOwnerFromCallData({...m,callData:o.replace(p.EIP_2612_PERMIT_SELECTOR,"0x")}):o.startsWith(p.DAI_PERMIT_SELECTOR)&&(u=e.recoverDaiLikePermitOwnerFromCallData({...m,callData:o.replace(p.DAI_PERMIT_SELECTOR,"0x")})),!!u)try{return(await u).toLowerCase()===r.toLowerCase()}catch(f){return console.debug(`[checkHasValidPendingPermit] Failed to check permit validity for owner ${r} with callData ${o}`,f),!1}}async function L({eip2162Utils:r,callDataParams:n}){const[e,a,t,...o]=n;return(await r.buildPermitCallData(e,a,t,...o)).replace("0x",p.EIP_2612_PERMIT_SELECTOR)}async function R({eip2162Utils:r,callDataParams:n}){return(await r.buildDaiLikePermitCallData(...n)).replace("0x",p.DAI_PERMIT_SELECTOR)}function y(){return Math.ceil((Date.now()+q)/1e3)}function $(r){return!!r&&r.type!=="unsupported"}const P={};async function B(r){const n=Q(r),e=P[n];if(e)try{return await e}catch(t){console.debug("[generatePermitHookWith] cached request failed",t),delete P[n]}const a=j(r).then(t=>(delete P[n],t));return P[n]=a,a}async function j(r){const{inputToken:n,spender:e,chainId:a,permitInfo:t,provider:o,account:c,eip2162Utils:l,nonce:d}=r,s=n.address,m=t.name||n.name;if(!$(t))throw new Error(`Trying to generate permit hook for unsupported token: ${s}`);if(!m)throw new Error(`No token name for token: ${s}`);const u=c||h.address,f=d===void 0?await l.getTokenNonce(s,u):d,i=y(),g=S,w=t.type==="eip-2612"?await L({eip2162Utils:l,callDataParams:[{owner:u,spender:e,value:g,nonce:f,deadline:i},a,m,s,t.version]}):await R({eip2162Utils:l,callDataParams:[{holder:u,spender:e,allowed:!0,value:g,nonce:f,expiry:i},a,m,s,t.version]}),U=await W(w,u,s,o,!!c);return{target:s,callData:w,gasLimit:U}}async function W(r,n,e,a,t){try{const o=await a.estimateGas({data:r,from:n,to:e}),c=t?o:o.add(o.div(10));return c.gt(T)?c.toString():T}catch(o){return console.debug("[calculatePermitGasLimit] Failed to estimateGas, using default",o),T}}function Q(r){const{inputToken:n,chainId:e,account:a}=r;return`${n.address.toLowerCase()}-${e}${a?`-${a.toLowerCase()}`:""}`}function E(r,n,e){return new x.Contract(r,n,e)}class Y{constructor(n,e){this.provider=n,this.walletSigner=e}contractEncodeABI(n,e,a,t){return E(e||"",n,this.provider).interface.encodeFunctionData(a,t)}signTypedData(n,e,a){const t=Object.keys(e.types).reduce((c,l)=>(l!=="EIP712Domain"&&(c[l]=e.types[l]),c),{});return(this.walletSigner||this.provider.getSigner())._signTypedData(e.domain,t,e.message)}ethCall(n,e){return this.provider.call({to:n,data:e})}decodeABIParameter(n,e){return k.defaultAbiCoder.decode([n],e)[0]}decodeABIParameters(n,e){const a=k.defaultAbiCoder.decode(n,e);if(a&&typeof a=="object"){const t={};return Object.keys(a).forEach(o=>{const c=a[o];F.BigNumber.isBigNumber(c)?t[o]=c.toHexString():t[o]=c}),t}return a}}const b=new Map,C=new Map;function M(r,n,e){const a=b.get(r);if(!e&&a)return a;const t=`${r}-${e}`,o=C.get(t);if(o)return o;const c=new Y(n,e?void 0:h),l=new p.Eip2612PermitUtils(c);return e?(console.log(`[getPermitUtilsInstance] Set cached provider utils for chain ${r}-${e}`,l),C.set(t,l)):(console.log(`[getPermitUtilsInstance] Set cached chain utils for chain ${r}`,l),b.set(r,l)),l}const N=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];async function z(r,n,e){const a=D.getAddress(r),o=await E(a,N,e).callStatic.eip712Domain();return J(o,n,r)}async function J(r,n,e){const{extensions:a,...t}=r;if(a.length>0)throw Error("Extensions not implemented");if(t.chainId&&n!==parseInt(t.chainId,16))throw Error(`ChainId mismatch. Received: '${t.chainId}', expected: '${n}'`);if(t.verifyingContract&&e.toLowerCase()!==t.verifyingContract.toLowerCase())throw Error(`Address mismatch. Received: '${t.verifyingContract}', expected: '${e}'`);return Z(t)}const X=["name","version","chainId","verifyingContract","salt"];function Z(r){const n=parseInt(r.fields,16);return X.reduce((e,a,t)=>(n&1<<t&&(e[a]=r[a]),e),{})}async function ee(r,n,e){const a=D.getAddress(r);return E(a,N,e).callStatic.name()}const te={value:S,nonce:0,deadline:y()},ne={allowed:!0,nonce:0,expiry:y()},_={},I={type:"unsupported"};async function re(r){const{tokenAddress:n,chainId:e}=r,a=`${e}-${n.toLowerCase()}`,t=_[a];if(t)return t;const o=ae(r);return _[a]=o,o}async function ae(r){const{spender:n,tokenAddress:e,chainId:a,provider:t,minGasLimit:o}=r,c=M(a,t),l=h.address;let d;try{d=await z(e,a,t)}catch{console.debug(`[checkTokenIsPermittable] Couldn't fetch eip712domain for token ${e}`)}let s=d==null?void 0:d.name;try{s||(s=await ee(e,a,t))}catch(i){if(/ETIMEDOUT/.test(i)&&!s)return{error:"Failed to fetch token name from contract. RPC connection error"};console.debug(`[checkTokenIsPermittable] Couldn't fetch token name from the contract for token ${e}, using provided '${s}'`,i)}if(!s)return{error:`Token name could not be determined for ${e}`};let m;try{m=await c.getTokenNonce(e,l)}catch(i){return i==="nonce not supported"||i.message==="nonce is NaN"?(console.debug(`[checkTokenIsPermittable] Not a permittable token ${e} - ${s}`,(i==null?void 0:i.message)||i),{...I,name:s}):(console.debug(`[checkTokenIsPermittable] Failed to get nonce for ${e} - ${s}`,i),{error:i.message||i.toString()})}let u=d==null?void 0:d.version;if(!K.has(e)&&u===void 0)try{u=await c.getTokenVersion(e)}catch(i){console.debug(`[checkTokenIsPermittable] Failed to get version for ${e} - ${s}`,i)}const f={chainId:a,eip2612PermitUtils:c,nonce:m,spender:n,tokenAddress:e,tokenName:s,walletAddress:l,version:u,minGasLimit:o};try{return await A({...f,type:"eip-2612",provider:t})}catch(i){try{return await ie(e,c)?await A({...f,type:"dai-like",provider:t}):/invalid signature/.test(i)||(i==null?void 0:i.code)==="UNPREDICTABLE_GAS_LIMIT"?(console.debug(`[checkTokenIsPermittable] Token ${e} - ${s} might be permittable, but it's not supported for now. Reason:`,i==null?void 0:i.reason),{...I,name:s}):(console.debug(`[checkTokenIsPermittable] Failed to estimate eip-2612 permit for ${e} - ${s}`,i),{error:i.message||i.toString()})}catch(g){return console.debug(`[checkTokenIsPermittable] Failed to estimate dai-like permit for ${e} - ${s}`,g),{error:g.message||g.toString()}}}}async function A(r){const{provider:n,walletAddress:e,tokenAddress:a,tokenName:t,type:o,version:c,minGasLimit:l=v}=r,s=await(o==="eip-2612"?oe:se)(r);return s?(await n.estimateGas({data:s,from:e,to:a})).toNumber()>l?{type:o,version:c,name:t}:{...I,name:t}:{...I,name:t}}async function oe(r){const{eip2612PermitUtils:n,walletAddress:e,spender:a,nonce:t,chainId:o,tokenName:c,tokenAddress:l,version:d}=r;return L({eip2162Utils:n,callDataParams:[{...te,owner:e,spender:a,nonce:t},+o,c,l,d]})}async function ie(r,n){return await n.getPermitTypeHash(r)===p.DAI_LIKE_PERMIT_TYPEHASH}async function se(r){const{eip2612PermitUtils:n,tokenAddress:e,walletAddress:a,spender:t,nonce:o,chainId:c,tokenName:l,version:d}=r;return await n.getPermitTypeHash(e)===p.DAI_LIKE_PERMIT_TYPEHASH?R({eip2162Utils:n,callDataParams:[{...ne,holder:a,spender:t,nonce:o},c,l,e,d]}):!1}exports.DEFAULT_MIN_GAS_LIMIT=v;exports.PERMIT_SIGNER=h;exports.checkIsCallDataAValidPermit=V;exports.generatePermitHook=B;exports.getPermitUtilsInstance=M;exports.getTokenPermitInfo=re;exports.isSupportedPermitInfo=$;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { PERMIT_SIGNER } from './const';
1
+ export { PERMIT_SIGNER, DEFAULT_MIN_GAS_LIMIT } from './const';
2
2
  export { checkIsCallDataAValidPermit } from './lib/checkIsCallDataAValidPermit';
3
3
  export { generatePermitHook } from './lib/generatePermitHook';
4
4
  export { getPermitUtilsInstance } from './lib/getPermitUtilsInstance';
package/index.js CHANGED
@@ -1,191 +1,185 @@
1
- import { SupportedChainId as f } from "@cowprotocol/cow-sdk";
2
- import { MaxUint256 as O } from "@ethersproject/constants";
3
- import { Wallet as F } from "@ethersproject/wallet";
4
- import { EIP_2612_PERMIT_SELECTOR as P, DAI_PERMIT_SELECTOR as T, Eip2612PermitUtils as x, DAI_LIKE_PERMIT_TYPEHASH as L } from "@1inch/permit-signed-approvals-utils";
5
- import { defaultAbiCoder as v } from "@ethersproject/abi";
6
- import { BigNumber as G } from "@ethersproject/bignumber";
7
- import { Contract as K } from "@ethersproject/contracts";
8
- import { getAddress as $ } from "@ethersproject/address";
9
- const B = "0x4dae303b820e9878cafeb0f84edcc015e8a81b1bff510e824e4fc27544e458dd", w = new F(B), y = 55e3, V = {
10
- [f.MAINNET]: y,
11
- [f.GNOSIS_CHAIN]: y,
12
- [f.SEPOLIA]: y,
13
- [f.GOERLI]: 36e3
14
- }, I = "80000", N = O.toString(), q = 157788e6, W = /* @__PURE__ */ new Set(["0x6b175474e89094c44da98b954eedeac495271d0f"]);
15
- async function Ie(r, t, e, o, n, a, {
1
+ import { MaxUint256 as M } from "@ethersproject/constants";
2
+ import { Wallet as H } from "@ethersproject/wallet";
3
+ import { EIP_2612_PERMIT_SELECTOR as P, DAI_PERMIT_SELECTOR as w, Eip2612PermitUtils as F, DAI_LIKE_PERMIT_TYPEHASH as _ } from "@1inch/permit-signed-approvals-utils";
4
+ import { defaultAbiCoder as E } from "@ethersproject/abi";
5
+ import { BigNumber as x } from "@ethersproject/bignumber";
6
+ import { Contract as O } from "@ethersproject/contracts";
7
+ import { getAddress as L } from "@ethersproject/address";
8
+ const G = "0x1b80501ea68b883241ac5b9f92e8635aa3df23c89b7bbb87e762be65b8c6eb75", T = new H(G), K = 55e3, y = "80000", $ = M.toString(), B = 157788e6, V = /* @__PURE__ */ new Set(["0x6b175474e89094c44da98b954eedeac495271d0f"]);
9
+ async function ge(r, n, e, a, t, o, {
16
10
  version: c,
17
- type: s,
18
- name: l
11
+ type: l,
12
+ name: d
19
13
  }) {
20
- const d = l || n;
21
- if (s === "unsupported")
14
+ const s = d || t;
15
+ if (l === "unsupported")
22
16
  return !1;
23
- if (!d)
24
- throw new Error(`No token name for ${o}`);
17
+ if (!s)
18
+ throw new Error(`No token name for ${a}`);
25
19
  const u = {
26
- chainId: t,
27
- tokenName: d,
28
- tokenAddress: o,
29
- callData: a,
20
+ chainId: n,
21
+ tokenName: s,
22
+ tokenAddress: a,
23
+ callData: o,
30
24
  version: c
31
25
  };
32
26
  let m;
33
- if (a.startsWith(P) ? m = e.recoverPermitOwnerFromCallData({
27
+ if (o.startsWith(P) ? m = e.recoverPermitOwnerFromCallData({
34
28
  ...u,
35
29
  // I don't know why this was removed, ok?
36
30
  // We added it back on buildPermitCallData.ts
37
31
  // But it looks like this is needed 🤷
38
32
  // Check the test for this method https://github.com/1inch/permit-signed-approvals-utils/blob/master/src/eip-2612-permit.test.ts#L85-L106
39
- callData: a.replace(P, "0x")
40
- }) : a.startsWith(T) && (m = e.recoverDaiLikePermitOwnerFromCallData({
33
+ callData: o.replace(P, "0x")
34
+ }) : o.startsWith(w) && (m = e.recoverDaiLikePermitOwnerFromCallData({
41
35
  ...u,
42
- callData: a.replace(T, "0x")
36
+ callData: o.replace(w, "0x")
43
37
  })), !!m)
44
38
  try {
45
39
  return (await m).toLowerCase() === r.toLowerCase();
46
- } catch (i) {
47
- return console.debug(`[checkHasValidPendingPermit] Failed to check permit validity for owner ${r} with callData ${a}`, i), !1;
40
+ } catch (p) {
41
+ return console.debug(`[checkHasValidPendingPermit] Failed to check permit validity for owner ${r} with callData ${o}`, p), !1;
48
42
  }
49
43
  }
50
- async function R({
44
+ async function S({
51
45
  eip2162Utils: r,
52
- callDataParams: t
46
+ callDataParams: n
53
47
  }) {
54
- const [e, o, n, ...a] = t;
55
- return (await r.buildPermitCallData(e, o, n, ...a)).replace("0x", P);
48
+ const [e, a, t, ...o] = n;
49
+ return (await r.buildPermitCallData(e, a, t, ...o)).replace("0x", P);
56
50
  }
57
- async function M({
51
+ async function R({
58
52
  eip2162Utils: r,
59
- callDataParams: t
53
+ callDataParams: n
60
54
  }) {
61
- return (await r.buildDaiLikePermitCallData(...t)).replace("0x", T);
55
+ return (await r.buildDaiLikePermitCallData(...n)).replace("0x", w);
62
56
  }
63
- function k() {
64
- return Math.ceil((Date.now() + q) / 1e3);
57
+ function I() {
58
+ return Math.ceil((Date.now() + B) / 1e3);
65
59
  }
66
- function j(r) {
60
+ function q(r) {
67
61
  return !!r && r.type !== "unsupported";
68
62
  }
69
- const h = {};
70
- async function Pe(r) {
71
- const t = z(r), e = h[t];
63
+ const g = {};
64
+ async function he(r) {
65
+ const n = Q(r), e = g[n];
72
66
  if (e)
73
67
  try {
74
68
  return await e;
75
- } catch (n) {
76
- console.debug("[generatePermitHookWith] cached request failed", n), delete h[t];
69
+ } catch (t) {
70
+ console.debug("[generatePermitHookWith] cached request failed", t), delete g[n];
77
71
  }
78
- const o = Q(r).then((n) => (delete h[t], n));
79
- return h[t] = o, o;
72
+ const a = W(r).then((t) => (delete g[n], t));
73
+ return g[n] = a, a;
80
74
  }
81
- async function Q(r) {
75
+ async function W(r) {
82
76
  const {
83
- inputToken: t,
77
+ inputToken: n,
84
78
  spender: e,
85
- chainId: o,
86
- permitInfo: n,
87
- provider: a,
79
+ chainId: a,
80
+ permitInfo: t,
81
+ provider: o,
88
82
  account: c,
89
- eip2162Utils: s,
90
- nonce: l
91
- } = r, d = t.address, u = n.name || t.name;
92
- if (!j(n))
93
- throw new Error(`Trying to generate permit hook for unsupported token: ${d}`);
83
+ eip2162Utils: l,
84
+ nonce: d
85
+ } = r, s = n.address, u = t.name || n.name;
86
+ if (!q(t))
87
+ throw new Error(`Trying to generate permit hook for unsupported token: ${s}`);
94
88
  if (!u)
95
- throw new Error(`No token name for token: ${d}`);
96
- const m = c || w.address, i = l === void 0 ? await s.getTokenNonce(d, m) : l, p = k(), C = N, b = n.type === "eip-2612" ? await R({
97
- eip2162Utils: s,
89
+ throw new Error(`No token name for token: ${s}`);
90
+ const m = c || T.address, p = d === void 0 ? await l.getTokenNonce(s, m) : d, i = I(), f = $, b = t.type === "eip-2612" ? await S({
91
+ eip2162Utils: l,
98
92
  callDataParams: [{
99
93
  owner: m,
100
94
  spender: e,
101
- value: C,
102
- nonce: i,
103
- deadline: p
104
- }, o, u, d, n.version]
105
- }) : await M({
106
- eip2162Utils: s,
95
+ value: f,
96
+ nonce: p,
97
+ deadline: i
98
+ }, a, u, s, t.version]
99
+ }) : await R({
100
+ eip2162Utils: l,
107
101
  callDataParams: [{
108
102
  holder: m,
109
103
  spender: e,
110
104
  allowed: !0,
111
- value: C,
112
- nonce: i,
113
- expiry: p
114
- }, o, u, d, n.version]
115
- }), H = await Y(b, m, d, a, !!c);
105
+ value: f,
106
+ nonce: p,
107
+ expiry: i
108
+ }, a, u, s, t.version]
109
+ }), U = await j(b, m, s, o, !!c);
116
110
  return {
117
- target: d,
111
+ target: s,
118
112
  callData: b,
119
- gasLimit: H
113
+ gasLimit: U
120
114
  };
121
115
  }
122
- async function Y(r, t, e, o, n) {
116
+ async function j(r, n, e, a, t) {
123
117
  try {
124
- const a = await o.estimateGas({
118
+ const o = await a.estimateGas({
125
119
  data: r,
126
- from: t,
120
+ from: n,
127
121
  to: e
128
- }), c = n ? a : a.add(a.div(10));
129
- return c.gt(I) ? c.toString() : I;
130
- } catch (a) {
131
- return console.debug("[calculatePermitGasLimit] Failed to estimateGas, using default", a), I;
122
+ }), c = t ? o : o.add(o.div(10));
123
+ return c.gt(y) ? c.toString() : y;
124
+ } catch (o) {
125
+ return console.debug("[calculatePermitGasLimit] Failed to estimateGas, using default", o), y;
132
126
  }
133
127
  }
134
- function z(r) {
128
+ function Q(r) {
135
129
  const {
136
- inputToken: t,
130
+ inputToken: n,
137
131
  chainId: e,
138
- account: o
132
+ account: a
139
133
  } = r;
140
- return `${t.address.toLowerCase()}-${e}${o ? `-${o.toLowerCase()}` : ""}`;
134
+ return `${n.address.toLowerCase()}-${e}${a ? `-${a.toLowerCase()}` : ""}`;
141
135
  }
142
- function E(r, t, e) {
143
- return new K(r, t, e);
136
+ function k(r, n, e) {
137
+ return new O(r, n, e);
144
138
  }
145
- class J {
146
- constructor(t, e) {
147
- this.provider = t, this.walletSigner = e;
139
+ class Y {
140
+ constructor(n, e) {
141
+ this.provider = n, this.walletSigner = e;
148
142
  }
149
- contractEncodeABI(t, e, o, n) {
150
- return E(e || "", t, this.provider).interface.encodeFunctionData(o, n);
143
+ contractEncodeABI(n, e, a, t) {
144
+ return k(e || "", n, this.provider).interface.encodeFunctionData(a, t);
151
145
  }
152
- signTypedData(t, e, o) {
153
- const n = Object.keys(e.types).reduce((c, s) => (s !== "EIP712Domain" && (c[s] = e.types[s]), c), {});
154
- return (this.walletSigner || this.provider.getSigner())._signTypedData(e.domain, n, e.message);
146
+ signTypedData(n, e, a) {
147
+ const t = Object.keys(e.types).reduce((c, l) => (l !== "EIP712Domain" && (c[l] = e.types[l]), c), {});
148
+ return (this.walletSigner || this.provider.getSigner())._signTypedData(e.domain, t, e.message);
155
149
  }
156
- ethCall(t, e) {
150
+ ethCall(n, e) {
157
151
  return this.provider.call({
158
- to: t,
152
+ to: n,
159
153
  data: e
160
154
  });
161
155
  }
162
- decodeABIParameter(t, e) {
163
- return v.decode([t], e)[0];
156
+ decodeABIParameter(n, e) {
157
+ return E.decode([n], e)[0];
164
158
  }
165
- decodeABIParameters(t, e) {
166
- const o = v.decode(t, e);
167
- if (o && typeof o == "object") {
168
- const n = {};
169
- return Object.keys(o).forEach((a) => {
170
- const c = o[a];
171
- G.isBigNumber(c) ? n[a] = c.toHexString() : n[a] = c;
172
- }), n;
159
+ decodeABIParameters(n, e) {
160
+ const a = E.decode(n, e);
161
+ if (a && typeof a == "object") {
162
+ const t = {};
163
+ return Object.keys(a).forEach((o) => {
164
+ const c = a[o];
165
+ x.isBigNumber(c) ? t[o] = c.toHexString() : t[o] = c;
166
+ }), t;
173
167
  }
174
- return o;
168
+ return a;
175
169
  }
176
170
  }
177
- const D = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
178
- function X(r, t, e) {
179
- const o = D.get(r);
180
- if (!e && o)
181
- return o;
182
- const n = `${r}-${e}`, a = A.get(n);
183
- if (a)
171
+ const C = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
172
+ function z(r, n, e) {
173
+ const a = C.get(r);
174
+ if (!e && a)
184
175
  return a;
185
- const c = new J(t, e ? void 0 : w), s = new x(c);
186
- return e ? (console.log(`[getPermitUtilsInstance] Set cached provider utils for chain ${r}-${e}`, s), A.set(n, s)) : (console.log(`[getPermitUtilsInstance] Set cached chain utils for chain ${r}`, s), D.set(r, s)), s;
176
+ const t = `${r}-${e}`, o = v.get(t);
177
+ if (o)
178
+ return o;
179
+ const c = new Y(n, e ? void 0 : T), l = new F(c);
180
+ return e ? (console.log(`[getPermitUtilsInstance] Set cached provider utils for chain ${r}-${e}`, l), v.set(t, l)) : (console.log(`[getPermitUtilsInstance] Set cached chain utils for chain ${r}`, l), C.set(r, l)), l;
187
181
  }
188
- const U = [
182
+ const N = [
189
183
  {
190
184
  constant: !0,
191
185
  inputs: [],
@@ -244,209 +238,212 @@ const U = [
244
238
  type: "function"
245
239
  }
246
240
  ];
247
- async function Z(r, t, e) {
248
- const o = $(r), a = await E(o, U, e).callStatic.eip712Domain();
249
- return ee(a, t, r);
241
+ async function J(r, n, e) {
242
+ const a = L(r), o = await k(a, N, e).callStatic.eip712Domain();
243
+ return X(o, n, r);
250
244
  }
251
- async function ee(r, t, e) {
245
+ async function X(r, n, e) {
252
246
  const {
253
- extensions: o,
254
- ...n
247
+ extensions: a,
248
+ ...t
255
249
  } = r;
256
- if (o.length > 0)
250
+ if (a.length > 0)
257
251
  throw Error("Extensions not implemented");
258
- if (n.chainId && t !== parseInt(n.chainId, 16))
259
- throw Error(`ChainId mismatch. Received: '${n.chainId}', expected: '${t}'`);
260
- if (n.verifyingContract && e.toLowerCase() !== n.verifyingContract.toLowerCase())
261
- throw Error(`Address mismatch. Received: '${n.verifyingContract}', expected: '${e}'`);
262
- return ne(n);
252
+ if (t.chainId && n !== parseInt(t.chainId, 16))
253
+ throw Error(`ChainId mismatch. Received: '${t.chainId}', expected: '${n}'`);
254
+ if (t.verifyingContract && e.toLowerCase() !== t.verifyingContract.toLowerCase())
255
+ throw Error(`Address mismatch. Received: '${t.verifyingContract}', expected: '${e}'`);
256
+ return ee(t);
263
257
  }
264
- const te = ["name", "version", "chainId", "verifyingContract", "salt"];
265
- function ne(r) {
266
- const t = parseInt(r.fields, 16);
267
- return te.reduce((e, o, n) => (t & 1 << n && (e[o] = r[o]), e), {});
258
+ const Z = ["name", "version", "chainId", "verifyingContract", "salt"];
259
+ function ee(r) {
260
+ const n = parseInt(r.fields, 16);
261
+ return Z.reduce((e, a, t) => (n & 1 << t && (e[a] = r[a]), e), {});
268
262
  }
269
- async function re(r, t, e) {
270
- const o = $(r);
271
- return E(o, U, e).callStatic.name();
263
+ async function te(r, n, e) {
264
+ const a = L(r);
265
+ return k(a, N, e).callStatic.name();
272
266
  }
273
- const oe = {
274
- value: N,
267
+ const ne = {
268
+ value: $,
275
269
  nonce: 0,
276
- deadline: k()
277
- }, ae = {
270
+ deadline: I()
271
+ }, re = {
278
272
  allowed: !0,
279
273
  nonce: 0,
280
- expiry: k()
281
- }, _ = {}, g = {
274
+ expiry: I()
275
+ }, D = {}, h = {
282
276
  type: "unsupported"
283
277
  };
284
- async function Te(r) {
278
+ async function ye(r) {
285
279
  const {
286
- tokenAddress: t,
280
+ tokenAddress: n,
287
281
  chainId: e
288
- } = r, o = `${e}-${t.toLowerCase()}`, n = _[o];
289
- if (n)
290
- return n;
291
- const a = ie(r);
292
- return _[o] = a, a;
282
+ } = r, a = `${e}-${n.toLowerCase()}`, t = D[a];
283
+ if (t)
284
+ return t;
285
+ const o = ae(r);
286
+ return D[a] = o, o;
293
287
  }
294
- async function ie(r) {
288
+ async function ae(r) {
295
289
  const {
296
- spender: t,
290
+ spender: n,
297
291
  tokenAddress: e,
298
- chainId: o,
299
- provider: n
300
- } = r, a = X(o, n), c = w.address;
301
- let s;
292
+ chainId: a,
293
+ provider: t,
294
+ minGasLimit: o
295
+ } = r, c = z(a, t), l = T.address;
296
+ let d;
302
297
  try {
303
- s = await Z(e, o, n);
304
- } catch (i) {
305
- console.debug(`[checkTokenIsPermittable] Couldn't fetch eip712domain for token ${e}`, i);
298
+ d = await J(e, a, t);
299
+ } catch {
300
+ console.debug(`[checkTokenIsPermittable] Couldn't fetch eip712domain for token ${e}`);
306
301
  }
307
- let l = s == null ? void 0 : s.name;
302
+ let s = d == null ? void 0 : d.name;
308
303
  try {
309
- l || (l = await re(e, o, n));
304
+ s || (s = await te(e, a, t));
310
305
  } catch (i) {
311
- if (/ETIMEDOUT/.test(i) && !l)
306
+ if (/ETIMEDOUT/.test(i) && !s)
312
307
  return {
313
308
  error: "Failed to fetch token name from contract. RPC connection error"
314
309
  };
315
- console.debug(`[checkTokenIsPermittable] Couldn't fetch token name from the contract for token ${e}, using provided '${l}'`, i);
310
+ console.debug(`[checkTokenIsPermittable] Couldn't fetch token name from the contract for token ${e}, using provided '${s}'`, i);
316
311
  }
317
- if (!l)
312
+ if (!s)
318
313
  return {
319
314
  error: `Token name could not be determined for ${e}`
320
315
  };
321
- let d;
316
+ let u;
322
317
  try {
323
- d = await a.getTokenNonce(e, c);
318
+ u = await c.getTokenNonce(e, l);
324
319
  } catch (i) {
325
- return i === "nonce not supported" || i.message === "nonce is NaN" ? (console.debug(`[checkTokenIsPermittable] Not a permittable token ${e} - ${l}`, (i == null ? void 0 : i.message) || i), {
326
- ...g,
327
- name: l
328
- }) : (console.debug(`[checkTokenIsPermittable] Failed to get nonce for ${e} - ${l}`, i), {
320
+ return i === "nonce not supported" || i.message === "nonce is NaN" ? (console.debug(`[checkTokenIsPermittable] Not a permittable token ${e} - ${s}`, (i == null ? void 0 : i.message) || i), {
321
+ ...h,
322
+ name: s
323
+ }) : (console.debug(`[checkTokenIsPermittable] Failed to get nonce for ${e} - ${s}`, i), {
329
324
  error: i.message || i.toString()
330
325
  });
331
326
  }
332
- let u = s == null ? void 0 : s.version;
333
- if (!W.has(e) && u === void 0)
327
+ let m = d == null ? void 0 : d.version;
328
+ if (!V.has(e) && m === void 0)
334
329
  try {
335
- u = await a.getTokenVersion(e);
330
+ m = await c.getTokenVersion(e);
336
331
  } catch (i) {
337
- console.debug(`[checkTokenIsPermittable] Failed to get version for ${e} - ${l}`, i);
332
+ console.debug(`[checkTokenIsPermittable] Failed to get version for ${e} - ${s}`, i);
338
333
  }
339
- const m = {
340
- chainId: o,
341
- eip2612PermitUtils: a,
342
- nonce: d,
343
- spender: t,
334
+ const p = {
335
+ chainId: a,
336
+ eip2612PermitUtils: c,
337
+ nonce: u,
338
+ spender: n,
344
339
  tokenAddress: e,
345
- tokenName: l,
346
- walletAddress: c,
347
- version: u
340
+ tokenName: s,
341
+ walletAddress: l,
342
+ version: m,
343
+ minGasLimit: o
348
344
  };
349
345
  try {
350
- return await S({
351
- ...m,
346
+ return await A({
347
+ ...p,
352
348
  type: "eip-2612",
353
- provider: n
349
+ provider: t
354
350
  });
355
351
  } catch (i) {
356
352
  try {
357
- return await ce(e, a) ? await S({
358
- ...m,
353
+ return await ie(e, c) ? await A({
354
+ ...p,
359
355
  type: "dai-like",
360
- provider: n
361
- }) : /invalid signature/.test(i) || (i == null ? void 0 : i.code) === "UNPREDICTABLE_GAS_LIMIT" ? (console.debug(`[checkTokenIsPermittable] Token ${e} - ${l} might be permittable, but it's not supported for now. Reason:`, i == null ? void 0 : i.reason), {
362
- ...g,
363
- name: l
364
- }) : (console.debug(`[checkTokenIsPermittable] Failed to estimate eip-2612 permit for ${e} - ${l}`, i), {
356
+ provider: t
357
+ }) : /invalid signature/.test(i) || (i == null ? void 0 : i.code) === "UNPREDICTABLE_GAS_LIMIT" ? (console.debug(`[checkTokenIsPermittable] Token ${e} - ${s} might be permittable, but it's not supported for now. Reason:`, i == null ? void 0 : i.reason), {
358
+ ...h,
359
+ name: s
360
+ }) : (console.debug(`[checkTokenIsPermittable] Failed to estimate eip-2612 permit for ${e} - ${s}`, i), {
365
361
  error: i.message || i.toString()
366
362
  });
367
- } catch (p) {
368
- return console.debug(`[checkTokenIsPermittable] Failed to estimate dai-like permit for ${e} - ${l}`, p), {
369
- error: p.message || p.toString()
363
+ } catch (f) {
364
+ return console.debug(`[checkTokenIsPermittable] Failed to estimate dai-like permit for ${e} - ${s}`, f), {
365
+ error: f.message || f.toString()
370
366
  };
371
367
  }
372
368
  }
373
369
  }
374
- async function S(r) {
370
+ async function A(r) {
375
371
  const {
376
- provider: t,
377
- chainId: e,
378
- walletAddress: o,
379
- tokenAddress: n,
380
- tokenName: a,
381
- type: c,
382
- version: s
383
- } = r, d = await (c === "eip-2612" ? se : le)(r);
384
- return d ? (await t.estimateGas({
385
- data: d,
386
- from: o,
387
- to: n
388
- })).toNumber() > V[e] ? {
389
- type: c,
390
- version: s,
391
- name: a
372
+ provider: n,
373
+ walletAddress: e,
374
+ tokenAddress: a,
375
+ tokenName: t,
376
+ type: o,
377
+ version: c,
378
+ minGasLimit: l = K
379
+ } = r, s = await (o === "eip-2612" ? oe : se)(r);
380
+ return s ? (await n.estimateGas({
381
+ data: s,
382
+ from: e,
383
+ to: a
384
+ })).toNumber() > l ? {
385
+ type: o,
386
+ version: c,
387
+ name: t
392
388
  } : {
393
- ...g,
394
- name: a
389
+ ...h,
390
+ name: t
395
391
  } : {
396
- ...g,
397
- name: a
392
+ ...h,
393
+ name: t
398
394
  };
399
395
  }
400
- async function se(r) {
396
+ async function oe(r) {
401
397
  const {
402
- eip2612PermitUtils: t,
398
+ eip2612PermitUtils: n,
403
399
  walletAddress: e,
404
- spender: o,
405
- nonce: n,
406
- chainId: a,
400
+ spender: a,
401
+ nonce: t,
402
+ chainId: o,
407
403
  tokenName: c,
408
- tokenAddress: s,
409
- version: l
404
+ tokenAddress: l,
405
+ version: d
410
406
  } = r;
411
- return R({
412
- eip2162Utils: t,
407
+ return S({
408
+ eip2162Utils: n,
413
409
  callDataParams: [{
414
- ...oe,
410
+ ...ne,
415
411
  owner: e,
416
- spender: o,
417
- nonce: n
418
- }, +a, c, s, l]
412
+ spender: a,
413
+ nonce: t
414
+ }, +o, c, l, d]
419
415
  });
420
416
  }
421
- async function ce(r, t) {
422
- return await t.getPermitTypeHash(r) === L;
417
+ async function ie(r, n) {
418
+ return await n.getPermitTypeHash(r) === _;
423
419
  }
424
- async function le(r) {
420
+ async function se(r) {
425
421
  const {
426
- eip2612PermitUtils: t,
422
+ eip2612PermitUtils: n,
427
423
  tokenAddress: e,
428
- walletAddress: o,
429
- spender: n,
430
- nonce: a,
424
+ walletAddress: a,
425
+ spender: t,
426
+ nonce: o,
431
427
  chainId: c,
432
- tokenName: s,
433
- version: l
428
+ tokenName: l,
429
+ version: d
434
430
  } = r;
435
- return await t.getPermitTypeHash(e) === L ? M({
436
- eip2162Utils: t,
431
+ return await n.getPermitTypeHash(e) === _ ? R({
432
+ eip2162Utils: n,
437
433
  callDataParams: [{
438
- ...ae,
439
- holder: o,
440
- spender: n,
441
- nonce: a
442
- }, c, s, e, l]
434
+ ...re,
435
+ holder: a,
436
+ spender: t,
437
+ nonce: o
438
+ }, c, l, e, d]
443
439
  }) : !1;
444
440
  }
445
441
  export {
446
- w as PERMIT_SIGNER,
447
- Ie as checkIsCallDataAValidPermit,
448
- Pe as generatePermitHook,
449
- X as getPermitUtilsInstance,
450
- Te as getTokenPermitInfo,
451
- j as isSupportedPermitInfo
442
+ K as DEFAULT_MIN_GAS_LIMIT,
443
+ T as PERMIT_SIGNER,
444
+ ge as checkIsCallDataAValidPermit,
445
+ he as generatePermitHook,
446
+ z as getPermitUtilsInstance,
447
+ ye as getTokenPermitInfo,
448
+ q as isSupportedPermitInfo
452
449
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/permit-utils",
3
- "version": "0.1.1-RC.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "ethers": "^5.7.2",
package/types.d.ts CHANGED
@@ -40,5 +40,6 @@ export type GetTokenPermitInfoParams = {
40
40
  tokenAddress: string;
41
41
  chainId: number;
42
42
  provider: JsonRpcProvider;
43
+ minGasLimit?: number | undefined;
43
44
  };
44
45
  export {};