mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Add gas constants (#11248)
This commit is contained in:
parent
64e6935558
commit
df9bc52e9f
@ -1,4 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
||||
import { txMetaStub } from '../../../../test/stub/tx-meta-stub';
|
||||
import {
|
||||
createPendingNonceMiddleware,
|
||||
@ -55,7 +56,7 @@ describe('PendingNonceMiddleware', function () {
|
||||
blockHash: null,
|
||||
blockNumber: null,
|
||||
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x1e8480',
|
||||
hash:
|
||||
'0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
|
||||
|
@ -23,6 +23,7 @@ import {
|
||||
TRANSACTION_TYPES,
|
||||
} from '../../../../shared/constants/transaction';
|
||||
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller';
|
||||
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
||||
import TransactionStateManager from './tx-state-manager';
|
||||
import TxGasUtil from './tx-gas-utils';
|
||||
import PendingTransactionTracker from './pending-tx-tracker';
|
||||
@ -30,7 +31,6 @@ import * as txUtils from './lib/util';
|
||||
|
||||
const hstInterface = new ethers.utils.Interface(abi);
|
||||
|
||||
const SIMPLE_GAS_COST = '0x5208'; // Hex for 21000, cost of a simple send.
|
||||
const MAX_MEMSTORE_TX_LIST_SIZE = 100; // Number of transactions (by unique nonces) to keep in memory
|
||||
|
||||
/**
|
||||
@ -366,7 +366,7 @@ export default class TransactionController extends EventEmitter {
|
||||
}
|
||||
|
||||
// This is a standard ether simple send, gas requirement is exactly 21k
|
||||
return { gasLimit: SIMPLE_GAS_COST };
|
||||
return { gasLimit: GAS_LIMITS.SIMPLE };
|
||||
}
|
||||
|
||||
const {
|
||||
@ -404,7 +404,7 @@ export default class TransactionController extends EventEmitter {
|
||||
from,
|
||||
to: from,
|
||||
nonce,
|
||||
gas: customGasLimit || '0x5208',
|
||||
gas: customGasLimit || GAS_LIMITS.SIMPLE,
|
||||
value: '0x0',
|
||||
gasPrice: newGasPrice,
|
||||
},
|
||||
|
9
shared/constants/gas.js
Normal file
9
shared/constants/gas.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { addHexPrefix } from 'ethereumjs-util';
|
||||
import { decimalToHex } from '../../ui/helpers/utils/conversions.util';
|
||||
|
||||
export const GAS_LIMITS = {
|
||||
// maximum gasLimit of a simple send
|
||||
SIMPLE: addHexPrefix(decimalToHex(21_000)),
|
||||
// a base estimate for token transfers.
|
||||
BASE_TOKEN_ESTIMATE: addHexPrefix(decimalToHex(100_000)),
|
||||
};
|
@ -1,3 +1,4 @@
|
||||
import { GAS_LIMITS } from '../../shared/constants/gas';
|
||||
import {
|
||||
TRANSACTION_STATUSES,
|
||||
TRANSACTION_TYPES,
|
||||
@ -16,7 +17,7 @@ export const txMetaStub = {
|
||||
type: TRANSACTION_TYPES.SENT_ETHER,
|
||||
txParams: {
|
||||
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x1e8480',
|
||||
to: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||
value: '0x0',
|
||||
@ -197,7 +198,7 @@ export const txMetaStub = {
|
||||
type: TRANSACTION_TYPES.SENT_ETHER,
|
||||
txParams: {
|
||||
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x1e8480',
|
||||
nonce: '0x4',
|
||||
to: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||
|
@ -56,6 +56,7 @@ import {
|
||||
import { MIN_GAS_LIMIT_DEC } from '../../../../pages/send/send.constants';
|
||||
import { calcMaxAmount } from '../../../../pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.utils';
|
||||
import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction';
|
||||
import { GAS_LIMITS } from '../../../../../shared/constants/gas';
|
||||
import GasModalPageContainer from './gas-modal-page-container.component';
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
@ -73,7 +74,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
const txParams = selectedTransaction?.txParams
|
||||
? selectedTransaction.txParams
|
||||
: {
|
||||
gas: send.gasLimit || '0x5208',
|
||||
gas: send.gasLimit || GAS_LIMITS.SIMPLE,
|
||||
gasPrice: send.gasPrice || getAveragePriceEstimateInHexWEI(state, true),
|
||||
value: sendToken ? '0x0' : send.amount,
|
||||
};
|
||||
@ -82,7 +83,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
const value = ownProps.transaction?.txParams?.value || txParams.value;
|
||||
const customModalGasPriceInHex = getCustomGasPrice(state) || currentGasPrice;
|
||||
const customModalGasLimitInHex =
|
||||
getCustomGasLimit(state) || currentGasLimit || '0x5208';
|
||||
getCustomGasLimit(state) || currentGasLimit || GAS_LIMITS.SIMPLE;
|
||||
const customGasTotal = calcGasTotal(
|
||||
customModalGasLimitInHex,
|
||||
customModalGasPriceInHex,
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
||||
import {
|
||||
ROPSTEN_CHAIN_ID,
|
||||
ROPSTEN_NETWORK_ID,
|
||||
@ -34,7 +35,7 @@ describe('TransactionActivityLog utils', () => {
|
||||
from: '0x50a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706',
|
||||
to: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||
value: '0x2386f26fc10000',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
},
|
||||
type: TRANSACTION_TYPES.STANDARD,
|
||||
@ -82,7 +83,7 @@ describe('TransactionActivityLog utils', () => {
|
||||
time: 1543958845581,
|
||||
txParams: {
|
||||
from: '0x50a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0x32',
|
||||
to: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||
@ -105,7 +106,7 @@ describe('TransactionActivityLog utils', () => {
|
||||
from: '0x50a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706',
|
||||
to: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||
value: '0x2386f26fc10000',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0x32',
|
||||
},
|
||||
@ -176,7 +177,7 @@ describe('TransactionActivityLog utils', () => {
|
||||
time: 1543958857697,
|
||||
txParams: {
|
||||
from: '0x50a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x481f2280',
|
||||
nonce: '0x32',
|
||||
to: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||
@ -244,7 +245,7 @@ describe('TransactionActivityLog utils', () => {
|
||||
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
@ -267,7 +268,7 @@ describe('TransactionActivityLog utils', () => {
|
||||
time: 1535507561452,
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
@ -395,7 +396,7 @@ describe('TransactionActivityLog utils', () => {
|
||||
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
|
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction';
|
||||
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
||||
import TransactionBreakdown from './transaction-breakdown.component';
|
||||
|
||||
describe('TransactionBreakdown Component', () => {
|
||||
@ -11,7 +12,7 @@ describe('TransactionBreakdown Component', () => {
|
||||
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
|
@ -5,6 +5,7 @@ import SenderToRecipient from '../../ui/sender-to-recipient';
|
||||
import TransactionBreakdown from '../transaction-breakdown';
|
||||
import TransactionActivityLog from '../transaction-activity-log';
|
||||
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction';
|
||||
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
||||
import TransactionListItemDetails from './transaction-list-item-details.component';
|
||||
|
||||
describe('TransactionListItemDetails Component', () => {
|
||||
@ -15,7 +16,7 @@ describe('TransactionListItemDetails Component', () => {
|
||||
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
@ -57,7 +58,7 @@ describe('TransactionListItemDetails Component', () => {
|
||||
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
@ -102,7 +103,7 @@ describe('TransactionListItemDetails Component', () => {
|
||||
status: 'confirmed',
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
@ -146,7 +147,7 @@ describe('TransactionListItemDetails Component', () => {
|
||||
hash: '0xaa',
|
||||
txParams: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0xa4',
|
||||
to: '0x2',
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { GAS_LIMITS } from '../../../shared/constants/gas';
|
||||
import * as utils from './confirm-tx.util';
|
||||
|
||||
describe('Confirm Transaction utils', () => {
|
||||
@ -34,7 +35,10 @@ describe('Confirm Transaction utils', () => {
|
||||
describe('getHexGasTotal', () => {
|
||||
it('should multiply the hex gasLimit and hex gasPrice values together', () => {
|
||||
expect(
|
||||
utils.getHexGasTotal({ gasLimit: '0x5208', gasPrice: '0x3b9aca00' }),
|
||||
utils.getHexGasTotal({
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
}),
|
||||
).toStrictEqual('0x1319718a5000');
|
||||
});
|
||||
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
setCustomGasPriceForRetry,
|
||||
} from '../ducks/gas/gas.duck';
|
||||
import { multiplyCurrencies } from '../helpers/utils/conversion-util';
|
||||
import { GAS_LIMITS } from '../../shared/constants/gas';
|
||||
|
||||
/**
|
||||
* Determine whether a transaction can be cancelled and provide a method to
|
||||
@ -52,13 +53,13 @@ export function useCancelTransaction(transactionGroup) {
|
||||
const cancelTransaction = useCallback(
|
||||
(event) => {
|
||||
event.stopPropagation();
|
||||
dispatch(setCustomGasLimit('0x5208'));
|
||||
dispatch(setCustomGasLimit(GAS_LIMITS.SIMPLE));
|
||||
dispatch(setCustomGasPriceForRetry(defaultNewGasPrice));
|
||||
const tx = {
|
||||
...transaction,
|
||||
txParams: {
|
||||
...transaction.txParams,
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
value: '0x0',
|
||||
},
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ import { getConversionRate, getSelectedAccount } from '../selectors';
|
||||
import { showModal } from '../store/actions';
|
||||
import { increaseLastGasPrice } from '../helpers/utils/confirm-tx.util';
|
||||
import * as actionConstants from '../store/actionConstants';
|
||||
import { GAS_LIMITS } from '../../shared/constants/gas';
|
||||
import { useCancelTransaction } from './useCancelTransaction';
|
||||
|
||||
describe('useCancelTransaction', function () {
|
||||
@ -77,7 +78,7 @@ describe('useCancelTransaction', function () {
|
||||
|
||||
// call onSubmit myself
|
||||
dispatchAction[dispatchAction.length - 1][0].value.props.onSubmit(
|
||||
'0x5208',
|
||||
GAS_LIMITS.SIMPLE,
|
||||
'0x1',
|
||||
);
|
||||
|
||||
@ -86,9 +87,9 @@ describe('useCancelTransaction', function () {
|
||||
showModal({
|
||||
name: 'CANCEL_TRANSACTION',
|
||||
transactionId,
|
||||
newGasFee: '0x5208',
|
||||
newGasFee: GAS_LIMITS.SIMPLE,
|
||||
defaultNewGasPrice: '0x1',
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
}),
|
||||
),
|
||||
).toStrictEqual(true);
|
||||
@ -147,7 +148,7 @@ describe('useCancelTransaction', function () {
|
||||
).toStrictEqual(transactionId);
|
||||
|
||||
dispatchAction[dispatchAction.length - 1][0].value.props.onSubmit(
|
||||
'0x5208',
|
||||
GAS_LIMITS.SIMPLE,
|
||||
'0x1',
|
||||
);
|
||||
|
||||
@ -156,9 +157,9 @@ describe('useCancelTransaction', function () {
|
||||
showModal({
|
||||
name: 'CANCEL_TRANSACTION',
|
||||
transactionId,
|
||||
newGasFee: '0x5208',
|
||||
newGasFee: GAS_LIMITS.SIMPLE,
|
||||
defaultNewGasPrice: '0x1',
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
}),
|
||||
),
|
||||
).toStrictEqual(true);
|
||||
|
@ -38,9 +38,6 @@ const KNOWN_RECIPIENT_ADDRESS_ERROR = 'knownAddressRecipient';
|
||||
const CONTRACT_ADDRESS_ERROR = 'contractAddressError';
|
||||
const CONFUSING_ENS_ERROR = 'confusingEnsDomain';
|
||||
|
||||
const SIMPLE_GAS_COST = '0x5208'; // Hex for 21000, cost of a simple send.
|
||||
const BASE_TOKEN_GAS_COST = '0x186a0'; // Hex for 100000, a base estimate for token transfers.
|
||||
|
||||
export {
|
||||
INSUFFICIENT_FUNDS_ERROR,
|
||||
INSUFFICIENT_TOKENS_ERROR,
|
||||
@ -57,7 +54,5 @@ export {
|
||||
NEGATIVE_ETH_ERROR,
|
||||
REQUIRED_ERROR,
|
||||
CONFUSING_ENS_ERROR,
|
||||
SIMPLE_GAS_COST,
|
||||
TOKEN_TRANSFER_FUNCTION_SIGNATURE,
|
||||
BASE_TOKEN_GAS_COST,
|
||||
};
|
||||
|
@ -11,13 +11,12 @@ import {
|
||||
import { calcTokenAmount } from '../../helpers/utils/token-util';
|
||||
import { addHexPrefix } from '../../../app/scripts/lib/util';
|
||||
|
||||
import { GAS_LIMITS } from '../../../shared/constants/gas';
|
||||
import {
|
||||
BASE_TOKEN_GAS_COST,
|
||||
INSUFFICIENT_FUNDS_ERROR,
|
||||
INSUFFICIENT_TOKENS_ERROR,
|
||||
MIN_GAS_LIMIT_HEX,
|
||||
NEGATIVE_ETH_ERROR,
|
||||
SIMPLE_GAS_COST,
|
||||
TOKEN_TRANSFER_FUNCTION_SIGNATURE,
|
||||
} from './send.constants';
|
||||
|
||||
@ -208,10 +207,10 @@ async function estimateGasForSend({
|
||||
// Geth will return '0x', and ganache-core v2.2.1 will return '0x0'
|
||||
const codeIsEmpty = !code || code === '0x' || code === '0x0';
|
||||
if (codeIsEmpty) {
|
||||
return SIMPLE_GAS_COST;
|
||||
return GAS_LIMITS.SIMPLE;
|
||||
}
|
||||
} else if (sendToken && !to) {
|
||||
return BASE_TOKEN_GAS_COST;
|
||||
return GAS_LIMITS.BASE_TOKEN_ESTIMATE;
|
||||
}
|
||||
|
||||
if (sendToken) {
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
conversionUtil,
|
||||
} from '../../helpers/utils/conversion-util';
|
||||
|
||||
import { GAS_LIMITS } from '../../../shared/constants/gas';
|
||||
import {
|
||||
calcGasTotal,
|
||||
estimateGasForSend,
|
||||
@ -23,8 +24,6 @@ import {
|
||||
} from './send.utils';
|
||||
|
||||
import {
|
||||
BASE_TOKEN_GAS_COST,
|
||||
SIMPLE_GAS_COST,
|
||||
INSUFFICIENT_FUNDS_ERROR,
|
||||
INSUFFICIENT_TOKENS_ERROR,
|
||||
} from './send.constants';
|
||||
@ -381,38 +380,38 @@ describe('send utils', () => {
|
||||
expect(result).toStrictEqual('0xabc16');
|
||||
});
|
||||
|
||||
it(`should return ${SIMPLE_GAS_COST} if ethQuery.getCode does not return '0x'`, async () => {
|
||||
it(`should return ${GAS_LIMITS.SIMPLE} if ethQuery.getCode does not return '0x'`, async () => {
|
||||
expect(baseMockParams.estimateGasMethod.callCount).toStrictEqual(0);
|
||||
const result = await estimateGasForSend({
|
||||
...baseMockParams,
|
||||
to: '0x123',
|
||||
});
|
||||
expect(result).toStrictEqual(SIMPLE_GAS_COST);
|
||||
expect(result).toStrictEqual(GAS_LIMITS.SIMPLE);
|
||||
});
|
||||
|
||||
it(`should return ${SIMPLE_GAS_COST} if not passed a sendToken or truthy to address`, async () => {
|
||||
it(`should return ${GAS_LIMITS.SIMPLE} if not passed a sendToken or truthy to address`, async () => {
|
||||
expect(baseMockParams.estimateGasMethod.callCount).toStrictEqual(0);
|
||||
const result = await estimateGasForSend({ ...baseMockParams, to: null });
|
||||
expect(result).toStrictEqual(SIMPLE_GAS_COST);
|
||||
expect(result).toStrictEqual(GAS_LIMITS.SIMPLE);
|
||||
});
|
||||
|
||||
it(`should not return ${SIMPLE_GAS_COST} if passed a sendToken`, async () => {
|
||||
it(`should not return ${GAS_LIMITS.SIMPLE} if passed a sendToken`, async () => {
|
||||
expect(baseMockParams.estimateGasMethod.callCount).toStrictEqual(0);
|
||||
const result = await estimateGasForSend({
|
||||
...baseMockParams,
|
||||
to: '0x123',
|
||||
sendToken: { address: '0x0' },
|
||||
});
|
||||
expect(result).not.toStrictEqual(SIMPLE_GAS_COST);
|
||||
expect(result).not.toStrictEqual(GAS_LIMITS.SIMPLE);
|
||||
});
|
||||
|
||||
it(`should return ${BASE_TOKEN_GAS_COST} if passed a sendToken but no to address`, async () => {
|
||||
it(`should return ${GAS_LIMITS.BASE_TOKEN_ESTIMATE} if passed a sendToken but no to address`, async () => {
|
||||
const result = await estimateGasForSend({
|
||||
...baseMockParams,
|
||||
to: null,
|
||||
sendToken: { address: '0x0' },
|
||||
});
|
||||
expect(result).toStrictEqual(BASE_TOKEN_GAS_COST);
|
||||
expect(result).toStrictEqual(GAS_LIMITS.BASE_TOKEN_ESTIMATE);
|
||||
});
|
||||
|
||||
it(`should return the adjusted blockGasLimit if it fails with a 'Transaction execution error.'`, async () => {
|
||||
|
@ -10,6 +10,7 @@ import { calcGasTotal } from '../pages/send/send.utils';
|
||||
|
||||
import { GAS_ESTIMATE_TYPES } from '../helpers/constants/common';
|
||||
import { BASIC_ESTIMATE_STATES, GAS_SOURCE } from '../ducks/gas/gas.duck';
|
||||
import { GAS_LIMITS } from '../../shared/constants/gas';
|
||||
import {
|
||||
getCurrentCurrency,
|
||||
getIsMainnet,
|
||||
@ -295,7 +296,9 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI(state) {
|
||||
const isMainnet = getIsMainnet(state);
|
||||
const showFiat = isMainnet || Boolean(showFiatInTestnets);
|
||||
const gasLimit =
|
||||
state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208';
|
||||
state.metamask.send.gasLimit ||
|
||||
getCustomGasLimit(state) ||
|
||||
GAS_LIMITS.SIMPLE;
|
||||
const { conversionRate } = state.metamask;
|
||||
const currentCurrency = getCurrentCurrency(state);
|
||||
const {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { GAS_LIMITS } from '../../shared/constants/gas';
|
||||
import {
|
||||
getCustomGasLimit,
|
||||
getCustomGasPrice,
|
||||
@ -221,7 +222,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: false,
|
||||
@ -272,7 +273,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: false,
|
||||
@ -323,7 +324,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: true,
|
||||
@ -368,7 +369,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: true,
|
||||
@ -393,7 +394,7 @@ describe('custom-gas selectors', () => {
|
||||
expect(
|
||||
getRenderableBasicEstimateData(
|
||||
test.mockState,
|
||||
'0x5208',
|
||||
GAS_LIMITS.SIMPLE,
|
||||
test.useFastestButtons,
|
||||
),
|
||||
).toStrictEqual(test.expectedResult);
|
||||
@ -429,7 +430,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 255.71,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: false,
|
||||
@ -474,7 +475,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: false,
|
||||
@ -525,7 +526,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: false,
|
||||
@ -576,7 +577,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: true,
|
||||
@ -621,7 +622,7 @@ describe('custom-gas selectors', () => {
|
||||
conversionRate: 2557.1,
|
||||
currentCurrency: 'usd',
|
||||
send: {
|
||||
gasLimit: '0x5208',
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
},
|
||||
preferences: {
|
||||
showFiatInTestnets: true,
|
||||
|
@ -5,6 +5,7 @@ import EthQuery from 'eth-query';
|
||||
import enLocale from '../../app/_locales/en/messages.json';
|
||||
import MetaMaskController from '../../app/scripts/metamask-controller';
|
||||
import { TRANSACTION_STATUSES } from '../../shared/constants/transaction';
|
||||
import { GAS_LIMITS } from '../../shared/constants/gas';
|
||||
import * as actions from './actions';
|
||||
|
||||
const middleware = [thunk];
|
||||
@ -902,8 +903,8 @@ describe('Actions', () => {
|
||||
|
||||
const expectedActions = [
|
||||
{ type: 'GAS_LOADING_STARTED' },
|
||||
{ type: 'UPDATE_GAS_LIMIT', value: '0x5208' },
|
||||
{ type: 'metamask/gas/SET_CUSTOM_GAS_LIMIT', value: '0x5208' },
|
||||
{ type: 'UPDATE_GAS_LIMIT', value: GAS_LIMITS.SIMPLE },
|
||||
{ type: 'metamask/gas/SET_CUSTOM_GAS_LIMIT', value: GAS_LIMITS.SIMPLE },
|
||||
{ type: 'UPDATE_SEND_ERRORS', value: { gasLoadingError: null } },
|
||||
{ type: 'GAS_LOADING_FINISHED' },
|
||||
];
|
||||
@ -929,7 +930,7 @@ describe('Actions', () => {
|
||||
describe('#updateTransaction', () => {
|
||||
const txParams = {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
to: '0x2',
|
||||
value: '0x0',
|
||||
@ -998,7 +999,7 @@ describe('Actions', () => {
|
||||
id: '1',
|
||||
value: {
|
||||
from: '0x1',
|
||||
gas: '0x5208',
|
||||
gas: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
to: '0x2',
|
||||
value: '0x0',
|
||||
|
Loading…
Reference in New Issue
Block a user