const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../constants/tx-confirmation.constants.cjs`);require(`../../constants/index.cjs`);const r=require(`../../error-handling/logger.cjs`),i=require(`./create-provider.cjs`);var a=`confirmed`,o=async(e,r,a={})=>{let{evmConfirmations:o=1,evmTimeoutMs:s=n.TX_CONFIRMATION_TIMEOUT_EXTENDED}=a,c=r.startsWith(`0x`)?r:`0x${r}`,l=await i.createJsonRpcProvider(e).waitForTransaction(c,o,s);if(!l||l.status!==1)throw Error(t.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED);return l},s=async(t,n,r={})=>{let{solanaCommitment:o=a}=r,{fetchRpcUrl:s}=e.networkRegistry[t];if(!s)throw Error(`RPC URL not found for the specified chain ID`);let c=await i.createCustomSolanaConnection(s,o).confirmTransaction(n,o);if(c.value.err)throw Error(`Transaction failed`);return c},c=async(t,n,i={})=>{try{if(e.isSolanaLike(t)){await s(t,n,i);return}await o(t,n.startsWith(`0x`)?n:`0x${n}`,i)}catch(e){throw r.Logger.error(`waitForTransactionConfirmation failed`,{chainId:t,txHash:n,error:e}),e}};exports.waitForEthereumTransactionConfirmation=o,exports.waitForSolanaTransactionConfirmation=s,exports.waitForTransactionConfirmation=c;