diff --git a/.metamaskrc.dist b/.metamaskrc.dist index da42a6508..8d7507e86 100644 --- a/.metamaskrc.dist +++ b/.metamaskrc.dist @@ -3,6 +3,5 @@ PASSWORD=METAMASK PASSWORD INFURA_PROJECT_ID=00000000000 SEGMENT_WRITE_KEY= ONBOARDING_V2= -EIP_1559_V2= SWAPS_USE_DEV_APIS= COLLECTIBLES_V1= diff --git a/development/build/scripts.js b/development/build/scripts.js index 156f49e6e..c317180e2 100644 --- a/development/build/scripts.js +++ b/development/build/scripts.js @@ -34,7 +34,6 @@ const metamaskrc = require('rc')('metamask', { INFURA_PROD_PROJECT_ID: process.env.INFURA_PROD_PROJECT_ID, ONBOARDING_V2: process.env.ONBOARDING_V2, COLLECTIBLES_V1: process.env.COLLECTIBLES_V1, - EIP_1559_V2: process.env.EIP_1559_V2, SEGMENT_HOST: process.env.SEGMENT_HOST, SEGMENT_WRITE_KEY: process.env.SEGMENT_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', ONBOARDING_V2: metamaskrc.ONBOARDING_V2 === '1', COLLECTIBLES_V1: metamaskrc.COLLECTIBLES_V1 === '1', - EIP_1559_V2: metamaskrc.EIP_1559_V2 === '1', }; } diff --git a/test/e2e/tests/edit-gas-fee.spec.js b/test/e2e/tests/edit-gas-fee.spec.js index 9c43c9e79..a00b18a0c 100644 --- a/test/e2e/tests/edit-gas-fee.spec.js +++ b/test/e2e/tests/edit-gas-fee.spec.js @@ -8,270 +8,268 @@ const { regularDelayMs, } = require('../helpers'); -if (process.env.EIP_1559_V2 === '1') { - describe('Editing Confirm Transaction', function () { - it('allows selecting high, medium, low gas estimates on edit gas fee popover', async function () { - const ganacheOptions = { - hardfork: 'london', - accounts: [ - { - secretKey: - '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - await withFixtures( +describe('Editing Confirm Transaction', function () { + it('allows selecting high, medium, low gas estimates on edit gas fee popover', async function () { + const ganacheOptions = { + hardfork: 'london', + accounts: [ { - fixtures: 'eip-1559-v2', - ganacheOptions, - title: this.test.title, + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: convertToHexValue(25000000000000000000), }, - async ({ driver }) => { - await driver.navigate(); + ], + }; + await withFixtures( + { + fixtures: 'eip-1559-v2', + ganacheOptions, + title: this.test.title, + }, + async ({ driver }) => { + await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); - const transactionAmounts = await driver.findElements( - '.currency-display-component__text', + const transactionAmounts = await driver.findElements( + '.currency-display-component__text', + ); + const transactionAmount = transactionAmounts[0]; + assert.equal(await transactionAmount.getText(), '2.2'); + + // update estimates to high + await driver.clickElement('[data-testid="edit-gas-fee-button"]'); + await driver.delay(regularDelayMs); + await driver.clickElement('[data-testid="edit-gas-fee-item-high"]'); + await driver.delay(regularDelayMs); + await driver.waitForSelector({ text: '🦍' }); + await driver.waitForSelector({ + text: 'Aggressive', + }); + + // update estimates to medium + await driver.clickElement('[data-testid="edit-gas-fee-button"]'); + await driver.delay(regularDelayMs); + await driver.clickElement('[data-testid="edit-gas-fee-item-medium"]'); + await driver.delay(regularDelayMs); + await driver.waitForSelector({ text: '🦊' }); + await driver.waitForSelector({ + text: 'Market', + }); + + // update estimates to low + await driver.clickElement('[data-testid="edit-gas-fee-button"]'); + await driver.delay(regularDelayMs); + await driver.clickElement('[data-testid="edit-gas-fee-item-low"]'); + await driver.delay(regularDelayMs); + await driver.waitForSelector({ text: '🐢' }); + await driver.waitForSelector({ + text: 'Low', + }); + await driver.waitForSelector('[data-testid="low-gas-fee-alert"]'); + + // confirms the transaction + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + await driver.delay(regularDelayMs); + + await driver.clickElement('[data-testid="home__activity-tab"]'); + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .transaction-list-item', ); - const transactionAmount = transactionAmounts[0]; - assert.equal(await transactionAmount.getText(), '2.2'); + return confirmedTxes.length === 1; + }, 10000); - // update estimates to high - await driver.clickElement('[data-testid="edit-gas-fee-button"]'); - await driver.delay(regularDelayMs); - await driver.clickElement('[data-testid="edit-gas-fee-item-high"]'); - await driver.delay(regularDelayMs); - await driver.waitForSelector({ text: '🦍' }); - await driver.waitForSelector({ - text: 'Aggressive', - }); - - // update estimates to medium - await driver.clickElement('[data-testid="edit-gas-fee-button"]'); - await driver.delay(regularDelayMs); - await driver.clickElement('[data-testid="edit-gas-fee-item-medium"]'); - await driver.delay(regularDelayMs); - await driver.waitForSelector({ text: '🦊' }); - await driver.waitForSelector({ - text: 'Market', - }); - - // update estimates to low - await driver.clickElement('[data-testid="edit-gas-fee-button"]'); - await driver.delay(regularDelayMs); - await driver.clickElement('[data-testid="edit-gas-fee-item-low"]'); - await driver.delay(regularDelayMs); - await driver.waitForSelector({ text: '🐢' }); - await driver.waitForSelector({ - text: 'Low', - }); - await driver.waitForSelector('[data-testid="low-gas-fee-alert"]'); - - // confirms the transaction - await driver.clickElement({ text: 'Confirm', tag: 'button' }); - await driver.delay(regularDelayMs); - - await driver.clickElement('[data-testid="home__activity-tab"]'); - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .transaction-list-item', - ); - return confirmedTxes.length === 1; - }, 10000); - - const txValues = await driver.findElements( - '.transaction-list-item__primary-currency', - ); - assert.equal(txValues.length, 1); - assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText())); - }, - ); - }); - - it('allows accessing advance gas fee popover from edit gas fee popover', async function () { - const ganacheOptions = { - hardfork: 'london', - accounts: [ - { - secretKey: - '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - await withFixtures( - { - fixtures: 'eip-1559-v2', - ganacheOptions, - title: this.test.title, - }, - async ({ driver }) => { - await driver.navigate(); - - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - - const transactionAmounts = await driver.findElements( - '.currency-display-component__text', - ); - const transactionAmount = transactionAmounts[0]; - assert.equal(await transactionAmount.getText(), '2.2'); - - // update estimates to high - await driver.clickElement('[data-testid="edit-gas-fee-button"]'); - await driver.delay(regularDelayMs); - await driver.clickElement('[data-testid="edit-gas-fee-item-custom"]'); - await driver.delay(regularDelayMs); - - // enter max fee - const maxBaseFee = await driver.findElement( - '[data-testid="base-fee-input"]', - ); - await maxBaseFee.clear(); - await maxBaseFee.sendKeys('8'); - await driver.delay(regularDelayMs); - - // enter priority fee - const priorityFee = await driver.findElement( - '[data-testid="priority-fee-input"]', - ); - await priorityFee.clear(); - await priorityFee.sendKeys('8'); - await driver.delay(regularDelayMs); - - // save default values - await driver.clickElement('input[type="checkbox"]'); - await driver.delay(regularDelayMs); - - // edit gas limit - await driver.clickElement('[data-testid="advanced-gas-fee-edit"]'); - await driver.delay(regularDelayMs); - const gasLimit = await driver.findElement( - '[data-testid="gas-limit-input"]', - ); - await gasLimit.clear(); - await gasLimit.sendKeys('100000'); - await driver.delay(regularDelayMs); - - // Submit gas fee changes - await driver.clickElement({ text: 'Save', tag: 'button' }); - - // has correct updated value on the confirm screen the transaction - const editedTransactionAmounts = await driver.findElements( - '.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type', - ); - const editedTransactionAmount = editedTransactionAmounts[0]; - assert.equal(await editedTransactionAmount.getText(), '0.0008'); - - const editedTransactionFee = editedTransactionAmounts[1]; - assert.equal(await editedTransactionFee.getText(), '2.2008'); - - // confirms the transaction - await driver.clickElement({ text: 'Confirm', tag: 'button' }); - await driver.delay(regularDelayMs); - - await driver.clickElement('[data-testid="home__activity-tab"]'); - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .transaction-list-item', - ); - return confirmedTxes.length === 1; - }, 10000); - - const txValues = await driver.findElements( - '.transaction-list-item__primary-currency', - ); - assert.equal(txValues.length, 1); - assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText())); - }, - ); - }); - - it('should use dapp suggested estimates for transaction coming from dapp', async function () { - const ganacheOptions = { - hardfork: 'london', - accounts: [ - { - secretKey: - '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - await withFixtures( - { - fixtures: 'eip-1559-v2-dapp', - ganacheOptions, - title: this.test.title, - dapp: true, - }, - async ({ driver }) => { - await driver.navigate(); - - // login to extension - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - - // open dapp and connect - await connectDappWithExtensionPopup(driver); - await driver.clickElement({ text: 'Send', tag: 'button' }); - - // check transaction in extension popup - const windowHandles = await getWindowHandles(driver, 3); - await driver.switchToWindow(windowHandles.popup); - await driver.delay(largeDelayMs); - await driver.waitForSelector({ text: '🌐' }); - await driver.waitForSelector({ - text: 'Site suggested', - }); - - await driver.clickElement('[data-testid="edit-gas-fee-button"]'); - await driver.delay(regularDelayMs); - await driver.clickElement( - '[data-testid="edit-gas-fee-item-dappSuggested"]', - ); - await driver.delay(regularDelayMs); - - const transactionAmounts = await driver.findElements( - '.currency-display-component__text', - ); - const transactionAmount = transactionAmounts[0]; - assert.equal(await transactionAmount.getText(), '3'); - - // has correct updated value on the confirm screen the transaction - const editedTransactionAmounts = await driver.findElements( - '.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type', - ); - const editedTransactionAmount = editedTransactionAmounts[0]; - assert.equal(await editedTransactionAmount.getText(), '0.00042'); - - const editedTransactionFee = editedTransactionAmounts[1]; - assert.equal(await editedTransactionFee.getText(), '3.00042'); - - // confirms the transaction - await driver.clickElement({ text: 'Confirm', tag: 'button' }); - await driver.delay(regularDelayMs); - - // transaction should correct values in activity tab - await driver.switchToWindow(windowHandles.extension); - await driver.clickElement('[data-testid="home__activity-tab"]'); - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .transaction-list-item', - ); - return confirmedTxes.length === 1; - }, 10000); - - const txValues = await driver.findElements( - '.transaction-list-item__primary-currency', - ); - assert.equal(txValues.length, 1); - assert.ok(/-3\s*ETH/u.test(await txValues[0].getText())); - }, - ); - }); + const txValues = await driver.findElements( + '.transaction-list-item__primary-currency', + ); + assert.equal(txValues.length, 1); + assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText())); + }, + ); }); -} + + it('allows accessing advance gas fee popover from edit gas fee popover', async function () { + const ganacheOptions = { + hardfork: 'london', + accounts: [ + { + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: convertToHexValue(25000000000000000000), + }, + ], + }; + await withFixtures( + { + fixtures: 'eip-1559-v2', + ganacheOptions, + title: this.test.title, + }, + async ({ driver }) => { + await driver.navigate(); + + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + + const transactionAmounts = await driver.findElements( + '.currency-display-component__text', + ); + const transactionAmount = transactionAmounts[0]; + assert.equal(await transactionAmount.getText(), '2.2'); + + // update estimates to high + await driver.clickElement('[data-testid="edit-gas-fee-button"]'); + await driver.delay(regularDelayMs); + await driver.clickElement('[data-testid="edit-gas-fee-item-custom"]'); + await driver.delay(regularDelayMs); + + // enter max fee + const maxBaseFee = await driver.findElement( + '[data-testid="base-fee-input"]', + ); + await maxBaseFee.clear(); + await maxBaseFee.sendKeys('8'); + await driver.delay(regularDelayMs); + + // enter priority fee + const priorityFee = await driver.findElement( + '[data-testid="priority-fee-input"]', + ); + await priorityFee.clear(); + await priorityFee.sendKeys('8'); + await driver.delay(regularDelayMs); + + // save default values + await driver.clickElement('input[type="checkbox"]'); + await driver.delay(regularDelayMs); + + // edit gas limit + await driver.clickElement('[data-testid="advanced-gas-fee-edit"]'); + await driver.delay(regularDelayMs); + const gasLimit = await driver.findElement( + '[data-testid="gas-limit-input"]', + ); + await gasLimit.clear(); + await gasLimit.sendKeys('100000'); + await driver.delay(regularDelayMs); + + // Submit gas fee changes + await driver.clickElement({ text: 'Save', tag: 'button' }); + + // has correct updated value on the confirm screen the transaction + const editedTransactionAmounts = await driver.findElements( + '.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type', + ); + const editedTransactionAmount = editedTransactionAmounts[0]; + assert.equal(await editedTransactionAmount.getText(), '0.0008'); + + const editedTransactionFee = editedTransactionAmounts[1]; + assert.equal(await editedTransactionFee.getText(), '2.2008'); + + // confirms the transaction + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + await driver.delay(regularDelayMs); + + await driver.clickElement('[data-testid="home__activity-tab"]'); + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .transaction-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + + const txValues = await driver.findElements( + '.transaction-list-item__primary-currency', + ); + assert.equal(txValues.length, 1); + assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText())); + }, + ); + }); + + it('should use dapp suggested estimates for transaction coming from dapp', async function () { + const ganacheOptions = { + hardfork: 'london', + accounts: [ + { + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: convertToHexValue(25000000000000000000), + }, + ], + }; + await withFixtures( + { + fixtures: 'eip-1559-v2-dapp', + ganacheOptions, + title: this.test.title, + dapp: true, + }, + async ({ driver }) => { + await driver.navigate(); + + // login to extension + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + + // open dapp and connect + await connectDappWithExtensionPopup(driver); + await driver.clickElement({ text: 'Send', tag: 'button' }); + + // check transaction in extension popup + const windowHandles = await getWindowHandles(driver, 3); + await driver.switchToWindow(windowHandles.popup); + await driver.delay(largeDelayMs); + await driver.waitForSelector({ text: '🌐' }); + await driver.waitForSelector({ + text: 'Site suggested', + }); + + await driver.clickElement('[data-testid="edit-gas-fee-button"]'); + await driver.delay(regularDelayMs); + await driver.clickElement( + '[data-testid="edit-gas-fee-item-dappSuggested"]', + ); + await driver.delay(regularDelayMs); + + const transactionAmounts = await driver.findElements( + '.currency-display-component__text', + ); + const transactionAmount = transactionAmounts[0]; + assert.equal(await transactionAmount.getText(), '3'); + + // has correct updated value on the confirm screen the transaction + const editedTransactionAmounts = await driver.findElements( + '.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type', + ); + const editedTransactionAmount = editedTransactionAmounts[0]; + assert.equal(await editedTransactionAmount.getText(), '0.00042'); + + const editedTransactionFee = editedTransactionAmounts[1]; + assert.equal(await editedTransactionFee.getText(), '3.00042'); + + // confirms the transaction + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + await driver.delay(regularDelayMs); + + // transaction should correct values in activity tab + await driver.switchToWindow(windowHandles.extension); + await driver.clickElement('[data-testid="home__activity-tab"]'); + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .transaction-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + + const txValues = await driver.findElements( + '.transaction-list-item__primary-currency', + ); + assert.equal(txValues.length, 1); + assert.ok(/-3\s*ETH/u.test(await txValues[0].getText())); + }, + ); + }); +}); diff --git a/test/e2e/tests/send-edit.spec.js b/test/e2e/tests/send-edit.spec.js index f63796d53..ec25342fc 100644 --- a/test/e2e/tests/send-edit.spec.js +++ b/test/e2e/tests/send-edit.spec.js @@ -23,6 +23,7 @@ describe('Editing Confirm Transaction', function () { fixtures: 'send-edit', ganacheOptions, title: this.test.title, + failOnConsoleError: false, }, async ({ driver }) => { await driver.navigate(); @@ -92,113 +93,112 @@ 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 () { - const ganacheOptions = { - hardfork: 'london', - accounts: [ - { - secretKey: - '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - await withFixtures( + it('goes back from confirm page to edit eth value, baseFee, priorityFee and gas limit - 1559 V2', async function () { + const ganacheOptions = { + hardfork: 'london', + accounts: [ { - fixtures: 'send-edit-v2', - ganacheOptions, - title: this.test.title, + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: convertToHexValue(25000000000000000000), }, - async ({ driver }) => { - await driver.navigate(); + ], + }; + await withFixtures( + { + fixtures: 'send-edit-v2', + ganacheOptions, + title: this.test.title, + failOnConsoleError: false, + }, + async ({ driver }) => { + await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); - const transactionAmounts = await driver.findElements( - '.currency-display-component__text', + const transactionAmounts = await driver.findElements( + '.currency-display-component__text', + ); + const transactionAmount = transactionAmounts[0]; + assert.equal(await transactionAmount.getText(), '1'); + + const transactionFee = transactionAmounts[1]; + assert.equal(await transactionFee.getText(), '0.0000375'); + + await driver.clickElement( + '.confirm-page-container-header__back-button', + ); + await driver.fill('.unit-input__input', '2.2'); + + await driver.clickElement({ text: 'Next', tag: 'button' }); + + // open gas fee popover + await driver.clickElement({ text: 'Edit', tag: 'button' }); + + // show gas limit + await driver.clickElement('[data-testid="advanced-gas-fee-edit"]'); + await driver.delay(largeDelayMs); + + // enter max fee + const maxBaseFee = await driver.findElement( + '[data-testid="base-fee-input"]', + ); + await maxBaseFee.clear(); + await maxBaseFee.sendKeys('8'); + await driver.delay(regularDelayMs); + + // enter priority fee + const priorityFee = await driver.findElement( + '[data-testid="priority-fee-input"]', + ); + await priorityFee.clear(); + await priorityFee.sendKeys('8'); + await driver.delay(regularDelayMs); + + // edit gas limit + const gasLimit = await driver.findElement( + '[data-testid="gas-limit-input"]', + ); + await gasLimit.clear(); + await gasLimit.sendKeys('100000'); + await driver.delay(regularDelayMs); + + // save default values + await driver.clickElement('input[type="checkbox"]'); + await driver.delay(regularDelayMs); + + // Submit gas fee changes + await driver.clickElement({ text: 'Save', tag: 'button' }); + + // has correct updated value on the confirm screen the transaction + const editedTransactionAmounts = await driver.findElements( + '.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type', + ); + const editedTransactionAmount = editedTransactionAmounts[0]; + assert.equal(await editedTransactionAmount.getText(), '0.0008'); + + const editedTransactionFee = editedTransactionAmounts[1]; + assert.equal(await editedTransactionFee.getText(), '2.2008'); + + // confirms the transaction + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + await driver.delay(regularDelayMs); + + await driver.clickElement('[data-testid="home__activity-tab"]'); + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .transaction-list-item', ); - const transactionAmount = transactionAmounts[0]; - assert.equal(await transactionAmount.getText(), '1'); + return confirmedTxes.length === 1; + }, 10000); - const transactionFee = transactionAmounts[1]; - assert.equal(await transactionFee.getText(), '0.0000375'); - - await driver.clickElement( - '.confirm-page-container-header__back-button', - ); - await driver.fill('.unit-input__input', '2.2'); - - await driver.clickElement({ text: 'Next', tag: 'button' }); - - // open gas fee popover - await driver.clickElement({ text: 'Edit', tag: 'button' }); - - // show gas limit - await driver.clickElement('[data-testid="advanced-gas-fee-edit"]'); - await driver.delay(largeDelayMs); - - // enter max fee - const maxBaseFee = await driver.findElement( - '[data-testid="base-fee-input"]', - ); - await maxBaseFee.clear(); - await maxBaseFee.sendKeys('8'); - await driver.delay(regularDelayMs); - - // enter priority fee - const priorityFee = await driver.findElement( - '[data-testid="priority-fee-input"]', - ); - await priorityFee.clear(); - await priorityFee.sendKeys('8'); - await driver.delay(regularDelayMs); - - // edit gas limit - const gasLimit = await driver.findElement( - '[data-testid="gas-limit-input"]', - ); - await gasLimit.clear(); - await gasLimit.sendKeys('100000'); - await driver.delay(regularDelayMs); - - // save default values - await driver.clickElement('input[type="checkbox"]'); - await driver.delay(regularDelayMs); - - // Submit gas fee changes - await driver.clickElement({ text: 'Save', tag: 'button' }); - - // has correct updated value on the confirm screen the transaction - const editedTransactionAmounts = await driver.findElements( - '.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type', - ); - const editedTransactionAmount = editedTransactionAmounts[0]; - assert.equal(await editedTransactionAmount.getText(), '0.0008'); - - const editedTransactionFee = editedTransactionAmounts[1]; - assert.equal(await editedTransactionFee.getText(), '2.2008'); - - // confirms the transaction - await driver.clickElement({ text: 'Confirm', tag: 'button' }); - await driver.delay(regularDelayMs); - - await driver.clickElement('[data-testid="home__activity-tab"]'); - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .transaction-list-item', - ); - return confirmedTxes.length === 1; - }, 10000); - - const txValues = await driver.findElements( - '.transaction-list-item__primary-currency', - ); - assert.equal(txValues.length, 1); - assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText())); - }, - ); - }); - } + const txValues = await driver.findElements( + '.transaction-list-item__primary-currency', + ); + assert.equal(txValues.length, 1); + assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText())); + }, + ); + }); }); diff --git a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js index 2d462738f..58e40e209 100644 --- a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js +++ b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js @@ -26,6 +26,7 @@ jest.mock('../../../../store/actions', () => ({ removePollingTokenFromAppState: jest.fn(), setAdvancedGasFee: jest.fn(), updateEventFragment: jest.fn(), + createTransactionEventFragment: jest.fn(), })); const render = (defaultGasParams, contextParams) => { diff --git a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-popover.test.js b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-popover.test.js index 1767143b9..2a0f18ba5 100644 --- a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-popover.test.js +++ b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-popover.test.js @@ -17,6 +17,7 @@ jest.mock('../../../store/actions', () => ({ .mockImplementation(() => Promise.resolve()), addPollingTokenToAppState: jest.fn(), removePollingTokenFromAppState: jest.fn(), + createTransactionEventFragment: jest.fn(), })); jest.mock('../../../contexts/transaction-modal', () => ({ diff --git a/ui/components/app/cancel-speedup-popover/cancel-speedup-popover.test.js b/ui/components/app/cancel-speedup-popover/cancel-speedup-popover.test.js index be8bee870..89b1151d0 100644 --- a/ui/components/app/cancel-speedup-popover/cancel-speedup-popover.test.js +++ b/ui/components/app/cancel-speedup-popover/cancel-speedup-popover.test.js @@ -22,6 +22,7 @@ jest.mock('../../../store/actions', () => ({ addPollingTokenToAppState: jest.fn(), removePollingTokenFromAppState: jest.fn(), updateTransaction: () => ({ type: 'UPDATE_TRANSACTION_PARAMS' }), + createTransactionEventFragment: jest.fn(), })); jest.mock('../../../contexts/transaction-modal', () => ({ diff --git a/ui/components/app/confirm-page-container/confirm-page-container-container.test.js b/ui/components/app/confirm-page-container/confirm-page-container-container.test.js index 757e86670..92fa00dc4 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container-container.test.js +++ b/ui/components/app/confirm-page-container/confirm-page-container-container.test.js @@ -41,6 +41,7 @@ describe('Confirm Page Container Container Test', () => { chainId: 'test', identities: [], featureFlags: {}, + enableEIP1559V2NoticeDismissed: true, }, }; diff --git a/ui/components/app/confirm-page-container/enableEIP1559V2-notice/enableEIP1559V2-notice.js b/ui/components/app/confirm-page-container/enableEIP1559V2-notice/enableEIP1559V2-notice.js index 1dd2dd71d..f0b92ff03 100644 --- a/ui/components/app/confirm-page-container/enableEIP1559V2-notice/enableEIP1559V2-notice.js +++ b/ui/components/app/confirm-page-container/enableEIP1559V2-notice/enableEIP1559V2-notice.js @@ -20,10 +20,6 @@ import { setEnableEIP1559V2NoticeDismissed } from '../../../../store/actions'; import { getEnableEIP1559V2NoticeDismissed } from '../../../../ducks/metamask/metamask'; 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 }) { const t = useI18nContext(); const history = useHistory(); @@ -32,11 +28,7 @@ export default function EnableEIP1559V2Notice({ isFirstAlert }) { ); const eip1559V2Enabled = useSelector(getEIP1559V2Enabled); - if ( - !EIP_1559_V2_ENABLED || - eip1559V2Enabled || - enableEIP1559V2NoticeDismissed - ) { + if (eip1559V2Enabled || enableEIP1559V2NoticeDismissed) { return null; } diff --git a/ui/components/app/edit-gas-fee-button/edit-gas-fee-button.test.js b/ui/components/app/edit-gas-fee-button/edit-gas-fee-button.test.js index c6ac0ae88..696fd7d6a 100644 --- a/ui/components/app/edit-gas-fee-button/edit-gas-fee-button.test.js +++ b/ui/components/app/edit-gas-fee-button/edit-gas-fee-button.test.js @@ -22,6 +22,7 @@ jest.mock('../../../store/actions', () => ({ .fn() .mockImplementation(() => Promise.resolve()), addPollingTokenToAppState: jest.fn(), + createTransactionEventFragment: jest.fn(), })); const render = ({ componentProps, contextProps } = {}) => { diff --git a/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js b/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js index 165cb3de0..f4fc6c651 100644 --- a/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js +++ b/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js @@ -15,6 +15,7 @@ jest.mock('../../../store/actions', () => ({ .fn() .mockImplementation(() => Promise.resolve()), addPollingTokenToAppState: jest.fn(), + createTransactionEventFragment: jest.fn(), })); jest.mock('../../../contexts/transaction-modal', () => ({ diff --git a/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js b/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js index 469348e2a..c4fdc679b 100644 --- a/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js +++ b/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js @@ -18,6 +18,7 @@ jest.mock('../../../../store/actions', () => ({ getGasFeeTimeEstimate: jest .fn() .mockImplementation(() => Promise.resolve('unknown')), + createTransactionEventFragment: jest.fn(), })); const MOCK_FEE_ESTIMATE = { diff --git a/ui/components/app/transaction-detail/transaction-detail.component.test.js b/ui/components/app/transaction-detail/transaction-detail.component.test.js index 7a0396377..958e0e9d2 100644 --- a/ui/components/app/transaction-detail/transaction-detail.component.test.js +++ b/ui/components/app/transaction-detail/transaction-detail.component.test.js @@ -18,6 +18,7 @@ jest.mock('../../../store/actions', () => ({ .fn() .mockImplementation(() => Promise.resolve()), addPollingTokenToAppState: jest.fn(), + createTransactionEventFragment: jest.fn(), })); const render = ({ componentProps, contextProps } = {}) => { diff --git a/ui/hooks/useTransactionEventFragment.js b/ui/hooks/useTransactionEventFragment.js index 10f44df83..21ea11e6b 100644 --- a/ui/hooks/useTransactionEventFragment.js +++ b/ui/hooks/useTransactionEventFragment.js @@ -1,10 +1,31 @@ -import { useCallback } from 'react'; +import { useCallback, useEffect } from 'react'; +import { useSelector } from 'react-redux'; 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 = () => { 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( (params) => { diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.js b/ui/pages/settings/experimental-tab/experimental-tab.component.js index 6b37d955a..1312af5cd 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.js @@ -148,12 +148,6 @@ export default class ExperimentalTab extends PureComponent { } 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 { eip1559V2Enabled, setEIP1559V2Enabled } = this.props; diff --git a/ui/pages/swaps/fee-card/fee-card.test.js b/ui/pages/swaps/fee-card/fee-card.test.js index 16f43da8d..f87078d96 100644 --- a/ui/pages/swaps/fee-card/fee-card.test.js +++ b/ui/pages/swaps/fee-card/fee-card.test.js @@ -63,6 +63,7 @@ const generateUseSelectorRouter = () => (selector) => { setBackgroundConnection({ getGasFeeTimeEstimate: jest.fn(), getGasFeeEstimatesAndStartPolling: jest.fn(), + createTransactionEventFragment: jest.fn(), }); const createProps = (customProps = {}) => { diff --git a/ui/store/actions.js b/ui/store/actions.js index 96226df26..5500cfbd1 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -3108,6 +3108,13 @@ export function createEventFragment(options) { return promisifiedBackground.createEventFragment(options); } +export function createTransactionEventFragment(transactionId, event) { + return promisifiedBackground.createTransactionEventFragment( + transactionId, + event, + ); +} + export function updateEventFragment(id, payload) { return promisifiedBackground.updateEventFragment(id, payload); }