Skip to content

Commit 6d483b2

Browse files
committed
fix merge commit
1 parent 54959f3 commit 6d483b2

File tree

5 files changed

+17
-31
lines changed

5 files changed

+17
-31
lines changed

pallets/subtensor/runtime-api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sp_api::decl_runtime_apis! {
4545
pub trait StakeInfoRuntimeApi {
4646
fn get_stake_info_for_coldkey( coldkey_account: AccountId32 ) -> Vec<StakeInfo<AccountId32>>;
4747
fn get_stake_info_for_coldkeys( coldkey_accounts: Vec<AccountId32> ) -> Vec<(AccountId32, Vec<StakeInfo<AccountId32>>)>;
48-
fn get_stake_info_for_hotkey_coldkey_netuid( hotkey_account_vec: Vec<u8>, coldkey_account_vec: Vec<u8>, netuid: u16 ) -> Vec<u8>;
48+
fn get_stake_info_for_hotkey_coldkey_netuid( hotkey_account: AccountId32, coldkey_account: AccountId32, netuid: u16 ) -> Option<StakeInfo<AccountId32>>;
4949
}
5050

5151
pub trait SubnetRegistrationRuntimeApi {

pallets/subtensor/src/rpc_info/dynamic_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use codec::Compact;
44
use frame_support::pallet_prelude::{Decode, Encode};
55
use subtensor_macros::freeze_struct;
66

7-
#[freeze_struct("a5cdc80d655398e9")]
7+
#[freeze_struct("70be0b07db585696")]
88
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, TypeInfo)]
99
pub struct DynamicInfo<AccountId: TypeInfo + Encode + Decode> {
1010
netuid: Compact<u16>,

pallets/subtensor/src/rpc_info/metagraph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use frame_support::pallet_prelude::{Decode, Encode};
66
use substrate_fixed::types::I64F64;
77
use subtensor_macros::freeze_struct;
88

9-
#[freeze_struct("7c5fe907490c5d5e")]
9+
#[freeze_struct("a92e51d2046f4be8")]
1010
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, TypeInfo)]
1111
pub struct Metagraph<AccountId: TypeInfo + Encode + Decode> {
1212
// Subnet index

pallets/subtensor/src/rpc_info/stake_info.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,21 @@ impl<T: Config> Pallet<T> {
8484
}
8585

8686
pub fn get_stake_info_for_hotkey_coldkey_netuid(
87-
hotkey_account_vec: Vec<u8>,
88-
coldkey_account_vec: Vec<u8>,
87+
hotkey_account: T::AccountId,
88+
coldkey_account: T::AccountId,
8989
netuid: u16,
90-
) -> Option<StakeInfo<T>> {
91-
if coldkey_account_vec.len() != 32 {
92-
return None; // Invalid coldkey
93-
}
94-
95-
let Ok(coldkey) = T::AccountId::decode(&mut coldkey_account_vec.as_bytes_ref()) else {
96-
return None;
97-
};
98-
99-
if hotkey_account_vec.len() != 32 {
100-
return None; // Invalid hotkey
101-
}
102-
103-
let Ok(hotkey) = T::AccountId::decode(&mut hotkey_account_vec.as_bytes_ref()) else {
104-
return None;
105-
};
106-
107-
let alpha: u64 =
108-
Self::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid);
109-
let emission: u64 = AlphaDividendsPerSubnet::<T>::get(netuid, &hotkey);
110-
let is_registered: bool = Self::is_hotkey_registered_on_network(netuid, &hotkey);
90+
) -> Option<StakeInfo<T::AccountId>> {
91+
let alpha: u64 = Self::get_stake_for_hotkey_and_coldkey_on_subnet(
92+
&hotkey_account,
93+
&coldkey_account,
94+
netuid,
95+
);
96+
let emission: u64 = AlphaDividendsPerSubnet::<T>::get(netuid, &hotkey_account);
97+
let is_registered: bool = Self::is_hotkey_registered_on_network(netuid, &hotkey_account);
11198

11299
Some(StakeInfo {
113-
hotkey: hotkey.clone(),
114-
coldkey: coldkey.clone(),
100+
hotkey: hotkey_account,
101+
coldkey: coldkey_account,
115102
netuid: (netuid).into(),
116103
stake: alpha.into(),
117104
locked: 0.into(),

runtime/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,9 +2103,8 @@ impl_runtime_apis! {
21032103
SubtensorModule::get_stake_info_for_coldkeys( coldkey_accounts )
21042104
}
21052105

2106-
fn get_stake_info_for_hotkey_coldkey_netuid( hotkey_account_vec: Vec<u8>, coldkey_account_vec: Vec<u8>, netuid: u16 ) -> Vec<u8> {
2107-
let result = SubtensorModule::get_stake_info_for_hotkey_coldkey_netuid( hotkey_account_vec, coldkey_account_vec, netuid );
2108-
result.encode()
2106+
fn get_stake_info_for_hotkey_coldkey_netuid( hotkey_account: AccountId32, coldkey_account: AccountId32, netuid: u16 ) -> Option<StakeInfo<AccountId32>> {
2107+
SubtensorModule::get_stake_info_for_hotkey_coldkey_netuid( hotkey_account, coldkey_account, netuid )
21092108
}
21102109
}
21112110

0 commit comments

Comments
 (0)