Skip to content

Commit 4bd6f1e

Browse files
authored
fix: cp-7.46.0 Fix Approval component to unnecessary override on confirmation (#14935)
<!-- 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? --> Legacy `Approval` component overriding `EIP-1559` transaction and it's gas values - when confirmations gets approved it's unnecessarily collecting and updating big chunk of `transaction` object. This PR aims to remove that update since it's unnecessary. ## **Related issues** Fixes: MetaMask/MetaMask-planning#4775 ## **Manual testing steps** 1. Go to test-dapp 2. Connect Sepolia or LineaSepolia 3. Try "Send EIP1559 transaction" or "Create ERC20 token". Those should be functional and working ## **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.
1 parent 14d2e69 commit 4bd6f1e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

  • app/components/Views/confirmations/legacy/Approval

app/components/Views/confirmations/legacy/Approval/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { PureComponent } from 'react';
2+
import { TransactionEnvelopeType } from '@metamask/transaction-controller';
23
import { StyleSheet, AppState, Alert, InteractionManager } from 'react-native';
34
import Engine from '../../../../../core/Engine';
45
import PropTypes from 'prop-types';
@@ -379,8 +380,8 @@ class Approval extends PureComponent {
379380
request_source: this.originIsMMSDKRemoteConn
380381
? AppConstants.REQUEST_SOURCES.SDK_REMOTE_CONN
381382
: this.originIsWalletConnect
382-
? AppConstants.REQUEST_SOURCES.WC
383-
: AppConstants.REQUEST_SOURCES.IN_APP_BROWSER,
383+
? AppConstants.REQUEST_SOURCES.WC
384+
: AppConstants.REQUEST_SOURCES.IN_APP_BROWSER,
384385
};
385386

386387
try {
@@ -497,7 +498,6 @@ class Approval extends PureComponent {
497498
const { KeyringController, ApprovalController } = Engine.context;
498499
const {
499500
transactions,
500-
chainId,
501501
shouldUseSmartTransaction,
502502
simulationData: { isUpdatedAfterSecurityCheck } = {},
503503
navigation,
@@ -565,20 +565,23 @@ class Approval extends PureComponent {
565565
},
566566
(transactionMeta) => transactionMeta.id === transaction.id,
567567
);
568+
await KeyringController.resetQRKeyringState();
568569

569570
const fullTx = transactions.find(({ id }) => id === transaction.id);
570571

572+
if (fullTx.txParams.type !== TransactionEnvelopeType.legacy) {
573+
// For EIP-1559 transactions, we need to remove gasPrice as it's not compatible
574+
delete transaction.gasPrice;
575+
}
576+
571577
const updatedTx = {
572578
...fullTx,
573579
txParams: {
574-
...fullTx.txParams,
575580
...transaction,
576-
chainId,
577581
},
578582
};
579583

580584
await updateTransaction(updatedTx);
581-
await KeyringController.resetQRKeyringState();
582585

583586
// For Ledger Accounts we handover the signing to the confirmation flow
584587
if (isLedgerAccount) {

0 commit comments

Comments
 (0)