Skip to content

Commit

Permalink
feat(webapp): add non-compliant BPs section
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Jan 17, 2023
1 parent 9fe6772 commit c32acfa
Show file tree
Hide file tree
Showing 33 changed files with 438 additions and 59 deletions.
34 changes: 8 additions & 26 deletions webapp/src/components/InformationCard/ProducerInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,21 @@ import Link from '@mui/material/Link'
import Typography from '@mui/material/Typography'

import CountryFlag from '../CountryFlag'
import CopyToClipboard from '../CopyToClipboard'
import MoreInfoModal from '../MoreInfoModal'
import VisitSite from '../VisitSite'

const ProducerInformation = ({ info, classes, t }) => {
const URLModal = ({ data }) => {
if (!Array.isArray(data)) return <></>
return (
<MoreInfoModal hideCloseButton>
{Array.isArray(data) ? (
<>
{data.map((url, i) => (
<div className={classes.dd} key={i}>
<Link href={url} target="_blank" rel="noopener noreferrer">
{url}
</Link>
</div>
))}
</>
) : (
<div className={classes.flex}>
<div className={classes.popoverStyle}>
<Link href={data} target="_blank" rel="noopener noreferrer">
{data}
</Link>
</div>
<CopyToClipboard text={data} />
<MoreInfoModal>
{data.map((url, index) => (
<div className={classes.dd} key={`more-info-${url}-${index}`}>
<Link href={url} target="_blank" rel="noopener noreferrer">
{url}
</Link>
</div>
)}
))}
</MoreInfoModal>
)
}
Expand All @@ -54,7 +41,6 @@ const ProducerInformation = ({ info, classes, t }) => {
{t('website')}:
</Typography>
<VisitSite title={t('openLink')} url={info?.website} />
<URLModal data={info?.website} />
</>
) : (
<Typography variant="body1" className={classes.textEllipsis}>
Expand All @@ -69,7 +55,6 @@ const ProducerInformation = ({ info, classes, t }) => {
{t('email')}:
</Typography>
<VisitSite title={t('openLink')} url={`mailto:${info.email}`} />
<URLModal data={info?.email} />
</>
) : (
<Typography variant="body1" className={classes.textEllipsis}>
Expand All @@ -84,7 +69,6 @@ const ProducerInformation = ({ info, classes, t }) => {
{t('ownershipDisclosure')}:
</Typography>
<VisitSite title={t('openLink')} url={info?.ownership} />
<URLModal data={info?.ownership} />
</>
) : null}
</div>
Expand All @@ -95,7 +79,6 @@ const ProducerInformation = ({ info, classes, t }) => {
{t('codeofconduct')}:
</Typography>
<VisitSite title={t('openLink')} url={info?.code_of_conduct} />
<URLModal data={info?.code_of_conduct} />
</>
) : null}
</div>
Expand All @@ -106,7 +89,6 @@ const ProducerInformation = ({ info, classes, t }) => {
{t('chainResources')}:
</Typography>
<VisitSite title={t('openLink')} url={info?.chain} />
<URLModal data={info?.chain} />
</>
) : null}
</div>
Expand Down
1 change: 1 addition & 0 deletions webapp/src/gql/producer.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const PRODUCERS_QUERY = gql`
) {
id
owner
url
total_votes
bp_json
total_votes_percent
Expand Down
61 changes: 61 additions & 0 deletions webapp/src/hooks/customHooks/useNonCompliantState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useState, useEffect } from 'react'
import { useLazyQuery } from '@apollo/client'

import { PRODUCERS_QUERY, SETTING_QUERY } from '../../gql'

const useNonCompliantState = () => {
const [loadProducers, { loading = true, data: { producers } = {} }] =
useLazyQuery(PRODUCERS_QUERY)
const [loadSettings, { data: { setting } = {} }] = useLazyQuery(SETTING_QUERY)
const [items, setItems] = useState([])
const [stats, setStats] = useState()

useEffect(() => {
loadSettings({})
loadProducers({
variables: {
where: { total_rewards: { _gte: 100 } },
offset: 0,
limit: 150,
},
})
}, [loadSettings, loadProducers])

useEffect(() => {
if (!producers) return

const { nonCompliantBPs, totalDailyRewards, nonCompliantRewards } =
producers.reduce(
(stats, producer) => {
if (!Object.keys(producer.bp_json).length) {
stats.nonCompliantBPs.push(producer)
stats.nonCompliantRewards += producer.total_rewards
}

stats.totalDailyRewards += producer.total_rewards

return stats
},
{ nonCompliantBPs: [], totalDailyRewards: 0, nonCompliantRewards: 0 },
)

const percentageRewards = (nonCompliantRewards / totalDailyRewards) * 100

setStats({
percentageRewards,
dailyRewards: nonCompliantRewards,
tokenPrice: setting?.token_price,
})
setItems(nonCompliantBPs)
}, [producers, setting])

return [
{
items,
stats,
loading,
},
]
}

export default useNonCompliantState
11 changes: 8 additions & 3 deletions webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"footer2": "Developed by Edenia",
"executeTransaction": "Execute Transaction",
"bugRequest": "Report a bug / Request a feature",
"moreInfo": "More Info"
"moreInfo": "More Info",
"openLink": "Visit Site"
},
"routes": {
"/>sidebar": "Dashboard",
Expand All @@ -54,6 +55,9 @@
"/block-producers>sidebar": "Block Producers",
"/block-producers>title": "Block Producers - EOSIO Network Dashboard",
"/block-producers>heading": "Block Producers",
"/non-compliant-bps>sidebar": "Non-compliant BPs",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - EOSIO Network Dashboard",
"/non-compliant-bps>heading": "Non-compliant Blocks Producers",
"/rewards-distribution>sidebar": "Rewards Distribution",
"/rewards-distribution>title": "Rewards Distribution - EOSIO Network Dashboard",
"/rewards-distribution>heading": "Rewards Distribution",
Expand Down Expand Up @@ -242,7 +246,6 @@
"health": "Compliance",
"collapse": "Collapse",
"moreInfo": "More Info",
"openLink": "Visit Site",
"version": "Version",
"info": "Info",
"keys": "Keys",
Expand All @@ -254,7 +257,9 @@
"hs_bpJson": "BP Json",
"emptyState": "This block producer does not provide any information.",
"average": "average rating",
"ratings": "ratings"
"ratings": "ratings",
"lastClaimTime": "Last time claimed",
"noInfo": "No info provided"
},
"nodeCardComponent": {
"features": "Features",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.jungle.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Jungle4 Testnet Network Dashboard",
"/block-producers>title": "Block Producers - Jungle4 Testnet Network Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Jungle4 Testnet Network Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Jungle4 Testnet Dashboard",
"/nodes>title": "Nodes - Jungle4 Testnet Network Dashboard",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Jungle4 Testnet Network Dashboard",
"/accounts>title": "Accounts and Contracts - Jungle4 Testnet Network Dashboard",
Expand All @@ -15,6 +16,7 @@
"/about>title": "About - Jungle4 Testnet Network Dashboard",
"/help>title": "Help - Jungle4 Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
"/ricardian-contract>moreDescription": "The on-chain ricardian contract that describes the validator node agreement of this network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.libre-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Libre Testnet Network Dashboard",
"/block-producers>title": "Block Producers - Libre Testnet Network Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Libre Testnet Network Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Libre Testnet Dashboard",
"/nodes>title": "Libre Testnet Nodes Status Monitor",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Libre Testnet Network Dashboard",
"/accounts>title": "Accounts and Contracts - Libre Testnet Network Dashboard",
Expand All @@ -15,6 +16,7 @@
"/about>title": "About - Libre Testnet Network Dashboard",
"/help>title": "Help - Libre Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/faucet>moreDescription": "This tool allows you to create an account and get LIBRE testnet tokens.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.libre.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Libre Mainnet Network Dashboard",
"/block-producers>title": "Block Producers - Libre Mainnet Network Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Libre Mainnet Network Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Libre Mainnet Dashboard",
"/nodes>title": "Libre Mainnet Nodes Status Monitor",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Libre Mainnet Network Dashboard",
"/accounts>title": "Accounts and Contracts - Libre Mainnet Network Dashboard",
Expand All @@ -15,6 +16,7 @@
"/about>title": "About - Libre Mainnet Network Dashboard",
"/help>title": "Help - Libre Mainnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/faucet>moreDescription": "This tool allows you to create an account and get LIBRE testnet tokens.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/language/en.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"/about>title": "About - EOS Network Monitor",
"/help>title": "Help - EOS Network Monitor",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
"/ricardian-contract>moreDescription": "The on-chain ricardian contract that describes the validator node agreement of this network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.proton-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Proton Testnet Network Dashboard",
"/block-producers>title": "Block Producers - Proton Testnet Network Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Proton Testnet Network Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Proton Testnet Dashboard",
"/nodes>title": "Proton Testnet Nodes Status Monitor",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Proton Testnet Network Dashboard",
"/accounts>title": "Accounts and Contracts - Proton Testnet Network Dashboard",
Expand All @@ -15,6 +16,7 @@
"/about>title": "About - Proton Testnet Network Dashboard",
"/help>title": "Help - Proton Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
"/ricardian-contract>moreDescription": "The on-chain ricardian contract that describes the validator node agreement of this network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.proton.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Proton Network Dashboard",
"/block-producers>title": "Block Producers - Proton Network Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Proton Network Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Proton Network Dashboard",
"/nodes>title": "Proton Nodes Status Monitor",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Proton Network Dashboard",
"/accounts>title": "Accounts and Contracts - Proton Network Dashboard",
Expand All @@ -15,6 +16,7 @@
"/about>title": "About - Proton Network Dashboard",
"/help>title": "Help - Proton Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
"/ricardian-contract>moreDescription": "The on-chain ricardian contract that describes the validator node agreement of this network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.telos-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Telos Testnet Network Dashboard",
"/block-producers>title": "Block Producers - Telos Testnet Network Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Telos Testnet Network Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Telos Testnet Dashboard",
"/nodes>title": "Telos Testnet Nodes Status Monitor",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Telos Testnet Network Dashboard",
"/accounts>title": "Accounts and Contracts - Telos Testnet Network Dashboard",
Expand All @@ -15,6 +16,7 @@
"/about>title": "About - Telos Testnet Network Dashboard",
"/help>title": "Help - Telos Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
"/ricardian-contract>moreDescription": "The on-chain ricardian contract that describes the validator node agreement of this network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.telos.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Telos Network Dashboard",
"/block-producers>title": "Block Producers - Telos Network Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Telos Network Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Telos Network Dashboard",
"/nodes>title": "Telos Nodes Status Monitor",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Telos Network Dashboard",
"/accounts>title": "Accounts and Contracts - Telos Network Dashboard",
Expand All @@ -15,6 +16,7 @@
"/about>title": "About - Telos Network Dashboard",
"/help>title": "Help - Telos Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
"/ricardian-contract>moreDescription": "The on-chain ricardian contract that describes the validator node agreement of this network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.ultra-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/cpu-benchmark>title": "CPU Benchmarks - Ultra Testnet Dashboard",
"/block-producers>title": "Block Producers - Ultra Testnet Dashboard",
"/rewards-distribution>title": "Rewards Distribution - Ultra Testnet Dashboard",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - Ultra Testnet Dashboard",
"/nodes>title": "Ultra Nodes Status Monitor",
"/nodes-distribution>title": "Geographic Distribution of Nodes - Ultra Testnet Dashboard",
"/accounts>title": "Accounts and Contracts - Ultra Testnet Dashboard",
Expand All @@ -16,6 +17,7 @@
"/about>title": "About - Ultra Testnet Dashboard",
"/help>title": "Help - Ultra Testnet Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of non-compliant paid block producers.",
"/non-compliant-bps>moreDescription": "A list of the paid block producers in the network which do not provide information in their BP.json files.",
"/bpjson>moreDescription": "A tool for block producers to provide details of their organizations and nodes to comply with the BP information standard.",
"/faucet>moreDescription": "This tool allows you to create an account and get UOS testnet tokens.",
"/node-config>moreDescription": "Use this tool to obtain example config files to help configure a new node on the network.",
Expand Down
Loading

0 comments on commit c32acfa

Please sign in to comment.