Skip to content

Commit

Permalink
ui: fix beacon stat display in the Lido app
Browse files Browse the repository at this point in the history
  • Loading branch information
skozin authored and ongrid committed Nov 22, 2020
1 parent 6d5cff2 commit 118bdc2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
22 changes: 12 additions & 10 deletions apps/lido/app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function App() {
// operators,
// treasury,
// insuranceFund,
// ether2Stat,
// beaconStat,
} = appState

return [
Expand Down Expand Up @@ -176,13 +176,15 @@ export default function App() {
]
}, [appState, theme])

const ether2StatData = useMemo(() => {
const { ether2Stat } = appState

return Object.entries(ether2Stat).map(([key, value]) => ({
label: key,
content: <strong>{value}</strong>,
}))
const beaconStatData = useMemo(() => {
const { beaconStat: stat } = appState
return [
{
label: 'Deposits',
content: <strong>{stat.depositedValidators}</strong>,
},
{ label: 'Balance', content: <strong>{stat.beaconBalance}</strong> },
]
}, [appState])

const [stakeSidePanelOpen, setStakeSidePanelOpen] = useState(false)
Expand Down Expand Up @@ -234,9 +236,9 @@ export default function App() {
</Box>
}
secondary={
<Box heading="ether2Stat">
<Box heading="Beacon stat">
<ul>
{ether2StatData.map(({ label, content }, index) => (
{beaconStatData.map(({ label, content }, index) => (
<ListItem key={label + index}>
<span>{label}</span>
<span>:</span>
Expand Down
2 changes: 1 addition & 1 deletion apps/lido/app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultState = {
operators: defaultValue,
treasury: defaultValue,
insuranceFund: defaultValue,
ether2Stat: defaultValue,
beaconStat: defaultValue,
isSyncing: true,
}

Expand Down
6 changes: 3 additions & 3 deletions apps/lido/app/src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function initializeState() {
// operators: await getOperators(),
// treasury: await getTreasury(),
// insuranceFund: await getInsuranceFund(),
ether2Stat: await getBeaconStat(),
beaconStat: await getBeaconStat(),
}
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ async function getOracle() {
async function getBeaconStat() {
const stat = await app.call('getBeaconStat').toPromise()
return {
Deposited: fromWei(stat.depositedValidators),
Remote: fromWei(stat.beaconBalance),
depositedValidators: +stat.depositedValidators,
beaconBalance: fromWei(stat.beaconBalance),
}
}

0 comments on commit 118bdc2

Please sign in to comment.