Commit 95b96ca
authored
fix: cp-7.60.0 automatic highest balance token in metamask pay (MetaMask#23152)
## **Description**
Automatically select the highest balance token on any chain in Perps and
Predict deposits.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: MetaMask#23131
## **Manual testing steps**
## **Screenshots/Recordings**
### **Before**
### **After**
## **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]
> Simplifies automatic pay token selection to the first available token
with balance, falling back to target token when none or on hardware
wallets, and updates tests accordingly.
>
> - **Logic (useAutomaticTransactionPayToken.ts)**
> - Replace multi-step selection (target match → highest balance same
chain → highest balance alt chain) with simple rule: pick `tokens[0]` if
any; otherwise fall back to required target token; always fall back for
hardware wallets.
> - **Tests (useAutomaticTransactionPayToken.test.ts)**
> - Update expectations to select the first available token.
> - Remove scenarios around highest-balance and cross-chain selection.
> - Keep fallbacks: target token when no tokens, hardware wallets, and
disabled state does nothing.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6907490. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b58ddba commit 95b96ca
2 files changed
Lines changed: 8 additions & 80 deletions
File tree
- app/components/Views/confirmations/hooks/pay
Lines changed: 5 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | 91 | | |
96 | 92 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 93 | | |
114 | 94 | | |
115 | 95 | | |
116 | 96 | | |
117 | 97 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 98 | + | |
123 | 99 | | |
124 | 100 | | |
125 | 101 | | |
126 | 102 | | |
127 | 103 | | |
128 | 104 | | |
129 | 105 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 106 | + | |
151 | 107 | | |
152 | 108 | | |
153 | 109 | | |
154 | 110 | | |
155 | | - | |
156 | | - | |
| 111 | + | |
| 112 | + | |
157 | 113 | | |
158 | 114 | | |
159 | 115 | | |
| |||
Lines changed: 3 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 100 | + | |
129 | 101 | | |
130 | | - | |
131 | | - | |
| 102 | + | |
| 103 | + | |
132 | 104 | | |
133 | 105 | | |
134 | 106 | | |
| |||
0 commit comments