Skip to content

Fix DFX back button, sell amount and geo-block - #6342

Merged
peachbits merged 4 commits into
developfrom
matthew/fix-dfx-ramp-issues
Nov 18, 2026
Merged

peachbits merged 4 commits into
developfrom
matthew/fix-dfx-ramp-issues

Conversation

@peachbits

@peachbits peachbits commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes four 4.53 QA bugs in the DFX ramp:

  • Back arrows don't leave DFX (iOS) (Asana): the header back button acted on whichever plugin webview mounted last, and nothing ever unregistered it. The Buy and Sell tabs each keep a plugin scene mounted, so back in one tab could act on the other tab's webview. It now follows the focused scene.
  • Sell BTC amount not prefilled (Android) (Asana): a sell entered in fiat opened DFX with no amount, so DFX showed its 0.001 BTC default. Edge now asks DFX's public PUT /v1/sell/quote for the crypto amount and passes it as amount-in. If DFX can't quote, it passes the fiat as amount-out, which DFX converts only after the user picks a bank account.
  • No Edge wallet option (iOS) (Asana): DFX rejects logins by the country of the IP address (403 "The country of IP address is not allowed"), whatever region the user chose in Edge. Edge fell back to plain DFX, which shows its wallet list with no Edge tile. Edge now shows an error and doesn't open DFX. Other login failures still open the plain link.
  • Android crash opening DFX (Asana): on Android 12+ the header and tab bar blur the focused scene by redrawing it into an offscreen layer. With a WebView in that scene, Chromium's Vulkan draw code aborts (SIGTRAP on the RenderThread, drawVk -> renderLayersImpl). WebView scenes now set hasWebView, so the chrome uses its plain tint over them. On a Pixel 9 Pro (Android 17, WebView 157), opening DFX crashed 6 times in about 12 tries before this change and 0 in 13 after. Blurred modals over a constantly redrawing DFX page (27 shown) also did not crash.

Tested: jest (168 suites), tsc and eslint pass on each commit. The Android crash fix was tested on a Pixel 9 Pro. The other fixes are not yet tested on a device or with an EU VPN.

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

@peachbits
peachbits marked this pull request as ready for review November 17, 2026 19:32
@cursor

cursor Bot commented Nov 17, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@paullinator paullinator left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed with the Edge review conventions (edge-conventions review-code), against 530f31a. Each inline comment says which commit addresses it. All the fixes are pushed to this branch as new commits on top, so the commits under review are untouched:

Fixups

  • bcf6d23 fixup! Scope the plugin back button to the focused scene: unit tests for the back-button handoff.
  • f22a400 fixup! Prefill the crypto amount on fiat-entered DFX sells: shared dfxApi.ts (DFX_API_URL, fetchDfx), an uncleaner for the quote request, the query lookup, and the missing quote and plugin tests, with a shared fake fetch.
  • 37930c9 fixup! Stop DFX launches that DFX blocks by country: a precise country match on DFX's error body, RampIpCountryError translated in translateError, the login on fetchDfx, an accurate CHANGELOG line, and an updated resolveDeepQuery comment.
  • c5821bf fixup! Keep WebViews out of the chrome blur on Android: modal sheet and QR underlay blurs fall back to their tint over a focused WebView scene on Android, the hasWebView comments are accurate, and there are tests.

Amends (message only)

  • 9328232 amend! Scope the plugin back button to the focused scene: body rewrapped to 72 columns.
  • ebc6c43 amend! Prefill the crypto amount on fiat-entered DFX sells: subject shortened to 47 characters (Prefill crypto amount on fiat-entered DFX sells), body rewrapped, and it now mentions dfxApi.
  • a2d97bb amend! Stop DFX launches that DFX blocks by country: describes the NestJS-body match, RampIpCountryError, and that only Bitcoin and EVM wallets are covered.
  • 345ec23 amend! Keep WebViews out of the chrome blur on Android: subject Keep WebViews out of the blur on Android, and the body covers the modal blurs and iOS.

The pre-commit hook (lint, tsc, the full jest suite) passed on every fixup, at 170 suites and 1653 tests.

Before squashing: git rebase -i --autosquash stops once, in CHANGELOG.md, on 37930c9. The Android crash line above the country line only arrives with the later blur commit. Keep the fixup's country line and drop the conflict markers. Everything else squashes cleanly to the same tree.

Device testing: only the Android crash fix was tested on a device so far. The iOS back button, the Android sell prefill and the country block still need checks on device, the country block through a VPN exit in a country DFX blocks. A Mason build of this branch is in progress for testing on the iPhone 13 Pro and Pixel 8. Also, the template's "Tested on Android device" box can be ticked for the Pixel 9 Pro test.

