Repository navigation
Fix DFX back button, sell amount and geo-block - #6342
Conversation
Bugbot is paused — on-demand spend limit reachedBugbot 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
left a comment
There was a problem hiding this comment.
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: shareddfxApi.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,RampIpCountryErrortranslated intranslateError, the login onfetchDfx, an accurate CHANGELOG line, and an updatedresolveDeepQuerycomment. - 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, thehasWebViewcomments 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 mentionsdfxApi. - 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: subjectKeep 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.
| ) | ||
| const text = await authResponse.text() | ||
| // DFX answers 403 "The country of IP address is not allowed": | ||
| if (authResponse.status === 403 && /country/i.test(text)) { |
There was a problem hiding this comment.
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.
| ## 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 |
There was a problem hiding this comment.
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.
| // 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 |
There was a problem hiding this comment.
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.
| // scene is focused (see BlurBackground): | ||
| const isSceneFocused = useIsFocused() | ||
| const sceneBlurTargetRef = useSceneBlurTarget(isSceneFocused) | ||
| const sceneBlurTargetRef = useSceneBlurTarget(isSceneFocused && !hasWebView) |
There was a problem hiding this comment.
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.
| @@ -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): | |||
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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.
| query: Record<string, string> | ||
| ): Promise<string | undefined> { | ||
| const fiatAmount = query['amount-out'] | ||
| const chain = DFX_CHAINS[request.wallet.currencyInfo.pluginId] |
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
|
One more fixup since my review: 19b3a59 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 The fix: 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):
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 Before merge: rebase onto develop (only |
paullinator
left a comment
There was a problem hiding this comment.
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.mdconflicts), then autosquash. The squash stops once onCHANGELOG.mdat 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.
83362a4 to
9454e29
Compare
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.
9454e29 to
11cea21
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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 | ||
| } |
There was a problem hiding this comment.
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)
Triggered by team rule: Edge shared bug rules
Reviewed by Cursor Bugbot for commit 11cea21. Configure here.


Description
Fixes four 4.53 QA bugs in the DFX ramp:
PUT /v1/sell/quotefor the crypto amount and passes it asamount-in. If DFX can't quote, it passes the fiat asamount-out, which DFX converts only after the user picks a bank account.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.drawVk->renderLayersImpl). WebView scenes now sethasWebView, 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?
Dependencies
none
Requirements
If you have made any visual changes to the GUI. Make sure you have: