diff --git a/package-lock.json b/package-lock.json index 1d46231..fcd9701 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47398,6 +47398,11 @@ "prop-types": "^15.7.2" } }, + "react-country-flag": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/react-country-flag/-/react-country-flag-3.0.2.tgz", + "integrity": "sha512-JPaz+q3QD0/nZtHBKj5x3O7r/SgSG9kxbymdaIU0RqlDAcorJIe4KV0DFhWIdKh69q5cPVkIVERcMYGZdvXgAA==" + }, "react-custom-scrollbars": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/react-custom-scrollbars/-/react-custom-scrollbars-4.2.1.tgz", diff --git a/package.json b/package.json index e60527c..b5a8f59 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "numeral": "2.0.6", "react": "16.13.1", "react-chartjs-2": "2.10.0", + "react-country-flag": "3.0.2", "react-custom-scrollbars": "4.2.1", "react-dom": "16.13.1", "react-helmet": "6.1.0", diff --git a/src/components/ServiceTable/ServiceTable.module.css b/src/components/ServiceTable/ServiceTable.module.css index 54574e8..6ac916a 100644 --- a/src/components/ServiceTable/ServiceTable.module.css +++ b/src/components/ServiceTable/ServiceTable.module.css @@ -30,4 +30,8 @@ .error > * { padding: 0; -} \ No newline at end of file +} + +.countryFlag { + margin: var(--unit-2); +} diff --git a/src/components/ServiceTable/ServiceTable.tsx b/src/components/ServiceTable/ServiceTable.tsx index b74a864..5f92029 100644 --- a/src/components/ServiceTable/ServiceTable.tsx +++ b/src/components/ServiceTable/ServiceTable.tsx @@ -1,5 +1,6 @@ import React from 'react' import clsx from 'clsx' +import ReactCountryFlag from 'react-country-flag' import { NodeService, ContentNode, DiscoveryProvider } from 'types' import styles from './ServiceTable.module.css' import Table from 'components/Table' @@ -46,6 +47,10 @@ const ServiceTable: React.FC = ({ return (
+ {data.endpoint}
diff --git a/src/services/Audius/AudiusClient.ts b/src/services/Audius/AudiusClient.ts index 05f6f80..095137a 100644 --- a/src/services/Audius/AudiusClient.ts +++ b/src/services/Audius/AudiusClient.ts @@ -18,7 +18,7 @@ import { displayShortAud, getAud, getWei, - getNodeVersion, + getNodeMetadata, getEthWallet, getBlock, getBlockNearTimestamp, @@ -86,7 +86,7 @@ export class AudiusClient { static displayShortAud = displayShortAud static getAud = getAud static getWei = getWei - static getNodeVersion = getNodeVersion + static getNodeMetadata = getNodeMetadata } window.AudiusClient = AudiusClient diff --git a/src/services/Audius/helpers.ts b/src/services/Audius/helpers.ts index 89afcf6..3b9cf4d 100644 --- a/src/services/Audius/helpers.ts +++ b/src/services/Audius/helpers.ts @@ -128,15 +128,21 @@ export function getWei(amount: BigNumber) { return amount.mul(Utils.toBN('1000000000000000000')) } -export async function getNodeVersion(endpoint: string): Promise { +type NodeMetadata = { + version: string + country: string +} + +export async function getNodeMetadata(endpoint: string): Promise { try { - const version = await fetchWithTimeout(`${endpoint}/health_check`).then( - r => r.data.version + const { data } = await fetchWithTimeout( + `${endpoint}/health_check?verbose=true` ) - return version + const { version, country } = data + return { version, country } } catch (e) { console.error(e) // Return no version if we couldn't find one, so we don't hold everything up - return '' + return { version: '', country: '' } } } diff --git a/src/store/cache/contentNode/hooks.ts b/src/store/cache/contentNode/hooks.ts index 01c8e1f..2eb3487 100644 --- a/src/store/cache/contentNode/hooks.ts +++ b/src/store/cache/contentNode/hooks.ts @@ -67,7 +67,7 @@ export const getFilteredNodes = ({ // -------------------------------- Helpers -------------------------------- const processNode = async (node: Node, aud: Audius): Promise => { - const version = await Audius.getNodeVersion(node.endpoint) + const { country, version } = await Audius.getNodeMetadata(node.endpoint) const isDeregistered = node.endpoint === '' let previousInfo = {} if (isDeregistered) { @@ -76,11 +76,13 @@ const processNode = async (node: Node, aud: Audius): Promise => { node.spID ) } + return { ...node, ...previousInfo, type: ServiceType.ContentNode, version, + country, isDeregistered } } diff --git a/src/store/cache/discoveryProvider/hooks.ts b/src/store/cache/discoveryProvider/hooks.ts index e116440..0f09004 100644 --- a/src/store/cache/discoveryProvider/hooks.ts +++ b/src/store/cache/discoveryProvider/hooks.ts @@ -71,7 +71,7 @@ const processDP = async ( node: Node, aud: Audius ): Promise => { - const version = await Audius.getNodeVersion(node.endpoint) + const { version, country } = await Audius.getNodeMetadata(node.endpoint) const isDeregistered = node.endpoint === '' let previousInfo = {} if (isDeregistered) { @@ -85,6 +85,7 @@ const processDP = async ( ...previousInfo, type: ServiceType.DiscoveryProvider, version, + country, isDeregistered } } diff --git a/src/types.ts b/src/types.ts index 1a6a651..6fdfb06 100644 --- a/src/types.ts +++ b/src/types.ts @@ -29,6 +29,7 @@ export type Node = { type: ServiceType blockNumber: BlockNumber delegateOwnerWallet: Wallet + country: string } export type DiscoveryProvider = {