Commit 81c5841
authored
fix: cp-7.65.0 totals in MUSD conversion using max button (#26029)
## **Description**
Cherry-pick #26015 into `7.65.0` release.
Applies a Yarn patch to `@metamask/transaction-pay-controller` instead
of bumping controller version to avoid unrelated changes.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: #25972
## **Manual testing steps**
## **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]
> **Medium Risk**
> Touches transaction-pay quoting/totals and stablecoin detection, which
can affect displayed costs and max-amount behavior across networks;
mitigated by being a targeted patch and limited app-side changes.
>
> **Overview**
> Fixes transaction pay quote/total calculations by **patching
`@metamask/transaction-pay-controller` 12.1.0** rather than bumping the
dependency.
>
> The patch centralizes a multi-chain `STABLECOINS` list, treats
stablecoins as $1 in token fiat-rate logic, and changes `targetAmount`
across quotes/totals to be a `FiatValue` summed via `sumFiat` (avoiding
incorrect max/totals math). Relay quote normalization now accounts for
`fees.subsidized` by zeroing provider fees when subsidized and
optionally including the subsidized amount in the computed target fiat
value; Bridge normalization aligns `targetAmount` to fiat-only as well.
>
> On the mobile side, `useTokenFiatRates` now uses a stablecoin
allowlist (Mainnet/Arbitrum/Linea/Polygon) to return a fixed USD rate of
`1`, and the related unit test is generalized accordingly. The
Transaction Pay controller messenger drops the unused
`TokenListController:getState` action, and `package.json`/`yarn.lock`
are updated to consume the patched controller via Yarn’s `patch:`
protocol.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
61d257e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent aec791a commit 81c5841
6 files changed
Lines changed: 556 additions & 32 deletions
File tree
- .yarn/patches
- app
- components/Views/confirmations/hooks/tokens
- core/Engine/messengers/transaction-pay-controller-messenger
Lines changed: 501 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
| |||
107 | 105 | | |
108 | 106 | | |
109 | 107 | | |
110 | | - | |
| 108 | + | |
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
114 | | - | |
| 112 | + | |
115 | 113 | | |
116 | 114 | | |
117 | 115 | | |
| |||
121 | 119 | | |
122 | 120 | | |
123 | 121 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | 122 | | |
139 | 123 | | |
140 | 124 | | |
| |||
Lines changed: 24 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
15 | 33 | | |
16 | 34 | | |
17 | 35 | | |
| |||
32 | 50 | | |
33 | 51 | | |
34 | 52 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
42 | 56 | | |
43 | | - | |
| 57 | + | |
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9829 | 9829 | | |
9830 | 9830 | | |
9831 | 9831 | | |
9832 | | - | |
| 9832 | + | |
9833 | 9833 | | |
9834 | 9834 | | |
9835 | 9835 | | |
| |||
9855 | 9855 | | |
9856 | 9856 | | |
9857 | 9857 | | |
| 9858 | + | |
| 9859 | + | |
| 9860 | + | |
| 9861 | + | |
| 9862 | + | |
| 9863 | + | |
| 9864 | + | |
| 9865 | + | |
| 9866 | + | |
| 9867 | + | |
| 9868 | + | |
| 9869 | + | |
| 9870 | + | |
| 9871 | + | |
| 9872 | + | |
| 9873 | + | |
| 9874 | + | |
| 9875 | + | |
| 9876 | + | |
| 9877 | + | |
| 9878 | + | |
| 9879 | + | |
| 9880 | + | |
| 9881 | + | |
| 9882 | + | |
| 9883 | + | |
9858 | 9884 | | |
9859 | 9885 | | |
9860 | 9886 | | |
| |||
34893 | 34919 | | |
34894 | 34920 | | |
34895 | 34921 | | |
34896 | | - | |
| 34922 | + | |
34897 | 34923 | | |
34898 | 34924 | | |
34899 | 34925 | | |
| |||
0 commit comments