Skip to content

Commit 72127ea

Browse files
committed
use options for netuids
1 parent 66c0e8a commit 72127ea

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pallets/subtensor/src/rpc_info/stake_info.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,17 @@ impl<T: Config> Pallet<T> {
118118
pub fn get_stake_fee_for_hotkey_coldkey_netuid(
119119
hotkey_account: T::AccountId,
120120
_coldkey_account: T::AccountId,
121-
origin_netuid: u16,
122-
_destination_netuid: u16,
121+
origin_netuid: Option<u16>,
122+
_destination_netuid: Option<u16>,
123123
amount: i64,
124124
) -> u64 {
125-
if amount >= 0 {
125+
if amount >= 0 || origin_netuid.is_none() {
126+
// Adding stake
126127
DefaultStakingFee::<T>::get()
127128
} else {
128129
// Calculate fee for unstake (negative amount)
129130
Self::calculate_staking_fee(
130-
origin_netuid,
131+
origin_netuid.unwrap_or(Self::get_root_netuid()),
131132
&hotkey_account,
132133
I96F32::saturating_from_num(amount.neg()),
133134
)

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ impl_runtime_apis! {
20672067
SubtensorModule::get_stake_info_for_hotkey_coldkey_netuid( hotkey_account, coldkey_account, netuid )
20682068
}
20692069

2070-
fn get_stake_fee_for_hotkey_coldkey_netuid( hotkey_account: AccountId32, coldkey_account: AccountId32, origin_netuid: u16, destination_netuid: u16, amount: i64 ) -> u64 {
2070+
fn get_stake_fee_for_hotkey_coldkey_netuid( hotkey_account: AccountId32, coldkey_account: AccountId32, origin_netuid: Option<u16>, destination_netuid: Option<u16>, amount: i64 ) -> u64 {
20712071
SubtensorModule::get_stake_fee_for_hotkey_coldkey_netuid( hotkey_account, coldkey_account, origin_netuid, destination_netuid, amount )
20722072
}
20732073
}

0 commit comments

Comments
 (0)