Skip to content

Commit 22b9eda

Browse files
runway-github[bot]Brunonascdevjoaoloureirop
authored
chore(runway): cherry-pick fix(card): delegation issues (#22249)
- fix(card): delegation issues (#22058) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> This PR addresses several issues affecting the Card experience, ensuring proper asset display, navigation flow, and data consistency across components. Fixes - Fixed an issue where assets were not loading correctly after opening the Card Home screen. - Corrected balance handling on the Change Asset Bottom Sheet — it now displays `availableBalance` for enabled tokens and the user’s total balance for disabled ones. - Restored asset icons on all asset-related bottom sheets. - Fixed incorrect titles on the Spending Limit screen: - Selecting a token that isn’t enabled now correctly shows “Change token and network.” - Pressing “Manage spending limit” on Card Home now correctly shows “Enable token.” - Resolved concurrency issues caused by promise caching in the `useLoadCardData` hook. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: Fixed issue where assets failed to load after opening the Card Home screen. CHANGELOG entry: Fixed balance display on the Change Asset Bottom Sheet to correctly show availableBalance for enabled tokens and user balance for disabled tokens. CHANGELOG entry: Restored missing asset icons on asset bottom sheets. CHANGELOG entry: Fixed incorrect Spending Limit title when selecting a token that’s not enabled (now shows “Change token and network”). CHANGELOG entry: Fixed incorrect Spending Limit title when pressing “Manage spending limit” on Card Home (now shows “Enable token”). CHANGELOG entry: Resolved concurrency and caching issues in useLoadCardData hook. ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Improve Card balances and UX (pull-to-refresh, spending limit progress), refactor delegation flow with confirmation and caching, enhance asset selection and data fetching with cache/timeout, and clear caches on logout/auth errors. > > - **Card Home UI**: > - Replace `useAssetBalance` with batched `useAssetBalances` and update balance fallbacks. > - Add pull‑to‑refresh, spending limit progress bar, and close‑limit warning with actions. > - Improve navigation for managing spending limit; hide Solana-specific options; show error toast on enable failure. > - **Spending Limit**: > - Refactor delegation flow: SIWE signing, tx confirmation wait, cache clearing, success/error toasts, navigation blocking; add `UserCancelledError`. > - **Asset Selection Bottom Sheet**: > - Use `useAssetBalances` for fiat/token balances and icons; filter/sort tokens; priority update with cache invalidation; Solana footer link. > - **Data Fetching & Caching**: > - Add `useGetDelegationSettings` and `useGetCardExternalWalletDetails` with caching and timeouts. > - Fix `useLoadCardData` concurrency; add `fetchAllData`/`refetchAllData` and authenticated data wiring. > - Clear all card caches on auth errors/logout. > - **SDK/Utils**: > - Simplify ethers provider usage; remove unused network mapper; add `mapCaipChainIdToChainName` and safer chainId utils. > - **Copy/UX**: > - Update warning dismiss label; add `enable_card_error` locale. > - **Tests**: > - Add/expand comprehensive unit/integration tests and snapshots across new hooks, components, and flows. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 69808b6. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [0b3c740](0b3c740) Co-authored-by: Bruno Nascimento <brunonascimentodev@gmail.com> Co-authored-by: João Loureiro <175489935+joaoloureirop@users.noreply.github.com>
1 parent ca57ba1 commit 22b9eda

36 files changed

+7859
-3022
lines changed

app/components/UI/Card/Views/CardHome/CardHome.test.tsx

Lines changed: 310 additions & 146 deletions
Large diffs are not rendered by default.

app/components/UI/Card/Views/CardHome/CardHome.tsx

Lines changed: 177 additions & 46 deletions
Large diffs are not rendered by default.

app/components/UI/Card/Views/CardHome/__snapshots__/CardHome.test.tsx.snap

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,18 @@ exports[`CardHome Component renders correctly and matches snapshot 1`] = `
320320
"paddingBottom": 32,
321321
}
322322
}
323+
refreshControl={
324+
<RefreshControlMock
325+
colors={
326+
[
327+
"#4459ff",
328+
]
329+
}
330+
onRefresh={[Function]}
331+
refreshing={false}
332+
tintColor="#121314"
333+
/>
334+
}
323335
showsVerticalScrollIndicator={false}
324336
style={
325337
{
@@ -328,6 +340,7 @@ exports[`CardHome Component renders correctly and matches snapshot 1`] = `
328340
}
329341
}
330342
>
343+
<RCTRefreshControl />
331344
<View>
332345
<View
333346
style={
@@ -413,6 +426,7 @@ exports[`CardHome Component renders correctly and matches snapshot 1`] = `
413426
}
414427
>
415428
<RNSVGSvgView
429+
address="0x78...x789"
416430
align="xMidYMid"
417431
bbHeight="100%"
418432
bbWidth="100%"
@@ -712,6 +726,55 @@ exports[`CardHome Component renders correctly and matches snapshot 1`] = `
712726
}
713727
/>
714728
</RNSVGGroup>
729+
<RNSVGText
730+
content={null}
731+
dx={[]}
732+
dy={[]}
733+
fill={
734+
{
735+
"payload": 4294967295,
736+
"type": 0,
737+
}
738+
}
739+
font={
740+
{
741+
"fontSize": "40px",
742+
"fontWeight": 800,
743+
}
744+
}
745+
propList={
746+
[
747+
"fill",
748+
]
749+
}
750+
rotate={[]}
751+
x={
752+
[
753+
40,
754+
]
755+
}
756+
y={
757+
[
758+
500,
759+
]
760+
}
761+
>
762+
<RNSVGTSpan
763+
content="0x78...x789"
764+
dx={[]}
765+
dy={[]}
766+
fill={
767+
{
768+
"payload": 4278190080,
769+
"type": 0,
770+
}
771+
}
772+
font={{}}
773+
rotate={[]}
774+
x={[]}
775+
y={[]}
776+
/>
777+
</RNSVGText>
715778
<RNSVGDefs>
716779
<RNSVGClipPath
717780
fill={
@@ -1439,6 +1502,18 @@ exports[`CardHome Component renders correctly with privacy mode enabled 1`] = `
14391502
"paddingBottom": 32,
14401503
}
14411504
}
1505+
refreshControl={
1506+
<RefreshControlMock
1507+
colors={
1508+
[
1509+
"#4459ff",
1510+
]
1511+
}
1512+
onRefresh={[Function]}
1513+
refreshing={false}
1514+
tintColor="#121314"
1515+
/>
1516+
}
14421517
showsVerticalScrollIndicator={false}
14431518
style={
14441519
{
@@ -1447,6 +1522,7 @@ exports[`CardHome Component renders correctly with privacy mode enabled 1`] = `
14471522
}
14481523
}
14491524
>
1525+
<RCTRefreshControl />
14501526
<View>
14511527
<View
14521528
style={
@@ -1532,6 +1608,7 @@ exports[`CardHome Component renders correctly with privacy mode enabled 1`] = `
15321608
}
15331609
>
15341610
<RNSVGSvgView
1611+
address="0x78...x789"
15351612
align="xMidYMid"
15361613
bbHeight="100%"
15371614
bbWidth="100%"
@@ -1831,6 +1908,55 @@ exports[`CardHome Component renders correctly with privacy mode enabled 1`] = `
18311908
}
18321909
/>
18331910
</RNSVGGroup>
1911+
<RNSVGText
1912+
content={null}
1913+
dx={[]}
1914+
dy={[]}
1915+
fill={
1916+
{
1917+
"payload": 4294967295,
1918+
"type": 0,
1919+
}
1920+
}
1921+
font={
1922+
{
1923+
"fontSize": "40px",
1924+
"fontWeight": 800,
1925+
}
1926+
}
1927+
propList={
1928+
[
1929+
"fill",
1930+
]
1931+
}
1932+
rotate={[]}
1933+
x={
1934+
[
1935+
40,
1936+
]
1937+
}
1938+
y={
1939+
[
1940+
500,
1941+
]
1942+
}
1943+
>
1944+
<RNSVGTSpan
1945+
content="0x78...x789"
1946+
dx={[]}
1947+
dy={[]}
1948+
fill={
1949+
{
1950+
"payload": 4278190080,
1951+
"type": 0,
1952+
}
1953+
}
1954+
font={{}}
1955+
rotate={[]}
1956+
x={[]}
1957+
y={[]}
1958+
/>
1959+
</RNSVGText>
18341960
<RNSVGDefs>
18351961
<RNSVGClipPath
18361962
fill={

0 commit comments

Comments
 (0)