chore: migrate nodes queries (#1923)

* chore: migrate nodes queries

* chore: fix tests

* chore: migrate nodes list over to new typings
This commit is contained in:
Dexter Edwards 2022-11-02 11:48:11 +00:00 committed by GitHub
parent e4baf5caee
commit c338ce0046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 280 additions and 376 deletions

View File

@ -1,19 +1,35 @@
fragment NodesFragment on Node {
avatarUrl
id
name
pubkey
stakedTotal
stakedTotalFormatted @client
pendingStake
pendingStakeFormatted @client
rankingScore {
rankingScore
stakeScore
performanceScore
votingPower
status
}
}
query Nodes { query Nodes {
nodes { epoch {
avatarUrl
id id
name timestamps {
pubkey start
stakedTotal end
stakedTotalFormatted @client expiry
pendingStake }
pendingStakeFormatted @client }
rankingScore { nodesConnection {
rankingScore edges {
stakeScore node {
performanceScore ...NodesFragment
votingPower }
status
} }
} }
nodeData { nodeData {

View File

@ -1,123 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { ValidatorStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: Nodes
// ====================================================
export interface Nodes_epoch_timestamps {
__typename: "EpochTimestamps";
/**
* RFC3339 timestamp - Vega time of epoch start, null if not started
*/
start: string | null;
/**
* RFC3339 timestamp - Vega time of epoch end, null if not ended
*/
end: string | null;
/**
* RFC3339 timestamp - Vega time of epoch expiry
*/
expiry: string | null;
}
export interface Nodes_epoch {
__typename: "Epoch";
/**
* Numeric sequence number used to identify the epoch
*/
id: string;
/**
* Timestamps for start and end of epochs
*/
timestamps: Nodes_epoch_timestamps;
}
export interface Nodes_nodes_rankingScore {
__typename: "RankingScore";
/**
* The ranking score of the validator
*/
rankingScore: string;
/**
* The stake based score of the validator (no anti-whaling)
*/
stakeScore: string;
/**
* The performance score of the validator
*/
performanceScore: string;
/**
* The Tendermint voting power of the validator (uint32)
*/
votingPower: string;
/**
* The current validation status of the validator
*/
status: ValidatorStatus;
}
export interface Nodes_nodes {
__typename: "Node";
avatarUrl: string | null;
/**
* The node URL eg n01.vega.xyz
*/
id: string;
name: string;
/**
* Public key of the node operator
*/
pubkey: string;
/**
* Total amount staked on node
*/
stakedTotal: string;
/**
* The total staked field formatted by the client
*/
stakedTotalFormatted: string;
/**
* Amount of stake on the next epoch
*/
pendingStake: string;
/**
* The pending staked field formatted by the client
*/
pendingStakeFormatted: string;
/**
* Ranking scores and status for the validator for the current epoch
*/
rankingScore: Nodes_nodes_rankingScore;
}
export interface Nodes_nodeData {
__typename: "NodeData";
/**
* Total staked amount across all nodes
*/
stakedTotal: string;
/**
* The total staked field formatted by the client
*/
stakedTotalFormatted: string;
}
export interface Nodes {
/**
* Get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
*/
epoch: Nodes_epoch;
/**
* All known network nodes
*/
nodes: Nodes_nodes[] | null;
/**
* Returns information about nodes
*/
nodeData: Nodes_nodeData | null;
}

View File

@ -3,29 +3,47 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; const defaultOptions = {} as const;
export type NodesFragmentFragment = { __typename?: 'Node', avatarUrl?: string | null, id: string, name: string, pubkey: string, stakedTotal: string, stakedTotalFormatted: string, pendingStake: string, pendingStakeFormatted: string, rankingScore: { __typename?: 'RankingScore', rankingScore: string, stakeScore: string, performanceScore: string, votingPower: string, status: Types.ValidatorStatus } };
export type NodesQueryVariables = Types.Exact<{ [key: string]: never; }>; export type NodesQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type NodesQuery = { __typename?: 'Query', nodes?: Array<{ __typename?: 'Node', avatarUrl?: string | null, id: string, name: string, pubkey: string, stakedTotal: string, stakedTotalFormatted: string, pendingStake: string, pendingStakeFormatted: string, rankingScore: { __typename?: 'RankingScore', rankingScore: string, stakeScore: string, performanceScore: string, votingPower: string, status: Types.ValidatorStatus } }> | null, nodeData?: { __typename?: 'NodeData', stakedTotal: string, stakedTotalFormatted: string } | null }; export type NodesQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: string | null, end?: string | null, expiry?: string | null } }, nodesConnection: { __typename?: 'NodesConnection', edges?: Array<{ __typename?: 'NodeEdge', node: { __typename?: 'Node', avatarUrl?: string | null, id: string, name: string, pubkey: string, stakedTotal: string, stakedTotalFormatted: string, pendingStake: string, pendingStakeFormatted: string, rankingScore: { __typename?: 'RankingScore', rankingScore: string, stakeScore: string, performanceScore: string, votingPower: string, status: Types.ValidatorStatus } } } | null> | null }, nodeData?: { __typename?: 'NodeData', stakedTotal: string, stakedTotalFormatted: string } | null };
export const NodesFragmentFragmentDoc = gql`
fragment NodesFragment on Node {
avatarUrl
id
name
pubkey
stakedTotal
stakedTotalFormatted @client
pendingStake
pendingStakeFormatted @client
rankingScore {
rankingScore
stakeScore
performanceScore
votingPower
status
}
}
`;
export const NodesDocument = gql` export const NodesDocument = gql`
query Nodes { query Nodes {
nodes { epoch {
avatarUrl
id id
name timestamps {
pubkey start
stakedTotal end
stakedTotalFormatted @client expiry
pendingStake }
pendingStakeFormatted @client }
rankingScore { nodesConnection {
rankingScore edges {
stakeScore node {
performanceScore ...NodesFragment
votingPower }
status
} }
} }
nodeData { nodeData {
@ -33,7 +51,7 @@ export const NodesDocument = gql`
stakedTotalFormatted @client stakedTotalFormatted @client
} }
} }
`; ${NodesFragmentFragmentDoc}`;
/** /**
* __useNodesQuery__ * __useNodesQuery__

View File

@ -1,33 +1,28 @@
import { act, fireEvent, render, screen } from '@testing-library/react'; import { act, fireEvent, render, screen } from '@testing-library/react';
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import { NodeList, NODES_QUERY } from './node-list'; import { NodeList } from './node-list';
import { MockedProvider } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import { addDecimal } from '@vegaprotocol/react-helpers'; import { addDecimal } from '@vegaprotocol/react-helpers';
import type { Nodes_nodes } from './__generated__/Nodes';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
import { ValidatorStatus } from '@vegaprotocol/types'; import type { NodesFragmentFragment } from './__generated___/Nodes';
import { NodesDocument } from './__generated___/Nodes';
import { Schema } from '@vegaprotocol/types';
jest.mock('../../../components/epoch-countdown', () => ({ jest.mock('../../../components/epoch-countdown', () => ({
EpochCountdown: () => <div data-testid="epoch-info"></div>, EpochCountdown: () => <div data-testid="epoch-info"></div>,
})); }));
const nodeFactory = (overrides?: PartialDeep<Nodes_nodes>) => { const nodeFactory = (overrides?: PartialDeep<NodesFragmentFragment>) => {
const defaultNode = { const defaultNode = {
id: 'ccc022b7e63a4d0a6d3a193c3940c88574060e58a184964c994998d86835a1b4', id: 'ccc022b7e63a4d0a6d3a193c3940c88574060e58a184964c994998d86835a1b4',
name: 'high', name: 'high',
avatarUrl: 'https://upload.wikimedia.org/wikipedia/en/2/25/Marvin-TV-3.jpg', avatarUrl: 'https://upload.wikimedia.org/wikipedia/en/2/25/Marvin-TV-3.jpg',
pubkey: '6abc23391a9f888ab240415bf63d6844b03fc360be822f4a1d2cd832d87b2917', pubkey: '6abc23391a9f888ab240415bf63d6844b03fc360be822f4a1d2cd832d87b2917',
infoUrl: 'https://en.wikipedia.org/wiki/Skynet_(Terminator)',
location: '',
stakedByOperator: '3000000000000000000000',
stakedByDelegates: '11182454495731682635157',
stakedTotal: '14182454495731682635157', stakedTotal: '14182454495731682635157',
stakedTotalFormatted: addDecimal('14182454495731682635157', 18), stakedTotalFormatted: addDecimal('14182454495731682635157', 18),
pendingStake: '0', pendingStake: '0',
pendingStakeFormatted: addDecimal('0', 18), pendingStakeFormatted: addDecimal('0', 18),
epochData: null,
status: 'Validator',
rankingScore: { rankingScore: {
rankingScore: '0.67845061012234727427532760837568', rankingScore: '0.67845061012234727427532760837568',
stakeScore: '0.3392701644525644', stakeScore: '0.3392701644525644',
@ -38,46 +33,50 @@ const nodeFactory = (overrides?: PartialDeep<Nodes_nodes>) => {
}, },
__typename: 'Node', __typename: 'Node',
}; };
return merge(defaultNode, overrides); return {
node: merge(defaultNode, overrides),
};
}; };
const MOCK_NODES = { const MOCK_NODES = {
nodes: [ nodesConnection: {
nodeFactory(), edges: [
nodeFactory({ nodeFactory(),
id: '966438c6bffac737cfb08173ffcb3f393c4692b099ad80cb45a82e2dc0a8cf99', nodeFactory({
name: 'medium', id: '966438c6bffac737cfb08173ffcb3f393c4692b099ad80cb45a82e2dc0a8cf99',
pubkey: name: 'medium',
'ccc3b8362c25b09d20df8ea407b0a476d6b24a0e72bc063d0033c8841652ddd4', pubkey:
stakedTotal: '9618711883996159534058', 'ccc3b8362c25b09d20df8ea407b0a476d6b24a0e72bc063d0033c8841652ddd4',
stakedTotalFormatted: addDecimal('9618711883996159534058', 18), stakedTotal: '9618711883996159534058',
rankingScore: { stakedTotalFormatted: addDecimal('9618711883996159534058', 18),
rankingScore: '0.4601942440481428', rankingScore: {
stakeScore: '0.2300971220240714', rankingScore: '0.4601942440481428',
performanceScore: '1', stakeScore: '0.2300971220240714',
votingPower: '2408', performanceScore: '1',
status: ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT, votingPower: '2408',
__typename: 'RankingScore', status: Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT,
}, __typename: 'RankingScore',
}), },
nodeFactory({ }),
id: '12c81b738e8051152e1afe44376ec37bca9216466e6d44cdd772194bad0ada81', nodeFactory({
name: 'low', id: '12c81b738e8051152e1afe44376ec37bca9216466e6d44cdd772194bad0ada81',
pubkey: name: 'low',
'0931a8fd8cc935458f470e435a05414387cea6f329d648be894fcd44bd517a2b', pubkey:
stakedTotal: '4041343338923442976709', '0931a8fd8cc935458f470e435a05414387cea6f329d648be894fcd44bd517a2b',
stakedTotalFormatted: addDecimal('4041343338923442976709', 18), stakedTotal: '4041343338923442976709',
pendingStake: '0', stakedTotalFormatted: addDecimal('4041343338923442976709', 18),
rankingScore: { pendingStake: '0',
rankingScore: '0.1932810100133910357676209647912', rankingScore: {
stakeScore: '0.0966762995515676', rankingScore: '0.1932810100133910357676209647912',
performanceScore: '0.999629748500531', stakeScore: '0.0966762995515676',
votingPower: '1163', performanceScore: '0.999629748500531',
status: ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT, votingPower: '1163',
__typename: 'RankingScore', status: Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT,
}, __typename: 'RankingScore',
}), },
], }),
],
},
nodeData: { nodeData: {
stakedTotal: '27842509718651285145924', stakedTotal: '27842509718651285145924',
stakedTotalFormatted: addDecimal('27842509718651285145924', 18), stakedTotalFormatted: addDecimal('27842509718651285145924', 18),
@ -105,7 +104,7 @@ const renderNodeList = (data = MOCK_NODES) => {
<MockedProvider <MockedProvider
mocks={[ mocks={[
{ {
request: { query: NODES_QUERY }, request: { query: NodesDocument },
result: { data }, result: { data },
}, },
]} ]}
@ -156,26 +155,28 @@ describe('Nodes list', () => {
it('should display the correctly formatted fields in the correct columns', async () => { it('should display the correctly formatted fields in the correct columns', async () => {
const MOCK_NODE = { const MOCK_NODE = {
nodes: [ nodesConnection: {
nodeFactory({ edges: [
id: '966438c6bffac737cfb08173ffcb3f393c4692b099ad80cb45a82e2dc0a8cf99', nodeFactory({
name: 'T-800 Terminator', id: '966438c6bffac737cfb08173ffcb3f393c4692b099ad80cb45a82e2dc0a8cf99',
avatarUrl: name: 'T-800 Terminator',
'https://upload.wikimedia.org/wikipedia/en/9/94/T-800_%28Model_101%29.png', avatarUrl:
pubkey: 'https://upload.wikimedia.org/wikipedia/en/9/94/T-800_%28Model_101%29.png',
'ccc3b8362c25b09d20df8ea407b0a476d6b24a0e72bc063d0033c8841652ddd4', pubkey:
stakedTotal: '9618711883996159534058', 'ccc3b8362c25b09d20df8ea407b0a476d6b24a0e72bc063d0033c8841652ddd4',
stakedTotalFormatted: addDecimal('9618711883996159534058', 18), stakedTotal: '9618711883996159534058',
rankingScore: { stakedTotalFormatted: addDecimal('9618711883996159534058', 18),
rankingScore: '0.4601942440481428', rankingScore: {
stakeScore: '0.2300971220240714', rankingScore: '0.4601942440481428',
performanceScore: '1', stakeScore: '0.2300971220240714',
votingPower: '2408', performanceScore: '1',
status: ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT, votingPower: '2408',
__typename: 'RankingScore', status: Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT,
}, __typename: 'RankingScore',
}), },
], }),
],
},
nodeData: { nodeData: {
stakedTotal: '9618711883996159534058', stakedTotal: '9618711883996159534058',
stakedTotalFormatted: addDecimal('9618711883996159534058', 18), stakedTotalFormatted: addDecimal('9618711883996159534058', 18),

View File

@ -1,4 +1,3 @@
import { gql, useQuery } from '@apollo/client';
import { forwardRef, useEffect, useMemo, useRef, useState } from 'react'; import { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
import { import {
AgGridDynamic as AgGrid, AgGridDynamic as AgGrid,
@ -11,9 +10,10 @@ import { useTranslation } from 'react-i18next';
import { EpochCountdown } from '../../../components/epoch-countdown'; import { EpochCountdown } from '../../../components/epoch-countdown';
import { BigNumber } from '../../../lib/bignumber'; import { BigNumber } from '../../../lib/bignumber';
import { formatNumber } from '@vegaprotocol/react-helpers'; import { formatNumber } from '@vegaprotocol/react-helpers';
import { ValidatorStatus } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Nodes } from './__generated__/Nodes';
import type { ColDef } from 'ag-grid-community'; import type { ColDef } from 'ag-grid-community';
import compact from 'lodash/compact';
import { useNodesQuery } from './__generated___/Nodes';
const VALIDATOR = 'validator'; const VALIDATOR = 'validator';
const STATUS = 'status'; const STATUS = 'status';
@ -26,40 +26,6 @@ const STAKE_SCORE = 'stakeScore';
const PERFORMANCE_SCORE = 'performanceScore'; const PERFORMANCE_SCORE = 'performanceScore';
const VOTING_POWER = 'votingPower'; const VOTING_POWER = 'votingPower';
export const NODES_QUERY = gql`
query Nodes {
epoch {
id
timestamps {
start
end
expiry
}
}
nodes {
avatarUrl
id
name
pubkey
stakedTotal
stakedTotalFormatted @client
pendingStake
pendingStakeFormatted @client
rankingScore {
rankingScore
stakeScore
performanceScore
votingPower
status
}
}
nodeData {
stakedTotal
stakedTotalFormatted @client
}
}
`;
interface ValidatorRendererProps { interface ValidatorRendererProps {
data: { validator: { avatarUrl: string; name: string } }; data: { validator: { avatarUrl: string; name: string } };
} }
@ -67,7 +33,7 @@ interface ValidatorRendererProps {
interface CanonisedNodeProps { interface CanonisedNodeProps {
id: string; id: string;
[VALIDATOR]: { [VALIDATOR]: {
avatarUrl: string | null; avatarUrl: string | null | undefined;
name: string; name: string;
}; };
[STATUS]: string; [STATUS]: string;
@ -109,9 +75,7 @@ const nodeListGridStyles = `
export const NodeList = () => { export const NodeList = () => {
const { t } = useTranslation(); const { t } = useTranslation();
// errorPolicy due to vegaprotocol/vega issue 5898 // errorPolicy due to vegaprotocol/vega issue 5898
const { data, error, loading, refetch } = useQuery<Nodes>(NODES_QUERY, { const { data, error, loading, refetch } = useNodesQuery();
errorPolicy: 'ignore',
});
const navigate = useNavigate(); const navigate = useNavigate();
const [hideTopThird, setHideTopThird] = useState(true); const [hideTopThird, setHideTopThird] = useState(true);
@ -133,22 +97,24 @@ export const NodeList = () => {
}, [data?.epoch.timestamps.expiry, refetch]); }, [data?.epoch.timestamps.expiry, refetch]);
const nodes = useMemo(() => { const nodes = useMemo(() => {
if (!data?.nodes) return []; if (!data?.nodesConnection.edges) return [];
const canonisedNodes = data.nodes.map( const canonisedNodes = compact(data.nodesConnection.edges).map(
({ ({
id, node: {
name, id,
avatarUrl, name,
stakedTotalFormatted, avatarUrl,
rankingScore: { stakedTotalFormatted,
rankingScore, rankingScore: {
stakeScore, rankingScore,
status, stakeScore,
performanceScore, status,
votingPower, performanceScore,
votingPower,
},
pendingStakeFormatted,
}, },
pendingStakeFormatted,
}) => { }) => {
const stakedTotal = new BigNumber( const stakedTotal = new BigNumber(
data?.nodeData?.stakedTotalFormatted || 0 data?.nodeData?.stakedTotalFormatted || 0
@ -161,11 +127,12 @@ export const NodeList = () => {
'%'; '%';
const statusTranslated = t( const statusTranslated = t(
`${ `${
(status === ValidatorStatus.VALIDATOR_NODE_STATUS_ERSATZ && (status === Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_ERSATZ &&
'Ersatz') || 'Ersatz') ||
(status === ValidatorStatus.VALIDATOR_NODE_STATUS_PENDING && (status === Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_PENDING &&
'Pending') || 'Pending') ||
(status === ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT && (status ===
Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_TENDERMINT &&
'Consensus') 'Consensus')
}` }`
); );

View File

@ -21,33 +21,37 @@ query Staking($partyId: ID!) {
expiry expiry
} }
} }
nodes { nodesConnection {
id edges {
name node {
pubkey id
infoUrl name
location pubkey
ethereumAddress infoUrl
stakedByOperator location
stakedByDelegates ethereumAddress
stakedTotal stakedByOperator
pendingStake stakedByDelegates
stakedByOperatorFormatted @client stakedTotal
stakedByDelegatesFormatted @client pendingStake
stakedTotalFormatted @client stakedByOperatorFormatted @client
pendingStakeFormatted @client stakedByDelegatesFormatted @client
epochData { stakedTotalFormatted @client
total pendingStakeFormatted @client
offline epochData {
online total
} offline
status online
rankingScore { }
rankingScore status
stakeScore rankingScore {
performanceScore rankingScore
votingPower stakeScore
stakeScore performanceScore
votingPower
stakeScore
}
}
} }
} }
nodeData { nodeData {

View File

@ -86,7 +86,7 @@ export interface Staking_epoch {
timestamps: Staking_epoch_timestamps; timestamps: Staking_epoch_timestamps;
} }
export interface Staking_nodes_epochData { export interface Staking_nodesConnection_edges_node_epochData {
__typename: "EpochData"; __typename: "EpochData";
/** /**
* Total number of epochs since node was created * Total number of epochs since node was created
@ -102,7 +102,7 @@ export interface Staking_nodes_epochData {
online: number; online: number;
} }
export interface Staking_nodes_rankingScore { export interface Staking_nodesConnection_edges_node_rankingScore {
__typename: "RankingScore"; __typename: "RankingScore";
/** /**
* The ranking score of the validator * The ranking score of the validator
@ -122,7 +122,7 @@ export interface Staking_nodes_rankingScore {
votingPower: string; votingPower: string;
} }
export interface Staking_nodes { export interface Staking_nodesConnection_edges_node {
__typename: "Node"; __typename: "Node";
/** /**
* The node URL eg n01.vega.xyz * The node URL eg n01.vega.xyz
@ -180,7 +180,7 @@ export interface Staking_nodes {
/** /**
* Summary of epoch data across all nodes * Summary of epoch data across all nodes
*/ */
epochData: Staking_nodes_epochData | null; epochData: Staking_nodesConnection_edges_node_epochData | null;
/** /**
* Validator status of the node * Validator status of the node
*/ */
@ -188,7 +188,23 @@ export interface Staking_nodes {
/** /**
* Ranking scores and status for the validator for the current epoch * Ranking scores and status for the validator for the current epoch
*/ */
rankingScore: Staking_nodes_rankingScore; rankingScore: Staking_nodesConnection_edges_node_rankingScore;
}
export interface Staking_nodesConnection_edges {
__typename: "NodeEdge";
/**
* The node
*/
node: Staking_nodesConnection_edges_node;
}
export interface Staking_nodesConnection {
__typename: "NodesConnection";
/**
* List of nodes available for the connection
*/
edges: (Staking_nodesConnection_edges | null)[] | null;
} }
export interface Staking_nodeData { export interface Staking_nodeData {
@ -231,7 +247,7 @@ export interface Staking {
/** /**
* All known network nodes * All known network nodes
*/ */
nodes: Staking_nodes[] | null; nodesConnection: Staking_nodesConnection;
/** /**
* Returns information about nodes * Returns information about nodes
*/ */

View File

@ -8,7 +8,7 @@ export type StakingQueryVariables = Types.Exact<{
}>; }>;
export type StakingQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string }, delegations?: Array<{ __typename?: 'Delegation', amount: string, amountFormatted: string, epoch: number, node: { __typename?: 'Node', id: string } }> | null } | null, epoch: { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: string | null, end?: string | null, expiry?: string | null } }, nodes?: Array<{ __typename?: 'Node', id: string, name: string, pubkey: string, infoUrl: string, location: string, ethereumAddress: string, stakedByOperator: string, stakedByDelegates: string, stakedTotal: string, pendingStake: string, stakedByOperatorFormatted: string, stakedByDelegatesFormatted: string, stakedTotalFormatted: string, pendingStakeFormatted: string, status: Types.NodeStatus, epochData?: { __typename?: 'EpochData', total: number, offline: number, online: number } | null, rankingScore: { __typename?: 'RankingScore', rankingScore: string, stakeScore: string, performanceScore: string, votingPower: string } }> | null, nodeData?: { __typename?: 'NodeData', stakedTotal: string, stakedTotalFormatted: string, totalNodes: number, inactiveNodes: number, validatingNodes: number, uptime: number } | null }; export type StakingQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string }, delegations?: Array<{ __typename?: 'Delegation', amount: string, amountFormatted: string, epoch: number, node: { __typename?: 'Node', id: string } }> | null } | null, epoch: { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: string | null, end?: string | null, expiry?: string | null } }, nodesConnection: { __typename?: 'NodesConnection', edges?: Array<{ __typename?: 'NodeEdge', node: { __typename?: 'Node', id: string, name: string, pubkey: string, infoUrl: string, location: string, ethereumAddress: string, stakedByOperator: string, stakedByDelegates: string, stakedTotal: string, pendingStake: string, stakedByOperatorFormatted: string, stakedByDelegatesFormatted: string, stakedTotalFormatted: string, pendingStakeFormatted: string, status: Types.NodeStatus, epochData?: { __typename?: 'EpochData', total: number, offline: number, online: number } | null, rankingScore: { __typename?: 'RankingScore', rankingScore: string, stakeScore: string, performanceScore: string, votingPower: string } } } | null> | null }, nodeData?: { __typename?: 'NodeData', stakedTotal: string, stakedTotalFormatted: string, totalNodes: number, inactiveNodes: number, validatingNodes: number, uptime: number } | null };
export const StakingDocument = gql` export const StakingDocument = gql`
@ -35,33 +35,37 @@ export const StakingDocument = gql`
expiry expiry
} }
} }
nodes { nodesConnection {
id edges {
name node {
pubkey id
infoUrl name
location pubkey
ethereumAddress infoUrl
stakedByOperator location
stakedByDelegates ethereumAddress
stakedTotal stakedByOperator
pendingStake stakedByDelegates
stakedByOperatorFormatted @client stakedTotal
stakedByDelegatesFormatted @client pendingStake
stakedTotalFormatted @client stakedByOperatorFormatted @client
pendingStakeFormatted @client stakedByDelegatesFormatted @client
epochData { stakedTotalFormatted @client
total pendingStakeFormatted @client
offline epochData {
online total
} offline
status online
rankingScore { }
rankingScore status
stakeScore rankingScore {
performanceScore rankingScore
votingPower stakeScore
stakeScore performanceScore
votingPower
stakeScore
}
}
} }
} }
nodeData { nodeData {

View File

@ -13,6 +13,7 @@ import NodeContainer from './nodes-container';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
import { useAppState } from '../../../contexts/app-state/app-state-context'; import { useAppState } from '../../../contexts/app-state/app-state-context';
import { toBigNum } from '@vegaprotocol/react-helpers'; import { toBigNum } from '@vegaprotocol/react-helpers';
import compact from 'lodash/compact';
interface StakingNodeProps { interface StakingNodeProps {
data?: StakingQueryResult; data?: StakingQueryResult;
@ -26,7 +27,9 @@ export const StakingNode = ({ data }: StakingNodeProps) => {
const { node } = useParams<{ node: string }>(); const { node } = useParams<{ node: string }>();
const { t } = useTranslation(); const { t } = useTranslation();
const nodeInfo = React.useMemo(() => { const nodeInfo = React.useMemo(() => {
return data?.nodes?.find(({ id }) => id === node); return compact(data?.nodesConnection?.edges).find(
({ node: { id } }) => id === node
)?.node;
}, [node, data]); }, [node, data]);
const currentEpoch = React.useMemo(() => { const currentEpoch = React.useMemo(() => {

View File

@ -32,33 +32,37 @@ export const STAKING_QUERY = gql`
expiry expiry
} }
} }
nodes { nodesConnection {
id edges {
name node {
pubkey id
infoUrl name
location pubkey
ethereumAddress infoUrl
stakedByOperator location
stakedByDelegates ethereumAddress
stakedTotal stakedByOperator
pendingStake stakedByDelegates
stakedByOperatorFormatted @client stakedTotal
stakedByDelegatesFormatted @client pendingStake
stakedTotalFormatted @client stakedByOperatorFormatted @client
pendingStakeFormatted @client stakedByDelegatesFormatted @client
epochData { stakedTotalFormatted @client
total pendingStakeFormatted @client
offline epochData {
online total
} offline
status online
rankingScore { }
rankingScore status
stakeScore rankingScore {
performanceScore rankingScore
votingPower stakeScore
stakeScore performanceScore
votingPower
stakeScore
}
}
} }
} }
nodeData { nodeData {

View File

@ -6,7 +6,7 @@ import { useEnvironment } from '@vegaprotocol/environment';
import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit'; import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit';
import { BigNumber } from '../../../lib/bignumber'; import { BigNumber } from '../../../lib/bignumber';
import { formatNumber } from '../../../lib/format-number'; import { formatNumber } from '../../../lib/format-number';
import type { Staking_nodes } from './__generated__/Staking'; import type { Staking_nodesConnection_edges_node } from './__generated__/Staking';
const ValidatorTableCell = ({ const ValidatorTableCell = ({
children, children,
@ -21,7 +21,7 @@ const ValidatorTableCell = ({
); );
export interface ValidatorTableProps { export interface ValidatorTableProps {
node: Staking_nodes; node: Staking_nodesConnection_edges_node;
stakedTotal: string; stakedTotal: string;
stakeThisEpoch: BigNumber; stakeThisEpoch: BigNumber;
} }

View File

@ -181,12 +181,6 @@ export enum StakeLinkingStatus {
STATUS_REJECTED = "STATUS_REJECTED", STATUS_REJECTED = "STATUS_REJECTED",
} }
export enum ValidatorStatus {
VALIDATOR_NODE_STATUS_ERSATZ = "VALIDATOR_NODE_STATUS_ERSATZ",
VALIDATOR_NODE_STATUS_PENDING = "VALIDATOR_NODE_STATUS_PENDING",
VALIDATOR_NODE_STATUS_TENDERMINT = "VALIDATOR_NODE_STATUS_TENDERMINT",
}
export enum VoteValue { export enum VoteValue {
VALUE_NO = "VALUE_NO", VALUE_NO = "VALUE_NO",
VALUE_YES = "VALUE_YES", VALUE_YES = "VALUE_YES",