Skip to content

Commit

Permalink
Fix fixed cost extrinsic (#1648)
Browse files Browse the repository at this point in the history
* Only allow root to call `validate_cdd_expiry_nominators`

* Fix test
  • Loading branch information
adamdossa committed Apr 12, 2024
1 parent 16be86f commit 9077a2a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pallets/runtime/tests/src/staking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5241,7 +5241,7 @@ fn validate_nominators_with_valid_cdd() {
println!("Current timestamp: {:?}", Timestamp::now());

assert_ok!(Staking::validate_cdd_expiry_nominators(
Origin::signed(claim_issuer_1),
root(),
claimed_nominator
));
assert!(Staking::nominators(&account_alice).is_none());
Expand Down
8 changes: 4 additions & 4 deletions pallets/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ use frame_system::{
};
use pallet_identity as identity;
use pallet_session::historical;
use polymesh_common_utilities::{identity::Config as IdentityConfig, Context, GC_DID};
use polymesh_common_utilities::{identity::Config as IdentityConfig, Context, GC_DID, constants::GC_PALLET_ID};
use polymesh_primitives::{IdentityId, storage_migration_ver, storage_migrate_on};
use scale_info::TypeInfo;
use frame_election_provider_support::{
Expand All @@ -339,7 +339,7 @@ use sp_runtime::{
curve::PiecewiseLinear,
traits::{
AtLeast32BitUnsigned, CheckedSub, Convert, Dispatchable, SaturatedConversion, Saturating,
StaticLookup, Zero,
StaticLookup, Zero, AccountIdConversion,
},
transaction_validity::{
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
Expand Down Expand Up @@ -2235,7 +2235,7 @@ decl_module! {
/// #</weight>
#[weight = 1_000_000_000]
pub fn validate_cdd_expiry_nominators(origin, targets: Vec<T::AccountId>) {
let (caller, caller_id) = Identity::<T>::ensure_did(origin)?;
ensure_root(origin.clone())?;

let mut expired_nominators = Vec::new();
ensure!(!targets.is_empty(), "targets cannot be empty");
Expand Down Expand Up @@ -2270,7 +2270,7 @@ decl_module! {
<Nominators<T>>::remove(target);
}
}
Self::deposit_event(RawEvent::InvalidatedNominators(caller_id, caller, expired_nominators));
Self::deposit_event(RawEvent::InvalidatedNominators(GC_DID, GC_PALLET_ID.into_account_truncating(), expired_nominators));
}

/// Changes commission rate which applies to all validators. Only Governance
Expand Down

0 comments on commit 9077a2a

Please sign in to comment.