1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Use gas estimate type constants (#12460)

This commit is contained in:
David Walsh 2021-11-10 13:50:43 -06:00 committed by GitHub
parent a4053b6b88
commit 3f9ec40107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 8 deletions

View File

@ -26,6 +26,7 @@ import {
TRANSACTION_TYPES, TRANSACTION_TYPES,
TRANSACTION_ENVELOPE_TYPES, TRANSACTION_ENVELOPE_TYPES,
} from '../../../../shared/constants/transaction'; } from '../../../../shared/constants/transaction';
import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../../ui/helpers/constants/transactions';
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller'; import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller';
import { import {
GAS_LIMITS, GAS_LIMITS,
@ -1447,8 +1448,8 @@ export default class TransactionController extends EventEmitter {
sensitiveProperties: { sensitiveProperties: {
status, status,
transaction_envelope_type: isEIP1559Transaction(txMeta) transaction_envelope_type: isEIP1559Transaction(txMeta)
? 'fee-market' ? TRANSACTION_ENVELOPE_TYPE_NAMES.FEE_MARKET
: 'legacy', : TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
first_seen: time, first_seen: time,
gas_limit: gasLimit, gas_limit: gasLimit,
...gasParamsInGwei, ...gasParamsInGwei,

View File

@ -20,6 +20,7 @@ import {
GAS_ESTIMATE_TYPES, GAS_ESTIMATE_TYPES,
GAS_RECOMMENDATIONS, GAS_RECOMMENDATIONS,
} from '../../../../shared/constants/gas'; } from '../../../../shared/constants/gas';
import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../../ui/helpers/constants/transactions';
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller'; import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller';
import TransactionController, { TRANSACTION_EVENTS } from '.'; import TransactionController, { TRANSACTION_EVENTS } from '.';
@ -774,7 +775,7 @@ describe('Transaction Controller', function () {
nonce: '0x4b', nonce: '0x4b',
}, },
type: TRANSACTION_TYPES.SIMPLE_SEND, type: TRANSACTION_TYPES.SIMPLE_SEND,
transaction_envelope_type: 'legacy', transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
origin: 'metamask', origin: 'metamask',
chainId: currentChainId, chainId: currentChainId,
time: 1624408066355, time: 1624408066355,
@ -1578,7 +1579,7 @@ describe('Transaction Controller', function () {
gas_price: '2', gas_price: '2',
gas_limit: '0x7b0d', gas_limit: '0x7b0d',
first_seen: 1624408066355, first_seen: 1624408066355,
transaction_envelope_type: 'legacy', transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
status: 'unapproved', status: 'unapproved',
}, },
}; };
@ -1625,7 +1626,7 @@ describe('Transaction Controller', function () {
gas_price: '2', gas_price: '2',
gas_limit: '0x7b0d', gas_limit: '0x7b0d',
first_seen: 1624408066355, first_seen: 1624408066355,
transaction_envelope_type: 'legacy', transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
status: 'unapproved', status: 'unapproved',
}, },
}; };
@ -1674,7 +1675,7 @@ describe('Transaction Controller', function () {
gas_price: '2', gas_price: '2',
gas_limit: '0x7b0d', gas_limit: '0x7b0d',
first_seen: 1624408066355, first_seen: 1624408066355,
transaction_envelope_type: 'legacy', transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
status: 'unapproved', status: 'unapproved',
}, },
}; };
@ -1731,7 +1732,7 @@ describe('Transaction Controller', function () {
max_priority_fee_per_gas: '2', max_priority_fee_per_gas: '2',
gas_limit: '0x7b0d', gas_limit: '0x7b0d',
first_seen: 1624408066355, first_seen: 1624408066355,
transaction_envelope_type: 'fee-market', transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.FEE_MARKET,
status: 'unapproved', status: 'unapproved',
estimate_suggested: GAS_RECOMMENDATIONS.MEDIUM, estimate_suggested: GAS_RECOMMENDATIONS.MEDIUM,
estimate_used: GAS_RECOMMENDATIONS.HIGH, estimate_used: GAS_RECOMMENDATIONS.HIGH,

View File

@ -19,3 +19,8 @@ export const TOKEN_CATEGORY_HASH = {
[TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER]: true, [TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER]: true,
[TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM]: true, [TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM]: true,
}; };
export const TRANSACTION_ENVELOPE_TYPE_NAMES = {
FEE_MARKET: 'fee-market',
LEGACY: 'legacy',
};

View File

@ -17,6 +17,7 @@ import {
MOCKS, MOCKS,
} from '../../../../test/jest'; } from '../../../../test/jest';
import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network'; import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network';
import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../helpers/constants/transactions';
import FeeCard from '.'; import FeeCard from '.';
const middleware = [thunk]; const middleware = [thunk];
@ -35,7 +36,7 @@ const generateUseSelectorRouter = () => (selector) => {
return true; return true;
} }
if (selector === getGasEstimateType) { if (selector === getGasEstimateType) {
return 'fee-market'; return TRANSACTION_ENVELOPE_TYPE_NAMES.FEE_MARKET;
} }
if (selector === getGasFeeEstimates) { if (selector === getGasFeeEstimates) {
return MOCKS.createGasFeeEstimatesForFeeMarket(); return MOCKS.createGasFeeEstimatesForFeeMarket();