From a048cb9867a0aafcfbbb1921400d2ac5dd783f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Thu, 15 Sep 2022 15:34:51 +0200 Subject: [PATCH] Update to latest set of selection chance buckets --- .../src/components/MixNodes/Economics/Rows.ts | 6 +----- .../src/components/MixNodes/Economics/Table.tsx | 4 +--- explorer/src/typeDefs/explorer-api.ts | 4 ++-- .../src/pages/settings/system-variables.tsx | 16 ++++++---------- .../types/src/types/rust/SelectionChance.ts | 2 +- .../validator-api-requests/src/models.rs | 16 +++++----------- 6 files changed, 16 insertions(+), 32 deletions(-) diff --git a/explorer/src/components/MixNodes/Economics/Rows.ts b/explorer/src/components/MixNodes/Economics/Rows.ts index 0a620318d7..e4c674f551 100644 --- a/explorer/src/components/MixNodes/Economics/Rows.ts +++ b/explorer/src/components/MixNodes/Economics/Rows.ts @@ -7,13 +7,9 @@ const selectionChance = (economicDynamicsStats: ApiState { if (field === 'selectionChance') { switch (fieldValue) { case 'High': - case 'Very High': return theme.palette.nym.networkExplorer.selectionChance.overModerate; - case 'Moderate': + case 'Good': return theme.palette.nym.networkExplorer.selectionChance.moderate; case 'Low': - case 'Very Low': return theme.palette.nym.networkExplorer.selectionChance.underModerate; default: return theme.palette.nym.wallet.fee; diff --git a/explorer/src/typeDefs/explorer-api.ts b/explorer/src/typeDefs/explorer-api.ts index 3463f55d98..241d656edf 100644 --- a/explorer/src/typeDefs/explorer-api.ts +++ b/explorer/src/typeDefs/explorer-api.ts @@ -215,8 +215,8 @@ export type UptimeStoryResponse = { export type MixNodeEconomicDynamicsStatsResponse = { stake_saturation: number; - active_set_inclusion_probability: 'VeryHigh' | 'High' | 'Moderate' | 'Low' | 'VeryLow'; - reserve_set_inclusion_probability: 'VeryHigh' | 'High' | 'Moderate' | 'Low' | 'VeryLow'; + active_set_inclusion_probability: 'High' | 'Good' | 'Low'; + reserve_set_inclusion_probability: 'High' | 'Good' | 'Low'; estimated_total_node_reward: number; estimated_operator_reward: number; estimated_delegators_reward: number; diff --git a/nym-wallet/src/pages/settings/system-variables.tsx b/nym-wallet/src/pages/settings/system-variables.tsx index 8545de6f68..9cbfe2e1e5 100644 --- a/nym-wallet/src/pages/settings/system-variables.tsx +++ b/nym-wallet/src/pages/settings/system-variables.tsx @@ -31,19 +31,15 @@ const DataField = ({ title, info, Indicator }: { title: string; info: string; In ); const colorMap: { [key in SelectionChance]: string } = { - VeryLow: 'error.main', - Low: 'error.main', - Moderate: 'warning.main', - High: 'success.main', - VeryHigh: 'success.main', + Low: 'error.main', + Good: 'warning.main', + High: 'success.main', }; const textMap: { [key in SelectionChance]: string } = { - VeryLow: 'VeryLow', - Low: 'Low', - Moderate: 'Moderate', - High: 'High', - VeryHigh: 'Very high', + Low: 'Low', + Good: 'Good', + High: 'High', }; const InclusionProbability = ({ probability }: { probability: SelectionChance }) => ( diff --git a/ts-packages/types/src/types/rust/SelectionChance.ts b/ts-packages/types/src/types/rust/SelectionChance.ts index a9e7e4797b..82af63c05d 100644 --- a/ts-packages/types/src/types/rust/SelectionChance.ts +++ b/ts-packages/types/src/types/rust/SelectionChance.ts @@ -1 +1 @@ -export type SelectionChance = 'VeryHigh' | 'High' | 'Moderate' | 'Low' | 'VeryLow'; +export type SelectionChance = 'High' | 'Good' | 'Low'; diff --git a/validator-api/validator-api-requests/src/models.rs b/validator-api/validator-api-requests/src/models.rs index b66eb6e217..ecbd2d5e12 100644 --- a/validator-api/validator-api-requests/src/models.rs +++ b/validator-api/validator-api-requests/src/models.rs @@ -141,21 +141,17 @@ pub type StakeSaturation = Decimal; ts(export_to = "ts-packages/types/src/types/rust/SelectionChance.ts") )] pub enum SelectionChance { - VeryHigh, High, - Moderate, + Good, Low, - VeryLow, } impl From for SelectionChance { fn from(p: f64) -> SelectionChance { match p { - p if p > 0.98 => SelectionChance::VeryHigh, - p if p > 0.9 => SelectionChance::High, - p if p > 0.7 => SelectionChance::Moderate, - p if p > 0.5 => SelectionChance::Low, - _ => SelectionChance::VeryLow, + p if p >= 0.7 => SelectionChance::High, + p if p >= 0.3 => SelectionChance::Good, + _ => SelectionChance::Low, } } } @@ -173,11 +169,9 @@ impl From for SelectionChance { impl fmt::Display for SelectionChance { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - SelectionChance::VeryHigh => write!(f, "VeryHigh"), SelectionChance::High => write!(f, "High"), - SelectionChance::Moderate => write!(f, "Moderate"), + SelectionChance::Good => write!(f, "Good"), SelectionChance::Low => write!(f, "Low"), - SelectionChance::VeryLow => write!(f, "VeryLow"), } } }