diff --git a/app/scripts/controllers/network/pending-middleware.test.js b/app/scripts/controllers/network/pending-middleware.test.js index 49e60aaa4..9d89e59f1 100644 --- a/app/scripts/controllers/network/pending-middleware.test.js +++ b/app/scripts/controllers/network/pending-middleware.test.js @@ -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', diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 9b7011a66..fa7c46a2b 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -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, }, diff --git a/shared/constants/gas.js b/shared/constants/gas.js new file mode 100644 index 000000000..03f8e29f7 --- /dev/null +++ b/shared/constants/gas.js @@ -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)), +}; diff --git a/test/stub/tx-meta-stub.js b/test/stub/tx-meta-stub.js index 0af67dd20..bb1fc4f99 100644 --- a/test/stub/tx-meta-stub.js +++ b/test/stub/tx-meta-stub.js @@ -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', diff --git a/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index 4dbbeec22..0c1597fe3 100644 --- a/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -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, diff --git a/ui/components/app/transaction-activity-log/transaction-activity-log.util.test.js b/ui/components/app/transaction-activity-log/transaction-activity-log.util.test.js index af7adee79..50a221a9e 100644 --- a/ui/components/app/transaction-activity-log/transaction-activity-log.util.test.js +++ b/ui/components/app/transaction-activity-log/transaction-activity-log.util.test.js @@ -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', diff --git a/ui/components/app/transaction-breakdown/transaction-breakdown.component.test.js b/ui/components/app/transaction-breakdown/transaction-breakdown.component.test.js index fb7916c46..3ac6aa268 100644 --- a/ui/components/app/transaction-breakdown/transaction-breakdown.component.test.js +++ b/ui/components/app/transaction-breakdown/transaction-breakdown.component.test.js @@ -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', diff --git a/ui/components/app/transaction-list-item-details/transaction-list-item-details.component.test.js b/ui/components/app/transaction-list-item-details/transaction-list-item-details.component.test.js index 409ca1092..4164de3a3 100644 --- a/ui/components/app/transaction-list-item-details/transaction-list-item-details.component.test.js +++ b/ui/components/app/transaction-list-item-details/transaction-list-item-details.component.test.js @@ -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', diff --git a/ui/helpers/utils/confirm-tx.util.test.js b/ui/helpers/utils/confirm-tx.util.test.js index 2dc8af0ce..71cd49a5a 100644 --- a/ui/helpers/utils/confirm-tx.util.test.js +++ b/ui/helpers/utils/confirm-tx.util.test.js @@ -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'); }); diff --git a/ui/hooks/useCancelTransaction.js b/ui/hooks/useCancelTransaction.js index 03bad3c54..389c2dcfa 100644 --- a/ui/hooks/useCancelTransaction.js +++ b/ui/hooks/useCancelTransaction.js @@ -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', }, }; diff --git a/ui/hooks/useCancelTransaction.test.js b/ui/hooks/useCancelTransaction.test.js index 28453bc6c..6bc391475 100644 --- a/ui/hooks/useCancelTransaction.test.js +++ b/ui/hooks/useCancelTransaction.test.js @@ -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); diff --git a/ui/pages/send/send.constants.js b/ui/pages/send/send.constants.js index ffeaf0397..ba5113603 100644 --- a/ui/pages/send/send.constants.js +++ b/ui/pages/send/send.constants.js @@ -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, }; diff --git a/ui/pages/send/send.utils.js b/ui/pages/send/send.utils.js index 1603061e2..12ebc901f 100644 --- a/ui/pages/send/send.utils.js +++ b/ui/pages/send/send.utils.js @@ -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) { diff --git a/ui/pages/send/send.utils.test.js b/ui/pages/send/send.utils.test.js index 06d3d8edc..f1da44f9b 100644 --- a/ui/pages/send/send.utils.test.js +++ b/ui/pages/send/send.utils.test.js @@ -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 () => { diff --git a/ui/selectors/custom-gas.js b/ui/selectors/custom-gas.js index 4485c2086..ce921eda5 100644 --- a/ui/selectors/custom-gas.js +++ b/ui/selectors/custom-gas.js @@ -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 { diff --git a/ui/selectors/custom-gas.test.js b/ui/selectors/custom-gas.test.js index 8838641fe..a81982f81 100644 --- a/ui/selectors/custom-gas.test.js +++ b/ui/selectors/custom-gas.test.js @@ -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, diff --git a/ui/store/actions.test.js b/ui/store/actions.test.js index 73975843d..cf32bac46 100644 --- a/ui/store/actions.test.js +++ b/ui/store/actions.test.js @@ -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',