Update to latest set of selection chance buckets

This commit is contained in:
Jon Häggblad
2022-09-15 15:34:51 +02:00
parent 7b76beab76
commit a048cb9867
6 changed files with 16 additions and 32 deletions
@@ -7,13 +7,9 @@ const selectionChance = (economicDynamicsStats: ApiState<MixNodeEconomicDynamics
const inclusionProbability = economicDynamicsStats?.data?.active_set_inclusion_probability;
switch (inclusionProbability) {
case 'High':
case 'Moderate':
case 'Good':
case 'Low':
return inclusionProbability;
case 'VeryHigh':
return 'Very High';
case 'VeryLow':
return 'Very Low';
default:
return '-';
}
@@ -21,12 +21,10 @@ const textColour = (value: EconomicsRowsType, field: string, theme: Theme) => {
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;
+2 -2
View File
@@ -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;
@@ -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 }) => (
@@ -1 +1 @@
export type SelectionChance = 'VeryHigh' | 'High' | 'Moderate' | 'Low' | 'VeryLow';
export type SelectionChance = 'High' | 'Good' | 'Low';
@@ -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<f64> 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<Decimal> 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"),
}
}
}