diff options
author | brunobar79 <brunobar79@gmail.com> | 2018-07-13 00:54:08 +0800 |
---|---|---|
committer | brunobar79 <brunobar79@gmail.com> | 2018-07-13 00:54:08 +0800 |
commit | 07d8bfaec51a798e090bd2521debeddaf53bf2f9 (patch) | |
tree | 735338e1dbaa38601376024ed6e4fa4d89c66a2c /app/scripts | |
parent | 2a0a7853249284cb27831890f3b62847ea27eb83 (diff) | |
parent | 0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9 (diff) | |
download | tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.gz tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.bz2 tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.lz tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.xz tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.zst tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.zip |
Merge branch 'develop' of github.com:MetaMask/metamask-extension into initial-trezor-support
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/controllers/network/enums.js | 3 | ||||
-rw-r--r-- | app/scripts/controllers/transactions/tx-state-manager.js | 6 | ||||
-rw-r--r-- | app/scripts/migrations/027.js | 35 |
3 files changed, 43 insertions, 1 deletions
diff --git a/app/scripts/controllers/network/enums.js b/app/scripts/controllers/network/enums.js index 9da7f309c..3190eb37c 100644 --- a/app/scripts/controllers/network/enums.js +++ b/app/scripts/controllers/network/enums.js @@ -4,6 +4,7 @@ const KOVAN = 'kovan' const MAINNET = 'mainnet' const LOCALHOST = 'localhost' +const MAINNET_CODE = 1 const ROPSTEN_CODE = 3 const RINKEYBY_CODE = 4 const KOVAN_CODE = 42 @@ -13,13 +14,13 @@ const RINKEBY_DISPLAY_NAME = 'Rinkeby' const KOVAN_DISPLAY_NAME = 'Kovan' const MAINNET_DISPLAY_NAME = 'Main Ethereum Network' - module.exports = { ROPSTEN, RINKEBY, KOVAN, MAINNET, LOCALHOST, + MAINNET_CODE, ROPSTEN_CODE, RINKEYBY_CODE, KOVAN_CODE, diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 0aae4774b..28a18ca2e 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -288,6 +288,7 @@ class TransactionStateManager extends EventEmitter { */ setTxStatusRejected (txId) { this._setTxStatus(txId, 'rejected') + this._removeTx(txId) } /** @@ -422,6 +423,11 @@ class TransactionStateManager extends EventEmitter { _saveTxList (transactions) { this.store.updateState({ transactions }) } + + _removeTx (txId) { + const transactionList = this.getFullTxList() + this._saveTxList(transactionList.filter((txMeta) => txMeta.id !== txId)) + } } module.exports = TransactionStateManager diff --git a/app/scripts/migrations/027.js b/app/scripts/migrations/027.js new file mode 100644 index 000000000..d6ebef580 --- /dev/null +++ b/app/scripts/migrations/027.js @@ -0,0 +1,35 @@ +// next version number +const version = 27 + +/* + +normalizes txParams on unconfirmed txs + +*/ +const clone = require('clone') + +module.exports = { + version, + + migrate: async function (originalVersionedData) { + const versionedData = clone(originalVersionedData) + versionedData.meta.version = version + const state = versionedData.data + const newState = transformState(state) + versionedData.data = newState + return versionedData + }, +} + +function transformState (state) { + const newState = state + + if (newState.TransactionController) { + if (newState.TransactionController.transactions) { + const transactions = newState.TransactionController.transactions + newState.TransactionController.transactions = transactions.filter((txMeta) => txMeta.status !== 'rejected') + } + } + + return newState +} |