mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 07:16:36 +01:00
c54f9b3097
* Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * This is a combination of 76 commits. normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> enforce that only the properties for the specific methid can be updated via the method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more parameters to updateSwapTransaction approvalTxId estimatedBaseFee Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas fees in edit-gas-popover. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove dup;icated method from rebase. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> unrelated change Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Force re-run workflow Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> UpdateTransaction should be renamed to updateGasFees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateGasFees in gas-modal-page-container. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> fix: update previous gas params update method add types to the jsdoc comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateTransactionGasFees should have been updatePreviousGasParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Previous gas fees can be updated for confirmed transactions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add updatePreviousGasParams to mocked functions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * we need to await the first dispatch before we call the second Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * update values to make tests pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * More changes to make e2e pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Need to wait a bit after save for changes to take effect. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove merge comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Await one dispatch before calling another Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * We don't need goHome anymore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Tests must use async...await syntax too since we have await in the useTranasctionFunction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add delay after button click for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait a moment after clicking save for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait after clicking save... Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Merge update transaction gas fees and transaction user settings Show loading indicator on edit gas popover Fix tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix JSDoc Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * updatePreviousGasParams should also return updated transaction meta. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
284 lines
9.9 KiB
JavaScript
284 lines
9.9 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const {
|
|
convertToHexValue,
|
|
connectDappWithExtensionPopup,
|
|
getWindowHandles,
|
|
largeDelayMs,
|
|
withFixtures,
|
|
regularDelayMs,
|
|
} = require('../helpers');
|
|
|
|
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(
|
|
{
|
|
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.waitForSelector({
|
|
text: 'sec',
|
|
tag: 'span',
|
|
});
|
|
await driver.clickElement('[data-testid="edit-gas-fee-item-high"]');
|
|
await driver.waitForSelector({ text: '🦍' });
|
|
await driver.waitForSelector({
|
|
text: 'Aggressive',
|
|
});
|
|
|
|
// update estimates to medium
|
|
await driver.clickElement('[data-testid="edit-gas-fee-button"]');
|
|
await driver.clickElement('[data-testid="edit-gas-fee-item-medium"]');
|
|
await driver.waitForSelector({ text: '🦊' });
|
|
await driver.waitForSelector({
|
|
text: 'Market',
|
|
});
|
|
|
|
// update estimates to low
|
|
await driver.clickElement('[data-testid="edit-gas-fee-button"]');
|
|
await driver.clickElement('[data-testid="edit-gas-fee-item-low"]');
|
|
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.waitForSelector({
|
|
text: 'sec',
|
|
tag: 'span',
|
|
});
|
|
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' });
|
|
await driver.delay(largeDelayMs);
|
|
|
|
// 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 EIP 1559 Transaction',
|
|
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.waitForSelector({
|
|
text: 'sec',
|
|
tag: 'span',
|
|
});
|
|
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(), '0');
|
|
|
|
// 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.00021');
|
|
|
|
const editedTransactionFee = editedTransactionAmounts[1];
|
|
assert.equal(await editedTransactionFee.getText(), '0.00021');
|
|
|
|
// 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(/-0\s*ETH/u.test(await txValues[0].getText()));
|
|
},
|
|
);
|
|
});
|
|
});
|