From 96a2f2e76f9727175ca5b7e8d9fc0b4ffa14f4f6 Mon Sep 17 00:00:00 2001 From: kukabi Date: Mon, 1 Aug 2022 20:42:53 +0300 Subject: [PATCH] Add network id to validator details and summary. --- subvt-substrate-client/src/lib.rs | 3 +++ subvt-types/src/subvt.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/subvt-substrate-client/src/lib.rs b/subvt-substrate-client/src/lib.rs index 770fa4aa..4a6d8f11 100644 --- a/subvt-substrate-client/src/lib.rs +++ b/subvt-substrate-client/src/lib.rs @@ -39,6 +39,7 @@ const KEY_QUERY_PAGE_SIZE: usize = 1000; /// The client. pub struct SubstrateClient { + network_id: u32, pub chain: Chain, pub metadata: Metadata, pub system_properties: SystemProperties, @@ -86,6 +87,7 @@ impl SubstrateClient { ws_client.request("system_properties", None).await?; log::info!("Got system properties. {:?}", system_properties); Ok(Self { + network_id: config.substrate.network_id, chain, metadata, system_properties, @@ -632,6 +634,7 @@ impl SubstrateClient { account.id, ValidatorDetails { account: account.clone(), + network_id: self.network_id, is_active, is_para_validator, para_core_assignment, diff --git a/subvt-types/src/subvt.rs b/subvt-types/src/subvt.rs index 13d72b13..97d8037d 100644 --- a/subvt-types/src/subvt.rs +++ b/subvt-types/src/subvt.rs @@ -49,6 +49,7 @@ pub struct NetworkStatusUpdate { pub struct ValidatorDetails { #[diff_key] pub account: Account, + pub network_id: u32, pub controller_account_id: AccountId, pub preferences: ValidatorPreferences, pub self_stake: Stake, @@ -98,6 +99,7 @@ pub struct ValidatorSummary { #[diff_key] pub account_id: AccountId, pub address: String, + pub network_id: u32, pub controller_account_id: AccountId, #[serde(skip_serializing_if = "Option::is_none")] pub display: Option, @@ -151,6 +153,7 @@ impl From<&ValidatorDetails> for ValidatorSummary { ValidatorSummary { account_id: validator.account.id, address: validator.account.address.clone(), + network_id: validator.network_id, controller_account_id: validator.controller_account_id, display: validator.account.get_display(), parent_display: validator.account.get_parent_display(),