Skip to content

Commit 88a47fc

Browse files
committed
fix: voting weight shows as NaN on account page (closes #113)
1 parent 1f48df7 commit 88a47fc

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

api/routes/accounts/index.mjs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ router.get('/:address', async (req, res) => {
2828
return res.status(200).send(cachedAccount)
2929
}
3030

31-
const accountInfo = await rpc.accountInfo({
32-
account: address,
33-
pending: true,
34-
representative: true
35-
})
31+
const [account_weight, accountInfo] = await Promise.all([
32+
rpc.accountWeight({ account: address }),
33+
rpc.accountInfo({
34+
account: address,
35+
pending: true,
36+
representative: true,
37+
weight: true
38+
})
39+
])
3640

3741
const data = {
3842
account: address,
@@ -46,7 +50,7 @@ router.get('/:address', async (req, res) => {
4650
pending: BigNumber(accountInfo.pending).toNumber(),
4751
balance: BigNumber(accountInfo.balance).toNumber(),
4852
block_count: BigNumber(accountInfo.block_count).toNumber(),
49-
weight: BigNumber(accountInfo.weight).toNumber(),
53+
weight: BigNumber(account_weight.weight).toNumber(),
5054
confirmation_height: BigNumber(
5155
accountInfo.confirmation_height
5256
).toNumber()

src/views/components/representative-info/representative-info.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ export default class RepresentativeNetwork extends React.Component {
3939
Weight Represented
4040
</div>
4141
<div className='account__section-metric-body'>
42-
{BigNumber(account.getIn(['account_meta', 'weight']))
43-
.shiftedBy(-30)
44-
.toFormat(0)}
42+
{account.getIn(['account_meta', 'weight'])
43+
? BigNumber(account.getIn(['account_meta', 'weight']))
44+
.shiftedBy(-30)
45+
.toFormat(0)
46+
: '-'}
4547
</div>
4648
</div>
4749
{rows}

0 commit comments

Comments
 (0)