MetaMask / MetaMask/metamask-mobile
Update confirmation flow for fiat payment path
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
**Goal**
When the user confirms a transaction with fiat payment selected, trigger the ramp purchase flow instead of direct transaction submission. After the ramp purchase completes, auto-submit the transaction so the `TransactionPayController` FiatStrategy can poll the order and relay the funds.
**Scope**
- **`useTransactionConfirm`**:
- Read `fiatPayment` via `useTransactionPayFiatPayment()`.
- Derive `isFiatPaymentSelected` and `quickBuyOrderId`.
- In `onConfirm`:
- If fiat is selected AND no `quickBuyOrderId` yet → trigger ramp flow (placeholder for `startHeadlessRamp`, not yet available).
- If fiat is selected AND `quickBuyOrderId` exists → proceed with normal confirmation (the FiatStrategy in the controller handles order polling).
- Otherwise → existing confirmation logic completely unchanged.
- **`useTransactionPayAutoFiatSubmission`** (new hook):
- Watches `fiatPayment.quickBuyOrderId` changes via `useEffect`.
- When a new `quickBuyOrderId` appears (and a payment method is selected), auto-calls `onConfirm()`.
- Deduplicates by tracking submitted order IDs in a `useRef>`.
- On failure, removes the order ID from the tracking set so retry is possible.
- This bridges the gap between "ramp purchase completed" and "transaction submission with FiatStrategy".
**Acceptance criteria**
- Pressing confirm with fiat selected + no order ID triggers ramp flow (placeholder).
- Pressing confirm with fiat selected + existing order ID proceeds with normal confirmation.
- Auto-submission fires exactly once per unique `quickBuyOrderId`.
- Failed auto-submission clears the order ID from tracking so retry is possible.
- Non-fiat confirmation flow is completely unchanged.
- Unit tests for both hooks.
**Out of scope**
- Full `startHeadlessRamp` integration — placeholder only until the Ramp team delivers the API.
- `quickBuyCallbackRegistry` — may not be needed with headless ramp approach.
- Core `FiatStrategy` quote/submit logic.
**Key files**
- `app/components/Views/confirmations/hooks/transactions/useTransactionConfirm.ts`
- `app/components/Views/confirmations/hooks/pay/useTransactionPayAutoFiatSubmission.ts` — **new**
Contributor guide
Research direction
Start with app/components/Views/confirmations/hooks/transactions/useTransactionConfirm.ts and the existing confirmation tests, then inspect the new hook path at app/components/Views/confirmations/hooks/pay/useTransactionPayAutoFiatSubmission.ts. Add unit tests for both hooks covering fiat and non-fiat confirmation, unique order IDs, and retry after failure. Done means all acceptance criteria pass without changing the existing non-fiat flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- frontend, mobile
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100