Skip to content

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

Draft
sirpy with 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
sirpy with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-error-message-on-swap

Conversation

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown

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
@L03TJ3 L03TJ3 removed this from GoodBounties May 22, 2026
@L03TJ3 L03TJ3 moved this to Blocked in GoodBounties Jun 12, 2026
@L03TJ3 L03TJ3 moved this from Blocked to In Review in GoodBounties Jun 12, 2026
@JHON12091986

Copy link
Copy Markdown

I'd like to work on this bounty. I have experience with React and UI/UX. I'll fix the error display so it only shows when the transaction actually fails, not when it completes successfully.

ETA: 1-2 days.

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

4 participants