From 6c2b189298d4e091ae1de95e99a6b3e7d253d7e7 Mon Sep 17 00:00:00 2001 From: Sunny Gleason Date: Tue, 31 Dec 2019 16:34:53 -0500 Subject: [PATCH] feat: fix commision (0-100) and staked sol (handle null/NaN) --- api/api.js | 4 ++-- src/v1/BxDialogWorldMap.jsx | 3 +-- src/v2/components/Validators/Detail/index.jsx | 4 ++-- src/v2/components/Validators/index.jsx | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/api/api.js b/api/api.js index d33467c9..0a952162 100644 --- a/api/api.js +++ b/api/api.js @@ -709,13 +709,13 @@ async function getClusterInfo() { _.find(voteAccounts.current, x => x.nodePubkey === nodePubkey) || _.find(voteAccounts.delinquent, x => x.nodePubkey === nodePubkey); node.activatedStake = node.voteStatus && node.voteStatus.activatedStake; - node.commission = node.voteStatus && node.voteStatus.commission; + node.commission = (node.voteStatus && node.voteStatus.commission) || 0.0; node.stakedSol = lamportsToSol(node.activatedStake).toFixed(8); node.stakedSolPercent = (100 * (node.activatedStake / totalStaked)).toFixed( 3, ); - node.calcCommission = (100 * (node.commission / 0xff)).toFixed(3); + node.calcCommission = node.commission.toFixed(3); } for (const node of Object.keys(network).sort()) { diff --git a/src/v1/BxDialogWorldMap.jsx b/src/v1/BxDialogWorldMap.jsx index 390ca681..93b7956d 100644 --- a/src/v1/BxDialogWorldMap.jsx +++ b/src/v1/BxDialogWorldMap.jsx @@ -112,8 +112,7 @@ class Node extends React.Component {
Stake: {node.voteAccount.stake}
- Commission:{' '} - {(100 * (node.voteAccount.commission / 0xff)).toFixed(3)}% + Commission: {node.voteAccount.calcCommission}%
Vote Account: {node.voteAccount.votePubkey} diff --git a/src/v2/components/Validators/Detail/index.jsx b/src/v2/components/Validators/Detail/index.jsx index fb439cf9..6476b698 100644 --- a/src/v2/components/Validators/Detail/index.jsx +++ b/src/v2/components/Validators/Detail/index.jsx @@ -39,7 +39,7 @@ const ValidatorsDetail = ({match}: {match: Match}) => { const { nodePubkey, - commission, + calcCommission, identity = {}, stakedSol, stakedSolPercent, @@ -116,7 +116,7 @@ const ValidatorsDetail = ({match}: {match: Match}) => { { label: 'commission', hint: '', - value: `${commission} (${(100 * (commission / 0xff)).toFixed(3)}%)`, + value: `${calcCommission}%`, }, ]; diff --git a/src/v2/components/Validators/index.jsx b/src/v2/components/Validators/index.jsx index 061b24b7..0f239908 100644 --- a/src/v2/components/Validators/index.jsx +++ b/src/v2/components/Validators/index.jsx @@ -35,7 +35,7 @@ const Validators = () => { }, { title: 'Staked SOL', - value: totalStakedSol.toFixed(8), + value: totalStakedSol && totalStakedSol.toFixed(8), changes: '', period: 'since yesterday', helpText: 'The total number of SOL staked to validators and activated.',