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

Fix connected field bis #102

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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,480 changes: 1,428 additions & 1,052 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = ["crates/ash_cli", "crates/ash_sdk"]
resolver = "2"

[workspace.package]
version = "0.4.5"
version = "0.4.6-rc.2"
edition = "2021"
authors = ["E36 Knots"]
homepage = "https://ash.center"
Expand Down
2 changes: 1 addition & 1 deletion crates/ash_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ categories.workspace = true
keywords.workspace = true

[dependencies]
ash_sdk = { path = "../ash_sdk", version = "0.4.5" }
ash_sdk = { path = "../ash_sdk", version = "0.4.6-rc.2" }
clap = { version = "4.0.32", features = ["derive", "env", "cargo", "string"] }
colored = "2.0.0"
exitcode = "1.1.2"
Expand Down
3 changes: 2 additions & 1 deletion crates/ash_cli/src/avalanche/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn list(
.get_subnet(parse_id(subnet_id)?)
.map_err(|e| CliError::dataerr(format!("Error listing validators: {e}")))?;
let validators = subnet.validators.clone();
format!(
let first_line = format!(
"Found {} validators on Subnet '{}':",
type_colorize(&subnet.validators.len()),
type_colorize(&subnet_id)
Expand All @@ -124,6 +124,7 @@ fn list(
return Ok(());
}

println!("{}", first_line);
for validator in validators.iter() {
println!(
"{}",
Expand Down
16 changes: 7 additions & 9 deletions crates/ash_cli/src/utils/templating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ash_sdk::{
},
console,
};
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::{DateTime, Utc};
use colored::{ColoredString, Colorize};
use indicatif::ProgressBar;
use indoc::formatdoc;
Expand Down Expand Up @@ -50,12 +50,10 @@ where
}

pub(crate) fn human_readable_timestamp(timestamp: u64) -> String {
DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(timestamp as i64, 0).unwrap(),
Utc,
)
.format("%Y-%m-%d %H:%M:%S")
.to_string()
DateTime::<Utc>::from_timestamp(timestamp as i64, 0)
.unwrap()
.format("%Y-%m-%d %H:%M:%S")
.to_string()
}

pub(crate) fn template_horizontal_rule(character: char, length: usize) -> String {
Expand Down Expand Up @@ -177,7 +175,7 @@ pub(crate) fn template_validator_info(
Locktime: {}
Threshold: {}
Addresses: {}",
type_colorize(&validator.connected),
type_colorize(&validator.connected.unwrap_or_default()),
type_colorize(&match validator.signer {
Some(ref signer) => format!("0x{}", hex::encode(signer.public_key.clone())),
None => String::from("None"),
Expand Down Expand Up @@ -1249,7 +1247,7 @@ pub(crate) fn template_resources_table(
}
console::api_models::ResourceType::AvalancheSubnet => {
template_avalanche_subnet_props_table(&resource.clone())
},
}
console::api_models::ResourceType::Blockscout => {
template_blockscout_props_table(&resource.clone())
}
Expand Down
4 changes: 2 additions & 2 deletions crates/ash_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ categories.workspace = true
keywords.workspace = true

[dependencies]
avalanche-types = { version = "0.1.2", features = [
avalanche-types = { version = "0.1.5", features = [
"jsonrpc_client",
"wallet",
"subnet_evm",
] }
], git = "https://github.com/AshAvalanche/avalanche-rs.git", branch = "fix-connected-0.1.5" }
config = { version = "0.13.3", features = ["yaml"] }
ethers = { version = "2.0.7", features = ["rustls"] }
hex = { version = "0.4.3", features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/ash_sdk/src/avalanche/jsonrpc/platformvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ mod tests {
.unwrap();

// Test that the node is connected
assert!(ava_labs_node.connected);
assert_eq!(ava_labs_node.connected, Some(true));
// Test that the node has a non-zero uptime
assert!(ava_labs_node.uptime > Some(0.0));
// Test that the node has a non-zero weight
Expand Down
2 changes: 1 addition & 1 deletion crates/ash_sdk/src/avalanche/subnets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ pub struct AvalancheSubnetValidator {
pub weight: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub potential_reward: Option<u64>,
pub connected: bool,
pub connected: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub signer: Option<ProofOfPossession>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
Loading