Skip to content

Commit

Permalink
fix: voting weight shows as NaN on account page (closes #113)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakia committed Apr 10, 2024
1 parent 1f48df7 commit 88a47fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 10 additions & 6 deletions api/routes/accounts/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ router.get('/:address', async (req, res) => {
return res.status(200).send(cachedAccount)
}

const accountInfo = await rpc.accountInfo({
account: address,
pending: true,
representative: true
})
const [account_weight, accountInfo] = await Promise.all([
rpc.accountWeight({ account: address }),
rpc.accountInfo({
account: address,
pending: true,
representative: true,
weight: true
})
])

const data = {
account: address,
Expand All @@ -46,7 +50,7 @@ router.get('/:address', async (req, res) => {
pending: BigNumber(accountInfo.pending).toNumber(),
balance: BigNumber(accountInfo.balance).toNumber(),
block_count: BigNumber(accountInfo.block_count).toNumber(),
weight: BigNumber(accountInfo.weight).toNumber(),
weight: BigNumber(account_weight.weight).toNumber(),
confirmation_height: BigNumber(
accountInfo.confirmation_height
).toNumber()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ export default class RepresentativeNetwork extends React.Component {
Weight Represented
</div>
<div className='account__section-metric-body'>
{BigNumber(account.getIn(['account_meta', 'weight']))
.shiftedBy(-30)
.toFormat(0)}
{account.getIn(['account_meta', 'weight'])
? BigNumber(account.getIn(['account_meta', 'weight']))
.shiftedBy(-30)
.toFormat(0)
: '-'}
</div>
</div>
{rows}
Expand Down

0 comments on commit 88a47fc

Please sign in to comment.