mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Call onbootcleanup at the end of the tx controller constructor (#16449)
* Call onbootcleanup at the end of the tx controller constructor * Update app/scripts/controllers/transactions/index.js Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
This commit is contained in:
parent
73ee36a972
commit
1db38adf4c
@ -161,7 +161,6 @@ export default class TransactionController extends EventEmitter {
|
|||||||
getNetwork: this.getNetwork.bind(this),
|
getNetwork: this.getNetwork.bind(this),
|
||||||
getCurrentChainId: opts.getCurrentChainId,
|
getCurrentChainId: opts.getCurrentChainId,
|
||||||
});
|
});
|
||||||
this._onBootCleanUp();
|
|
||||||
|
|
||||||
this.store = this.txStateManager.store;
|
this.store = this.txStateManager.store;
|
||||||
this.nonceTracker = new NonceTracker({
|
this.nonceTracker = new NonceTracker({
|
||||||
@ -208,6 +207,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
|
|
||||||
// request state update to finalize initialization
|
// request state update to finalize initialization
|
||||||
this._updatePendingTxsAfterFirstBlock();
|
this._updatePendingTxsAfterFirstBlock();
|
||||||
|
this._onBootCleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -981,6 +981,117 @@ class FixtureBuilder {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withTransactionControllerApprovedTransaction() {
|
||||||
|
return this.withTransactionController({
|
||||||
|
transactions: {
|
||||||
|
4046084157914634: {
|
||||||
|
chainId: '0x539',
|
||||||
|
history: [
|
||||||
|
{
|
||||||
|
chainId: '0x539',
|
||||||
|
id: 4046084157914634,
|
||||||
|
loadingDefaults: true,
|
||||||
|
metamaskNetworkId: '1337',
|
||||||
|
origin: 'metamask',
|
||||||
|
status: 'unapproved',
|
||||||
|
time: 1617228030067,
|
||||||
|
txParams: {
|
||||||
|
from: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||||
|
gas: '0x61a8',
|
||||||
|
maxFeePerGas: '0x59682f0c',
|
||||||
|
maxPriorityFeePerGas: '0x59682f00',
|
||||||
|
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||||
|
type: '0x2',
|
||||||
|
value: '0xde0b6b3a7640000',
|
||||||
|
},
|
||||||
|
type: 'simpleSend',
|
||||||
|
},
|
||||||
|
[
|
||||||
|
{
|
||||||
|
note: 'Added new unapproved transaction.',
|
||||||
|
op: 'replace',
|
||||||
|
path: '/loadingDefaults',
|
||||||
|
timestamp: 1617228030069,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
op: 'add',
|
||||||
|
path: '/txParams/nonce',
|
||||||
|
value: '0x0',
|
||||||
|
note: 'transactions#approveTransaction',
|
||||||
|
timestamp: 1617228031069,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: 'add',
|
||||||
|
path: '/nonceDetails',
|
||||||
|
value: {
|
||||||
|
params: {
|
||||||
|
highestLocallyConfirmed: 0,
|
||||||
|
highestSuggested: 0,
|
||||||
|
nextNetworkNonce: 0,
|
||||||
|
},
|
||||||
|
local: {
|
||||||
|
name: 'local',
|
||||||
|
nonce: 0,
|
||||||
|
details: {
|
||||||
|
startPoint: 0,
|
||||||
|
highest: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
network: {
|
||||||
|
name: 'network',
|
||||||
|
nonce: 0,
|
||||||
|
details: {
|
||||||
|
blockNumber: '0x0',
|
||||||
|
baseCount: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
id: 4046084157914634,
|
||||||
|
loadingDefaults: false,
|
||||||
|
metamaskNetworkId: '1337',
|
||||||
|
origin: 'metamask',
|
||||||
|
primaryTransaction: {
|
||||||
|
chainId: '0x539',
|
||||||
|
id: 4046084157914634,
|
||||||
|
loadingDefaults: true,
|
||||||
|
metamaskNetworkId: '1337',
|
||||||
|
origin: 'metamask',
|
||||||
|
status: 'approved',
|
||||||
|
time: 1617228030067,
|
||||||
|
txParams: {
|
||||||
|
from: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||||
|
gas: '0x61a8',
|
||||||
|
maxFeePerGas: '0x59682f0c',
|
||||||
|
maxPriorityFeePerGas: '0x59682f00',
|
||||||
|
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||||
|
type: '0x2',
|
||||||
|
value: '0xde0b6b3a7640000',
|
||||||
|
},
|
||||||
|
type: 'sentEther',
|
||||||
|
},
|
||||||
|
status: 'approved',
|
||||||
|
time: 1617228030067,
|
||||||
|
txParams: {
|
||||||
|
from: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||||
|
gas: '0x61a8',
|
||||||
|
maxFeePerGas: '0x59682f0c',
|
||||||
|
maxPriorityFeePerGas: '0x59682f00',
|
||||||
|
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||||
|
type: '0x2',
|
||||||
|
value: '0xde0b6b3a7640000',
|
||||||
|
},
|
||||||
|
type: 'simpleSend',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
this.fixture.meta = {
|
this.fixture.meta = {
|
||||||
version: 74,
|
version: 74,
|
||||||
|
47
test/e2e/tests/stuck-approved-transaction.spec.js
Normal file
47
test/e2e/tests/stuck-approved-transaction.spec.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
const { strict: assert } = require('assert');
|
||||||
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
||||||
|
const FixtureBuilder = require('../fixture-builder');
|
||||||
|
|
||||||
|
describe('Editing Confirm Transaction', function () {
|
||||||
|
it('approves a transaction stuck in approved state on boot', async function () {
|
||||||
|
const ganacheOptions = {
|
||||||
|
hardfork: 'london',
|
||||||
|
accounts: [
|
||||||
|
{
|
||||||
|
secretKey:
|
||||||
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
||||||
|
balance: convertToHexValue(25000000000000000000),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
await withFixtures(
|
||||||
|
{
|
||||||
|
fixtures: new FixtureBuilder()
|
||||||
|
.withTransactionControllerApprovedTransaction()
|
||||||
|
.build(),
|
||||||
|
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.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(/-1\s*ETH/u.test(await txValues[0].getText()));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user