mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 06:47:57 +00:00
Replace T::AccountId with <T::Lookup as StaticLookup>::Source (#11670)
* initial * update * update * update * cargo fmt * update * update benchmarks * AccountIdLookupOf<T> * cargo fmt * fix conflits * cargo fmt * update Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -83,7 +83,7 @@ pub fn create_validator_with_nominators<T: Config>(
|
||||
let validator_prefs =
|
||||
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
||||
Staking::<T>::validate(RawOrigin::Signed(v_controller).into(), validator_prefs)?;
|
||||
let stash_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(v_stash.clone());
|
||||
let stash_lookup = T::Lookup::unlookup(v_stash.clone());
|
||||
|
||||
points_total += 10;
|
||||
points_individual.push((v_stash.clone(), 10));
|
||||
@@ -217,8 +217,7 @@ benchmarks! {
|
||||
bond {
|
||||
let stash = create_funded_user::<T>("stash", USER_SEED, 100);
|
||||
let controller = create_funded_user::<T>("controller", USER_SEED, 100);
|
||||
let controller_lookup: <T::Lookup as StaticLookup>::Source
|
||||
= T::Lookup::unlookup(controller.clone());
|
||||
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||
let reward_destination = RewardDestination::Staked;
|
||||
let amount = T::Currency::minimum_balance() * 10u32.into();
|
||||
whitelist_account!(stash);
|
||||
@@ -365,7 +364,7 @@ benchmarks! {
|
||||
100,
|
||||
Default::default(),
|
||||
)?;
|
||||
let stash_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(stash.clone());
|
||||
let stash_lookup = T::Lookup::unlookup(stash.clone());
|
||||
|
||||
// they start validating.
|
||||
Staking::<T>::validate(RawOrigin::Signed(controller.clone()).into(), Default::default())?;
|
||||
|
||||
@@ -309,7 +309,7 @@ use frame_support::{
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
curve::PiecewiseLinear,
|
||||
traits::{AtLeast32BitUnsigned, Convert, Saturating, Zero},
|
||||
traits::{AtLeast32BitUnsigned, Convert, Saturating, StaticLookup, Zero},
|
||||
Perbill, Perquintill, RuntimeDebug,
|
||||
};
|
||||
use sp_staking::{
|
||||
@@ -347,6 +347,8 @@ type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
>>::NegativeImbalance;
|
||||
|
||||
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||
|
||||
parameter_types! {
|
||||
pub MaxUnlockingChunks: u32 = 32;
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ mod impls;
|
||||
pub use impls::*;
|
||||
|
||||
use crate::{
|
||||
slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, EraPayout, EraRewardPoints, Exposure,
|
||||
Forcing, MaxUnlockingChunks, NegativeImbalanceOf, Nominations, PositiveImbalanceOf, Releases,
|
||||
RewardDestination, SessionInterface, StakingLedger, UnappliedSlash, UnlockChunk,
|
||||
ValidatorPrefs,
|
||||
slashing, weights::WeightInfo, AccountIdLookupOf, ActiveEraInfo, BalanceOf, EraPayout,
|
||||
EraRewardPoints, Exposure, Forcing, MaxUnlockingChunks, NegativeImbalanceOf, Nominations,
|
||||
PositiveImbalanceOf, Releases, RewardDestination, SessionInterface, StakingLedger,
|
||||
UnappliedSlash, UnlockChunk, ValidatorPrefs,
|
||||
};
|
||||
|
||||
const STAKING_ID: LockIdentifier = *b"staking ";
|
||||
@@ -768,7 +768,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::bond())]
|
||||
pub fn bond(
|
||||
origin: OriginFor<T>,
|
||||
controller: <T::Lookup as StaticLookup>::Source,
|
||||
controller: AccountIdLookupOf<T>,
|
||||
#[pallet::compact] value: BalanceOf<T>,
|
||||
payee: RewardDestination<T::AccountId>,
|
||||
) -> DispatchResult {
|
||||
@@ -1055,7 +1055,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::nominate(targets.len() as u32))]
|
||||
pub fn nominate(
|
||||
origin: OriginFor<T>,
|
||||
targets: Vec<<T::Lookup as StaticLookup>::Source>,
|
||||
targets: Vec<AccountIdLookupOf<T>>,
|
||||
) -> DispatchResult {
|
||||
let controller = ensure_signed(origin)?;
|
||||
|
||||
@@ -1175,7 +1175,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::set_controller())]
|
||||
pub fn set_controller(
|
||||
origin: OriginFor<T>,
|
||||
controller: <T::Lookup as StaticLookup>::Source,
|
||||
controller: AccountIdLookupOf<T>,
|
||||
) -> DispatchResult {
|
||||
let stash = ensure_signed(origin)?;
|
||||
let old_controller = Self::bonded(&stash).ok_or(Error::<T>::NotStash)?;
|
||||
@@ -1521,10 +1521,7 @@ pub mod pallet {
|
||||
/// Note: Making this call only makes sense if you first set the validator preferences to
|
||||
/// block any further nominations.
|
||||
#[pallet::weight(T::WeightInfo::kick(who.len() as u32))]
|
||||
pub fn kick(
|
||||
origin: OriginFor<T>,
|
||||
who: Vec<<T::Lookup as StaticLookup>::Source>,
|
||||
) -> DispatchResult {
|
||||
pub fn kick(origin: OriginFor<T>, who: Vec<AccountIdLookupOf<T>>) -> DispatchResult {
|
||||
let controller = ensure_signed(origin)?;
|
||||
let ledger = Self::ledger(&controller).ok_or(Error::<T>::NotController)?;
|
||||
let stash = &ledger.stash;
|
||||
|
||||
@@ -78,8 +78,7 @@ pub fn create_stash_controller<T: Config>(
|
||||
) -> Result<(T::AccountId, T::AccountId), &'static str> {
|
||||
let stash = create_funded_user::<T>("stash", n, balance_factor);
|
||||
let controller = create_funded_user::<T>("controller", n, balance_factor);
|
||||
let controller_lookup: <T::Lookup as StaticLookup>::Source =
|
||||
T::Lookup::unlookup(controller.clone());
|
||||
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||
let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into();
|
||||
Staking::<T>::bond(
|
||||
RawOrigin::Signed(stash.clone()).into(),
|
||||
@@ -98,8 +97,7 @@ pub fn create_stash_controller_with_balance<T: Config>(
|
||||
) -> Result<(T::AccountId, T::AccountId), &'static str> {
|
||||
let stash = create_funded_user_with_balance::<T>("stash", n, balance);
|
||||
let controller = create_funded_user_with_balance::<T>("controller", n, balance);
|
||||
let controller_lookup: <T::Lookup as StaticLookup>::Source =
|
||||
T::Lookup::unlookup(controller.clone());
|
||||
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||
|
||||
Staking::<T>::bond(
|
||||
RawOrigin::Signed(stash.clone()).into(),
|
||||
@@ -120,8 +118,7 @@ pub fn create_stash_and_dead_controller<T: Config>(
|
||||
let stash = create_funded_user::<T>("stash", n, balance_factor);
|
||||
// controller has no funds
|
||||
let controller = create_funded_user::<T>("controller", n, 0);
|
||||
let controller_lookup: <T::Lookup as StaticLookup>::Source =
|
||||
T::Lookup::unlookup(controller.clone());
|
||||
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||
let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into();
|
||||
Staking::<T>::bond(
|
||||
RawOrigin::Signed(stash.clone()).into(),
|
||||
@@ -136,7 +133,7 @@ pub fn create_stash_and_dead_controller<T: Config>(
|
||||
pub fn create_validators<T: Config>(
|
||||
max: u32,
|
||||
balance_factor: u32,
|
||||
) -> Result<Vec<<T::Lookup as StaticLookup>::Source>, &'static str> {
|
||||
) -> Result<Vec<AccountIdLookupOf<T>>, &'static str> {
|
||||
create_validators_with_seed::<T>(max, balance_factor, 0)
|
||||
}
|
||||
|
||||
@@ -145,15 +142,15 @@ pub fn create_validators_with_seed<T: Config>(
|
||||
max: u32,
|
||||
balance_factor: u32,
|
||||
seed: u32,
|
||||
) -> Result<Vec<<T::Lookup as StaticLookup>::Source>, &'static str> {
|
||||
let mut validators: Vec<<T::Lookup as StaticLookup>::Source> = Vec::with_capacity(max as usize);
|
||||
) -> Result<Vec<AccountIdLookupOf<T>>, &'static str> {
|
||||
let mut validators: Vec<AccountIdLookupOf<T>> = Vec::with_capacity(max as usize);
|
||||
for i in 0..max {
|
||||
let (stash, controller) =
|
||||
create_stash_controller::<T>(i + seed, balance_factor, RewardDestination::Staked)?;
|
||||
let validator_prefs =
|
||||
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
||||
Staking::<T>::validate(RawOrigin::Signed(controller).into(), validator_prefs)?;
|
||||
let stash_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(stash);
|
||||
let stash_lookup = T::Lookup::unlookup(stash);
|
||||
validators.push(stash_lookup);
|
||||
}
|
||||
Ok(validators)
|
||||
@@ -180,11 +177,10 @@ pub fn create_validators_with_nominators_for_era<T: Config>(
|
||||
edge_per_nominator: usize,
|
||||
randomize_stake: bool,
|
||||
to_nominate: Option<u32>,
|
||||
) -> Result<Vec<<T::Lookup as StaticLookup>::Source>, &'static str> {
|
||||
) -> Result<Vec<AccountIdLookupOf<T>>, &'static str> {
|
||||
clear_validators_and_nominators::<T>();
|
||||
|
||||
let mut validators_stash: Vec<<T::Lookup as StaticLookup>::Source> =
|
||||
Vec::with_capacity(validators as usize);
|
||||
let mut validators_stash: Vec<AccountIdLookupOf<T>> = Vec::with_capacity(validators as usize);
|
||||
let mut rng = ChaChaRng::from_seed(SEED.using_encoded(blake2_256));
|
||||
|
||||
// Create validators
|
||||
@@ -195,8 +191,7 @@ pub fn create_validators_with_nominators_for_era<T: Config>(
|
||||
let validator_prefs =
|
||||
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
||||
Staking::<T>::validate(RawOrigin::Signed(v_controller.clone()).into(), validator_prefs)?;
|
||||
let stash_lookup: <T::Lookup as StaticLookup>::Source =
|
||||
T::Lookup::unlookup(v_stash.clone());
|
||||
let stash_lookup = T::Lookup::unlookup(v_stash.clone());
|
||||
validators_stash.push(stash_lookup.clone());
|
||||
}
|
||||
|
||||
@@ -211,7 +206,7 @@ pub fn create_validators_with_nominators_for_era<T: Config>(
|
||||
|
||||
// Have them randomly validate
|
||||
let mut available_validators = validator_chosen.clone();
|
||||
let mut selected_validators: Vec<<T::Lookup as StaticLookup>::Source> =
|
||||
let mut selected_validators: Vec<AccountIdLookupOf<T>> =
|
||||
Vec::with_capacity(edge_per_nominator);
|
||||
|
||||
for _ in 0..validators.min(edge_per_nominator as u32) {
|
||||
|
||||
Reference in New Issue
Block a user