Skip to content

Commit 95f1f00

Browse files
authored
Merge pull request #1282 from opentensor/feat/dont-let-coldkey-in-swap-add-stake
Feat/dont let coldkey in swap add stake
2 parents 3192e31 + 45a67fc commit 95f1f00

File tree

3 files changed

+412
-2
lines changed

3 files changed

+412
-2
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,12 @@ where
18851885
netuid,
18861886
amount_staked,
18871887
}) => {
1888+
if ColdkeySwapScheduled::<T>::contains_key(who) {
1889+
return InvalidTransaction::Custom(
1890+
CustomTransactionError::ColdkeyInSwapSchedule.into(),
1891+
)
1892+
.into();
1893+
}
18881894
// Fully validate the user input
18891895
Self::result_to_validity(Pallet::<T>::validate_add_stake(
18901896
who,
@@ -1902,6 +1908,13 @@ where
19021908
limit_price,
19031909
allow_partial,
19041910
}) => {
1911+
if ColdkeySwapScheduled::<T>::contains_key(who) {
1912+
return InvalidTransaction::Custom(
1913+
CustomTransactionError::ColdkeyInSwapSchedule.into(),
1914+
)
1915+
.into();
1916+
}
1917+
19051918
// Calcaulate the maximum amount that can be executed with price limit
19061919
let max_amount = Pallet::<T>::get_max_amount_add(*netuid, *limit_price);
19071920

@@ -1957,6 +1970,13 @@ where
19571970
destination_netuid,
19581971
alpha_amount,
19591972
}) => {
1973+
if ColdkeySwapScheduled::<T>::contains_key(who) {
1974+
return InvalidTransaction::Custom(
1975+
CustomTransactionError::ColdkeyInSwapSchedule.into(),
1976+
)
1977+
.into();
1978+
}
1979+
19601980
// Fully validate the user input
19611981
Self::result_to_validity(Pallet::<T>::validate_stake_transition(
19621982
who,
@@ -1978,6 +1998,13 @@ where
19781998
destination_netuid,
19791999
alpha_amount,
19802000
}) => {
2001+
if ColdkeySwapScheduled::<T>::contains_key(who) {
2002+
return InvalidTransaction::Custom(
2003+
CustomTransactionError::ColdkeyInSwapSchedule.into(),
2004+
)
2005+
.into();
2006+
}
2007+
19812008
// Fully validate the user input
19822009
Self::result_to_validity(Pallet::<T>::validate_stake_transition(
19832010
who,
@@ -1998,6 +2025,13 @@ where
19982025
destination_netuid,
19992026
alpha_amount,
20002027
}) => {
2028+
if ColdkeySwapScheduled::<T>::contains_key(who) {
2029+
return InvalidTransaction::Custom(
2030+
CustomTransactionError::ColdkeyInSwapSchedule.into(),
2031+
)
2032+
.into();
2033+
}
2034+
20012035
// Fully validate the user input
20022036
Self::result_to_validity(Pallet::<T>::validate_stake_transition(
20032037
who,
@@ -2020,6 +2054,13 @@ where
20202054
limit_price,
20212055
allow_partial,
20222056
}) => {
2057+
if ColdkeySwapScheduled::<T>::contains_key(who) {
2058+
return InvalidTransaction::Custom(
2059+
CustomTransactionError::ColdkeyInSwapSchedule.into(),
2060+
)
2061+
.into();
2062+
}
2063+
20232064
// Get the max amount possible to exchange
20242065
let max_amount = Pallet::<T>::get_max_amount_move(
20252066
*origin_netuid,
@@ -2042,6 +2083,13 @@ where
20422083
))
20432084
}
20442085
Some(Call::register { netuid, .. } | Call::burned_register { netuid, .. }) => {
2086+
if ColdkeySwapScheduled::<T>::contains_key(who) {
2087+
return InvalidTransaction::Custom(
2088+
CustomTransactionError::ColdkeyInSwapSchedule.into(),
2089+
)
2090+
.into();
2091+
}
2092+
20452093
let registrations_this_interval =
20462094
Pallet::<T>::get_registrations_this_interval(*netuid);
20472095
let max_registrations_per_interval =

0 commit comments

Comments
 (0)