const e=require(`../../../types/ethereum-network.types.cjs`),t=require(`../../../constants/protocol.constants.cjs`),n=require(`../../utils/caseInsensitive.utils.cjs`),r=require(`../../../externalABIs/index.cjs`),i=require(`../../utils/time.utils.cjs`);var a=async(r,a,o,s,c,l=30,u=1e3)=>{let d=c.filter(({tokenAddress:e,requiredAmount:r})=>r>0n&&!n.caseInsensitiveEqual(e,t.zeroAddress));if(d.length===0)return;let f=d.map(({tokenAddress:t})=>r.getContractWithSigner(a,e.ContractType.ERC20Contract,t));for(let e=0;e<l;e+=1){let e=!0;for(let t=0;t<d.length;t+=1){let{requiredAmount:n}=d[t],r=f[t];if(BigInt(await r.allowance(o,s))<n){e=!1;break}}if(e)break;await i.waitLittle(u)}},o=async(e,a,o,s,c=30,l=1e3)=>{let u=s.filter(({tokenAddress:e,requiredAmount:r})=>r>0n&&!n.caseInsensitiveEqual(e,t.zeroAddress)&&!!e);if(u.length===0)return;let d=await Promise.all(u.map(async({tokenAddress:t})=>e.contract(r.ERC20ABI,t)));for(let e=0;e<c;e+=1){let e=!0;for(let t=0;t<u.length;t+=1){let{requiredAmount:n}=u[t],r=await d[t].allowance(a,o).call({from:a});if(BigInt(String(r))<n){e=!1;break}}if(e)break;await i.waitLittle(l)}};exports.waitForErc20Approvals=a,exports.waitForTronErc20Approvals=o;