Skip to content

Commit

Permalink
add custom error 7 & fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnReedV committed Jul 30, 2024
1 parent 38ad516 commit 826e55c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
18 changes: 8 additions & 10 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,16 +2403,14 @@ where
_len: usize,
) -> TransactionValidity {
// Check if the call is one of the balance transfer types we want to reject
if let Some(balances_call) = call.is_sub_type() {
match balances_call {
BalancesCall::transfer_allow_death { .. }
| BalancesCall::transfer_keep_alive { .. }
| BalancesCall::transfer_all { .. } => {
if Pallet::<T>::coldkey_in_arbitration(who) {
return Err(TransactionValidityError::Invalid(InvalidTransaction::Call));
}
}
_ => {} // Other Balances calls are allowed
if let Some(
BalancesCall::transfer_allow_death { .. }
| BalancesCall::transfer_keep_alive { .. }
| BalancesCall::transfer_all { .. },
) = call.is_sub_type()
{
if Pallet::<T>::coldkey_in_arbitration(who) {
return Err(InvalidTransaction::Custom(7).into());
}
}
match call.is_sub_type() {
Expand Down
6 changes: 2 additions & 4 deletions pallets/subtensor/tests/staking.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#![allow(clippy::unwrap_used)]
#![allow(clippy::arithmetic_side_effects)]

use frame_support::pallet_prelude::{
InvalidTransaction, TransactionValidity, TransactionValidityError,
};
use frame_support::pallet_prelude::{InvalidTransaction, TransactionValidity};
use frame_support::traits::{OnFinalize, OnIdle, OnInitialize};
use frame_support::weights::Weight;
use frame_support::{assert_err, assert_noop, assert_ok, traits::Currency};
Expand Down Expand Up @@ -3876,7 +3874,7 @@ fn test_transfer_coldkey_in_arbitration() {

assert_eq!(
validate_transaction(&coldkey_account_id, &call),
Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
Err(InvalidTransaction::Custom(7).into())
);
});
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ impl pallet_collective::Config<TriumvirateCollective> for Runtime {
}

// We call council members Triumvirate
#[allow(dead_code)]
type TriumvirateMembership = pallet_membership::Instance1;
impl pallet_membership::Config<TriumvirateMembership> for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand All @@ -531,6 +532,7 @@ impl pallet_membership::Config<TriumvirateMembership> for Runtime {
}

// We call our top K delegates membership Senate
#[allow(dead_code)]
type SenateMembership = pallet_membership::Instance2;
impl pallet_membership::Config<SenateMembership> for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down

0 comments on commit 826e55c

Please sign in to comment.