|
|
|
@ -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) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|