Skip to content

Suppress false Reserve Approve/Swap failures on Celo nonce preflight exceptions#636

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-error-message-on-swap
Draft

Suppress false Reserve Approve/Swap failures on Celo nonce preflight exceptions#636
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-error-message-on-swap

Conversation

Copy link
Copy Markdown

Copilot AI commented May 13, 2026

Reserve swaps on Celo were surfacing an error modal before wallet signature (Approve transaction failed / Swap transaction failed) even when the transaction later completed successfully. The UI was treating a transient preflight CALL_EXCEPTION on method="nonce()" as a terminal tx failure.

  • Problem scope

    • Error modal shown too early in Reserve swap flow on Celo.
    • False negative UX: failure displayed, then MetaMask signing + on-chain tx still succeeds.
  • UI error handling update (mentoReserve.tsx)

    • Added a narrow guard for preflight nonce-call exceptions:
      • matches CALL_EXCEPTION
      • matches method="nonce()"
    • Applied guard to both approve.state.status === 'Exception' and swap.state.status === 'Exception'.
    • Existing error modal behavior is unchanged for all other exception types.
  • Behavioral impact

    • Suppresses misleading pre-signature errors specific to transient nonce preflight calls.
    • Preserves user-visible failures for real approve/swap exceptions.
const NONCE_METHOD_REGEX = /method\s*=\s*"nonce\(\)"/i
const CALL_EXCEPTION_REGEX = /call_exception/i

const isSwapPreflightNonceException = Boolean(
  swap?.state?.errorMessage &&
    CALL_EXCEPTION_REGEX.test(swap.state.errorMessage) &&
    NONCE_METHOD_REGEX.test(swap.state.errorMessage)
)

if (swap?.state?.status === 'Exception' && !isSwapPreflightNonceException) {
  setError({
    message: i18n._(t`Swap transaction failed, please try again.`),
    reason: decodeTransactionErrorReason(swap.state.errorMessage),
  })
}

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 13, 2026

Deploying goodprotocolui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9c49146
Status: ✅  Deploy successful!
Preview URL: https://e320c237.goodprotocolui.pages.dev
Branch Preview URL: https://copilot-fix-error-message-on.goodprotocolui.pages.dev

View logs

Copilot AI changed the title [WIP] Fix error message displayed before approve/swap on Celo Reserve Suppress false Reserve Approve/Swap failures on Celo nonce preflight exceptions May 13, 2026
Copilot finished work on behalf of sirpy May 13, 2026 09:05
Copilot AI requested a review from sirpy May 13, 2026 09:05
@L03TJ3 L03TJ3 moved this from Ready-For-Assignment to In Review in GoodBounties May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

Bug: Error displayed before Approve/Swap on Celo Reserve, but transaction completes

3 participants