Skip to content

Commit e8401ae

Browse files
fix: max mUSD conversion displays wrong value (#29175)
## **Description** Fixes the max mUSD conversion showing an inflated receive amount. Relay previously charged a fee and reimbursed it on the destination side; they have since stopped charging the fee, so our compensating adjustment now over-reports the received value. Bumps `@metamask/transaction-pay-controller` from `^19.1.1` to `^19.2.1`, which stops double-counting the subsidised fee in Relay quote target amounts, and patches the installed package to rename the Relay gasless feature flag from `executeEnabled` to `gaslessEnabled` so older, known-broken versions cannot be re-enabled by the flag (which predates per-version gating). ## **Changelog** CHANGELOG entry: Fixed max mUSD conversion displaying an inflated receive amount. ## **Related issues** Fixes: #29173 ## **Manual testing steps** ```gherkin Feature: Max mUSD conversion displays correct value Scenario: user converts max USDC to mUSD Given a 7.74 build with this patch installed And the user holds some USDC When the user taps max on the mUSD conversion screen Then the displayed mUSD receive amount matches the USDC balance (no inflation) ``` ## **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] > **Medium Risk** > Updates core transaction/pay controller dependencies and applies a patch that changes which remote feature flag enables Relay gasless execution, which could affect pay/quote flows if flag configuration or dependency behavior differs from expectations. > > **Overview** > Fixes an inflated “max” conversion receive amount by bumping `@metamask/transaction-pay-controller` to `^19.2.1` (and aligning related controller versions via `yarn.lock`/resolutions). > > Adds a patch to `@metamask/transaction-pay-controller` that switches the Relay enablement check from `confirmations_pay.payStrategies.relay.executeEnabled` to `...relay.gaslessEnabled`, preventing older broken builds from being re-enabled by the previous flag name. > > Separately removes the locally-defined `MANTLE` entry from `NETWORK_CHAIN_ID` in `customNetworks.tsx` (relying on `CHAIN_IDS` for it instead). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 67e50b9. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c249da7 commit e8401ae

4 files changed

Lines changed: 175 additions & 92 deletions

File tree

app/util/networks/customNetworks.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ export const NETWORK_CHAIN_ID: {
391391
readonly TEMPO_MAINNET: '0x1079';
392392
readonly CHILIZ: '0x15b38';
393393
readonly STABLE_MAINNET: '0x3dc';
394-
readonly MANTLE: '0x1388';
395394
} & typeof CHAIN_IDS = {
396395
FLARE_MAINNET: '0xe',
397396
SONGBIRD_TESTNET: '0x13',
@@ -438,7 +437,6 @@ export const NETWORK_CHAIN_ID: {
438437
TEMPO_MAINNET: '0x1079',
439438
CHILIZ: '0x15b38',
440439
STABLE_MAINNET: '0x3dc',
441-
MANTLE: '0x1388',
442440
...CHAIN_IDS,
443441
};
444442

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@
198198
"expo-web-browser@npm:~14.0.2": "patch:expo-web-browser@npm%3A14.0.2#~/.yarn/patches/expo-web-browser-npm-14.0.2-98d00ce880.patch",
199199
"@metamask/messenger@^0.3.0": "^1.0.0",
200200
"@metamask/accounts-controller": "^37.2.0",
201-
"@metamask/profile-sync-controller": "^28.0.2"
201+
"@metamask/profile-sync-controller": "^28.0.2",
202+
"@metamask/transaction-controller@^63.0.0": "^64.2.0",
203+
"@metamask/transaction-controller@^63.3.1": "^64.2.0"
202204
},
203205
"dependencies": {
204206
"@braze/react-native-sdk": "patch:@braze/react-native-sdk@npm%3A19.1.0#~/.yarn/patches/@braze-react-native-sdk-npm-19.1.0-076-reactmoduleinfo.patch",
@@ -325,7 +327,7 @@
325327
"@metamask/superstruct": "^3.2.1",
326328
"@metamask/swappable-obj-proxy": "^2.1.0",
327329
"@metamask/transaction-controller": "^64.2.0",
328-
"@metamask/transaction-pay-controller": "^19.1.1",
330+
"@metamask/transaction-pay-controller": "^19.2.1",
329331
"@metamask/tron-wallet-snap": "^1.25.2",
330332
"@metamask/utils": "^11.11.0",
331333
"@myx-trade/sdk": "^0.1.265",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
diff --git a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.cjs b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.cjs
2+
index 66884ed..d475de2 100644
3+
--- a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.cjs
4+
+++ b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.cjs
5+
@@ -238,7 +238,8 @@ exports.getPayStrategiesConfig = getPayStrategiesConfig;
6+
function isRelayExecuteEnabled(messenger) {
7+
const state = messenger.call('RemoteFeatureFlagController:getState');
8+
const featureFlags = state.remoteFeatureFlags?.confirmations_pay ?? {};
9+
- return featureFlags.payStrategies?.relay?.executeEnabled ?? false;
10+
+ // Renamed from `executeEnabled` so the flag cannot re-enable the flow on older broken versions (predates version support).
11+
+ return featureFlags.payStrategies?.relay?.gaslessEnabled ?? false;
12+
}
13+
exports.isRelayExecuteEnabled = isRelayExecuteEnabled;
14+
/**
15+
diff --git a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.mjs b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.mjs
16+
index c8b2f8a..5ab03a9 100644
17+
--- a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.mjs
18+
+++ b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.mjs
19+
@@ -232,7 +232,7 @@ export function getPayStrategiesConfig(messenger) {
20+
export function isRelayExecuteEnabled(messenger) {
21+
const state = messenger.call('RemoteFeatureFlagController:getState');
22+
const featureFlags = state.remoteFeatureFlags?.confirmations_pay ?? {};
23+
- return featureFlags.payStrategies?.relay?.executeEnabled ?? false;
24+
+ return featureFlags.payStrategies?.relay?.gaslessEnabled ?? false;
25+
}
26+
/**
27+
* Get the origin gas overhead to include in Relay quote requests
28+
diff --git a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.cts b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.cts
29+
index 0ef444d..0538026 100644
30+
--- a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.cts
31+
+++ b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.cts
32+
@@ -41,7 +41,7 @@ export type PayStrategiesConfigRaw = {
33+
across?: AcrossConfigRaw;
34+
relay?: {
35+
enabled?: boolean;
36+
- executeEnabled?: boolean;
37+
+ gaslessEnabled?: boolean;
38+
originGasOverhead?: string;
39+
pollingInterval?: number;
40+
pollingTimeout?: number;
41+
diff --git a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.mts b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.mts
42+
index e08336e..8dd8f42 100644
43+
--- a/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.mts
44+
+++ b/node_modules/@metamask/transaction-pay-controller/dist/utils/feature-flags.d.mts
45+
@@ -41,7 +41,7 @@ export type PayStrategiesConfigRaw = {
46+
across?: AcrossConfigRaw;
47+
relay?: {
48+
enabled?: boolean;
49+
- executeEnabled?: boolean;
50+
+ gaslessEnabled?: boolean;
51+
originGasOverhead?: string;
52+
pollingInterval?: number;
53+
pollingTimeout?: number;

0 commit comments

Comments
 (0)