From 2aa5c7a17e83f7694e09025821355d6e85d285ca Mon Sep 17 00:00:00 2001 From: Ryuash <42913823+ryuash@users.noreply.github.com> Date: Tue, 14 Dec 2021 15:14:00 +0800 Subject: [PATCH] add: tombstoned status (#601) --- CHANGELOG.md | 2 ++ public/locales/en/validators.json | 3 ++- src/graphql/account.graphql | 3 +++ src/graphql/types.tsx | 13 +++++++++++++ src/graphql/validator_details.graphql | 1 + src/graphql/validators.graphql | 1 + .../__snapshots__/index.test.tsx.snap | 3 +++ .../delegations/components/desktop/index.tsx | 6 +++++- .../delegations/components/mobile/index.tsx | 6 +++++- src/screens/account_details/hooks.ts | 3 +++ src/screens/account_details/index.test.tsx | 5 +++++ src/screens/account_details/types.ts | 3 +++ .../components/validator_overview/index.tsx | 2 +- src/screens/validator_details/hooks.ts | 2 ++ src/screens/validator_details/index.tsx | 1 + src/screens/validator_details/types.ts | 1 + .../list/components/desktop/index.test.tsx | 1 + .../list/components/desktop/index.tsx | 2 +- .../list/components/mobile/index.test.tsx | 1 + .../list/components/mobile/index.tsx | 2 +- .../validators/components/list/hooks.ts | 1 + .../validators/components/list/index.test.tsx | 1 + .../validators/components/list/types.ts | 1 + src/utils/get_validator_status.ts | 19 ++++++++++++++----- 24 files changed, 72 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4f696966e..45cfd55e9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Changes - Add logs in tx details ([\#515](https://github.com/forbole/big-dipper-2.0-cosmos/issues/515)) +- Add tombstoned status ([\#600](https://github.com/forbole/big-dipper-2.0-cosmos/issues/600)) + # base-v1.8.4 - 2021-12-08 ## Bug fixes - Fix `feegrant` and `authz` messages ([\#588](https://github.com/forbole/big-dipper-2.0-cosmos/issues/588)) diff --git a/public/locales/en/validators.json b/public/locales/en/validators.json index 71c4c7bc74..5e9085e03d 100644 --- a/public/locales/en/validators.json +++ b/public/locales/en/validators.json @@ -55,5 +55,6 @@ "signedBlockWindow": "Signed Block Window: {{amount}}", "lastSeen": "Last Seen", "status": "Status", - "votingPowerExplanation": "As the top 34% voting power can easily <0>decrease network security and <0>halt the network they will be highlighted differently in order to educate and encourage decentralization" + "votingPowerExplanation": "As the top 34% voting power can easily <0>decrease network security and <0>halt the network they will be highlighted differently in order to educate and encourage decentralization", + "tombstoned": "Tombstoned" } diff --git a/src/graphql/account.graphql b/src/graphql/account.graphql index a6a00be91c..50ae813267 100644 --- a/src/graphql/account.graphql +++ b/src/graphql/account.graphql @@ -20,6 +20,9 @@ query Account($address: String, $utc: timestamp) { status jailed } + validatorSigningInfos: validator_signing_infos(order_by: {height: desc}, limit: 1) { + tombstoned + } } } unbonding: unbonding_delegations(where: {completion_timestamp: {_gt: $utc}}) { diff --git a/src/graphql/types.tsx b/src/graphql/types.tsx index 950021eff3..1dad8bdb5b 100644 --- a/src/graphql/types.tsx +++ b/src/graphql/types.tsx @@ -18499,6 +18499,9 @@ export type AccountQuery = { stakingParams: Array<( )>, validatorStatuses: Array<( { __typename?: 'validator_status' } & Pick + )>, validatorSigningInfos: Array<( + { __typename?: 'validator_signing_info' } + & Pick )> } ) } )>, unbonding: Array<( @@ -18978,6 +18981,7 @@ export type ValidatorDetailsQuery = { stakingParams: Array<( & Pick )>, validatorSigningInfos: Array<( { __typename?: 'validator_signing_info' } + & Pick & { missedBlocksCounter: Validator_Signing_Info['missed_blocks_counter'] } )>, validatorInfo?: Maybe<( { __typename?: 'validator_info' } @@ -19027,6 +19031,7 @@ export type ValidatorsQuery = { stakingParams: Array<( & Pick )>, validatorSigningInfos: Array<( { __typename?: 'validator_signing_info' } + & Pick & { missedBlocksCounter: Validator_Signing_Info['missed_blocks_counter'] } )>, validatorInfo?: Maybe<( { __typename?: 'validator_info' } @@ -19101,6 +19106,12 @@ export const AccountDocument = gql` status jailed } + validatorSigningInfos: validator_signing_infos( + order_by: {height: desc} + limit: 1 + ) { + tombstoned + } } } unbonding: unbonding_delegations(where: {completion_timestamp: {_gt: $utc}}) { @@ -20208,6 +20219,7 @@ export const ValidatorDetailsDocument = gql` limit: 1 ) { missedBlocksCounter: missed_blocks_counter + tombstoned } validatorInfo: validator_info { operatorAddress: operator_address @@ -20301,6 +20313,7 @@ export const ValidatorsDocument = gql` limit: 1 ) { missedBlocksCounter: missed_blocks_counter + tombstoned } validatorInfo: validator_info { operatorAddress: operator_address diff --git a/src/graphql/validator_details.graphql b/src/graphql/validator_details.graphql index 114d461349..9211584e4c 100644 --- a/src/graphql/validator_details.graphql +++ b/src/graphql/validator_details.graphql @@ -44,6 +44,7 @@ query ValidatorDetails($address: String, $utc: timestamp) { } validatorSigningInfos: validator_signing_infos(order_by: {height: desc}, limit: 1) { missedBlocksCounter: missed_blocks_counter + tombstoned } validatorInfo: validator_info { operatorAddress: operator_address diff --git a/src/graphql/validators.graphql b/src/graphql/validators.graphql index 7ac750c10a..dd2a9f8b45 100644 --- a/src/graphql/validators.graphql +++ b/src/graphql/validators.graphql @@ -13,6 +13,7 @@ query Validators { } validatorSigningInfos: validator_signing_infos(order_by: {height: desc}, limit: 1) { missedBlocksCounter: missed_blocks_counter + tombstoned } validatorInfo: validator_info { operatorAddress: operator_address diff --git a/src/screens/account_details/__snapshots__/index.test.tsx.snap b/src/screens/account_details/__snapshots__/index.test.tsx.snap index b874178a64..35b7096003 100644 --- a/src/screens/account_details/__snapshots__/index.test.tsx.snap +++ b/src/screens/account_details/__snapshots__/index.test.tsx.snap @@ -161,6 +161,9 @@ exports[`screen: BlockDetails matches snapshot 1`] = ` "value": "58219.061338275262315", }, "validator": "desmosvaloper1u0dae8r8hay6r2gvccegg2fz6ryftf2wfnj5ft", + "validatorSigningInfo": Object { + "tombstoned": false, + }, "validatorStatus": Object { "jailed": false, "status": 3, diff --git a/src/screens/account_details/components/staking/components/delegations/components/desktop/index.tsx b/src/screens/account_details/components/staking/components/delegations/components/desktop/index.tsx index 58124da009..606455fae2 100644 --- a/src/screens/account_details/components/staking/components/delegations/components/desktop/index.tsx +++ b/src/screens/account_details/components/staking/components/delegations/components/desktop/index.tsx @@ -30,7 +30,11 @@ const Desktop: React.FC<{ const formattedItems = items.map((x) => { const amount = formatNumber(x.amount.value, x.amount.exponent); const reward = formatNumber(x.reward.value, x.reward.exponent); - const statusTheme = getValidatorStatus(x.validatorStatus.status, x.validatorStatus.jailed); + const statusTheme = getValidatorStatus( + x.validatorStatus.status, + x.validatorStatus.jailed, + x.validatorSigningInfo.tombstoned, + ); return ({ validator: ( {items.map((x, i) => { - const statusTheme = getValidatorStatus(x.validatorStatus.status, x.validatorStatus.jailed); + const statusTheme = getValidatorStatus( + x.validatorStatus.status, + x.validatorStatus.jailed, + x.validatorSigningInfo.tombstoned, + ); return (
diff --git a/src/screens/account_details/hooks.ts b/src/screens/account_details/hooks.ts index 2d42a7b663..44cf51ece9 100644 --- a/src/screens/account_details/hooks.ts +++ b/src/screens/account_details/hooks.ts @@ -379,6 +379,9 @@ export const useAccountDetails = () => { status: R.pathOr(3, ['validator', 'validatorStatuses', 0, 'status'], x), jailed: R.pathOr(false, ['validator', 'validatorStatuses', 0, 'jailed'], x), }, + validatorSigningInfo: { + tombstoned: R.pathOr(false, ['validator', 'validatorSigningInfos', 0, 'tombstoned'], x), + }, reward: rewardsDict[validatorAddress], amount: formatToken(x.amount.amount, x.amount.denom), commission: R.pathOr(0, ['validator', 'validatorCommissions', 0, 'commission'], x), diff --git a/src/screens/account_details/index.test.tsx b/src/screens/account_details/index.test.tsx index 40eacdb401..41c71dcee6 100644 --- a/src/screens/account_details/index.test.tsx +++ b/src/screens/account_details/index.test.tsx @@ -83,6 +83,11 @@ const mockAccount = jest.fn().mockResolvedValue({ jailed: false, }, ], + validatorSigningInfos: [ + { + tombstoned: false, + }, + ], }, }, ], diff --git a/src/screens/account_details/types.ts b/src/screens/account_details/types.ts index 042feba518..4ead1103c2 100644 --- a/src/screens/account_details/types.ts +++ b/src/screens/account_details/types.ts @@ -25,6 +25,9 @@ export type DelegationType = { status: number; jailed: boolean; } + validatorSigningInfo: { + tombstoned: boolean; + } commission: number; amount: TokenUnit; reward: TokenUnit; diff --git a/src/screens/validator_details/components/validator_overview/index.tsx b/src/screens/validator_details/components/validator_overview/index.tsx index f9b7badad5..914e4b6799 100644 --- a/src/screens/validator_details/components/validator_overview/index.tsx +++ b/src/screens/validator_details/components/validator_overview/index.tsx @@ -41,7 +41,7 @@ const ValidatorOverview: React.FC { const profile = { status: R.pathOr(3, ['validatorStatuses', 0, 'status'], data.validator[0]), jailed: R.pathOr(false, ['validatorStatuses', 0, 'jailed'], data.validator[0]), + tombstoned: R.pathOr(false, ['validatorSigningInfos', 0, 'tombstoned'], data.validator[0]), commission: R.pathOr(0, ['validatorCommissions', 0, 'commission'], data.validator[0]), condition, missedBlockCounter, diff --git a/src/screens/validator_details/index.tsx b/src/screens/validator_details/index.tsx index 0db3b4e94c..99372e4ca1 100644 --- a/src/screens/validator_details/index.tsx +++ b/src/screens/validator_details/index.tsx @@ -73,6 +73,7 @@ const ValidatorDetails = () => { selfDelegateAddress={overview.selfDelegateAddress} status={status.status} jailed={status.jailed} + tombstoned={status.tombstoned} condition={status.condition} commission={status.commission} signedBlockWindow={status.signedBlockWindow} diff --git a/src/screens/validator_details/types.ts b/src/screens/validator_details/types.ts index 4fe14a5aa1..c7343cf9c4 100644 --- a/src/screens/validator_details/types.ts +++ b/src/screens/validator_details/types.ts @@ -9,6 +9,7 @@ export type OverviewType = { export type StatusType = { status: number; jailed: boolean; + tombstoned: boolean; condition: number; commission: number; signedBlockWindow: number; diff --git a/src/screens/validators/components/list/components/desktop/index.test.tsx b/src/screens/validators/components/list/components/desktop/index.test.tsx index c8510a6e0b..0c497f1644 100644 --- a/src/screens/validators/components/list/components/desktop/index.test.tsx +++ b/src/screens/validators/components/list/components/desktop/index.test.tsx @@ -47,6 +47,7 @@ describe('screen: Validators/Desktop', () => { jailed: true, delegators: 4, status: 3, + tombstoned: false, }, ]} /> diff --git a/src/screens/validators/components/list/components/desktop/index.tsx b/src/screens/validators/components/list/components/desktop/index.tsx index 7ebf424883..68d80fa83b 100644 --- a/src/screens/validators/components/list/components/desktop/index.tsx +++ b/src/screens/validators/components/list/components/desktop/index.tsx @@ -42,7 +42,7 @@ const Desktop: React.FC<{ } = useGrid(columns); const formattedItems = props.items.map((x, i) => { - const status = getValidatorStatus(x.status, x.jailed); + const status = getValidatorStatus(x.status, x.jailed, x.tombstoned); const condition = x.status === 3 ? getValidatorConditionClass(x.condition) : undefined; const percentDisplay = x.status === 3 ? `${numeral(x.votingPowerPercent).format('0.[00]')}%` : '0%'; const votingPower = numeral(x.votingPower).format('0,0'); diff --git a/src/screens/validators/components/list/components/mobile/index.test.tsx b/src/screens/validators/components/list/components/mobile/index.test.tsx index d5679c4b55..bd7eca5f63 100644 --- a/src/screens/validators/components/list/components/mobile/index.test.tsx +++ b/src/screens/validators/components/list/components/mobile/index.test.tsx @@ -39,6 +39,7 @@ describe('screen: Validators/Tabs', () => { jailed: true, delegators: 4, status: 3, + tombstoned: false, }, ]} /> diff --git a/src/screens/validators/components/list/components/mobile/index.tsx b/src/screens/validators/components/list/components/mobile/index.tsx index ecc9ef0b71..aeed250d9d 100644 --- a/src/screens/validators/components/list/components/mobile/index.tsx +++ b/src/screens/validators/components/list/components/mobile/index.tsx @@ -30,7 +30,7 @@ const Mobile: React.FC<{ } = useList(); const formattedItems = items.map((x, i) => { - const status = getValidatorStatus(x.status, x.jailed); + const status = getValidatorStatus(x.status, x.jailed, x.tombstoned); const condition = x.status === 3 ? getValidatorConditionClass(x.condition) : undefined; const percentDisplay = x.status === 3 ? `${numeral(x.votingPowerPercent).format('0.[00]')}%` : '0%'; const votingPower = numeral(x.votingPower).format('0,0'); diff --git a/src/screens/validators/components/list/hooks.ts b/src/screens/validators/components/list/hooks.ts index d2ecdb9473..e7f2117cc8 100644 --- a/src/screens/validators/components/list/hooks.ts +++ b/src/screens/validators/components/list/hooks.ts @@ -87,6 +87,7 @@ export const useValidators = () => { condition, status: R.pathOr(0, ['validatorStatuses', 0, 'status'], x), jailed: R.pathOr(false, ['validatorStatuses', 0, 'jailed'], x), + tombstoned: R.pathOr(false, ['validatorSigningInfos', 0, 'tombstoned'], x), delegators: x.delegations.length, }); }); diff --git a/src/screens/validators/components/list/index.test.tsx b/src/screens/validators/components/list/index.test.tsx index efcd196afb..221de16440 100644 --- a/src/screens/validators/components/list/index.test.tsx +++ b/src/screens/validators/components/list/index.test.tsx @@ -48,6 +48,7 @@ const mockValidatorsDocument = jest.fn().mockResolvedValue({ validatorSigningInfos: [ { missedBlocksCounter: 1, + tombstoned: false, }, ], validatorInfo: { diff --git a/src/screens/validators/components/list/types.ts b/src/screens/validators/components/list/types.ts index 57202aa18c..39ca35a491 100644 --- a/src/screens/validators/components/list/types.ts +++ b/src/screens/validators/components/list/types.ts @@ -7,6 +7,7 @@ export type ValidatorType = { condition: number; status: number; jailed: boolean; + tombstoned: boolean; delegators: number; topVotingPower?: boolean; // top 34% VP } diff --git a/src/utils/get_validator_status.ts b/src/utils/get_validator_status.ts index f99fa01bdf..62439aa711 100644 --- a/src/utils/get_validator_status.ts +++ b/src/utils/get_validator_status.ts @@ -4,19 +4,28 @@ * @param jailed boolean * @returns an object with status and theme */ -export const getValidatorStatus = (status: number, jailed: boolean) => { +export const getValidatorStatus = (status: number, jailed: boolean, tombstoned: boolean) => { const results = { status: 'na', theme: 'zero', }; + // jailed and tombstone statuses are prioritised over their unbonding state + if (jailed) { + results.status = 'jailed'; + results.theme = 'two'; + return results; + } + + if (tombstoned) { + results.status = 'tombstoned'; + results.theme = 'two'; + return results; + } if (status === 3) { results.status = 'active'; results.theme = 'one'; - } else if (status === 2 && jailed) { - results.status = 'jailed'; - results.theme = 'two'; - } else if (status === 2 && !jailed) { + } else if (status === 2) { results.status = 'unbonding'; results.theme = 'three'; } else if (status === 1) {