mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 06:27:58 +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:
@@ -92,18 +92,20 @@ benchmarks_instance_pallet! {
|
||||
report_awesome {
|
||||
let r in 0 .. T::MaximumReasonLength::get();
|
||||
let (caller, reason, awesome_person) = setup_awesome::<T, I>(r);
|
||||
let awesome_person_lookup = T::Lookup::unlookup(awesome_person);
|
||||
// Whitelist caller account from further DB operations.
|
||||
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
||||
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
||||
}: _(RawOrigin::Signed(caller), reason, awesome_person)
|
||||
}: _(RawOrigin::Signed(caller), reason, awesome_person_lookup)
|
||||
|
||||
retract_tip {
|
||||
let r = T::MaximumReasonLength::get();
|
||||
let (caller, reason, awesome_person) = setup_awesome::<T, I>(r);
|
||||
let awesome_person_lookup = T::Lookup::unlookup(awesome_person.clone());
|
||||
TipsMod::<T, I>::report_awesome(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
reason.clone(),
|
||||
awesome_person.clone()
|
||||
awesome_person_lookup
|
||||
)?;
|
||||
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||
let hash = T::Hashing::hash_of(&(&reason_hash, &awesome_person));
|
||||
@@ -117,19 +119,21 @@ benchmarks_instance_pallet! {
|
||||
let t in 1 .. T::Tippers::max_len() as u32;
|
||||
|
||||
let (caller, reason, beneficiary, value) = setup_tip::<T, I>(r, t)?;
|
||||
let beneficiary_lookup = T::Lookup::unlookup(beneficiary);
|
||||
// Whitelist caller account from further DB operations.
|
||||
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
||||
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
||||
}: _(RawOrigin::Signed(caller), reason, beneficiary, value)
|
||||
}: _(RawOrigin::Signed(caller), reason, beneficiary_lookup, value)
|
||||
|
||||
tip {
|
||||
let t in 1 .. T::Tippers::max_len() as u32;
|
||||
let (member, reason, beneficiary, value) = setup_tip::<T, I>(0, t)?;
|
||||
let beneficiary_lookup = T::Lookup::unlookup(beneficiary.clone());
|
||||
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||
TipsMod::<T, I>::tip_new(
|
||||
RawOrigin::Signed(member).into(),
|
||||
reason.clone(),
|
||||
beneficiary.clone(),
|
||||
beneficiary_lookup,
|
||||
value
|
||||
)?;
|
||||
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||
@@ -150,11 +154,12 @@ benchmarks_instance_pallet! {
|
||||
|
||||
// Set up a new tip proposal
|
||||
let (member, reason, beneficiary, value) = setup_tip::<T, I>(0, t)?;
|
||||
let beneficiary_lookup = T::Lookup::unlookup(beneficiary.clone());
|
||||
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||
TipsMod::<T, I>::tip_new(
|
||||
RawOrigin::Signed(member).into(),
|
||||
reason.clone(),
|
||||
beneficiary.clone(),
|
||||
beneficiary_lookup,
|
||||
value
|
||||
)?;
|
||||
|
||||
@@ -179,11 +184,12 @@ benchmarks_instance_pallet! {
|
||||
|
||||
// Set up a new tip proposal
|
||||
let (member, reason, beneficiary, value) = setup_tip::<T, I>(0, t)?;
|
||||
let beneficiary_lookup = T::Lookup::unlookup(beneficiary.clone());
|
||||
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||
TipsMod::<T, I>::tip_new(
|
||||
RawOrigin::Signed(member).into(),
|
||||
reason.clone(),
|
||||
beneficiary.clone(),
|
||||
beneficiary_lookup,
|
||||
value
|
||||
)?;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ pub mod migrations;
|
||||
pub mod weights;
|
||||
|
||||
use sp_runtime::{
|
||||
traits::{AccountIdConversion, BadOrigin, Hash, TrailingZeroInput, Zero},
|
||||
traits::{AccountIdConversion, BadOrigin, Hash, StaticLookup, TrailingZeroInput, Zero},
|
||||
Percent, RuntimeDebug,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
@@ -80,6 +80,7 @@ pub use weights::WeightInfo;
|
||||
|
||||
pub type BalanceOf<T, I = ()> = pallet_treasury::BalanceOf<T, I>;
|
||||
pub type NegativeImbalanceOf<T, I = ()> = pallet_treasury::NegativeImbalanceOf<T, I>;
|
||||
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||
|
||||
/// An open tipping "motion". Retains all details of a tip including information on the finder
|
||||
/// and the members who have voted.
|
||||
@@ -237,9 +238,10 @@ pub mod pallet {
|
||||
pub fn report_awesome(
|
||||
origin: OriginFor<T>,
|
||||
reason: Vec<u8>,
|
||||
who: T::AccountId,
|
||||
who: AccountIdLookupOf<T>,
|
||||
) -> DispatchResult {
|
||||
let finder = ensure_signed(origin)?;
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
|
||||
ensure!(
|
||||
reason.len() <= T::MaximumReasonLength::get() as usize,
|
||||
@@ -331,10 +333,11 @@ pub mod pallet {
|
||||
pub fn tip_new(
|
||||
origin: OriginFor<T>,
|
||||
reason: Vec<u8>,
|
||||
who: T::AccountId,
|
||||
who: AccountIdLookupOf<T>,
|
||||
#[pallet::compact] tip_value: BalanceOf<T, I>,
|
||||
) -> DispatchResult {
|
||||
let tipper = ensure_signed(origin)?;
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
ensure!(T::Tippers::contains(&tipper), BadOrigin);
|
||||
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||
ensure!(!Reasons::<T, I>::contains_key(&reason_hash), Error::<T, I>::AlreadyKnown);
|
||||
|
||||
Reference in New Issue
Block a user