Comment thread src/plugins/ramps/dfx/dfxSession.ts Outdated
)
const text = await authResponse.text()
// DFX answers 403 "The country of IP address is not allowed":
if (authResponse.status === 403 && /country/i.test(text)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

status === 403 && /country/i.test(text) is too fragile and too loose at the same time. If DFX rewords the message, the 403 becomes a generic error, fetchDfxSessionQuery swallows it and opens the plain link again, which is the bug this fixes. And any other 403 that mentions a country (residence, KYC) gets reported to the user as an IP-location block. The raw response is also thrown away, so a wrong match can't be diagnosed.

Addressed in 37930c9 (fixup! Stop DFX launches that DFX blocks by country): fetchDfx parses DFX's NestJS error body ({ statusCode, message, error }) with a cleaner and matches /\bcountry of (the )?IP\b/i. The error keeps DFX's response as serverMessage. Tests pin the exact body, and a 403 about "country of residence" now falls back to the plain link.

Comment thread CHANGELOG.md Outdated
## Unreleased (develop)

- fixed: Android crash when opening DFX and other web pages on some Android 12+ phones, where the blurred header and tab bar redrew the page
- fixed: DFX shows an error instead of opening when it blocks the country of the user's internet connection

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The country check only runs in the /auth login, which only DFX_SESSION_CHAINS do (Bitcoin and the EVM chains). Solana and Monero have no session login, so DFX still opens for them when it blocks the country. This line promised the fix for DFX in general.

Addressed in 37930c9 (fixup! Stop DFX launches that DFX blocks by country): the line now says it covers Bitcoin and EVM wallets, which Edge logs in to DFX. Detecting the block for Solana and Monero would need some other DFX request to probe with, so I left that out.

Comment thread src/components/common/SceneWrapper.tsx Outdated
// True if this scene has a bottom tab bar:
hasTabs?: boolean

// True if the scene shows a WebView. The header and tab bar then use their

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment reads as if hasWebView turns the blur off everywhere. It only matters on Android: ChromeBlurBackground reads the scene target only in its isAndroid branch and always renders the native blur on iOS. The prop also affects the footer and notification cards, not just the header and tab bar.

Addressed in c5821bf (fixup! Keep WebViews out of the chrome blur on Android): the comment says Android 12+ only, lists every surface it affects, and says iOS keeps its native blur.

Comment thread src/components/common/SceneWrapper.tsx Outdated
// scene is focused (see BlurBackground):
const isSceneFocused = useIsFocused()
const sceneBlurTargetRef = useSceneBlurTarget(isSceneFocused)
const sceneBlurTargetRef = useSceneBlurTarget(isSceneFocused && !hasWebView)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hasWebView only takes the WebView scene away from the chrome blur. On Android 12+, ModalBlurBackground and BlurUnderlayReversed render AndroidBlur with no targetRef, so they sample the app-level <BlurTarget> in Providers.tsx. That target wraps <Main />, WebView scenes included, and EdgeProvider opens Airship modals right over the plugin WebView (the wallet pickers and the confirm in EdgeProviderServer.tsx). If drawing a WebView into an offscreen blur layer is what trips Chromium, those modals take the same path. Your 27 blurred modals without a crash suggest it's rarer there, but the explanation doesn't say why it would be safe.

Addressed in c5821bf (fixup! Keep WebViews out of the chrome blur on Android): a focused WebView scene now counts itself in the scene blur registry, and while one is focused the modal sheet and QR underlay blurs fall back to their tint on Android. useSceneBlurTarget(focused, hasWebView) does both jobs. BlurBackground.test.tsx covers the chrome and modal surfaces over WebView and ordinary scenes. iOS is unchanged.

Comment thread src/components/common/SceneWrapper.tsx Outdated
@@ -179,7 +186,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
// Publish this scene's content as the blur target chrome samples while the
// scene is focused (see BlurBackground):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: this still says the scene publishes its blur target "while the scene is focused", but the condition is now focused and no WebView.

Addressed in c5821bf (fixup! Keep WebViews out of the chrome blur on Android).

if (dfxFiat == null) throw new Error(`no DFX fiat ${fiat}`)

const quote = asDfxSellQuoteResponse(
await fetchDfx('/sell/quote', {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: the responses go through cleaners, but the request body is a hand-built object passed to JSON.stringify. We prefer uncleaners for serializing.

Addressed in f22a400 (fixup! Prefill the crypto amount on fiat-entered DFX sells): asDfxSellQuoteRequest and wasDfxSellQuoteRequest in dfxRampTypes.ts.

Comment thread src/plugins/ramps/dfx/dfxRampPlugin.ts Outdated
query: Record<string, string>
): Promise<string | undefined> {
const fiatAmount = query['amount-out']
const chain = DFX_CHAINS[request.wallet.currencyInfo.pluginId]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: this looks DFX_CHAINS up again, though makeDfxRequestQuery already put the blockchain and asset in the query passed in. The quote ends up built from two sources.

Addressed in f22a400 (fixup! Prefill the crypto amount on fiat-entered DFX sells): it reads blockchain, asset-in, asset-out and amount-out from the query.

})
})

