From bae7cb175eefc1d261059c79560255d015aee4fd Mon Sep 17 00:00:00 2001 From: unconst Date: Mon, 6 Jan 2025 17:37:49 -0500 Subject: [PATCH] spec --- pallets/subtensor/rpc/src/lib.rs | 9 +++++++++ pallets/subtensor/runtime-api/src/lib.rs | 1 + runtime/src/lib.rs | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/pallets/subtensor/rpc/src/lib.rs b/pallets/subtensor/rpc/src/lib.rs index 4c5e6ae04..ae2d12d2f 100644 --- a/pallets/subtensor/rpc/src/lib.rs +++ b/pallets/subtensor/rpc/src/lib.rs @@ -53,6 +53,8 @@ pub trait SubtensorCustomApi { fn get_subnet_hyperparams(&self, netuid: u16, at: Option) -> RpcResult>; #[method(name = "subnetInfo_getAllDynamicInfo")] fn get_all_dynamic_info(&self, at: Option) -> RpcResult>; + #[method(name = "subnetInfo_getDynamicInfo")] + fn get_dynamic_info(&self, netuid: u16, at: Option) -> RpcResult>; #[method(name = "subnetInfo_getLockCost")] fn get_network_lock_cost(&self, at: Option) -> RpcResult; } @@ -218,6 +220,13 @@ where .map_err(|e| Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()) } + fn get_dynamic_info(&self, netuid: u16, at: Option<::Hash>) -> RpcResult> { + let api = self.client.runtime_api(); + let at = at.unwrap_or_else(|| self.client.info().best_hash); + api.get_dynamic_info(at, netuid) + .map_err(|e| Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()) + } + fn get_subnets_info(&self, at: Option<::Hash>) -> RpcResult> { let api = self.client.runtime_api(); let at = at.unwrap_or_else(|| self.client.info().best_hash); diff --git a/pallets/subtensor/runtime-api/src/lib.rs b/pallets/subtensor/runtime-api/src/lib.rs index e76120a33..119962ba8 100644 --- a/pallets/subtensor/runtime-api/src/lib.rs +++ b/pallets/subtensor/runtime-api/src/lib.rs @@ -25,6 +25,7 @@ sp_api::decl_runtime_apis! { fn get_subnets_info_v2() -> Vec; fn get_subnet_hyperparams(netuid: u16) -> Vec; fn get_all_dynamic_info() -> Vec; + fn get_dynamic_info(netuid: u16) -> Vec; } pub trait StakeInfoRuntimeApi { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index e46f7fcfc..3713baa16 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -2082,6 +2082,16 @@ impl_runtime_apis! { } } + fn get_dynamic_info(netuid: u16) -> Vec { + let _result = SubtensorModule::get_dynamic_info(netuid); + if _result.is_some() { + let result = _result.expect("Could not get DynamicInfo."); + result.encode() + } else { + vec![] + } + } + fn get_all_dynamic_info() -> Vec { let result = SubtensorModule::get_all_dynamic_info(); result.encode()