From 2de3039b6b21ca05ef185c078b67815448864c72 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 9 Jul 2018 17:55:37 -0400 Subject: fix account duplication --- app/scripts/metamask-controller.js | 4 +++- ui/app/components/pages/create-account/connect-hardware/index.js | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 8104374bc..08b75e839 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -550,7 +550,9 @@ module.exports = class MetamaskController extends EventEmitter { } // Merge with existing accounts - this.accountTracker.syncWithAddresses(oldAccounts.concat(accounts.map(a => a.address))) + // and make sure addresses are not repeated + const accountsToTrack = [...new Set(oldAccounts.concat(accounts.map(a => a.address.toLowerCase())))] + this.accountTracker.syncWithAddresses(accountsToTrack) return accounts default: diff --git a/ui/app/components/pages/create-account/connect-hardware/index.js b/ui/app/components/pages/create-account/connect-hardware/index.js index 1aaa0be64..126102235 100644 --- a/ui/app/components/pages/create-account/connect-hardware/index.js +++ b/ui/app/components/pages/create-account/connect-hardware/index.js @@ -37,7 +37,6 @@ class ConnectHardwareForm extends Component { const { accounts } = this.props const balanceValue = accounts && accounts[address.toLowerCase()] ? accounts[address.toLowerCase()].balance : '' const formattedBalance = balanceValue !== null ? formatBalance(balanceValue, 6) : '...' - console.log('[TREZOR]: got balance', address, accounts, balanceValue, formattedBalance) return formattedBalance } @@ -45,21 +44,17 @@ class ConnectHardwareForm extends Component { this.props .connectHardware('trezor', page) .then(accounts => { - console.log('[TREZOR]: GOT PAGE!', accounts) if (accounts.length) { const newState = {} // Default to the first account if (this.state.selectedAccount === null) { const firstAccount = accounts[0] newState.selectedAccount = firstAccount.index.toString() === '0' ? firstAccount.index.toString() : null - console.log('[TREZOR]: just defaulted to account', newState.selectedAccount) // If the page doesn't contain the selected account, let's deselect it } else if (!accounts.filter(a => a.index.toString() === this.state.selectedAccount).length) { newState.selectedAccount = null - console.log('[TREZOR]: just removed default account', newState.selectedAccount) } - console.log('[TREZOR]: mapping balances') // Map accounts with balances newState.accounts = accounts.map(account => { @@ -67,7 +62,6 @@ class ConnectHardwareForm extends Component { return account }) - console.log('[TREZOR]: ABOUT TO RENDER ACCOUNTS: ', page, newState.accounts) this.setState(newState) } }) -- cgit