mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'master' into localStorage-clean-up
This commit is contained in:
commit
201e0579a5
@ -3,6 +3,7 @@
|
|||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
- Remove BlacklistController from disk state
|
- Remove BlacklistController from disk state
|
||||||
|
- Add a "reset account" feature to Settings
|
||||||
- Add warning for importing some kinds of files.
|
- Add warning for importing some kinds of files.
|
||||||
|
|
||||||
## 3.13.8 2018-1-29
|
## 3.13.8 2018-1-29
|
||||||
|
@ -152,6 +152,10 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wipeTransactions (address) {
|
||||||
|
this.txStateManager.wipeTransactions(address)
|
||||||
|
}
|
||||||
|
|
||||||
// Adds a tx to the txlist
|
// Adds a tx to the txlist
|
||||||
addTx (txMeta) {
|
addTx (txMeta) {
|
||||||
this.txStateManager.addTx(txMeta)
|
this.txStateManager.addTx(txMeta)
|
||||||
|
@ -221,6 +221,17 @@ module.exports = class TransactionStateManger extends EventEmitter {
|
|||||||
this._setTxStatus(txId, 'failed')
|
this._setTxStatus(txId, 'failed')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wipeTransactions (address) {
|
||||||
|
// network only tx
|
||||||
|
const txs = this.getFullTxList()
|
||||||
|
const network = this.getNetwork()
|
||||||
|
|
||||||
|
// Filter out the ones from the current account and network
|
||||||
|
const otherAccountTxs = txs.filter((txMeta) => !(txMeta.txParams.from === address && txMeta.metamaskNetworkId === network))
|
||||||
|
|
||||||
|
// Update state
|
||||||
|
this._saveTxList(otherAccountTxs)
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// PRIVATE METHODS
|
// PRIVATE METHODS
|
||||||
//
|
//
|
||||||
|
@ -341,6 +341,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
addNewAccount: nodeify(this.addNewAccount, this),
|
addNewAccount: nodeify(this.addNewAccount, this),
|
||||||
placeSeedWords: this.placeSeedWords.bind(this),
|
placeSeedWords: this.placeSeedWords.bind(this),
|
||||||
clearSeedWordCache: this.clearSeedWordCache.bind(this),
|
clearSeedWordCache: this.clearSeedWordCache.bind(this),
|
||||||
|
resetAccount: this.resetAccount.bind(this),
|
||||||
importAccountWithStrategy: this.importAccountWithStrategy.bind(this),
|
importAccountWithStrategy: this.importAccountWithStrategy.bind(this),
|
||||||
|
|
||||||
// vault management
|
// vault management
|
||||||
@ -597,6 +598,13 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
cb(null, this.preferencesController.getSelectedAddress())
|
cb(null, this.preferencesController.getSelectedAddress())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetAccount (cb) {
|
||||||
|
const selectedAddress = this.preferencesController.getSelectedAddress()
|
||||||
|
this.txController.wipeTransactions(selectedAddress)
|
||||||
|
cb(null, selectedAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
importAccountWithStrategy (strategy, args, cb) {
|
importAccountWithStrategy (strategy, args, cb) {
|
||||||
accountImporter.importAccount(strategy, args)
|
accountImporter.importAccount(strategy, args)
|
||||||
.then((privateKey) => {
|
.then((privateKey) => {
|
||||||
|
@ -238,4 +238,47 @@ describe('TransactionStateManger', function () {
|
|||||||
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('#wipeTransactions', function () {
|
||||||
|
|
||||||
|
const specificAddress = '0xaa'
|
||||||
|
const otherAddress = '0xbb'
|
||||||
|
|
||||||
|
it('should remove only the transactions from a specific address', function () {
|
||||||
|
|
||||||
|
const txMetas = [
|
||||||
|
{ id: 0, status: 'unapproved', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: currentNetworkId },
|
||||||
|
{ id: 1, status: 'confirmed', txParams: { from: otherAddress, to: specificAddress }, metamaskNetworkId: currentNetworkId },
|
||||||
|
{ id: 2, status: 'confirmed', txParams: { from: otherAddress, to: specificAddress }, metamaskNetworkId: currentNetworkId },
|
||||||
|
]
|
||||||
|
txMetas.forEach((txMeta) => txStateManager.addTx(txMeta, noop))
|
||||||
|
|
||||||
|
txStateManager.wipeTransactions(specificAddress)
|
||||||
|
|
||||||
|
const transactionsFromCurrentAddress = txStateManager.getTxList().filter((txMeta) => txMeta.txParams.from === specificAddress)
|
||||||
|
const transactionsFromOtherAddresses = txStateManager.getTxList().filter((txMeta) => txMeta.txParams.from !== specificAddress)
|
||||||
|
|
||||||
|
assert.equal(transactionsFromCurrentAddress.length, 0)
|
||||||
|
assert.equal(transactionsFromOtherAddresses.length, 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should not remove the transactions from other networks', function () {
|
||||||
|
const txMetas = [
|
||||||
|
{ id: 0, status: 'unapproved', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: currentNetworkId },
|
||||||
|
{ id: 1, status: 'confirmed', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: otherNetworkId },
|
||||||
|
{ id: 2, status: 'confirmed', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: otherNetworkId },
|
||||||
|
]
|
||||||
|
|
||||||
|
txMetas.forEach((txMeta) => txStateManager.addTx(txMeta, noop))
|
||||||
|
|
||||||
|
txStateManager.wipeTransactions(specificAddress)
|
||||||
|
|
||||||
|
const txsFromCurrentNetworkAndAddress = txStateManager.getTxList().filter((txMeta) => txMeta.txParams.from === specificAddress)
|
||||||
|
const txFromOtherNetworks = txStateManager.getFullTxList().filter((txMeta) => txMeta.metamaskNetworkId === otherNetworkId)
|
||||||
|
|
||||||
|
assert.equal(txsFromCurrentNetworkAndAddress.length, 0)
|
||||||
|
assert.equal(txFromOtherNetworks.length, 2)
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
@ -47,12 +47,14 @@ var actions = {
|
|||||||
addNewAccount,
|
addNewAccount,
|
||||||
NEW_ACCOUNT_SCREEN: 'NEW_ACCOUNT_SCREEN',
|
NEW_ACCOUNT_SCREEN: 'NEW_ACCOUNT_SCREEN',
|
||||||
navigateToNewAccountScreen,
|
navigateToNewAccountScreen,
|
||||||
|
resetAccount,
|
||||||
showNewVaultSeed: showNewVaultSeed,
|
showNewVaultSeed: showNewVaultSeed,
|
||||||
showInfoPage: showInfoPage,
|
showInfoPage: showInfoPage,
|
||||||
// seed recovery actions
|
// seed recovery actions
|
||||||
REVEAL_SEED_CONFIRMATION: 'REVEAL_SEED_CONFIRMATION',
|
REVEAL_SEED_CONFIRMATION: 'REVEAL_SEED_CONFIRMATION',
|
||||||
revealSeedConfirmation: revealSeedConfirmation,
|
revealSeedConfirmation: revealSeedConfirmation,
|
||||||
requestRevealSeed: requestRevealSeed,
|
requestRevealSeed: requestRevealSeed,
|
||||||
|
|
||||||
// unlock screen
|
// unlock screen
|
||||||
UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS',
|
UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS',
|
||||||
UNLOCK_FAILED: 'UNLOCK_FAILED',
|
UNLOCK_FAILED: 'UNLOCK_FAILED',
|
||||||
@ -308,6 +310,20 @@ function requestRevealSeed (password) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetAccount () {
|
||||||
|
return (dispatch) => {
|
||||||
|
background.resetAccount((err, account) => {
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
if (err) {
|
||||||
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info('Transaction history reset for ' + account)
|
||||||
|
dispatch(actions.showAccountsPage())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addNewKeyring (type, opts) {
|
function addNewKeyring (type, opts) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
@ -55,6 +55,7 @@ ConfigScreen.prototype.render = function () {
|
|||||||
h('.flex-space-around', {
|
h('.flex-space-around', {
|
||||||
style: {
|
style: {
|
||||||
padding: '20px',
|
padding: '20px',
|
||||||
|
overflow: 'auto',
|
||||||
},
|
},
|
||||||
}, [
|
}, [
|
||||||
|
|
||||||
@ -142,6 +143,24 @@ ConfigScreen.prototype.render = function () {
|
|||||||
}, 'Reveal Seed Words'),
|
}, 'Reveal Seed Words'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
h('hr.horizontal-line'),
|
||||||
|
|
||||||
|
h('div', {
|
||||||
|
style: {
|
||||||
|
marginTop: '20px',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
h('button', {
|
||||||
|
style: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
},
|
||||||
|
onClick (event) {
|
||||||
|
event.preventDefault()
|
||||||
|
state.dispatch(actions.resetAccount())
|
||||||
|
},
|
||||||
|
}, 'Reset Account'),
|
||||||
|
]),
|
||||||
|
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user