Skip to content

Commit cf00f30

Browse files
committed
return different format for get delegated
1 parent 4aad852 commit cf00f30

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sp_api::decl_runtime_apis! {
1919
pub trait DelegateInfoRuntimeApi {
2020
fn get_delegates() -> Vec<DelegateInfo<AccountId32>>;
2121
fn get_delegate( delegate_account: AccountId32 ) -> Option<DelegateInfo<AccountId32>>;
22-
fn get_delegated( delegatee_account: AccountId32 ) -> Vec<(DelegateInfo<AccountId32>, Compact<u64>)>;
22+
fn get_delegated( delegatee_account: AccountId32 ) -> Vec<(DelegateInfo<AccountId32>, (Compact<u16>, Compact<u64>))>;
2323
}
2424

2525
pub trait NeuronInfoRuntimeApi {

pallets/subtensor/src/rpc_info/delegate_info.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,22 @@ impl<T: Config> Pallet<T> {
151151
///
152152
pub fn get_delegated(
153153
delegatee: T::AccountId,
154-
) -> Vec<(DelegateInfo<T::AccountId>, Compact<u64>)> {
155-
let mut delegates: Vec<(DelegateInfo<T::AccountId>, Compact<u64>)> = Vec::new();
154+
) -> Vec<(DelegateInfo<T::AccountId>, (Compact<u16>, Compact<u64>))> {
155+
let mut delegates: Vec<(DelegateInfo<T::AccountId>, (Compact<u16>, Compact<u64>))> =
156+
Vec::new();
156157
for delegate in <Delegates<T> as IterableStorageMap<T::AccountId, u16>>::iter_keys() {
157158
// Staked to this delegate, so add to list
158159
for (netuid, _) in Alpha::<T>::iter_prefix((delegate.clone(), delegatee.clone())) {
159160
let delegate_info = Self::get_delegate_by_existing_account(delegate.clone(), true);
160161
delegates.push((
161162
delegate_info,
162-
Self::get_stake_for_hotkey_and_coldkey_on_subnet(&delegate, &delegatee, netuid)
163+
(
164+
netuid.into(),
165+
Self::get_stake_for_hotkey_and_coldkey_on_subnet(
166+
&delegate, &delegatee, netuid,
167+
)
163168
.into(),
169+
),
164170
));
165171
}
166172
}

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ impl_runtime_apis! {
20622062
SubtensorModule::get_delegate(delegate_account)
20632063
}
20642064

2065-
fn get_delegated(delegatee_account: AccountId32) -> Vec<(DelegateInfo<AccountId32>, Compact<u64>)> {
2065+
fn get_delegated(delegatee_account: AccountId32) -> Vec<(DelegateInfo<AccountId32>, (Compact<u16>, Compact<u64>))> {
20662066
SubtensorModule::get_delegated(delegatee_account)
20672067
}
20682068
}

0 commit comments

Comments
 (0)