mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
remove ui lookup of lastGasPrice field (#11411)
This commit is contained in:
parent
3aae36754f
commit
844a021fcd
@ -11,8 +11,6 @@ import {
|
|||||||
getHexGasTotal,
|
getHexGasTotal,
|
||||||
addFiat,
|
addFiat,
|
||||||
addEth,
|
addEth,
|
||||||
increaseLastGasPrice,
|
|
||||||
hexGreaterThan,
|
|
||||||
} from '../../helpers/utils/confirm-tx.util';
|
} from '../../helpers/utils/confirm-tx.util';
|
||||||
|
|
||||||
import { getTokenData, sumHexes } from '../../helpers/utils/transactions.util';
|
import { getTokenData, sumHexes } from '../../helpers/utils/transactions.util';
|
||||||
@ -180,32 +178,6 @@ export function updateNonce(nonce) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function increaseFromLastGasPrice(txData) {
|
|
||||||
const {
|
|
||||||
lastGasPrice,
|
|
||||||
txParams: { gasPrice: previousGasPrice } = {},
|
|
||||||
} = txData;
|
|
||||||
|
|
||||||
// Set the minimum to a 10% increase from the lastGasPrice.
|
|
||||||
const minimumGasPrice = increaseLastGasPrice(lastGasPrice);
|
|
||||||
const gasPriceBelowMinimum = hexGreaterThan(
|
|
||||||
minimumGasPrice,
|
|
||||||
previousGasPrice,
|
|
||||||
);
|
|
||||||
const gasPrice =
|
|
||||||
!previousGasPrice || gasPriceBelowMinimum
|
|
||||||
? minimumGasPrice
|
|
||||||
: previousGasPrice;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...txData,
|
|
||||||
txParams: {
|
|
||||||
...txData.txParams,
|
|
||||||
gasPrice,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateTxDataAndCalculate(txData) {
|
export function updateTxDataAndCalculate(txData) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
@ -303,12 +275,7 @@ export function setTransactionToConfirm(transactionId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (transaction.txParams) {
|
if (transaction.txParams) {
|
||||||
const { lastGasPrice } = transaction;
|
dispatch(updateTxDataAndCalculate(transaction));
|
||||||
const txData = lastGasPrice
|
|
||||||
? increaseFromLastGasPrice(transaction)
|
|
||||||
: transaction;
|
|
||||||
dispatch(updateTxDataAndCalculate(txData));
|
|
||||||
|
|
||||||
const { txParams } = transaction;
|
const { txParams } = transaction;
|
||||||
|
|
||||||
if (txParams.data) {
|
if (txParams.data) {
|
||||||
|
@ -51,7 +51,6 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
hexTransactionAmount: PropTypes.string,
|
hexTransactionAmount: PropTypes.string,
|
||||||
hexTransactionFee: PropTypes.string,
|
hexTransactionFee: PropTypes.string,
|
||||||
hexTransactionTotal: PropTypes.string,
|
hexTransactionTotal: PropTypes.string,
|
||||||
isTxReprice: PropTypes.bool,
|
|
||||||
methodData: PropTypes.object,
|
methodData: PropTypes.object,
|
||||||
nonce: PropTypes.string,
|
nonce: PropTypes.string,
|
||||||
useNonceField: PropTypes.bool,
|
useNonceField: PropTypes.bool,
|
||||||
@ -649,7 +648,6 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
render() {
|
render() {
|
||||||
const { t } = this.context;
|
const { t } = this.context;
|
||||||
const {
|
const {
|
||||||
isTxReprice,
|
|
||||||
fromName,
|
fromName,
|
||||||
fromAddress,
|
fromAddress,
|
||||||
toName,
|
toName,
|
||||||
@ -709,7 +707,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
toAddress={toAddress}
|
toAddress={toAddress}
|
||||||
toEns={toEns}
|
toEns={toEns}
|
||||||
toNickname={toNickname}
|
toNickname={toNickname}
|
||||||
showEdit={onEdit && !isTxReprice}
|
showEdit={onEdit}
|
||||||
action={functionType}
|
action={functionType}
|
||||||
title={title}
|
title={title}
|
||||||
titleComponent={this.renderTitleComponent()}
|
titleComponent={this.renderTitleComponent()}
|
||||||
|
@ -78,7 +78,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
provider: { chainId },
|
provider: { chainId },
|
||||||
} = metamask;
|
} = metamask;
|
||||||
const { tokenData, txData, tokenProps, nonce } = confirmTransaction;
|
const { tokenData, txData, tokenProps, nonce } = confirmTransaction;
|
||||||
const { txParams = {}, lastGasPrice, id: transactionId, type } = txData;
|
const { txParams = {}, id: transactionId, type } = txData;
|
||||||
const transaction =
|
const transaction =
|
||||||
Object.values(unapprovedTxs).find(
|
Object.values(unapprovedTxs).find(
|
||||||
({ id }) => id === (transactionId || Number(paramsTransactionId)),
|
({ id }) => id === (transactionId || Number(paramsTransactionId)),
|
||||||
@ -107,7 +107,6 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const addressBookObject = addressBook[checksummedAddress];
|
const addressBookObject = addressBook[checksummedAddress];
|
||||||
const toEns = ensResolutionsByAddress[checksummedAddress] || '';
|
const toEns = ensResolutionsByAddress[checksummedAddress] || '';
|
||||||
const toNickname = addressBookObject ? addressBookObject.name : '';
|
const toNickname = addressBookObject ? addressBookObject.name : '';
|
||||||
const isTxReprice = Boolean(lastGasPrice);
|
|
||||||
const transactionStatus = transaction ? transaction.status : '';
|
const transactionStatus = transaction ? transaction.status : '';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -165,7 +164,6 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
tokenData,
|
tokenData,
|
||||||
methodData,
|
methodData,
|
||||||
tokenProps,
|
tokenProps,
|
||||||
isTxReprice,
|
|
||||||
conversionRate,
|
conversionRate,
|
||||||
transactionStatus,
|
transactionStatus,
|
||||||
nonce,
|
nonce,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user