aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-10 05:24:52 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-10 05:24:52 +0800
commit7cca7ace2ea4cd4b9d3a242067c9a7c344406aba (patch)
tree5203febbb77d924aba63295a1a42460c34144b92 /ui
parent512760154528c47213cc8ff75475c21e3e674a23 (diff)
downloadtangerine-wallet-browser-7cca7ace2ea4cd4b9d3a242067c9a7c344406aba.tar
tangerine-wallet-browser-7cca7ace2ea4cd4b9d3a242067c9a7c344406aba.tar.gz
tangerine-wallet-browser-7cca7ace2ea4cd4b9d3a242067c9a7c344406aba.tar.bz2
tangerine-wallet-browser-7cca7ace2ea4cd4b9d3a242067c9a7c344406aba.tar.lz
tangerine-wallet-browser-7cca7ace2ea4cd4b9d3a242067c9a7c344406aba.tar.xz
tangerine-wallet-browser-7cca7ace2ea4cd4b9d3a242067c9a7c344406aba.tar.zst
tangerine-wallet-browser-7cca7ace2ea4cd4b9d3a242067c9a7c344406aba.zip
fix all the account related bugs
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/pages/create-account/connect-hardware/account-list.js11
-rw-r--r--ui/app/components/pages/create-account/connect-hardware/index.js29
2 files changed, 27 insertions, 13 deletions
diff --git a/ui/app/components/pages/create-account/connect-hardware/account-list.js b/ui/app/components/pages/create-account/connect-hardware/account-list.js
index 77e0af3ac..170d8f0b3 100644
--- a/ui/app/components/pages/create-account/connect-hardware/account-list.js
+++ b/ui/app/components/pages/create-account/connect-hardware/account-list.js
@@ -2,21 +2,12 @@ const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const genAccountLink = require('../../../../../lib/account-link.js')
-const { formatBalance } = require('../../../../util')
class AccountList extends Component {
constructor (props, context) {
super(props)
}
- getBalance (address) {
- // Get the balance
- const { accounts } = this.props
- const balanceValue = accounts && accounts[address] ? accounts[address].balance : ''
- const formattedBalance = balanceValue ? formatBalance(balanceValue, 6) : '...'
- return formattedBalance
- }
-
renderAccounts () {
return h('div.hw-account-list', [
h('div.hw-account-list__title_wrapper', [
@@ -44,7 +35,7 @@ class AccountList extends Component {
`${a.address.slice(0, 4)}...${a.address.slice(-4)}`
),
]),
- h('span.hw-account-list__item__balance', `${this.getBalance(a.address)}`),
+ h('span.hw-account-list__item__balance', `${a.balance}`),
h(
'a.hw-account-list__item__link',
{
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 22c54d28c..1aaa0be64 100644
--- a/ui/app/components/pages/create-account/connect-hardware/index.js
+++ b/ui/app/components/pages/create-account/connect-hardware/index.js
@@ -6,6 +6,7 @@ const actions = require('../../../../actions')
const ConnectScreen = require('./connect-screen')
const AccountList = require('./account-list')
const { DEFAULT_ROUTE } = require('../../../../routes')
+const { formatBalance } = require('../../../../util')
class ConnectHardwareForm extends Component {
constructor (props, context) {
@@ -31,20 +32,42 @@ class ConnectHardwareForm extends Component {
this.setState({selectedAccount: account.toString(), error: null})
}
+ getBalance (address) {
+ // Get the balance
+ 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
+ }
+
getPage = (page) => {
this.props
.connectHardware('trezor', page)
.then(accounts => {
+ console.log('[TREZOR]: GOT PAGE!', accounts)
if (accounts.length) {
- const newState = { accounts: accounts }
+ const newState = {}
// Default to the first account
if (this.state.selectedAccount === null) {
const firstAccount = accounts[0]
- newState.selectedAccount = firstAccount.index.toString()
+ 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() === '').lenght) {
+ } 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 => {
+ account.balance = this.getBalance(account.address)
+ return account
+ })
+
+ console.log('[TREZOR]: ABOUT TO RENDER ACCOUNTS: ', page, newState.accounts)
this.setState(newState)
}
})