Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: tombstoned status #601

Merged
merged 2 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/validators.json
Original file line number Diff line number Diff line change
Expand Up @@ -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</0> and <0>halt the network</0> 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</0> and <0>halt the network</0> they will be highlighted differently in order to educate and encourage decentralization",
"tombstoned": "Tombstoned"
}
3 changes: 3 additions & 0 deletions src/graphql/account.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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}}) {
Expand Down
13 changes: 13 additions & 0 deletions src/graphql/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18499,6 +18499,9 @@ export type AccountQuery = { stakingParams: Array<(
)>, validatorStatuses: Array<(
{ __typename?: 'validator_status' }
& Pick<Validator_Status, 'status' | 'jailed'>
)>, validatorSigningInfos: Array<(
{ __typename?: 'validator_signing_info' }
& Pick<Validator_Signing_Info, 'tombstoned'>
)> }
) }
)>, unbonding: Array<(
Expand Down Expand Up @@ -18978,6 +18981,7 @@ export type ValidatorDetailsQuery = { stakingParams: Array<(
& Pick<Validator_Status, 'status' | 'jailed' | 'height'>
)>, validatorSigningInfos: Array<(
{ __typename?: 'validator_signing_info' }
& Pick<Validator_Signing_Info, 'tombstoned'>
& { missedBlocksCounter: Validator_Signing_Info['missed_blocks_counter'] }
)>, validatorInfo?: Maybe<(
{ __typename?: 'validator_info' }
Expand Down Expand Up @@ -19027,6 +19031,7 @@ export type ValidatorsQuery = { stakingParams: Array<(
& Pick<Validator_Status, 'status' | 'jailed' | 'height'>
)>, validatorSigningInfos: Array<(
{ __typename?: 'validator_signing_info' }
& Pick<Validator_Signing_Info, 'tombstoned'>
& { missedBlocksCounter: Validator_Signing_Info['missed_blocks_counter'] }
)>, validatorInfo?: Maybe<(
{ __typename?: 'validator_info' }
Expand Down Expand Up @@ -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}}) {
Expand Down Expand Up @@ -20208,6 +20219,7 @@ export const ValidatorDetailsDocument = gql`
limit: 1
) {
missedBlocksCounter: missed_blocks_counter
tombstoned
}
validatorInfo: validator_info {
operatorAddress: operator_address
Expand Down Expand Up @@ -20301,6 +20313,7 @@ export const ValidatorsDocument = gql`
limit: 1
) {
missedBlocksCounter: missed_blocks_counter
tombstoned
}
validatorInfo: validator_info {
operatorAddress: operator_address
Expand Down
1 change: 1 addition & 0 deletions src/graphql/validator_details.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/graphql/validators.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/screens/account_details/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
<AvatarName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ const Mobile: React.FC<{
return (
<div className={classnames(className)}>
{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 (
<React.Fragment key={`votes-mobile-${i}`}>
<div className={classes.list}>
Expand Down
3 changes: 3 additions & 0 deletions src/screens/account_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions src/screens/account_details/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ const mockAccount = jest.fn().mockResolvedValue({
jailed: false,
},
],
validatorSigningInfos: [
{
tombstoned: false,
},
],
},
},
],
Expand Down
3 changes: 3 additions & 0 deletions src/screens/account_details/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export type DelegationType = {
status: number;
jailed: boolean;
}
validatorSigningInfo: {
tombstoned: boolean;
}
commission: number;
amount: TokenUnit;
reward: TokenUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ValidatorOverview: React.FC<StatusType &{
const { handleCopyToClipboard } = useAddress(t);

const dateFormat = useRecoilValue(readDate);
const statusTheme = getValidatorStatus(data.status, data.jailed);
const statusTheme = getValidatorStatus(data.status, data.jailed, data.tombstoned);
const condition = getCondition(data.condition, data.status);

const statusItems = [
Expand Down
2 changes: 2 additions & 0 deletions src/screens/validator_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const initialState: ValidatorDetailsState = {
status: {
status: 0,
jailed: false,
tombstoned: false,
condition: 0,
commission: 0,
missedBlockCounter: 0,
Expand Down Expand Up @@ -264,6 +265,7 @@ export const useValidatorDetails = () => {
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,
Expand Down
1 change: 1 addition & 0 deletions src/screens/validator_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions src/screens/validator_details/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type OverviewType = {
export type StatusType = {
status: number;
jailed: boolean;
tombstoned: boolean;
condition: number;
commission: number;
signedBlockWindow: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
ryuash marked this conversation as resolved.
Show resolved Hide resolved
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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
ryuash marked this conversation as resolved.
Show resolved Hide resolved
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');
Expand Down
1 change: 1 addition & 0 deletions src/screens/validators/components/list/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
});
Expand Down
1 change: 1 addition & 0 deletions src/screens/validators/components/list/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const mockValidatorsDocument = jest.fn().mockResolvedValue({
validatorSigningInfos: [
{
missedBlocksCounter: 1,
tombstoned: false,
},
],
validatorInfo: {
Expand Down
1 change: 1 addition & 0 deletions src/screens/validators/components/list/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ValidatorType = {
condition: number;
status: number;
jailed: boolean;
tombstoned: boolean;
delegators: number;
topVotingPower?: boolean; // top 34% VP
}
Expand Down
25 changes: 16 additions & 9 deletions src/utils/get_validator_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @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',
Expand All @@ -13,15 +13,22 @@ export const getValidatorStatus = (status: number, jailed: boolean) => {
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) {
results.status = 'unbonding';
results.theme = 'three';
} else if (status === 2) {
if (jailed) {
results.status = 'jailed';
results.theme = 'two';
} else {
results.status = 'unbonding';
results.theme = 'three';
}
} else if (status === 1) {
results.status = 'unbonded';
results.theme = 'zero';
if (tombstoned) {
results.status = 'tombstoned';
results.theme = 'zero';
} else {
results.status = 'unbonded';
results.theme = 'zero';
}
} else {
results.status = 'unknown';
results.theme = 'zero';
Expand Down