@cowprotocol/permit-utils 0.2.0 → 0.3.1

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