Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add validators fee voting tab & reorganize Network tab #1098

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion public/locales/ca-CA/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,5 +560,6 @@
"search_results_banner": null,
"enable_amendment_name": null,
"amendment_status": null,
"expected_date": null
"expected_date": null,
"base": null
}
4 changes: 2 additions & 2 deletions public/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,6 @@
"search_results_banner": "Token search by name and account is now available! Try searching for USD",
"enable_amendment_name": "Amendment Name",
"amendment_status": "Amendment Status",
"expected_date": "Expected Date"

"expected_date": "Expected Date",
"base": "Base"
}
3 changes: 2 additions & 1 deletion public/locales/es-ES/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,5 +556,6 @@
"search_results_banner": null,
"enable_amendment_name": null,
"amendment_status": null,
"expected_date": null
"expected_date": null,
"base": null
}
3 changes: 2 additions & 1 deletion public/locales/fr-FR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -557,5 +557,6 @@
"search_results_banner": null,
"enable_amendment_name": null,
"amendment_status": null,
"expected_date": null
"expected_date": null,
"base": null
}
3 changes: 2 additions & 1 deletion public/locales/ja-JP/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,5 +556,6 @@
"search_results_banner": null,
"enable_amendment_name": null,
"amendment_status": null,
"expected_date": null
"expected_date": null,
"base": null
}
3 changes: 2 additions & 1 deletion public/locales/ko-KR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,5 +554,6 @@
"search_results_banner": null,
"enable_amendment_name": null,
"amendment_status": null,
"expected_date": null
"expected_date": null,
"base": null
}
12 changes: 9 additions & 3 deletions src/containers/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
ACCOUNT_ROUTE,
LEDGER_ROUTE,
LEDGERS_ROUTE,
NETWORK_ROUTE,
NFT_ROUTE,
PAYSTRING_ROUTE,
TOKEN_ROUTE,
Expand All @@ -26,12 +25,14 @@ import {
AMENDMENTS_ROUTE,
AMENDMENT_ROUTE,
MPT_ROUTE,
NODES_ROUTE,
VALIDATORS_ROUTE,
UPGRADE_STATUS_ROUTE,
} from './routes'
import { LedgersPage as Ledgers } from '../Ledgers'
import { Ledger } from '../Ledger'
import { AccountsRouter } from '../Accounts/AccountsRouter'
import { Transaction } from '../Transactions'
import { Network } from '../Network'
import { Validator } from '../Validators'
import { PayString } from '../PayStrings'
import Token from '../Token'
Expand All @@ -41,6 +42,9 @@ import { useCustomNetworks } from '../shared/hooks'
import { Amendments } from '../Amendments'
import { Amendment } from '../Amendment'
import { MPT } from '../MPT/MPT'
import { Nodes } from '../Network/Nodes'
import { Validators } from '../Network/Validators'
import { UpgradeStatus } from '../Network/UpgradeStatus'

