1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 03:20:23 +01:00

Removing EIP_1559_V2 feature flag (#13481)

This commit is contained in:
Jyoti Puri 2022-02-03 05:58:28 +05:30 committed by GitHub
parent 9e0f6f3e3e
commit 760ed3457d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 401 additions and 383 deletions

View File

@ -3,6 +3,5 @@ PASSWORD=METAMASK PASSWORD
INFURA_PROJECT_ID=00000000000 INFURA_PROJECT_ID=00000000000
SEGMENT_WRITE_KEY= SEGMENT_WRITE_KEY=
ONBOARDING_V2= ONBOARDING_V2=
EIP_1559_V2=
SWAPS_USE_DEV_APIS= SWAPS_USE_DEV_APIS=
COLLECTIBLES_V1= COLLECTIBLES_V1=

View File

@ -34,7 +34,6 @@ const metamaskrc = require('rc')('metamask', {
INFURA_PROD_PROJECT_ID: process.env.INFURA_PROD_PROJECT_ID, INFURA_PROD_PROJECT_ID: process.env.INFURA_PROD_PROJECT_ID,
ONBOARDING_V2: process.env.ONBOARDING_V2, ONBOARDING_V2: process.env.ONBOARDING_V2,
COLLECTIBLES_V1: process.env.COLLECTIBLES_V1, COLLECTIBLES_V1: process.env.COLLECTIBLES_V1,
EIP_1559_V2: process.env.EIP_1559_V2,
SEGMENT_HOST: process.env.SEGMENT_HOST, SEGMENT_HOST: process.env.SEGMENT_HOST,
SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY, SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY,
SEGMENT_BETA_WRITE_KEY: process.env.SEGMENT_BETA_WRITE_KEY, SEGMENT_BETA_WRITE_KEY: process.env.SEGMENT_BETA_WRITE_KEY,
@ -797,7 +796,6 @@ function getEnvironmentVariables({ buildType, devMode, testing }) {
SWAPS_USE_DEV_APIS: process.env.SWAPS_USE_DEV_APIS === '1', SWAPS_USE_DEV_APIS: process.env.SWAPS_USE_DEV_APIS === '1',
ONBOARDING_V2: metamaskrc.ONBOARDING_V2 === '1', ONBOARDING_V2: metamaskrc.ONBOARDING_V2 === '1',
COLLECTIBLES_V1: metamaskrc.COLLECTIBLES_V1 === '1', COLLECTIBLES_V1: metamaskrc.COLLECTIBLES_V1 === '1',
EIP_1559_V2: metamaskrc.EIP_1559_V2 === '1',
}; };
} }

View File

@ -8,7 +8,6 @@ const {
regularDelayMs, regularDelayMs,
} = require('../helpers'); } = require('../helpers');
if (process.env.EIP_1559_V2 === '1') {
describe('Editing Confirm Transaction', function () { describe('Editing Confirm Transaction', function () {
it('allows selecting high, medium, low gas estimates on edit gas fee popover', async function () { it('allows selecting high, medium, low gas estimates on edit gas fee popover', async function () {
const ganacheOptions = { const ganacheOptions = {
@ -274,4 +273,3 @@ if (process.env.EIP_1559_V2 === '1') {
); );
}); });
}); });
}

View File

@ -23,6 +23,7 @@ describe('Editing Confirm Transaction', function () {
fixtures: 'send-edit', fixtures: 'send-edit',
ganacheOptions, ganacheOptions,
title: this.test.title, title: this.test.title,
failOnConsoleError: false,
}, },
async ({ driver }) => { async ({ driver }) => {
await driver.navigate(); await driver.navigate();
@ -92,7 +93,6 @@ describe('Editing Confirm Transaction', function () {
); );
}); });
if (process.env.EIP_1559_V2 === '1') {
it('goes back from confirm page to edit eth value, baseFee, priorityFee and gas limit - 1559 V2', async function () { it('goes back from confirm page to edit eth value, baseFee, priorityFee and gas limit - 1559 V2', async function () {
const ganacheOptions = { const ganacheOptions = {
hardfork: 'london', hardfork: 'london',
@ -109,6 +109,7 @@ describe('Editing Confirm Transaction', function () {
fixtures: 'send-edit-v2', fixtures: 'send-edit-v2',
ganacheOptions, ganacheOptions,
title: this.test.title, title: this.test.title,
failOnConsoleError: false,
}, },
async ({ driver }) => { async ({ driver }) => {
await driver.navigate(); await driver.navigate();
@ -200,5 +201,4 @@ describe('Editing Confirm Transaction', function () {
}, },
); );
}); });
}
}); });

