Commit 7648fd7
authored
feat: cp-7.60.0 validate source amount in metamask pay (#22758)
## **Description**
Validate the raw source amount in MetaMask Pay after quotes are
retrieved.
Also validate the source network fee using the max raw amount, rather
than the estimated USD value.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
[#6263](MetaMask/MetaMask-planning#6263)
#22722
## **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]
> Validates MetaMask Pay source amounts and max network fees using new
totals fields, consolidates insufficient-fee alerts, updates fee
displays/metrics, and bumps transaction-pay-controller to v7.
>
> - **Confirmations / Pay**:
> - **Validation & totals**: Use
`totals.fees.sourceNetwork.estimate.usd` for displayed network fees and
validate fees with raw amounts (`sourceAmount.raw` +
`fees.sourceNetwork.max.*`).
> - **Alerts**: Add `AlertKeys.InsufficientPayTokenFees`; fold
native-fee checks into `useInsufficientPayTokenBalanceAlert`; remove
`useInsufficientPayTokenNativeAlert`; update alert metrics mapping and
alert filtering; rename prop to `pendingAmountUsd`.
> - **UI**: `BridgeFeeRow` sums provider + source network estimate +
target network; tooltip network fee uses estimate.
> - **Metrics**: `mm_pay_network_fee_usd` now from
`fees.sourceNetwork.estimate.usd`; strategy/quote metrics unchanged.
> - **Tokens**: `useTokenWithBalance` now exposes `balanceRaw`.
> - **Selectors**: Default `selectTransactionPayTokensByTransactionId`
to `[]`.
> - **I18n**: Update `insufficient_pay_token_balance_fees.message` copy.
> - **Dependencies**: Bump `@metamask/transaction-pay-controller` to
`^7.0.0`.
> - **Tests**: Update/add tests for new fee fields, alerts, metrics, and
token balance raw support.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
7a2c188. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 4a528d0 commit 7648fd7
File tree
20 files changed
+389
-357
lines changed- app
- components/Views/confirmations
- components/rows/bridge-fee-row
- constants
- hooks
- alerts
- metrics
- pay
- tokens
- transactions
- selectors
- locales/languages
20 files changed
+389
-357
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 0 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
118 | 116 | | |
119 | 117 | | |
120 | 118 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | 119 | | |
131 | 120 | | |
132 | 121 | | |
| |||
155 | 144 | | |
156 | 145 | | |
157 | 146 | | |
158 | | - | |
159 | 147 | | |
160 | 148 | | |
161 | 149 | | |
| |||
219 | 207 | | |
220 | 208 | | |
221 | 209 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | 210 | | |
226 | 211 | | |
227 | 212 | | |
| |||
238 | 223 | | |
239 | 224 | | |
240 | 225 | | |
241 | | - | |
242 | 226 | | |
243 | 227 | | |
244 | 228 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
| |||
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
42 | | - | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
| |||
50 | 47 | | |
51 | 48 | | |
52 | 49 | | |
53 | | - | |
54 | 50 | | |
55 | 51 | | |
56 | 52 | | |
| |||
0 commit comments