From 64429d6bca828493c7dddb5599a164bf0469f0f2 Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Wed, 15 Feb 2023 19:19:36 +0100 Subject: [PATCH 1/6] backend: point to API v2 --- package-lock.json | 6 +++--- package.json | 2 +- src/actions/blockActions.ts | 7 ++++++- src/actions/contractActions.ts | 7 ++++++- src/actions/searchActions.ts | 7 ++++++- src/actions/transactionActions.ts | 7 ++++++- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 56c3bc0..8aa909e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2102,9 +2102,9 @@ } }, "@cityofzion/dora-ts": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/@cityofzion/dora-ts/-/dora-ts-0.0.6.tgz", - "integrity": "sha512-yrSwc/AUAZcQ8T0HKjzgdrtXmbk3x1ivPSzywRckevNOFUF+gfCsWT2qcEPtq/8DETglaUFkS5llQv9c4U4pzA==", + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/@cityofzion/dora-ts/-/dora-ts-0.0.11.tgz", + "integrity": "sha512-LJWGU29BHPTHkt0i/OwhNdMfUGM/rgAa4rqlDwBy95spxSoUHGSoAtOD5k4aSVKmLFwq77ghNna0Lpc7lEuHBA==", "requires": { "axios": "^0.21.1" } diff --git a/package.json b/package.json index 78fc26f..212fb3b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@chakra-ui/react": "^1.8.8", - "@cityofzion/dora-ts": "^0.0.6", + "@cityofzion/dora-ts": "^0.0.11", "@cityofzion/neon-js": "^5.0.0", "@emotion/react": "^11.9.0", "@emotion/styled": "^11.8.1", diff --git a/src/actions/blockActions.ts b/src/actions/blockActions.ts index df75495..cd38519 100644 --- a/src/actions/blockActions.ts +++ b/src/actions/blockActions.ts @@ -9,10 +9,15 @@ import { } from '../constants' import { Block, State } from '../reducers/blockReducer' import { sortSingleListByDate } from '../utils/time' -import { NeoLegacyREST, NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoLegacyREST, NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { BlocksResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo' import { BlocksResponse as NLBlocksResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo_legacy' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export const REQUEST_BLOCK = 'REQUEST_BLOCK' // We can dispatch this action if requesting // block by height (index) or by its hash diff --git a/src/actions/contractActions.ts b/src/actions/contractActions.ts index 3ee19b5..eb75f98 100644 --- a/src/actions/contractActions.ts +++ b/src/actions/contractActions.ts @@ -4,13 +4,18 @@ import { ThunkDispatch } from 'redux-thunk' import { GENERATE_BASE_URL, SUPPORTED_PLATFORMS } from '../constants' import { Contract, State } from '../reducers/contractReducer' import { sortSingleListByDate } from '../utils/time' -import { NeoLegacyREST, NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoLegacyREST, NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { ContractsResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo' import { ContractsResponse as NLContractsResponse, InvocationStatsResponse, } from '@cityofzion/dora-ts/dist/interfaces/api/neo_legacy' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export const REQUEST_CONTRACT = 'REQUEST_CONTRACT' export const requestContract = (hash: string) => diff --git a/src/actions/searchActions.ts b/src/actions/searchActions.ts index e81a044..3a2aac6 100644 --- a/src/actions/searchActions.ts +++ b/src/actions/searchActions.ts @@ -1,7 +1,12 @@ import { ThunkDispatch } from 'redux-thunk' import { Dispatch, Action } from 'redux' import { State } from '../reducers/searchReducer' -import { NeoLegacyREST, NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoLegacyREST, NeoRESTApi } from '@cityofzion/dora-ts/dist/api' + +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) export const SEARCH_INPUT_ENTERED = 'SEARCH_INPUT_ENTERED' export const searchInputEntered = diff --git a/src/actions/transactionActions.ts b/src/actions/transactionActions.ts index 05db751..ca240c4 100644 --- a/src/actions/transactionActions.ts +++ b/src/actions/transactionActions.ts @@ -10,10 +10,15 @@ import { import { State as NetworkState } from '../reducers/networkReducer' import { State, Transaction } from '../reducers/transactionReducer' import { sortSingleListByDate } from '../utils/time' -import { NeoLegacyREST, NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoLegacyREST, NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { TransactionsResponse as NLTransactionsResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo_legacy' import { TransactionsResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export const REQUEST_TRANSACTION = 'REQUEST_TRANSACTION' export const requestTransaction = (hash: string) => From 489f3857c68f421765506e681458bae3b639cfe3 Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Fri, 28 Jul 2023 10:15:21 +0200 Subject: [PATCH 2/6] Point endpoints to v2 api --- src/actions/addressActions.ts | 7 ++++++- src/actions/blockActions.ts | 7 ++++++- src/actions/contractActions.ts | 7 ++++++- src/actions/searchActions.ts | 7 ++++++- src/actions/transactionActions.ts | 7 ++++++- src/components/transaction/notification/Notification.tsx | 7 ++++++- .../fragments/transactions/AddressTransactionService.ts | 7 ++++++- .../address/fragments/transactions/AddressTransactions.tsx | 7 ++++++- src/pages/transaction/Transaction.tsx | 7 ++++++- src/pages/transaction/fragment/TransactionLog.tsx | 7 ++++++- 10 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/actions/addressActions.ts b/src/actions/addressActions.ts index 24a515b..6b71d71 100644 --- a/src/actions/addressActions.ts +++ b/src/actions/addressActions.ts @@ -3,7 +3,12 @@ import { ThunkDispatch } from 'redux-thunk' import { State } from '../reducers/addressReducer' import { State as NetworkState } from '../reducers/networkReducer' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' + +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) export const REQUEST_ADDRESS = 'REQUEST_ADDRESS' export const requestAddress = diff --git a/src/actions/blockActions.ts b/src/actions/blockActions.ts index a8d83bd..43b32c7 100644 --- a/src/actions/blockActions.ts +++ b/src/actions/blockActions.ts @@ -4,10 +4,15 @@ import { ThunkDispatch } from 'redux-thunk' import { SUPPORTED_PLATFORMS } from '../constants' import { Block, DetailedBlock, State } from '../reducers/blockReducer' import { sortSingleListByDate } from '../utils/time' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { BlockTransaction } from '../reducers/transactionReducer' import { State as NetworkState } from '../reducers/networkReducer' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export const REQUEST_BLOCK = 'REQUEST_BLOCK' // We can dispatch this action if requesting // block by height (index) diff --git a/src/actions/contractActions.ts b/src/actions/contractActions.ts index 8e1d204..71c105c 100644 --- a/src/actions/contractActions.ts +++ b/src/actions/contractActions.ts @@ -4,10 +4,15 @@ import { ThunkDispatch } from 'redux-thunk' import { SUPPORTED_PLATFORMS } from '../constants' import { Contract, InvocationStat, State } from '../reducers/contractReducer' import { sortSingleListByDate } from '../utils/time' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { ContractResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo' import { State as NetworkState } from '../reducers/networkReducer' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export const REQUEST_CONTRACT = 'REQUEST_CONTRACT' export const requestContract = (hash: string) => diff --git a/src/actions/searchActions.ts b/src/actions/searchActions.ts index 1ae8fda..ffaae9d 100644 --- a/src/actions/searchActions.ts +++ b/src/actions/searchActions.ts @@ -1,7 +1,12 @@ import { ThunkDispatch } from 'redux-thunk' import { Dispatch, Action } from 'redux' import { State } from '../reducers/searchReducer' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' + +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) export const SEARCH_INPUT_ENTERED = 'SEARCH_INPUT_ENTERED' export const searchInputEntered = diff --git a/src/actions/transactionActions.ts b/src/actions/transactionActions.ts index d4baa40..9bdc1e5 100644 --- a/src/actions/transactionActions.ts +++ b/src/actions/transactionActions.ts @@ -5,7 +5,12 @@ import { SUPPORTED_PLATFORMS } from '../constants' import { State as NetworkState } from '../reducers/networkReducer' import { State, Transaction } from '../reducers/transactionReducer' import { sortSingleListByDate } from '../utils/time' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' + +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) export const REQUEST_TRANSACTION = 'REQUEST_TRANSACTION' export const requestTransaction = diff --git a/src/components/transaction/notification/Notification.tsx b/src/components/transaction/notification/Notification.tsx index 306fe55..133df1e 100644 --- a/src/components/transaction/notification/Notification.tsx +++ b/src/components/transaction/notification/Notification.tsx @@ -10,9 +10,14 @@ import Skeleton, { SkeletonTheme } from 'react-loading-skeleton' import { uuid } from '../../../utils/formatter' import { u } from '@cityofzion/neon-js' import { StackPanel } from '../StackPanel' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { ContractResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export const Notification: React.FC<{ notifications: TransactionNotification[] chain: string diff --git a/src/pages/address/fragments/transactions/AddressTransactionService.ts b/src/pages/address/fragments/transactions/AddressTransactionService.ts index 4d2f1c5..40cefc8 100644 --- a/src/pages/address/fragments/transactions/AddressTransactionService.ts +++ b/src/pages/address/fragments/transactions/AddressTransactionService.ts @@ -1,7 +1,12 @@ -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { store } from '../../../../store' import { AddressTransactionsResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export const fetchTransaction = async (hash: string, page = 1) => { try { const network = store.getState().network.network diff --git a/src/pages/address/fragments/transactions/AddressTransactions.tsx b/src/pages/address/fragments/transactions/AddressTransactions.tsx index 1ea7430..6204916 100644 --- a/src/pages/address/fragments/transactions/AddressTransactions.tsx +++ b/src/pages/address/fragments/transactions/AddressTransactions.tsx @@ -8,13 +8,18 @@ import Skeleton, { SkeletonTheme } from 'react-loading-skeleton' import { convertToArbitraryDecimals } from '../../../../utils/formatter' import AddressTransactionsCard from './fragments/AddressTransactionCard' import useUpdateNetworkState from '../../../../hooks/useUpdateNetworkState' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { Notification, TransactionEnhanced, Transfer as TransferDoraTS, } from '@cityofzion/dora-ts/dist/interfaces/api/neo/interface' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + interface MatchParams { hash: string chain: string diff --git a/src/pages/transaction/Transaction.tsx b/src/pages/transaction/Transaction.tsx index 7902f95..2fa68d0 100644 --- a/src/pages/transaction/Transaction.tsx +++ b/src/pages/transaction/Transaction.tsx @@ -17,9 +17,14 @@ import BackButton from '../../components/navigation/BackButton' import { ReactComponent as TransactionIcon } from '../../assets/icons/invocation.svg' import { Box, Flex, Text } from '@chakra-ui/react' import { u } from '@cityofzion/neon-js' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { store } from '../../store' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + export type ParsedTransfer = { name: string amount: string | number diff --git a/src/pages/transaction/fragment/TransactionLog.tsx b/src/pages/transaction/fragment/TransactionLog.tsx index 0d01592..17559f6 100644 --- a/src/pages/transaction/fragment/TransactionLog.tsx +++ b/src/pages/transaction/fragment/TransactionLog.tsx @@ -3,10 +3,15 @@ import { Box, BoxProps, Flex, Text } from '@chakra-ui/react' import Copy from '../../../components/copy/Copy' import { DetailedTransaction } from '../../../reducers/transactionReducer' -import { NeoRest } from '@cityofzion/dora-ts/dist/api' +import { NeoRESTApi } from '@cityofzion/dora-ts/dist/api' import { store } from '../../../store' import { LogResponse } from '@cityofzion/dora-ts/dist/interfaces/api/neo' +const NeoRest = new NeoRESTApi({ + doraUrl: 'https://dora.coz.io', + endpoint: '/api/v2/neo3', +}) + interface Props extends BoxProps { transaction: DetailedTransaction | null } From 3a9d61f8073d914629a60e4b6e92729d4c6140dc Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Mon, 21 Aug 2023 13:47:35 +0200 Subject: [PATCH 3/6] package-lock.json --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index eb482bd..f9f8d37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11833,7 +11833,7 @@ "growly": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", - "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", + "integrity": "sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw==", "dev": true, "optional": true }, From 8c625f4ba55001931d07566ab44beb2eaf1f15d0 Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Tue, 22 Aug 2023 15:45:42 +0200 Subject: [PATCH 4/6] fix "completed on" date for transactions on block details page --- src/components/transaction/N3BlockTransactionList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/transaction/N3BlockTransactionList.tsx b/src/components/transaction/N3BlockTransactionList.tsx index f243c41..7886cf0 100644 --- a/src/components/transaction/N3BlockTransactionList.tsx +++ b/src/components/transaction/N3BlockTransactionList.tsx @@ -33,7 +33,7 @@ const mapTransactionData = ( } const returnTxListData = (block: DetailedBlock): Array => { - return block.tx.map(tx => mapTransactionData(tx, block.blocktime)) + return block.tx.map(tx => mapTransactionData(tx, block.time)) } const N3BlockTransactionsList: React.FC<{ From 53f9f0c51e7c364442c81ab18f9ca9e0717a3eb5 Mon Sep 17 00:00:00 2001 From: Thais Bastos Date: Thu, 24 Aug 2023 04:46:21 -0300 Subject: [PATCH 5/6] CU-86a0bqr0f - migrate monitor page to new websocket (#651) --- src/pages/endpoint/Endpoint.tsx | 16 +-------- src/pages/monitor/Monitor.tsx | 64 ++++++++++++++------------------- src/reducers/nodeReducer.ts | 52 +++++++-------------------- 3 files changed, 39 insertions(+), 93 deletions(-) diff --git a/src/pages/endpoint/Endpoint.tsx b/src/pages/endpoint/Endpoint.tsx index 0eb4d2b..c906aa6 100644 --- a/src/pages/endpoint/Endpoint.tsx +++ b/src/pages/endpoint/Endpoint.tsx @@ -83,12 +83,6 @@ const Endpoint: React.FC = (props: Props) => { -
- - - {endpointSelected && endpointSelected.type} - -
-
- - - #{endpointSelected && endpointSelected.stateheight} - -
- {endpointSelected && endpointSelected.version} + {endpointSelected && endpointSelected.user_agent}
diff --git a/src/pages/monitor/Monitor.tsx b/src/pages/monitor/Monitor.tsx index 1d42991..37152a5 100644 --- a/src/pages/monitor/Monitor.tsx +++ b/src/pages/monitor/Monitor.tsx @@ -43,10 +43,8 @@ import { uniqueId } from 'lodash' type ParsedNodes = { endpoint: React.FC<{}> - type: React.FC<{}> isItUp: React.FC<{}> availability: string | React.FC<{}> - stateHeight: string | React.FC<{}> blockHeight: string | React.FC<{}> version: string | React.FC<{}> peers: number | React.FC<{}> @@ -59,7 +57,7 @@ interface AllNodes { interface Endpoint extends AllNodes { url: string - locale: string + endpointLocation: string } const STATUS_ICONS = [ @@ -69,7 +67,7 @@ const STATUS_ICONS = [ { status: 'stalled', Icon: DisapprovedSVG, color: '#de4c85' }, ] -const Endpoint: React.FC = ({ url, locale, disable }) => { +const Endpoint: React.FC = ({ url, endpointLocation, disable }) => { const { setMessage, setShowMessage } = useContext(MonitorContext) const handleClickEndpoint = ( e: React.MouseEvent, @@ -80,6 +78,18 @@ const Endpoint: React.FC = ({ url, locale, disable }) => { setShowMessage(true) } + const LOCATIONS_FLAGS = [ + { location: 'United States', countryCode: 'US' }, + { location: 'USA', countryCode: 'US' }, + { location: 'Hong Kong', countryCode: 'HK' }, + { location: 'Canada', countryCode: 'CA' }, + { location: 'China', countryCode: 'CN' }, + { location: 'US', countryCode: 'US' }, + { location: 'Singapore', countryCode: 'SG' }, + { location: 'France', countryCode: 'FR' }, + { location: 'Russia', countryCode: 'RU' }, + ] + return (
@@ -89,7 +99,11 @@ const Endpoint: React.FC = ({ url, locale, disable }) => { fontSize: '1.5em', lineHeight: '1.5em', }} - countryCode={locale} + countryCode={ + LOCATIONS_FLAGS.find( + ({ location }) => location === endpointLocation, + )?.countryCode + } />
{url}
@@ -346,14 +360,11 @@ const mapNodesData = (data: WSDoraData): ParsedNodes => { endpoint: (): ReactElement => ( ), - type: (): ReactElement => ( - - ), blockHeight: isPositive() ? (): ReactElement => ( @@ -366,7 +377,7 @@ const mapNodesData = (data: WSDoraData): ParsedNodes => { /> ), version: isPositive() - ? (): ReactElement => + ? (): ReactElement => : (): ReactElement => ( ), @@ -381,7 +392,7 @@ const mapNodesData = (data: WSDoraData): ParsedNodes => { ), availability: isPositive() ? (): ReactElement => ( - + ) : (): ReactElement => ( { url={url} /> ), - stateHeight: isPositive() - ? (): ReactElement => ( - - ) - : (): ReactElement => ( - - ), isItUp: (): ReactElement => ( = ({ network, protocol }) => { }>({ desc: false, sort: 'isItUp' }) const selectedData = (): WSDoraData[] => { - let sortedNodes = OrderNodes( + const sortedNodes = OrderNodes( sortDataList.sort, nodes.nodesArray, sortDataList.desc, ) - sortedNodes = sortedNodes.filter(node => node.protocol !== 'neo2') - if (protocol === 'all' && network === 'all') { return sortedNodes - } else if (protocol === 'all' && network !== 'all') { + } else if (network !== 'all') { return sortedNodes.filter(node => node.network === network) - } else if (protocol !== 'all' && network === 'all') { - return sortedNodes.filter(node => node.protocol === protocol) } else { //temporary state, remove when api cuts over let mutableNetwork = network @@ -594,9 +588,7 @@ const ListMonitor: React.FC = ({ network, protocol }) => { mutableNetwork = 'testnet' } - return sortedNodes.filter( - node => node.protocol === protocol && node.network === mutableNetwork, - ) + return sortedNodes.filter(node => node.network === mutableNetwork) } } @@ -620,7 +612,7 @@ const ListMonitor: React.FC = ({ network, protocol }) => { useEffect(() => { let socket: Socket if (window.location.pathname.includes(ROUTES.MONITOR.url)) { - socket = new Socket('wss://dora.coz.io/ws/v1/unified/network_status') + socket = new Socket('wss://dora.coz.io/ws/v2/unified/network_status') socket.listening(data => { dispatch(setNode(data)) }) @@ -835,10 +827,6 @@ const Monitor: React.FC<{}> = () => { sortDataList.desc, ) - if (protocol !== 'all') { - sortedNodes = sortedNodes.filter(node => node.protocol === protocol) - } - if (network !== 'all') { sortedNodes = sortedNodes.filter(node => node.network === network) } diff --git a/src/reducers/nodeReducer.ts b/src/reducers/nodeReducer.ts index e8e29b7..85639b7 100644 --- a/src/reducers/nodeReducer.ts +++ b/src/reducers/nodeReducer.ts @@ -1,26 +1,16 @@ import { SET_NODE, NodeDTO } from '../actions/nodeActions' export type WSDoraData = { - locale: string location: string network: string - protocol: string - type: string height: number - last_seen: number peers: number - stateheight: number status: string - version: string - reliability: number - plugins: { - name: string - version: string - interfaces: string[] - }[] - lastblocktime: number - laststatetime: number + user_agent: string availability: number url: string + scheme: string + host: string + port: number } export type State = { @@ -45,10 +35,8 @@ export const INITIAL_STATE: State = { export type SORT_OPTION = | 'endpoint' - | 'type' | 'isItUp' | 'availability' - | 'stateHeight' | 'blockHeight' | 'version' | 'peers' @@ -86,8 +74,8 @@ export const OrderNodes = ( case 'availability': return !desc ? nodes.sort((node1, node2) => { - const nodeValidated1 = node1.reliability ?? node1.availability - const nodeValidated2 = node2.reliability ?? node2.availability + const nodeValidated1 = node1.availability + const nodeValidated2 = node2.availability return nodeValidated1 > nodeValidated2 ? -1 : nodeValidated2 > nodeValidated1 @@ -95,8 +83,8 @@ export const OrderNodes = ( : 0 }) : nodes.sort((node1, node2) => { - const nodeValidated1 = node1.reliability ?? node1.availability - const nodeValidated2 = node2.reliability ?? node2.availability + const nodeValidated1 = node1.availability + const nodeValidated2 = node2.availability return nodeValidated1 < nodeValidated2 ? -1 : nodeValidated2 < nodeValidated1 @@ -207,35 +195,19 @@ export const OrderNodes = ( ? greenCheck.concat(yellowCheck, redX) : redX.concat(yellowCheck, greenCheck) - case 'stateHeight': - return !desc - ? nodes.sort((node1, node2) => { - return node1.stateheight > node2.stateheight - ? -1 - : node2.stateheight > node1.stateheight - ? 1 - : 0 - }) - : nodes.sort((node1, node2) => { - return node1.stateheight < node2.stateheight - ? -1 - : node2.stateheight < node1.stateheight - ? 1 - : 0 - }) case 'version': return !desc ? nodes.sort((node1, node2) => { - return node1.version > node2.version + return node1.user_agent > node2.user_agent ? -1 - : node2.version > node1.version + : node2.user_agent > node1.user_agent ? 1 : 0 }) : nodes.sort((node1, node2) => { - return node1.version < node2.version + return node1.user_agent < node2.user_agent ? -1 - : node2.version < node1.version + : node2.user_agent < node1.user_agent ? 1 : 0 }) From 345d05c672014469d70f9f10e7b3fd81c4e3275b Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Fri, 1 Sep 2023 11:00:49 +0200 Subject: [PATCH 6/6] monitor: restrict availability decimals to 2 --- src/pages/monitor/Monitor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/monitor/Monitor.tsx b/src/pages/monitor/Monitor.tsx index 37152a5..6403ad4 100644 --- a/src/pages/monitor/Monitor.tsx +++ b/src/pages/monitor/Monitor.tsx @@ -392,7 +392,7 @@ const mapNodesData = (data: WSDoraData): ParsedNodes => { ), availability: isPositive() ? (): ReactElement => ( - + ) : (): ReactElement => (