View File

@ -26,6 +26,7 @@ jest.mock('../../../../store/actions', () => ({
removePollingTokenFromAppState: jest.fn(), removePollingTokenFromAppState: jest.fn(),
setAdvancedGasFee: jest.fn(), setAdvancedGasFee: jest.fn(),
updateEventFragment: jest.fn(), updateEventFragment: jest.fn(),
createTransactionEventFragment: jest.fn(),
})); }));
const render = (defaultGasParams, contextParams) => { const render = (defaultGasParams, contextParams) => {

View File

@ -17,6 +17,7 @@ jest.mock('../../../store/actions', () => ({
.mockImplementation(() => Promise.resolve()), .mockImplementation(() => Promise.resolve()),
addPollingTokenToAppState: jest.fn(), addPollingTokenToAppState: jest.fn(),
removePollingTokenFromAppState: jest.fn(), removePollingTokenFromAppState: jest.fn(),
createTransactionEventFragment: jest.fn(),
})); }));
jest.mock('../../../contexts/transaction-modal', () => ({ jest.mock('../../../contexts/transaction-modal', () => ({

View File

@ -22,6 +22,7 @@ jest.mock('../../../store/actions', () => ({
addPollingTokenToAppState: jest.fn(), addPollingTokenToAppState: jest.fn(),
removePollingTokenFromAppState: jest.fn(), removePollingTokenFromAppState: jest.fn(),
updateTransaction: () => ({ type: 'UPDATE_TRANSACTION_PARAMS' }), updateTransaction: () => ({ type: 'UPDATE_TRANSACTION_PARAMS' }),
createTransactionEventFragment: jest.fn(),
})); }));
jest.mock('../../../contexts/transaction-modal', () => ({ jest.mock('../../../contexts/transaction-modal', () => ({

View File

@ -41,6 +41,7 @@ describe('Confirm Page Container Container Test', () => {
chainId: 'test', chainId: 'test',
identities: [], identities: [],
featureFlags: {}, featureFlags: {},
enableEIP1559V2NoticeDismissed: true,
}, },
}; };

View File

@ -20,10 +20,6 @@ import { setEnableEIP1559V2NoticeDismissed } from '../../../../store/actions';
import { getEnableEIP1559V2NoticeDismissed } from '../../../../ducks/metamask/metamask'; import { getEnableEIP1559V2NoticeDismissed } from '../../../../ducks/metamask/metamask';
import { getEIP1559V2Enabled } from '../../../../selectors'; import { getEIP1559V2Enabled } from '../../../../selectors';
const EIP_1559_V2_ENABLED =
// This is a string in unit tests but is a boolean in the browser
process.env.EIP_1559_V2 === true || process.env.EIP_1559_V2 === 'true';
export default function EnableEIP1559V2Notice({ isFirstAlert }) { export default function EnableEIP1559V2Notice({ isFirstAlert }) {
const t = useI18nContext(); const t = useI18nContext();
const history = useHistory(); const history = useHistory();
@ -32,11 +28,7 @@ export default function EnableEIP1559V2Notice({ isFirstAlert }) {
); );
const eip1559V2Enabled = useSelector(getEIP1559V2Enabled); const eip1559V2Enabled = useSelector(getEIP1559V2Enabled);
if ( if (eip1559V2Enabled || enableEIP1559V2NoticeDismissed) {
!EIP_1559_V2_ENABLED ||
eip1559V2Enabled ||
enableEIP1559V2NoticeDismissed
) {
return null; return null;
} }

View File

@ -22,6 +22,7 @@ jest.mock('../../../store/actions', () => ({
.fn() .fn()
.mockImplementation(() => Promise.resolve()), .mockImplementation(() => Promise.resolve()),
addPollingTokenToAppState: jest.fn(), addPollingTokenToAppState: jest.fn(),
createTransactionEventFragment: jest.fn(),
})); }));
const render = ({ componentProps, contextProps } = {}) => { const render = ({ componentProps, contextProps } = {}) => {

View File

@ -15,6 +15,7 @@ jest.mock('../../../store/actions', () => ({
.fn() .fn()
.mockImplementation(() => Promise.resolve()), .mockImplementation(() => Promise.resolve()),
addPollingTokenToAppState: jest.fn(), addPollingTokenToAppState: jest.fn(),
createTransactionEventFragment: jest.fn(),
})); }));
jest.mock('../../../contexts/transaction-modal', () => ({ jest.mock('../../../contexts/transaction-modal', () => ({

View File

@ -18,6 +18,7 @@ jest.mock('../../../../store/actions', () => ({
getGasFeeTimeEstimate: jest getGasFeeTimeEstimate: jest
.fn() .fn()
.mockImplementation(() => Promise.resolve('unknown')), .mockImplementation(() => Promise.resolve('unknown')),
createTransactionEventFragment: jest.fn(),
})); }));
const MOCK_FEE_ESTIMATE = { const MOCK_FEE_ESTIMATE = {

View File

@ -18,6 +18,7 @@ jest.mock('../../../store/actions', () => ({
.fn() .fn()
.mockImplementation(() => Promise.resolve()), .mockImplementation(() => Promise.resolve()),
addPollingTokenToAppState: jest.fn(), addPollingTokenToAppState: jest.fn(),
createTransactionEventFragment: jest.fn(),
})); }));
const render = ({ componentProps, contextProps } = {}) => { const render = ({ componentProps, contextProps } = {}) => {

View File

@ -1,10 +1,31 @@
import { useCallback } from 'react'; import { useCallback, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { useGasFeeContext } from '../contexts/gasFee'; import { useGasFeeContext } from '../contexts/gasFee';
import { updateEventFragment } from '../store/actions'; import {
createTransactionEventFragment,
updateEventFragment,
} from '../store/actions';
import { selectMatchingFragment } from '../selectors';
import { TRANSACTION_EVENTS } from '../../shared/constants/transaction';
export const useTransactionEventFragment = () => { export const useTransactionEventFragment = () => {
const { transaction } = useGasFeeContext(); const { transaction } = useGasFeeContext();
const fragment = useSelector((state) =>
selectMatchingFragment(state, {
fragmentOptions: {},
existingId: `transaction-added-${transaction?.id}`,
}),
);
useEffect(() => {
if (!fragment && transaction) {
createTransactionEventFragment(
transaction.id,
TRANSACTION_EVENTS.APPROVED,
);
}
}, [fragment, transaction]);
const updateTransactionEventFragment = useCallback( const updateTransactionEventFragment = useCallback(
(params) => { (params) => {

View File

@ -148,12 +148,6 @@ export default class ExperimentalTab extends PureComponent {
} }
renderEIP1559V2EnabledToggle() { renderEIP1559V2EnabledToggle() {
const EIP_1559_V2_ENABLED =
// This is a string in unit tests but is a boolean in the browser
process.env.EIP_1559_V2 === true || process.env.EIP_1559_V2 === 'true';
if (!EIP_1559_V2_ENABLED) {
return null;
}
const { t } = this.context; const { t } = this.context;
const { eip1559V2Enabled, setEIP1559V2Enabled } = this.props; const { eip1559V2Enabled, setEIP1559V2Enabled } = this.props;

View File

@ -63,6 +63,7 @@ const generateUseSelectorRouter = () => (selector) => {
setBackgroundConnection({ setBackgroundConnection({
getGasFeeTimeEstimate: jest.fn(), getGasFeeTimeEstimate: jest.fn(),
getGasFeeEstimatesAndStartPolling: jest.fn(), getGasFeeEstimatesAndStartPolling: jest.fn(),
createTransactionEventFragment: jest.fn(),
}); });
const createProps = (customProps = {}) => { const createProps = (customProps = {}) => {

View File

@ -3108,6 +3108,13 @@ export function createEventFragment(options) {
return promisifiedBackground.createEventFragment(options); return promisifiedBackground.createEventFragment(options);
} }
export function createTransactionEventFragment(transactionId, event) {
return promisifiedBackground.createTransactionEventFragment(
transactionId,
event,
);
}
export function updateEventFragment(id, payload) { export function updateEventFragment(id, payload) {
return promisifiedBackground.updateEventFragment(id, payload); return promisifiedBackground.updateEventFragment(id, payload);
} }