15c3012199
* explorer-api: add nym node endpoints + UI to show nym-nodes and account balances * explorer-api: add endpoints to get operator rewards explorer-ui: show delegations on nym-nodes, show operator rewards, bug fixes * explorer-ui: change summary screen to only show nym-node stats * explorer-api: add unstable routes to get legacy mixnodes and gateways from the contract instead of the Nym API explorer-ui: adapt front-end to show less information in legacy nodes with plain bond types * explorer-ui: fix up source of legacy mixnode data * explorer-ui: add more account page null and undefined checks * explorer-ui: filter out null gateway versions * explorer-ui: sanitise gateway versions * explorer-ui: add more guards on the balance parts to check that greater than 0 * explorer-api: make /tmp/unstable/gateways endpoint compatible with the current Harbour Master API * explorer-ui: fix typo * cargo fmt * Add node-id, total stake and links to nodes list --------- Co-authored-by: Mark Sinclair <mmsinclair@users.noreply.github.com> Co-authored-by: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import {GatewayResponse, GatewayBond, GatewayReportResponse, LocatedGateway} from '@/app/typeDefs/explorer-api';
|
|
import { toPercentInteger } from '@/app/utils';
|
|
|
|
export type GatewayRowType = {
|
|
id: string;
|
|
owner: string;
|
|
identity_key: string;
|
|
bond: number;
|
|
host: string;
|
|
location: string;
|
|
version: string;
|
|
// node_performance: number;
|
|
};
|
|
|
|
export type GatewayEnrichedRowType = GatewayRowType & {
|
|
routingScore: string;
|
|
avgUptime: string;
|
|
clientsPort: number;
|
|
mixPort: number;
|
|
};
|
|
|
|
export function gatewayToGridRow(arrayOfGateways: GatewayResponse): GatewayRowType[] {
|
|
return !arrayOfGateways
|
|
? []
|
|
: arrayOfGateways.map((gw) => ({
|
|
id: gw.owner,
|
|
owner: gw.owner,
|
|
identity_key: gw.gateway.identity_key || '',
|
|
location: gw.location?.country_name.toUpperCase() || '',
|
|
bond: gw.pledge_amount.amount || 0,
|
|
host: gw.gateway.host || '',
|
|
version: gw.gateway.version || '',
|
|
// node_performance: toPercentInteger(gw.node_performance.last_24h),
|
|
}));
|
|
}
|
|
|
|
export function gatewayEnrichedToGridRow(gateway: LocatedGateway, report: GatewayReportResponse): GatewayEnrichedRowType {
|
|
return {
|
|
id: gateway.owner,
|
|
owner: gateway.owner,
|
|
identity_key: gateway.gateway.identity_key || '',
|
|
location: gateway.location?.country_name.toUpperCase() || '',
|
|
bond: gateway.pledge_amount.amount || 0,
|
|
host: gateway.gateway.host || '',
|
|
version: gateway.gateway.version || '',
|
|
clientsPort: gateway.gateway.clients_port || 0,
|
|
mixPort: gateway.gateway.mix_port || 0,
|
|
routingScore: `${report.most_recent}%`,
|
|
avgUptime: `${report.last_day || report.last_hour}%`,
|
|
// node_performance: toPercentInteger(gateway.node_performance.most_recent),
|
|
};
|
|
}
|