Skip to content

Conversation

@broody
Copy link
Contributor

@broody broody commented Dec 19, 2025

Summary

This PR improves error handling in the onchain checkout flow for starter packs, particularly around bridging from external networks.

Changes

Error Handling Improvements:

  • Add feeEstimationError state to layerswap hook for tracking fee estimation errors separately from general display errors
  • Clear displayError when token or wallet selection changes to provide a clean slate for retries
  • Clear displayError before sending bridge deposits
  • Fix race condition in fee estimation with isCurrent flag pattern to prevent stale requests from overwriting state
  • Handle "bridge amount too low" error with a dedicated warning card instead of generic error alert
  • Stop showing spinner in cost breakdown when there's a fee estimation error (show dash instead)

Refactoring:

  • Split pending.tsx into smaller, focused components:
    • base.tsx - Base pending state component
    • bridge.tsx - Bridge-specific pending logic with deposit polling
    • claim.tsx - Claim completion component
    • purchase.tsx - Purchase completion component
    • confirming-transaction.tsx - Transaction confirmation component
  • Add retry.ts utility for retry logic with exponential backoff

Testing

  • Tested with various wallet/token combinations
  • Verified error states are properly cleared on selection changes
  • Confirmed race condition fix prevents stale error messages

Note

Improves onchain checkout error handling (bridge fee estimation, UI states), refactors pending screens into modular components, adds a retry utility, and enables multi-network wallet selection.

  • Onchain Checkout (UI/logic):
    • Disable actions on feeEstimationError; suppress generic alert for "amount too low" and show a dedicated warning card; hide spinner and show dash in totals when fee estimation fails.
    • Clear errors on token/wallet changes and before bridge/purchase actions; wrap bridge handler to clear errors and navigate to pending.
    • Integrates feeEstimationError into disabled state and insufficient balance logic.
  • Layerswap hook:
    • Add feeEstimationError state; fix fee-estimation race with isCurrent guard; expose error through context.
    • Compute deposit with updated fees; preserve existing deposit flow.
  • Pending flow refactor:
    • Split pending.tsx into pending/base.tsx, pending/purchase.tsx, pending/claim.tsx, pending/bridge.tsx, and pending/confirming-transaction.tsx with shared transaction waiting and navigation.
    • Update router pending/index.tsx and Storybook stories to use new components.
  • Wallet Drawer:
    • Enable multiple platforms in SUPPORTED_PLATFORMS and retain controller/external wallet selection UX.
  • Utilities:
    • Add utils/retry.ts for exponential backoff and use it in pending/bridge flows.

Written by Cursor Bugbot for commit 9f150b7. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
controller-example-next Ready Ready Preview Dec 19, 2025 11:55pm
keychain Error Error Dec 19, 2025 11:55pm
keychain-storybook Ready Ready Preview Dec 19, 2025 11:55pm

- Add feeEstimationError state to layerswap hook for tracking fee estimation errors separately
- Clear displayError when token or wallet selection changes
- Clear displayError before sending deposit
- Handle 'bridge amount too low' error with dedicated warning card
- Fix race condition in fee estimation with isCurrent flag pattern
- Stop showing spinner in cost breakdown when there's a fee estimation error
- Hide generic error alert when dedicated warning is shown
onError?.(e as Error);
if (isCurrent) {
setFeeEstimationError(e as Error);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-"too low" fee estimation errors silently hidden from users

The refactoring changed fee estimation error handling to set feeEstimationError instead of calling onError. However, only errors with "too low" in their message get a dedicated warning card. Other fee estimation errors (like network failures or rate limit errors) won't set displayError (since onError is no longer called) and won't match the "too low" check, so no error message is shown to the user. The button will be disabled and cost shows a dash, but users receive no explanation of what went wrong.

Additional Locations (1)

Fix in Cursor Fix in Web

useEffect(() => {
if (!swapInput) return;

let isCurrent = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale fee error disables button after switching to starknet

When switching from an external platform (ethereum, base, etc.) to starknet, feeEstimationError is never cleared. The effect at lines 505-523 doesn't clear swapInput when switching to starknet (because selectedPlatform is truthy), so the fee-fetching effect at line 526 doesn't re-run and feeEstimationError persists. Since globalDisabled checks feeEstimationError first (line 88), a stale error from a previous platform incorrectly disables the purchase button even though starknet doesn't require fee estimation.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants