Skip to content

Commit 826e55c

Browse files
committed
add custom error 7 & fix clippy
1 parent 38ad516 commit 826e55c

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,16 +2403,14 @@ where
24032403
_len: usize,
24042404
) -> TransactionValidity {
24052405
// Check if the call is one of the balance transfer types we want to reject
2406-
if let Some(balances_call) = call.is_sub_type() {
2407-
match balances_call {
2408-
BalancesCall::transfer_allow_death { .. }
2409-
| BalancesCall::transfer_keep_alive { .. }
2410-
| BalancesCall::transfer_all { .. } => {
2411-
if Pallet::<T>::coldkey_in_arbitration(who) {
2412-
return Err(TransactionValidityError::Invalid(InvalidTransaction::Call));
2413-
}
2414-
}
2415-
_ => {} // Other Balances calls are allowed
2406+
if let Some(
2407+
BalancesCall::transfer_allow_death { .. }
2408+
| BalancesCall::transfer_keep_alive { .. }
2409+
| BalancesCall::transfer_all { .. },
2410+
) = call.is_sub_type()
2411+
{
2412+
if Pallet::<T>::coldkey_in_arbitration(who) {
2413+
return Err(InvalidTransaction::Custom(7).into());
24162414
}
24172415
}
24182416
match call.is_sub_type() {

pallets/subtensor/tests/staking.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#![allow(clippy::unwrap_used)]
22
#![allow(clippy::arithmetic_side_effects)]
33

4-
use frame_support::pallet_prelude::{
5-
InvalidTransaction, TransactionValidity, TransactionValidityError,
6-
};
4+
use frame_support::pallet_prelude::{InvalidTransaction, TransactionValidity};
75
use frame_support::traits::{OnFinalize, OnIdle, OnInitialize};
86
use frame_support::weights::Weight;
97
use frame_support::{assert_err, assert_noop, assert_ok, traits::Currency};
@@ -3876,7 +3874,7 @@ fn test_transfer_coldkey_in_arbitration() {
38763874

38773875
assert_eq!(
38783876
validate_transaction(&coldkey_account_id, &call),
3879-
Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
3877+
Err(InvalidTransaction::Custom(7).into())
38803878
);
38813879
});
38823880
}

runtime/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ impl pallet_collective::Config<TriumvirateCollective> for Runtime {
516516
}
517517

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

533534
// We call our top K delegates membership Senate
535+
#[allow(dead_code)]
534536
type SenateMembership = pallet_membership::Instance2;
535537
impl pallet_membership::Config<SenateMembership> for Runtime {
536538
type RuntimeEvent = RuntimeEvent;

0 commit comments

Comments
 (0)