import type { OpenOceanStep } from '@openocean.finance/widget-types' import { formatUnits } from 'viem' import { config } from '../config.js' import type { Process } from '../core/types.js' export const getTransactionNotSentMessage = async ( step?: OpenOceanStep, process?: Process ): Promise => { let transactionNotSend = 'Transaction was not sent, your funds are still in your wallet' // add information about funds if available if (step) { const chain = await config.getChainById(step.action.fromChainId) transactionNotSend += ` (${formatUnits( BigInt(step.action.fromAmount), step.action.fromToken.decimals )} ${step.action.fromToken.symbol} on ${chain.name})` } transactionNotSend += ", please retry.
If it still doesn't work, it is safe to delete this transfer and start a new one." // add transaction explorer link if available transactionNotSend += process?.txLink ? `
You can check the failed transaction here.` : '' return transactionNotSend } export const getTransactionFailedMessage = async ( step: OpenOceanStep, txLink?: string ): Promise => { const chain = await config.getChainById(step.action.toChainId) const baseString = `It appears that your transaction may not have been successful. However, to confirm this, please check your ${chain.name} wallet for ${step.action.toToken.symbol}.` return txLink ? `${baseString} You can also check the block explorer for more information.` : baseString }