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 }, diff --git a/src/actions/addressActions.ts b/src/actions/addressActions.ts index b40b738..23ff4fd 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 304f32a..d291c1e 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 7799a2d..5ce7cf3 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 338d3a8..e7a5fed 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/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..6403ad4 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/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/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 })