diff --git a/background/services/chain/index.ts b/background/services/chain/index.ts index d436699c0..a64c1cc9c 100644 --- a/background/services/chain/index.ts +++ b/background/services/chain/index.ts @@ -581,15 +581,25 @@ export default class ChainService extends BaseService { // eslint-disable-next-line @typescript-eslint/no-explicit-any const anyError: any = error - if ( - "code" in anyError && - anyError.code === Logger.errors.UNPREDICTABLE_GAS_LIMIT - ) { - gasEstimationError = anyError.error ?? "Unknown transaction error." + if ("code" in anyError) { + if (anyError.code === Logger.errors.UNPREDICTABLE_GAS_LIMIT) { + gasEstimationError = anyError.error ?? "Unknown transaction error." + } + + if (anyError.code === Logger.errors.INSUFFICIENT_FUNDS) { + gasEstimationError = anyError.error ?? "Insufficient funds error." + + if ( + "annotation" in transactionRequest && + transactionRequest.annotation !== undefined + ) { + transactionRequest.annotation.warnings ??= [] + transactionRequest.annotation.warnings.push("insufficient-funds") + } + } } } } - // We use the estimate as the actual limit only if user did not specify the // gas explicitly or if it was set below the minimum network-allowed value. if ( diff --git a/background/services/enrichment/transactions.ts b/background/services/enrichment/transactions.ts index e081ab82a..00fe4babf 100644 --- a/background/services/enrichment/transactions.ts +++ b/background/services/enrichment/transactions.ts @@ -248,10 +248,6 @@ export default async function resolveTransactionAnnotation( if (!txAnnotation.warnings.includes("insufficient-funds")) { txAnnotation.warnings.push("insufficient-funds") } - } else { - txAnnotation.warnings = txAnnotation.warnings.filter( - (warning) => warning !== "insufficient-funds", - ) } // If the transaction has been mined, get the block and set the timestamp