describe('a fiat-entered sell', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only the fiat-entered sell path of fetchFiatSellCryptoAmount is tested. A crypto-entered buy also produces amount-out (holding a crypto amount), so the direction !== 'sell' check is what stops a crypto amount from being quoted as fiat, and nothing covers it. The mocks are also never cleared between tests.

Addressed in f22a400 (fixup! Prefill the crypto amount on fiat-entered DFX sells): jest.clearAllMocks() in afterEach, plus approve cases for a crypto-entered buy and sell that assert no quote call and an unchanged query.

quoteStatus = 200
quoteAmount = 0.003502
console.warn = jest.fn()
global.fetch = (async (input: unknown, init?: RequestInit) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Untested failure paths: the 10 s timeout, an unknown fiat, and a failed /asset or /fiat. The mock also accepts any /asset? URL, so the blockchains filter is never checked. And this fetch mock is nearly a line-for-line copy of the one in dfxSession.test.ts.

Addressed in f22a400 (fixup! Prefill the crypto amount on fiat-entered DFX sells): timeout (fake timers), unknown-fiat and HTTP 500 cases, and an assertion on the exact /asset?blockchains=Bitcoin URL. Both test files now use a shared installFakeFetch and makeTextResponse in src/util/fake/fakeFetch.ts; the session test moved over in 37930c9 (fixup! Stop DFX launches that DFX blocks by country).

* focus rather than whichever webview mounted last.
* Returns a cleanup that releases the button if this scene still holds it.
*/
export function setPluginScene(plugin: PluginScene): () => void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nothing tests this handoff: the same-scene guard in the cleanup is the subtle part, since it stops a blurring scene from releasing the button after the newly focused one claimed it. Reverting the fix would pass CI.

Addressed in bcf6d23 (fixup! Scope the plugin back button to the focused scene): GuiPluginBackButton.test.tsx covers the last registration winning, a late blur leaving the focused scene in charge, a release then a new registration, and a press after release doing nothing.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@paullinator

Copy link
Copy Markdown
Member

One more fixup since my review: 19b3a59 fixup! Scope the plugin back button to the focused scene, for the iOS back arrow.

What was still wrong: on an iPhone build of this branch, the header back arrow never left DFX, even with DFX open in only one tab. So the iOS QA bug wasn't the cross-tab registration alone. DFX's deep link replaces its /buy history entry, then pushes /login. The webview reports canGoBack, and webView.goBack() pops to /buy, where DFX pushes /login again, so the arrow looks dead. I confirmed this sequence in a desktop browser against app.dfx.swiss.

The fix: src/components/navigation/pluginBackHistory.ts, used by EdgeProviderComponent. A back press remembers the page it started from. If the webview is on that page again within 1.5 s (the redirect bounced it back), the arrow leaves the scene. A real step back ends on a different page and stays in the webview. It has 8 unit tests in pluginBackHistory.test.ts. The pre-commit hook passed: 171 suites, 1661 tests.

Device results: I built this branch with Mason, plus a separate unmerged branch that points the app at the tester servers and enables DFX there. I tested through the maestro-d hub on an iPhone 13 Pro (iOS 26.6.1) and a Pixel 8 (Android 16):

iOS Android
Back arrow, DFX in one tab ✅ leaves in one press (with 19b3a59) ✅
Back arrow, DFX open in Buy and Sell ✅ each tab's arrow acts on its own DFX —
Back from a real DFX page (menu > Support) ✅ back to DFX's login first, then out —
Country block (BTC buy from a US connection) ✅ alert, DFX doesn't open ✅
WebView blur crash — ✅ 12/12 open/back cycles, no crash
Fiat sell prefill ⚠️ not verified ⚠️ not verified

The sell prefill couldn't be seen: DFX shows its own login before the sell form, and BTC is blocked from the US. DFX's public quote API does return the amount the app reads. QA's exact case, a fiat-entered BTC sell from an allowed country such as an EU VPN exit, is still untested. Android hasn't been retested on the build that includes 19b3a59.

Before merge: rebase onto develop (only CHANGELOG.md conflicts), then autosquash. The squash stops once on CHANGELOG.md at 37930c9; keep the fixup's country line.

@paullinator paullinator left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving so you're not blocked on me. As the PR owner, please review my fixup and amend commits before merging, especially the two that change behaviour: 19b3a59 (back-button bounce check) and c5821bf (modal and QR blur fallback over WebView scenes on Android).

Still to do before merge:

  • Rebase onto develop (only CHANGELOG.md conflicts), then autosquash. The squash stops once on CHANGELOG.md at 37930c9; keep the fixup's country line.
  • Get the fiat-entered BTC sell prefill checked from an allowed country (an EU VPN exit, or QA). It hasn't been verified on a device.
  • Optionally recheck the Android back arrow on a build that includes 19b3a59.

@peachbits
peachbits force-pushed the matthew/fix-dfx-ramp-issues branch from 83362a4 to 9454e29 Compare November 18, 2026 07:22
The header back button calls whichever plugin scene registered last,
and nothing ever unregistered. The Buy and Sell tabs each keep a plugin
scene mounted, so after opening a plugin in both tabs the back button
in one tab acted on the other tab's webview and stack. QA saw the DFX
back arrows fail to leave DFX on iOS.

Register on focus and release on blur, so the button always acts on the
scene the user is looking at.
A sell entered in fiat opened DFX with no amount, so DFX showed its own
default (0.001 BTC). DFX does read a fiat `amount-out` on its sell
screen, but it only turns that into a crypto amount once the user picks
a bank account.

Ask DFX's public sell quote API for the crypto amount that pays out the
entered fiat, and open DFX with that as `amount-in`, beside the login.
If DFX cannot quote it, open with the fiat as `amount-out` instead.
Only fiat-entered sells are quoted. The DFX API URL and fetch helper
live in dfxApi.
DFX refuses logins by the country of the IP address, whatever region
the user chose in Edge. It answers with NestJS's 403 body, whose message
is "The country of IP address is not allowed". The login fell back to
the plain DFX link, which showed DFX's wallet grid with competitor
wallets and no Edge option, and DFX's own login fails from there the
same way.

Recognize that message in fetchDfx and throw a RampIpCountryError,
which translateError shows as DFX not accepting connections from the
user's country, instead of opening DFX. Other login failures, including
other 403s, still open the plain link. Only Bitcoin and EVM wallets log
in to DFX, so the check covers those.
On Android 12+ the header and tab bar blur the focused scene by
redrawing its BlurTargetView recording through a blur effect, which
renders it into an offscreen layer. When the scene holds a WebView,
Chromium's Vulkan draw functor hits a CHECK while drawing into that
layer and kills the app with SIGTRAP on the RenderThread. QA saw this
as an intermittent crash opening DFX (Pixel 8 Pro, Android 17, WebView
157).

Let scenes declare hasWebView. Such scenes do not publish their blur
target, so the chrome falls back to its plain tint and never redraws
the WebView. While one is focused, the modal sheet and QR underlay
blurs, which sample the app-level target holding the scene, use their
tint too. iOS blurs natively and is unaffected. On a Pixel 9 Pro
(Android 17, WebView 157) opening DFX crashed 6 times in about 12 tries
before this change and 0 in 13 after.
@peachbits
peachbits force-pushed the matthew/fix-dfx-ramp-issues branch from 9454e29 to 11cea21 Compare November 18, 2026 08:51
@peachbits
peachbits merged commit 11a2f98 into develop Nov 18, 2026
6 of 7 checks passed
@peachbits
peachbits deleted the matthew/fix-dfx-ramp-issues branch November 18, 2026 08:52

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 11cea21. Configure here.

} catch (error: unknown) {
console.warn(`DFX sell quote failed: ${String(error)}`)
return undefined
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quote path swallows IP country errors

Medium Severity

fetchDfxSellCryptoAmount catches every error, including RampIpCountryError, and returns undefined. Session login rethrows that error so DFX does not open, but the quote runs beside it in Promise.all. When login is skipped or fails for another reason, a geo-blocked fiat-entered sell still opens DFX. dont-mask-errors

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by team rule: Edge shared bug rules

Reviewed by Cursor Bugbot for commit 11cea21. Configure here.

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