export const AppWrapper = () => {
const mode = process.env.VITE_ENVIRONMENT
Expand All @@ -67,7 +71,9 @@ export const AppWrapper = () => {
[LEDGER_ROUTE, Ledger],
[ACCOUNT_ROUTE, AccountsRouter],
[TRANSACTION_ROUTE, Transaction],
[NETWORK_ROUTE, Network],
[NODES_ROUTE, Nodes],
[VALIDATORS_ROUTE, Validators],
[UPGRADE_STATUS_ROUTE, UpgradeStatus],
[AMENDMENTS_ROUTE, Amendments],
[VALIDATOR_ROUTE, Validator],
[PAYSTRING_ROUTE, PayString],
Expand Down
21 changes: 10 additions & 11 deletions src/containers/App/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { NavigationMenuAnyRoute } from '../Header/NavigationMenu'
import {
AMENDMENTS_ROUTE,
LEDGERS_ROUTE,
NETWORK_ROUTE,
VALIDATOR_ROUTE,
NODES_ROUTE,
UPGRADE_STATUS_ROUTE,
VALIDATORS_ROUTE,
} from './routes'

const isNetwork = (path) =>
path.indexOf(buildPath(NETWORK_ROUTE, {})) === 0 ||
path.indexOf(buildPath(VALIDATOR_ROUTE, { identifier: '' })) === 0
path.indexOf(buildPath(VALIDATORS_ROUTE, {})) === 0 ||
path.indexOf(buildPath(NODES_ROUTE, {})) === 0 ||
path.indexOf(buildPath(UPGRADE_STATUS_ROUTE, {})) === 0 ||
path.indexOf(buildPath(AMENDMENTS_ROUTE, {})) === 0

// NOTE: for submenus, remove `path` field and add `children` array of objects
export const navigationConfig: NavigationMenuAnyRoute[] = [
Expand All @@ -19,24 +22,20 @@ export const navigationConfig: NavigationMenuAnyRoute[] = [
current: (path: string) => !isNetwork(path),
},
{
route: NETWORK_ROUTE,
title: 'network',
current: (path: string) => isNetwork(path),
children: [
{
route: NETWORK_ROUTE,
route: NODES_ROUTE,
title: 'nodes',
params: { tab: 'nodes' },
},
{
route: NETWORK_ROUTE,
route: VALIDATORS_ROUTE,
title: 'validators',
params: { tab: 'validators' },
},
{
route: NETWORK_ROUTE,
route: UPGRADE_STATUS_ROUTE,
title: 'upgrade_status',
params: { tab: 'upgrade-status' },
},
{
route: AMENDMENTS_ROUTE,
Expand Down
14 changes: 11 additions & 3 deletions src/containers/App/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ export const LEDGER_ROUTE: RouteDefinition<{
path: `/ledgers/:identifier`,
}

export const NETWORK_ROUTE: RouteDefinition<{
tab?: 'nodes' | 'validators' | 'upgrade-status'
export const NODES_ROUTE: RouteDefinition = {
path: '/network/nodes',
}

export const VALIDATORS_ROUTE: RouteDefinition<{
tab?: 'uptime' | 'voting'
}> = {
path: '/network/:tab?',
path: '/network/validators/:tab?',
}

export const UPGRADE_STATUS_ROUTE: RouteDefinition = {
path: '/network/upgrade-status',
}

export const NFT_ROUTE: RouteDefinition<{
Expand Down
17 changes: 0 additions & 17 deletions src/containers/Network/NetworkTabs.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/containers/Network/Nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useContext } from 'react'
import axios from 'axios'
import { useTranslation } from 'react-i18next'
import { useQuery } from 'react-query'
import NetworkTabs from './NetworkTabs'
import { Map } from './Map'
import { NodesTable } from './NodesTable'
import Log from '../shared/log'
Expand All @@ -15,6 +14,7 @@ import {
import { useLanguage } from '../shared/hooks'
import { NodeData, NodeResponse } from '../shared/vhsTypes'
import NetworkContext from '../shared/NetworkContext'
import './css/style.scss'

export const ledgerCompare = (a: NodeData, b: NodeData) => {
const aLedger = a.validated_ledger.ledger_index
Expand Down Expand Up @@ -78,6 +78,7 @@ export const Nodes = () => {

return (
<div className="network-page">
<div className="type">{t('nodes')}</div>
{
// @ts-ignore - Work around for complex type assignment issues
<Map locations={data?.locations} />
Expand All @@ -99,7 +100,6 @@ export const Nodes = () => {
)}
</div>
<div className="wrap">
<NetworkTabs selected="nodes" />
<NodesTable nodes={data?.nodes} />
</div>
</div>
Expand Down
65 changes: 5 additions & 60 deletions src/containers/Network/UpgradeStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import { useState, useContext } from 'react'
import { useTranslation } from 'react-i18next'
import axios from 'axios'
import { useQuery } from 'react-query'
import { useTranslation } from 'react-i18next'
import BarChartVersion from './BarChartVersion'
import NetworkTabs from './NetworkTabs'
import Streams from '../shared/components/Streams'
import { Hexagons } from './Hexagons'
import {
FETCH_INTERVAL_MILLIS,
FETCH_INTERVAL_ERROR_MILLIS,
localizeNumber,
isEarlierVersion,
} from '../shared/utils'
import { useLanguage } from '../shared/hooks'
import Log from '../shared/log'
import {
NodeData,
NodeResponse,
StreamValidator,
ValidatorResponse,
} from '../shared/vhsTypes'
import { NodeData, NodeResponse, ValidatorResponse } from '../shared/vhsTypes'
import NetworkContext from '../shared/NetworkContext'
import { ledgerCompare } from './Nodes'
import { Loader } from '../shared/components/Loader'
import './css/style.scss'

interface NodeStats {
nodePercent: number
Expand Down Expand Up @@ -152,14 +143,10 @@ const handleNodeVersion = (version: string | undefined) => {
}

export const UpgradeStatus = () => {
const [vList, setVList] = useState<Record<string, ValidatorResponse>>({})
const [validations, setValidations] = useState<ValidatorResponse[]>([])
const [unlCount, setUnlCount] = useState(0)
const { t } = useTranslation()
const [validatorAggregation, setValidatorAggregation] =
useState<ValidatorAggregation>({})
const [nodeAggregation, setNodeAggregation] = useState<NodeAggregation>({})
const { t } = useTranslation()
const language = useLanguage()
const network = useContext(NetworkContext)

useQuery(
Expand Down Expand Up @@ -200,10 +187,6 @@ export const UpgradeStatus = () => {
validators.forEach((validator) => {
newValidatorList[validator.signing_key] = validator
})
setVList(newValidatorList)
setUnlCount(
validators.filter((validator) => Boolean(validator.unl)).length,
)
setValidatorAggregation(aggregateValidators(validators))
return Object.values(newValidatorList)
})
Expand Down Expand Up @@ -254,48 +237,10 @@ export const UpgradeStatus = () => {
)
}

const updateValidators = (newValidations: StreamValidator[]) => {
setValidations(newValidations)
setVList((validatorList) => {
const newValidatorsList: Record<string, StreamValidator> = {
...validatorList,
}
newValidations.forEach((validation) => {
if (validation.pubkey) {
newValidatorsList[validation.pubkey] = {
...validatorList[validation.pubkey],
ledger_index: validation.ledger_index,
ledger_hash: validation.ledger_hash,
}
}
})
return newValidatorsList
})
}

const validatorCount = Object.keys(vList).length

return (
<div className="network-page">
<Streams validators={vList} updateValidators={updateValidators} />
{
// @ts-ignore - Work around for complex type assignment issues
<Hexagons data={validations} list={vList} />
}
<div className="stat">
<span>{t('validators_found')}: </span>
<span>
{localizeNumber(validatorCount, language)}
{unlCount !== 0 && (
<i>
{' '}
({t('unl')}: {unlCount})
</i>
)}
</span>
</div>
<div className="type">{t('upgrade_status')}</div>
<div className="wrap">
<NetworkTabs selected="upgrade-status" />
{Object.keys(validatorAggregation).length > 0 ||
Object.keys(nodeAggregation).length > 0 ? (
<div className="upgrade_status">
Expand Down
Loading
Loading