|
|
@ -37,7 +37,6 @@ class ConnectHardwareForm extends Component { |
|
|
|
const { accounts } = this.props |
|
|
|
const { accounts } = this.props |
|
|
|
const balanceValue = accounts && accounts[address.toLowerCase()] ? accounts[address.toLowerCase()].balance : '' |
|
|
|
const balanceValue = accounts && accounts[address.toLowerCase()] ? accounts[address.toLowerCase()].balance : '' |
|
|
|
const formattedBalance = balanceValue !== null ? formatBalance(balanceValue, 6) : '...' |
|
|
|
const formattedBalance = balanceValue !== null ? formatBalance(balanceValue, 6) : '...' |
|
|
|
console.log('[TREZOR]: got balance', address, accounts, balanceValue, formattedBalance) |
|
|
|
|
|
|
|
return formattedBalance |
|
|
|
return formattedBalance |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -45,21 +44,17 @@ class ConnectHardwareForm extends Component { |
|
|
|
this.props |
|
|
|
this.props |
|
|
|
.connectHardware('trezor', page) |
|
|
|
.connectHardware('trezor', page) |
|
|
|
.then(accounts => { |
|
|
|
.then(accounts => { |
|
|
|
console.log('[TREZOR]: GOT PAGE!', accounts) |
|
|
|
|
|
|
|
if (accounts.length) { |
|
|
|
if (accounts.length) { |
|
|
|
const newState = {} |
|
|
|
const newState = {} |
|
|
|
// Default to the first account
|
|
|
|
// Default to the first account
|
|
|
|
if (this.state.selectedAccount === null) { |
|
|
|
if (this.state.selectedAccount === null) { |
|
|
|
const firstAccount = accounts[0] |
|
|
|
const firstAccount = accounts[0] |
|
|
|
newState.selectedAccount = firstAccount.index.toString() === '0' ? firstAccount.index.toString() : null |
|
|
|
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
|
|
|
|
// 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) { |
|
|
|
} else if (!accounts.filter(a => a.index.toString() === this.state.selectedAccount).length) { |
|
|
|
newState.selectedAccount = null |
|
|
|
newState.selectedAccount = null |
|
|
|
console.log('[TREZOR]: just removed default account', newState.selectedAccount) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log('[TREZOR]: mapping balances') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Map accounts with balances
|
|
|
|
// Map accounts with balances
|
|
|
|
newState.accounts = accounts.map(account => { |
|
|
|
newState.accounts = accounts.map(account => { |
|
|
@ -67,7 +62,6 @@ class ConnectHardwareForm extends Component { |
|
|
|
return account |
|
|
|
return account |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
console.log('[TREZOR]: ABOUT TO RENDER ACCOUNTS: ', page, newState.accounts) |
|
|
|
|
|
|
|
this.setState(newState) |
|
|
|
this.setState(newState) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|