mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +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:
@@ -662,7 +662,7 @@ benchmarks_instance_pallet! {
|
|||||||
assert!(!Alliance::<T, I>::is_member(&outsider));
|
assert!(!Alliance::<T, I>::is_member(&outsider));
|
||||||
assert_eq!(DepositOf::<T, I>::get(&outsider), None);
|
assert_eq!(DepositOf::<T, I>::get(&outsider), None);
|
||||||
|
|
||||||
let outsider_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(outsider.clone());
|
let outsider_lookup = T::Lookup::unlookup(outsider.clone());
|
||||||
}: _(SystemOrigin::Signed(founder1.clone()), outsider_lookup)
|
}: _(SystemOrigin::Signed(founder1.clone()), outsider_lookup)
|
||||||
verify {
|
verify {
|
||||||
assert!(Alliance::<T, I>::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally
|
assert!(Alliance::<T, I>::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally
|
||||||
@@ -681,7 +681,7 @@ benchmarks_instance_pallet! {
|
|||||||
let ally1 = ally::<T, I>(1);
|
let ally1 = ally::<T, I>(1);
|
||||||
assert!(Alliance::<T, I>::is_ally(&ally1));
|
assert!(Alliance::<T, I>::is_ally(&ally1));
|
||||||
|
|
||||||
let ally1_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(ally1.clone());
|
let ally1_lookup = T::Lookup::unlookup(ally1.clone());
|
||||||
let call = Call::<T, I>::elevate_ally { ally: ally1_lookup };
|
let call = Call::<T, I>::elevate_ally { ally: ally1_lookup };
|
||||||
let origin = T::MembershipManager::successful_origin();
|
let origin = T::MembershipManager::successful_origin();
|
||||||
}: { call.dispatch_bypass_filter(origin)? }
|
}: { call.dispatch_bypass_filter(origin)? }
|
||||||
@@ -720,7 +720,7 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
assert_eq!(DepositOf::<T, I>::get(&fellow2), Some(T::AllyDeposit::get()));
|
assert_eq!(DepositOf::<T, I>::get(&fellow2), Some(T::AllyDeposit::get()));
|
||||||
|
|
||||||
let fellow2_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(fellow2.clone());
|
let fellow2_lookup = T::Lookup::unlookup(fellow2.clone());
|
||||||
let call = Call::<T, I>::kick_member { who: fellow2_lookup };
|
let call = Call::<T, I>::kick_member { who: fellow2_lookup };
|
||||||
let origin = T::MembershipManager::successful_origin();
|
let origin = T::MembershipManager::successful_origin();
|
||||||
}: { call.dispatch_bypass_filter(origin)? }
|
}: { call.dispatch_bypass_filter(origin)? }
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ pub enum UnscrupulousItem<AccountId, Url> {
|
|||||||
type UnscrupulousItemOf<T, I> =
|
type UnscrupulousItemOf<T, I> =
|
||||||
UnscrupulousItem<<T as frame_system::Config>::AccountId, UrlOf<T, I>>;
|
UnscrupulousItem<<T as frame_system::Config>::AccountId, UrlOf<T, I>>;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -744,10 +746,7 @@ pub mod pallet {
|
|||||||
/// A founder or fellow can nominate someone to join the alliance as an Ally.
|
/// A founder or fellow can nominate someone to join the alliance as an Ally.
|
||||||
/// There is no deposit required to the nominator or nominee.
|
/// There is no deposit required to the nominator or nominee.
|
||||||
#[pallet::weight(T::WeightInfo::nominate_ally())]
|
#[pallet::weight(T::WeightInfo::nominate_ally())]
|
||||||
pub fn nominate_ally(
|
pub fn nominate_ally(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
|
||||||
) -> DispatchResult {
|
|
||||||
let nominator = ensure_signed(origin)?;
|
let nominator = ensure_signed(origin)?;
|
||||||
ensure!(Self::has_voting_rights(&nominator), Error::<T, I>::NoVotingRights);
|
ensure!(Self::has_voting_rights(&nominator), Error::<T, I>::NoVotingRights);
|
||||||
let who = T::Lookup::lookup(who)?;
|
let who = T::Lookup::lookup(who)?;
|
||||||
@@ -771,10 +770,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// Elevate an ally to fellow.
|
/// Elevate an ally to fellow.
|
||||||
#[pallet::weight(T::WeightInfo::elevate_ally())]
|
#[pallet::weight(T::WeightInfo::elevate_ally())]
|
||||||
pub fn elevate_ally(
|
pub fn elevate_ally(origin: OriginFor<T>, ally: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
ally: <T::Lookup as StaticLookup>::Source,
|
|
||||||
) -> DispatchResult {
|
|
||||||
T::MembershipManager::ensure_origin(origin)?;
|
T::MembershipManager::ensure_origin(origin)?;
|
||||||
let ally = T::Lookup::lookup(ally)?;
|
let ally = T::Lookup::lookup(ally)?;
|
||||||
ensure!(Self::is_ally(&ally), Error::<T, I>::NotAlly);
|
ensure!(Self::is_ally(&ally), Error::<T, I>::NotAlly);
|
||||||
@@ -807,10 +803,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// Kick a member from the alliance and slash its deposit.
|
/// Kick a member from the alliance and slash its deposit.
|
||||||
#[pallet::weight(T::WeightInfo::kick_member())]
|
#[pallet::weight(T::WeightInfo::kick_member())]
|
||||||
pub fn kick_member(
|
pub fn kick_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
|
||||||
) -> DispatchResult {
|
|
||||||
T::MembershipManager::ensure_origin(origin)?;
|
T::MembershipManager::ensure_origin(origin)?;
|
||||||
let member = T::Lookup::lookup(who)?;
|
let member = T::Lookup::lookup(who)?;
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const SEED: u32 = 0;
|
|||||||
|
|
||||||
fn create_default_asset<T: Config<I>, I: 'static>(
|
fn create_default_asset<T: Config<I>, I: 'static>(
|
||||||
is_sufficient: bool,
|
is_sufficient: bool,
|
||||||
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
) -> (T::AccountId, AccountIdLookupOf<T>) {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
let root = SystemOrigin::Root.into();
|
let root = SystemOrigin::Root.into();
|
||||||
@@ -55,7 +55,7 @@ fn create_default_asset<T: Config<I>, I: 'static>(
|
|||||||
fn create_default_minted_asset<T: Config<I>, I: 'static>(
|
fn create_default_minted_asset<T: Config<I>, I: 'static>(
|
||||||
is_sufficient: bool,
|
is_sufficient: bool,
|
||||||
amount: T::Balance,
|
amount: T::Balance,
|
||||||
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
) -> (T::AccountId, AccountIdLookupOf<T>) {
|
||||||
let (caller, caller_lookup) = create_default_asset::<T, I>(is_sufficient);
|
let (caller, caller_lookup) = create_default_asset::<T, I>(is_sufficient);
|
||||||
if !is_sufficient {
|
if !is_sufficient {
|
||||||
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());
|
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());
|
||||||
|
|||||||
@@ -164,6 +164,8 @@ use frame_system::Config as SystemConfig;
|
|||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
pub use weights::WeightInfo;
|
pub use weights::WeightInfo;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -501,7 +503,7 @@ pub mod pallet {
|
|||||||
pub fn create(
|
pub fn create(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
admin: <T::Lookup as StaticLookup>::Source,
|
admin: AccountIdLookupOf<T>,
|
||||||
min_balance: T::Balance,
|
min_balance: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let owner = ensure_signed(origin)?;
|
let owner = ensure_signed(origin)?;
|
||||||
@@ -557,7 +559,7 @@ pub mod pallet {
|
|||||||
pub fn force_create(
|
pub fn force_create(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
is_sufficient: bool,
|
is_sufficient: bool,
|
||||||
#[pallet::compact] min_balance: T::Balance,
|
#[pallet::compact] min_balance: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
@@ -623,7 +625,7 @@ pub mod pallet {
|
|||||||
pub fn mint(
|
pub fn mint(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
beneficiary: <T::Lookup as StaticLookup>::Source,
|
beneficiary: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] amount: T::Balance,
|
#[pallet::compact] amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
@@ -651,7 +653,7 @@ pub mod pallet {
|
|||||||
pub fn burn(
|
pub fn burn(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
who: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] amount: T::Balance,
|
#[pallet::compact] amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
@@ -684,7 +686,7 @@ pub mod pallet {
|
|||||||
pub fn transfer(
|
pub fn transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] amount: T::Balance,
|
#[pallet::compact] amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
@@ -716,7 +718,7 @@ pub mod pallet {
|
|||||||
pub fn transfer_keep_alive(
|
pub fn transfer_keep_alive(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] amount: T::Balance,
|
#[pallet::compact] amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let source = ensure_signed(origin)?;
|
let source = ensure_signed(origin)?;
|
||||||
@@ -749,8 +751,8 @@ pub mod pallet {
|
|||||||
pub fn force_transfer(
|
pub fn force_transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
source: <T::Lookup as StaticLookup>::Source,
|
source: AccountIdLookupOf<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] amount: T::Balance,
|
#[pallet::compact] amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
@@ -775,7 +777,7 @@ pub mod pallet {
|
|||||||
pub fn freeze(
|
pub fn freeze(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
who: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
|
|
||||||
@@ -806,7 +808,7 @@ pub mod pallet {
|
|||||||
pub fn thaw(
|
pub fn thaw(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
who: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
|
|
||||||
@@ -891,7 +893,7 @@ pub mod pallet {
|
|||||||
pub fn transfer_ownership(
|
pub fn transfer_ownership(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let owner = T::Lookup::lookup(owner)?;
|
let owner = T::Lookup::lookup(owner)?;
|
||||||
@@ -932,9 +934,9 @@ pub mod pallet {
|
|||||||
pub fn set_team(
|
pub fn set_team(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
issuer: <T::Lookup as StaticLookup>::Source,
|
issuer: AccountIdLookupOf<T>,
|
||||||
admin: <T::Lookup as StaticLookup>::Source,
|
admin: AccountIdLookupOf<T>,
|
||||||
freezer: <T::Lookup as StaticLookup>::Source,
|
freezer: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let issuer = T::Lookup::lookup(issuer)?;
|
let issuer = T::Lookup::lookup(issuer)?;
|
||||||
@@ -1117,10 +1119,10 @@ pub mod pallet {
|
|||||||
pub fn force_asset_status(
|
pub fn force_asset_status(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
issuer: <T::Lookup as StaticLookup>::Source,
|
issuer: AccountIdLookupOf<T>,
|
||||||
admin: <T::Lookup as StaticLookup>::Source,
|
admin: AccountIdLookupOf<T>,
|
||||||
freezer: <T::Lookup as StaticLookup>::Source,
|
freezer: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] min_balance: T::Balance,
|
#[pallet::compact] min_balance: T::Balance,
|
||||||
is_sufficient: bool,
|
is_sufficient: bool,
|
||||||
is_frozen: bool,
|
is_frozen: bool,
|
||||||
@@ -1167,7 +1169,7 @@ pub mod pallet {
|
|||||||
pub fn approve_transfer(
|
pub fn approve_transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
delegate: <T::Lookup as StaticLookup>::Source,
|
delegate: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] amount: T::Balance,
|
#[pallet::compact] amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let owner = ensure_signed(origin)?;
|
let owner = ensure_signed(origin)?;
|
||||||
@@ -1192,7 +1194,7 @@ pub mod pallet {
|
|||||||
pub fn cancel_approval(
|
pub fn cancel_approval(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
delegate: <T::Lookup as StaticLookup>::Source,
|
delegate: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let owner = ensure_signed(origin)?;
|
let owner = ensure_signed(origin)?;
|
||||||
let delegate = T::Lookup::lookup(delegate)?;
|
let delegate = T::Lookup::lookup(delegate)?;
|
||||||
@@ -1225,8 +1227,8 @@ pub mod pallet {
|
|||||||
pub fn force_cancel_approval(
|
pub fn force_cancel_approval(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
delegate: <T::Lookup as StaticLookup>::Source,
|
delegate: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let mut d = Asset::<T, I>::get(id).ok_or(Error::<T, I>::Unknown)?;
|
let mut d = Asset::<T, I>::get(id).ok_or(Error::<T, I>::Unknown)?;
|
||||||
T::ForceOrigin::try_origin(origin)
|
T::ForceOrigin::try_origin(origin)
|
||||||
@@ -1272,8 +1274,8 @@ pub mod pallet {
|
|||||||
pub fn transfer_approved(
|
pub fn transfer_approved(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] id: T::AssetId,
|
#[pallet::compact] id: T::AssetId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
destination: <T::Lookup as StaticLookup>::Source,
|
destination: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] amount: T::Balance,
|
#[pallet::compact] amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let delegate = ensure_signed(origin)?;
|
let delegate = ensure_signed(origin)?;
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ frame_benchmarking::benchmarks_instance_pallet! {
|
|||||||
let dest_head: T::AccountId = account("dest_head", 0, 0);
|
let dest_head: T::AccountId = account("dest_head", 0, 0);
|
||||||
assert_ok!(List::<T, _>::insert(dest_head.clone(), dest_bag_thresh));
|
assert_ok!(List::<T, _>::insert(dest_head.clone(), dest_bag_thresh));
|
||||||
|
|
||||||
|
let origin_middle_lookup = T::Lookup::unlookup(origin_middle.clone());
|
||||||
|
|
||||||
// the bags are in the expected state after initial setup.
|
// the bags are in the expected state after initial setup.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
List::<T, _>::get_bags(),
|
List::<T, _>::get_bags(),
|
||||||
@@ -69,7 +71,7 @@ frame_benchmarking::benchmarks_instance_pallet! {
|
|||||||
let caller = whitelisted_caller();
|
let caller = whitelisted_caller();
|
||||||
// update the weight of `origin_middle` to guarantee it will be rebagged into the destination.
|
// update the weight of `origin_middle` to guarantee it will be rebagged into the destination.
|
||||||
T::ScoreProvider::set_score_of(&origin_middle, dest_bag_thresh);
|
T::ScoreProvider::set_score_of(&origin_middle, dest_bag_thresh);
|
||||||
}: rebag(SystemOrigin::Signed(caller), origin_middle.clone())
|
}: rebag(SystemOrigin::Signed(caller), origin_middle_lookup.clone())
|
||||||
verify {
|
verify {
|
||||||
// check the bags have updated as expected.
|
// check the bags have updated as expected.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -114,6 +116,8 @@ frame_benchmarking::benchmarks_instance_pallet! {
|
|||||||
let dest_head: T::AccountId = account("dest_head", 0, 0);
|
let dest_head: T::AccountId = account("dest_head", 0, 0);
|
||||||
assert_ok!(List::<T, _>::insert(dest_head.clone(), dest_bag_thresh));
|
assert_ok!(List::<T, _>::insert(dest_head.clone(), dest_bag_thresh));
|
||||||
|
|
||||||
|
let origin_tail_lookup = T::Lookup::unlookup(origin_tail.clone());
|
||||||
|
|
||||||
// the bags are in the expected state after initial setup.
|
// the bags are in the expected state after initial setup.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
List::<T, _>::get_bags(),
|
List::<T, _>::get_bags(),
|
||||||
@@ -126,7 +130,7 @@ frame_benchmarking::benchmarks_instance_pallet! {
|
|||||||
let caller = whitelisted_caller();
|
let caller = whitelisted_caller();
|
||||||
// update the weight of `origin_tail` to guarantee it will be rebagged into the destination.
|
// update the weight of `origin_tail` to guarantee it will be rebagged into the destination.
|
||||||
T::ScoreProvider::set_score_of(&origin_tail, dest_bag_thresh);
|
T::ScoreProvider::set_score_of(&origin_tail, dest_bag_thresh);
|
||||||
}: rebag(SystemOrigin::Signed(caller), origin_tail.clone())
|
}: rebag(SystemOrigin::Signed(caller), origin_tail_lookup.clone())
|
||||||
verify {
|
verify {
|
||||||
// check the bags have updated as expected.
|
// check the bags have updated as expected.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -166,13 +170,15 @@ frame_benchmarking::benchmarks_instance_pallet! {
|
|||||||
T::ScoreProvider::set_score_of(&lighter, bag_thresh - One::one());
|
T::ScoreProvider::set_score_of(&lighter, bag_thresh - One::one());
|
||||||
T::ScoreProvider::set_score_of(&heavier, bag_thresh);
|
T::ScoreProvider::set_score_of(&heavier, bag_thresh);
|
||||||
|
|
||||||
|
let lighter_lookup = T::Lookup::unlookup(lighter.clone());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
List::<T, _>::iter().map(|n| n.id().clone()).collect::<Vec<_>>(),
|
List::<T, _>::iter().map(|n| n.id().clone()).collect::<Vec<_>>(),
|
||||||
vec![lighter.clone(), heavier_prev.clone(), heavier.clone(), heavier_next.clone()]
|
vec![lighter.clone(), heavier_prev.clone(), heavier.clone(), heavier_next.clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
whitelist_account!(heavier);
|
whitelist_account!(heavier);
|
||||||
}: _(SystemOrigin::Signed(heavier.clone()), lighter.clone())
|
}: _(SystemOrigin::Signed(heavier.clone()), lighter_lookup.clone())
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
List::<T, _>::iter().map(|n| n.id().clone()).collect::<Vec<_>>(),
|
List::<T, _>::iter().map(|n| n.id().clone()).collect::<Vec<_>>(),
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
use codec::FullCodec;
|
use codec::FullCodec;
|
||||||
use frame_election_provider_support::{ScoreProvider, SortedListProvider};
|
use frame_election_provider_support::{ScoreProvider, SortedListProvider};
|
||||||
use frame_system::ensure_signed;
|
use frame_system::ensure_signed;
|
||||||
use sp_runtime::traits::{AtLeast32BitUnsigned, Bounded};
|
use sp_runtime::traits::{AtLeast32BitUnsigned, Bounded, StaticLookup};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||||
@@ -90,6 +90,8 @@ macro_rules! log {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -222,8 +224,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// If `dislocated` does not exists, it returns an error.
|
/// If `dislocated` does not exists, it returns an error.
|
||||||
#[pallet::weight(T::WeightInfo::rebag_non_terminal().max(T::WeightInfo::rebag_terminal()))]
|
#[pallet::weight(T::WeightInfo::rebag_non_terminal().max(T::WeightInfo::rebag_terminal()))]
|
||||||
pub fn rebag(origin: OriginFor<T>, dislocated: T::AccountId) -> DispatchResult {
|
pub fn rebag(origin: OriginFor<T>, dislocated: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
ensure_signed(origin)?;
|
ensure_signed(origin)?;
|
||||||
|
let dislocated = T::Lookup::lookup(dislocated)?;
|
||||||
let current_score = T::ScoreProvider::score(&dislocated);
|
let current_score = T::ScoreProvider::score(&dislocated);
|
||||||
let _ = Pallet::<T, I>::do_rebag(&dislocated, current_score)
|
let _ = Pallet::<T, I>::do_rebag(&dislocated, current_score)
|
||||||
.map_err::<Error<T, I>, _>(Into::into)?;
|
.map_err::<Error<T, I>, _>(Into::into)?;
|
||||||
@@ -239,8 +242,12 @@ pub mod pallet {
|
|||||||
/// - both nodes are within the same bag,
|
/// - both nodes are within the same bag,
|
||||||
/// - and `origin` has a greater `Score` than `lighter`.
|
/// - and `origin` has a greater `Score` than `lighter`.
|
||||||
#[pallet::weight(T::WeightInfo::put_in_front_of())]
|
#[pallet::weight(T::WeightInfo::put_in_front_of())]
|
||||||
pub fn put_in_front_of(origin: OriginFor<T>, lighter: T::AccountId) -> DispatchResult {
|
pub fn put_in_front_of(
|
||||||
|
origin: OriginFor<T>,
|
||||||
|
lighter: AccountIdLookupOf<T>,
|
||||||
|
) -> DispatchResult {
|
||||||
let heavier = ensure_signed(origin)?;
|
let heavier = ensure_signed(origin)?;
|
||||||
|
let lighter = T::Lookup::lookup(lighter)?;
|
||||||
List::<T, I>::put_in_front_of(&lighter, &heavier)
|
List::<T, I>::put_in_front_of(&lighter, &heavier)
|
||||||
.map_err::<Error<T, I>, _>(Into::into)
|
.map_err::<Error<T, I>, _>(Into::into)
|
||||||
.map_err::<DispatchError, _>(Into::into)
|
.map_err::<DispatchError, _>(Into::into)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ benchmarks_instance_pallet! {
|
|||||||
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
|
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
|
||||||
// and reap this user.
|
// and reap this user.
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
||||||
}: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount)
|
}: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount)
|
||||||
verify {
|
verify {
|
||||||
@@ -60,7 +60,7 @@ benchmarks_instance_pallet! {
|
|||||||
transfer_best_case {
|
transfer_best_case {
|
||||||
let caller = whitelisted_caller();
|
let caller = whitelisted_caller();
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
|
|
||||||
// Give the sender account max funds for transfer (their account will never reasonably be killed).
|
// Give the sender account max funds for transfer (their account will never reasonably be killed).
|
||||||
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
|
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
|
||||||
@@ -80,7 +80,7 @@ benchmarks_instance_pallet! {
|
|||||||
transfer_keep_alive {
|
transfer_keep_alive {
|
||||||
let caller = whitelisted_caller();
|
let caller = whitelisted_caller();
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
|
|
||||||
// Give the sender account max funds, thus a transfer will not kill account.
|
// Give the sender account max funds, thus a transfer will not kill account.
|
||||||
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
|
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
|
||||||
@@ -95,7 +95,7 @@ benchmarks_instance_pallet! {
|
|||||||
// Benchmark `set_balance` coming from ROOT account. This always creates an account.
|
// Benchmark `set_balance` coming from ROOT account. This always creates an account.
|
||||||
set_balance_creating {
|
set_balance_creating {
|
||||||
let user: T::AccountId = account("user", 0, SEED);
|
let user: T::AccountId = account("user", 0, SEED);
|
||||||
let user_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(user.clone());
|
let user_lookup = T::Lookup::unlookup(user.clone());
|
||||||
|
|
||||||
// Give the user some initial balance.
|
// Give the user some initial balance.
|
||||||
let existential_deposit = T::ExistentialDeposit::get();
|
let existential_deposit = T::ExistentialDeposit::get();
|
||||||
@@ -110,7 +110,7 @@ benchmarks_instance_pallet! {
|
|||||||
// Benchmark `set_balance` coming from ROOT account. This always kills an account.
|
// Benchmark `set_balance` coming from ROOT account. This always kills an account.
|
||||||
set_balance_killing {
|
set_balance_killing {
|
||||||
let user: T::AccountId = account("user", 0, SEED);
|
let user: T::AccountId = account("user", 0, SEED);
|
||||||
let user_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(user.clone());
|
let user_lookup = T::Lookup::unlookup(user.clone());
|
||||||
|
|
||||||
// Give the user some initial balance.
|
// Give the user some initial balance.
|
||||||
let existential_deposit = T::ExistentialDeposit::get();
|
let existential_deposit = T::ExistentialDeposit::get();
|
||||||
@@ -127,7 +127,7 @@ benchmarks_instance_pallet! {
|
|||||||
force_transfer {
|
force_transfer {
|
||||||
let existential_deposit = T::ExistentialDeposit::get();
|
let existential_deposit = T::ExistentialDeposit::get();
|
||||||
let source: T::AccountId = account("source", 0, SEED);
|
let source: T::AccountId = account("source", 0, SEED);
|
||||||
let source_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(source.clone());
|
let source_lookup = T::Lookup::unlookup(source.clone());
|
||||||
|
|
||||||
// Give some multiple of the existential deposit
|
// Give some multiple of the existential deposit
|
||||||
let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into());
|
let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into());
|
||||||
@@ -135,7 +135,7 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user.
|
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user.
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
||||||
}: force_transfer(RawOrigin::Root, source_lookup, recipient_lookup, transfer_amount)
|
}: force_transfer(RawOrigin::Root, source_lookup, recipient_lookup, transfer_amount)
|
||||||
verify {
|
verify {
|
||||||
@@ -160,7 +160,7 @@ benchmarks_instance_pallet! {
|
|||||||
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
|
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
|
||||||
// and reap this user.
|
// and reap this user.
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
||||||
|
|
||||||
// Create a bunch of users in storage.
|
// Create a bunch of users in storage.
|
||||||
@@ -182,7 +182,7 @@ benchmarks_instance_pallet! {
|
|||||||
transfer_all {
|
transfer_all {
|
||||||
let caller = whitelisted_caller();
|
let caller = whitelisted_caller();
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
|
|
||||||
// Give some multiple of the existential deposit
|
// Give some multiple of the existential deposit
|
||||||
let existential_deposit = T::ExistentialDeposit::get();
|
let existential_deposit = T::ExistentialDeposit::get();
|
||||||
@@ -196,7 +196,7 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
force_unreserve {
|
force_unreserve {
|
||||||
let user: T::AccountId = account("user", 0, SEED);
|
let user: T::AccountId = account("user", 0, SEED);
|
||||||
let user_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(user.clone());
|
let user_lookup = T::Lookup::unlookup(user.clone());
|
||||||
|
|
||||||
// Give some multiple of the existential deposit
|
// Give some multiple of the existential deposit
|
||||||
let existential_deposit = T::ExistentialDeposit::get();
|
let existential_deposit = T::ExistentialDeposit::get();
|
||||||
|
|||||||
@@ -192,6 +192,8 @@ pub use weights::WeightInfo;
|
|||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -275,7 +277,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::transfer())]
|
#[pallet::weight(T::WeightInfo::transfer())]
|
||||||
pub fn transfer(
|
pub fn transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] value: T::Balance,
|
#[pallet::compact] value: T::Balance,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let transactor = ensure_signed(origin)?;
|
let transactor = ensure_signed(origin)?;
|
||||||
@@ -303,7 +305,7 @@ pub mod pallet {
|
|||||||
)]
|
)]
|
||||||
pub fn set_balance(
|
pub fn set_balance(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
who: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] new_free: T::Balance,
|
#[pallet::compact] new_free: T::Balance,
|
||||||
#[pallet::compact] new_reserved: T::Balance,
|
#[pallet::compact] new_reserved: T::Balance,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
@@ -353,8 +355,8 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::force_transfer())]
|
#[pallet::weight(T::WeightInfo::force_transfer())]
|
||||||
pub fn force_transfer(
|
pub fn force_transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
source: <T::Lookup as StaticLookup>::Source,
|
source: AccountIdLookupOf<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] value: T::Balance,
|
#[pallet::compact] value: T::Balance,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
@@ -378,7 +380,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::transfer_keep_alive())]
|
#[pallet::weight(T::WeightInfo::transfer_keep_alive())]
|
||||||
pub fn transfer_keep_alive(
|
pub fn transfer_keep_alive(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] value: T::Balance,
|
#[pallet::compact] value: T::Balance,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let transactor = ensure_signed(origin)?;
|
let transactor = ensure_signed(origin)?;
|
||||||
@@ -407,7 +409,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::transfer_all())]
|
#[pallet::weight(T::WeightInfo::transfer_all())]
|
||||||
pub fn transfer_all(
|
pub fn transfer_all(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
keep_alive: bool,
|
keep_alive: bool,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
use fungible::Inspect;
|
use fungible::Inspect;
|
||||||
@@ -425,7 +427,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::force_unreserve())]
|
#[pallet::weight(T::WeightInfo::force_unreserve())]
|
||||||
pub fn force_unreserve(
|
pub fn force_unreserve(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
who: AccountIdLookupOf<T>,
|
||||||
amount: T::Balance,
|
amount: T::Balance,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ fn setup_bounty<T: Config<I>, I: 'static>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_bounty<T: Config<I>, I: 'static>(
|
fn create_bounty<T: Config<I>, I: 'static>(
|
||||||
) -> Result<(<T::Lookup as StaticLookup>::Source, BountyIndex), &'static str> {
|
) -> Result<(AccountIdLookupOf<T>, BountyIndex), &'static str> {
|
||||||
let (caller, curator, fee, value, reason) =
|
let (caller, curator, fee, value, reason) =
|
||||||
setup_bounty::<T, I>(0, T::MaximumReasonLength::get());
|
setup_bounty::<T, I>(0, T::MaximumReasonLength::get());
|
||||||
let curator_lookup = T::Lookup::unlookup(curator.clone());
|
let curator_lookup = T::Lookup::unlookup(curator.clone());
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ type PositiveImbalanceOf<T, I = ()> = pallet_treasury::PositiveImbalanceOf<T, I>
|
|||||||
/// An index of a bounty. Just a `u32`.
|
/// An index of a bounty. Just a `u32`.
|
||||||
pub type BountyIndex = u32;
|
pub type BountyIndex = u32;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// A bounty proposal.
|
/// A bounty proposal.
|
||||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||||
pub struct Bounty<AccountId, Balance, BlockNumber> {
|
pub struct Bounty<AccountId, Balance, BlockNumber> {
|
||||||
@@ -381,7 +383,7 @@ pub mod pallet {
|
|||||||
pub fn propose_curator(
|
pub fn propose_curator(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] bounty_id: BountyIndex,
|
#[pallet::compact] bounty_id: BountyIndex,
|
||||||
curator: <T::Lookup as StaticLookup>::Source,
|
curator: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] fee: BalanceOf<T, I>,
|
#[pallet::compact] fee: BalanceOf<T, I>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::ApproveOrigin::ensure_origin(origin)?;
|
T::ApproveOrigin::ensure_origin(origin)?;
|
||||||
@@ -553,7 +555,7 @@ pub mod pallet {
|
|||||||
pub fn award_bounty(
|
pub fn award_bounty(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] bounty_id: BountyIndex,
|
#[pallet::compact] bounty_id: BountyIndex,
|
||||||
beneficiary: <T::Lookup as StaticLookup>::Source,
|
beneficiary: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let signer = ensure_signed(origin)?;
|
let signer = ensure_signed(origin)?;
|
||||||
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ pub use pallet::*;
|
|||||||
type BalanceOf<T> = pallet_treasury::BalanceOf<T>;
|
type BalanceOf<T> = pallet_treasury::BalanceOf<T>;
|
||||||
type BountiesError<T> = pallet_bounties::Error<T>;
|
type BountiesError<T> = pallet_bounties::Error<T>;
|
||||||
type BountyIndex = pallet_bounties::BountyIndex;
|
type BountyIndex = pallet_bounties::BountyIndex;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// A child bounty proposal.
|
/// A child bounty proposal.
|
||||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||||
@@ -315,7 +316,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] parent_bounty_id: BountyIndex,
|
#[pallet::compact] parent_bounty_id: BountyIndex,
|
||||||
#[pallet::compact] child_bounty_id: BountyIndex,
|
#[pallet::compact] child_bounty_id: BountyIndex,
|
||||||
curator: <T::Lookup as StaticLookup>::Source,
|
curator: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] fee: BalanceOf<T>,
|
#[pallet::compact] fee: BalanceOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let signer = ensure_signed(origin)?;
|
let signer = ensure_signed(origin)?;
|
||||||
@@ -574,7 +575,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] parent_bounty_id: BountyIndex,
|
#[pallet::compact] parent_bounty_id: BountyIndex,
|
||||||
#[pallet::compact] child_bounty_id: BountyIndex,
|
#[pallet::compact] child_bounty_id: BountyIndex,
|
||||||
beneficiary: <T::Lookup as StaticLookup>::Source,
|
beneficiary: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let signer = ensure_signed(origin)?;
|
let signer = ensure_signed(origin)?;
|
||||||
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ const INSTR_BENCHMARK_BATCHES: u32 = 50;
|
|||||||
struct Contract<T: Config> {
|
struct Contract<T: Config> {
|
||||||
caller: T::AccountId,
|
caller: T::AccountId,
|
||||||
account_id: T::AccountId,
|
account_id: T::AccountId,
|
||||||
addr: <T::Lookup as StaticLookup>::Source,
|
addr: AccountIdLookupOf<T>,
|
||||||
value: BalanceOf<T>,
|
value: BalanceOf<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ type BalanceOf<T> =
|
|||||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
type CodeVec<T> = BoundedVec<u8, <T as Config>::MaxCodeLen>;
|
type CodeVec<T> = BoundedVec<u8, <T as Config>::MaxCodeLen>;
|
||||||
type RelaxedCodeVec<T> = BoundedVec<u8, <T as Config>::RelaxedMaxCodeLen>;
|
type RelaxedCodeVec<T> = BoundedVec<u8, <T as Config>::RelaxedMaxCodeLen>;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// Used as a sentinel value when reading and writing contract memory.
|
/// Used as a sentinel value when reading and writing contract memory.
|
||||||
///
|
///
|
||||||
@@ -435,7 +436,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::call().saturating_add(*gas_limit))]
|
#[pallet::weight(T::WeightInfo::call().saturating_add(*gas_limit))]
|
||||||
pub fn call(
|
pub fn call(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] value: BalanceOf<T>,
|
#[pallet::compact] value: BalanceOf<T>,
|
||||||
#[pallet::compact] gas_limit: Weight,
|
#[pallet::compact] gas_limit: Weight,
|
||||||
storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>,
|
storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>,
|
||||||
@@ -617,7 +618,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::set_code())]
|
#[pallet::weight(T::WeightInfo::set_code())]
|
||||||
pub fn set_code(
|
pub fn set_code(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
code_hash: CodeHash<T>,
|
code_hash: CodeHash<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ benchmarks_instance_pallet! {
|
|||||||
remove_other_vote {
|
remove_other_vote {
|
||||||
let caller = funded_account::<T, I>("caller", 0);
|
let caller = funded_account::<T, I>("caller", 0);
|
||||||
let voter = funded_account::<T, I>("caller", 0);
|
let voter = funded_account::<T, I>("caller", 0);
|
||||||
|
let voter_lookup = T::Lookup::unlookup(voter.clone());
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
let old_account_vote = account_vote::<T, I>(100u32.into());
|
let old_account_vote = account_vote::<T, I>(100u32.into());
|
||||||
|
|
||||||
@@ -167,7 +168,7 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
let index = polls[0];
|
let index = polls[0];
|
||||||
assert!(T::Polls::end_ongoing(index, false).is_ok());
|
assert!(T::Polls::end_ongoing(index, false).is_ok());
|
||||||
}: _(RawOrigin::Signed(caller.clone()), voter.clone(), class.clone(), index)
|
}: _(RawOrigin::Signed(caller.clone()), voter_lookup, class.clone(), index)
|
||||||
verify {
|
verify {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
VotingFor::<T, I>::get(&voter, &class),
|
VotingFor::<T, I>::get(&voter, &class),
|
||||||
@@ -182,6 +183,7 @@ benchmarks_instance_pallet! {
|
|||||||
let class = T::Polls::max_ongoing().0;
|
let class = T::Polls::max_ongoing().0;
|
||||||
let polls = &all_polls[&class];
|
let polls = &all_polls[&class];
|
||||||
let voter = funded_account::<T, I>("voter", 0);
|
let voter = funded_account::<T, I>("voter", 0);
|
||||||
|
let voter_lookup = T::Lookup::unlookup(voter.clone());
|
||||||
let caller = funded_account::<T, I>("caller", 0);
|
let caller = funded_account::<T, I>("caller", 0);
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
|
|
||||||
@@ -197,7 +199,7 @@ benchmarks_instance_pallet! {
|
|||||||
Voting::Casting(Casting { votes, .. }) if votes.len() == r as usize
|
Voting::Casting(Casting { votes, .. }) if votes.len() == r as usize
|
||||||
);
|
);
|
||||||
|
|
||||||
}: _(RawOrigin::Signed(caller.clone()), class.clone(), voter, Conviction::Locked1x, delegated_balance)
|
}: _(RawOrigin::Signed(caller.clone()), class.clone(), voter_lookup, Conviction::Locked1x, delegated_balance)
|
||||||
verify {
|
verify {
|
||||||
assert_matches!(VotingFor::<T, I>::get(&caller, &class), Voting::Delegating(_));
|
assert_matches!(VotingFor::<T, I>::get(&caller, &class), Voting::Delegating(_));
|
||||||
}
|
}
|
||||||
@@ -209,6 +211,7 @@ benchmarks_instance_pallet! {
|
|||||||
let class = T::Polls::max_ongoing().0;
|
let class = T::Polls::max_ongoing().0;
|
||||||
let polls = &all_polls[&class];
|
let polls = &all_polls[&class];
|
||||||
let voter = funded_account::<T, I>("voter", 0);
|
let voter = funded_account::<T, I>("voter", 0);
|
||||||
|
let voter_lookup = T::Lookup::unlookup(voter.clone());
|
||||||
let caller = funded_account::<T, I>("caller", 0);
|
let caller = funded_account::<T, I>("caller", 0);
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
|
|
||||||
@@ -218,7 +221,7 @@ benchmarks_instance_pallet! {
|
|||||||
ConvictionVoting::<T, I>::delegate(
|
ConvictionVoting::<T, I>::delegate(
|
||||||
RawOrigin::Signed(caller.clone()).into(),
|
RawOrigin::Signed(caller.clone()).into(),
|
||||||
class.clone(),
|
class.clone(),
|
||||||
voter.clone(),
|
voter_lookup,
|
||||||
Conviction::Locked1x,
|
Conviction::Locked1x,
|
||||||
delegated_balance,
|
delegated_balance,
|
||||||
)?;
|
)?;
|
||||||
@@ -239,6 +242,7 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
unlock {
|
unlock {
|
||||||
let caller = funded_account::<T, I>("caller", 0);
|
let caller = funded_account::<T, I>("caller", 0);
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
let normal_account_vote = account_vote::<T, I>(T::Currency::free_balance(&caller) - 100u32.into());
|
let normal_account_vote = account_vote::<T, I>(T::Currency::free_balance(&caller) - 100u32.into());
|
||||||
let big_account_vote = account_vote::<T, I>(T::Currency::free_balance(&caller));
|
let big_account_vote = account_vote::<T, I>(T::Currency::free_balance(&caller));
|
||||||
@@ -266,7 +270,7 @@ benchmarks_instance_pallet! {
|
|||||||
ConvictionVoting::<T, I>::remove_vote(RawOrigin::Signed(caller.clone()).into(), Some(class.clone()), polls[0])?;
|
ConvictionVoting::<T, I>::remove_vote(RawOrigin::Signed(caller.clone()).into(), Some(class.clone()), polls[0])?;
|
||||||
|
|
||||||
// We can now unlock on `class` from 200 to 100...
|
// We can now unlock on `class` from 200 to 100...
|
||||||
}: _(RawOrigin::Signed(caller.clone()), class, caller.clone())
|
}: _(RawOrigin::Signed(caller.clone()), class, caller_lookup)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(orig_usable, <T::Currency as fungible::Inspect<T::AccountId>>::reducible_balance(&caller, false));
|
assert_eq!(orig_usable, <T::Currency as fungible::Inspect<T::AccountId>>::reducible_balance(&caller, false));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ use frame_support::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{AtLeast32BitUnsigned, Saturating, Zero},
|
traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero},
|
||||||
ArithmeticError, Perbill,
|
ArithmeticError, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -62,6 +62,7 @@ pub mod benchmarking;
|
|||||||
|
|
||||||
const CONVICTION_VOTING_ID: LockIdentifier = *b"pyconvot";
|
const CONVICTION_VOTING_ID: LockIdentifier = *b"pyconvot";
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
type BalanceOf<T, I = ()> =
|
type BalanceOf<T, I = ()> =
|
||||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
type VotingOf<T, I = ()> = Voting<
|
type VotingOf<T, I = ()> = Voting<
|
||||||
@@ -245,11 +246,12 @@ pub mod pallet {
|
|||||||
pub fn delegate(
|
pub fn delegate(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
class: ClassOf<T, I>,
|
class: ClassOf<T, I>,
|
||||||
to: T::AccountId,
|
to: AccountIdLookupOf<T>,
|
||||||
conviction: Conviction,
|
conviction: Conviction,
|
||||||
balance: BalanceOf<T, I>,
|
balance: BalanceOf<T, I>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let to = T::Lookup::lookup(to)?;
|
||||||
let votes = Self::try_delegate(who, class, to, conviction, balance)?;
|
let votes = Self::try_delegate(who, class, to, conviction, balance)?;
|
||||||
|
|
||||||
Ok(Some(T::WeightInfo::delegate(votes)).into())
|
Ok(Some(T::WeightInfo::delegate(votes)).into())
|
||||||
@@ -294,9 +296,10 @@ pub mod pallet {
|
|||||||
pub fn unlock(
|
pub fn unlock(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
class: ClassOf<T, I>,
|
class: ClassOf<T, I>,
|
||||||
target: T::AccountId,
|
target: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_signed(origin)?;
|
ensure_signed(origin)?;
|
||||||
|
let target = T::Lookup::lookup(target)?;
|
||||||
Self::update_lock(&class, &target);
|
Self::update_lock(&class, &target);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -359,11 +362,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::remove_other_vote())]
|
#[pallet::weight(T::WeightInfo::remove_other_vote())]
|
||||||
pub fn remove_other_vote(
|
pub fn remove_other_vote(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
target: T::AccountId,
|
target: AccountIdLookupOf<T>,
|
||||||
class: ClassOf<T, I>,
|
class: ClassOf<T, I>,
|
||||||
index: PollIndexOf<T, I>,
|
index: PollIndexOf<T, I>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let target = T::Lookup::lookup(target)?;
|
||||||
let scope = if target == who { UnvoteScope::Any } else { UnvoteScope::OnlyExpired };
|
let scope = if target == who { UnvoteScope::Any } else { UnvoteScope::OnlyExpired };
|
||||||
Self::try_remove_vote(&target, index, Some(class), scope)?;
|
Self::try_remove_vote(&target, index, Some(class), scope)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -483,9 +483,10 @@ benchmarks! {
|
|||||||
let caller = funded_account::<T>("caller", 0);
|
let caller = funded_account::<T>("caller", 0);
|
||||||
// Caller will initially delegate to `old_delegate`
|
// Caller will initially delegate to `old_delegate`
|
||||||
let old_delegate: T::AccountId = funded_account::<T>("old_delegate", r);
|
let old_delegate: T::AccountId = funded_account::<T>("old_delegate", r);
|
||||||
|
let old_delegate_lookup = T::Lookup::unlookup(old_delegate.clone());
|
||||||
Democracy::<T>::delegate(
|
Democracy::<T>::delegate(
|
||||||
RawOrigin::Signed(caller.clone()).into(),
|
RawOrigin::Signed(caller.clone()).into(),
|
||||||
old_delegate.clone(),
|
old_delegate_lookup,
|
||||||
Conviction::Locked1x,
|
Conviction::Locked1x,
|
||||||
delegated_balance,
|
delegated_balance,
|
||||||
)?;
|
)?;
|
||||||
@@ -497,6 +498,7 @@ benchmarks! {
|
|||||||
assert_eq!(balance, delegated_balance, "delegation balance didn't work");
|
assert_eq!(balance, delegated_balance, "delegation balance didn't work");
|
||||||
// Caller will now switch to `new_delegate`
|
// Caller will now switch to `new_delegate`
|
||||||
let new_delegate: T::AccountId = funded_account::<T>("new_delegate", r);
|
let new_delegate: T::AccountId = funded_account::<T>("new_delegate", r);
|
||||||
|
let new_delegate_lookup = T::Lookup::unlookup(new_delegate.clone());
|
||||||
let account_vote = account_vote::<T>(initial_balance);
|
let account_vote = account_vote::<T>(initial_balance);
|
||||||
// We need to create existing direct votes for the `new_delegate`
|
// We need to create existing direct votes for the `new_delegate`
|
||||||
for i in 0..r {
|
for i in 0..r {
|
||||||
@@ -509,7 +511,7 @@ benchmarks! {
|
|||||||
};
|
};
|
||||||
assert_eq!(votes.len(), r as usize, "Votes were not recorded.");
|
assert_eq!(votes.len(), r as usize, "Votes were not recorded.");
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
}: _(RawOrigin::Signed(caller.clone()), new_delegate.clone(), Conviction::Locked1x, delegated_balance)
|
}: _(RawOrigin::Signed(caller.clone()), new_delegate_lookup, Conviction::Locked1x, delegated_balance)
|
||||||
verify {
|
verify {
|
||||||
let (target, balance) = match VotingOf::<T>::get(&caller) {
|
let (target, balance) = match VotingOf::<T>::get(&caller) {
|
||||||
Voting::Delegating { target, balance, .. } => (target, balance),
|
Voting::Delegating { target, balance, .. } => (target, balance),
|
||||||
@@ -533,9 +535,10 @@ benchmarks! {
|
|||||||
let caller = funded_account::<T>("caller", 0);
|
let caller = funded_account::<T>("caller", 0);
|
||||||
// Caller will delegate
|
// Caller will delegate
|
||||||
let the_delegate: T::AccountId = funded_account::<T>("delegate", r);
|
let the_delegate: T::AccountId = funded_account::<T>("delegate", r);
|
||||||
|
let the_delegate_lookup = T::Lookup::unlookup(the_delegate.clone());
|
||||||
Democracy::<T>::delegate(
|
Democracy::<T>::delegate(
|
||||||
RawOrigin::Signed(caller.clone()).into(),
|
RawOrigin::Signed(caller.clone()).into(),
|
||||||
the_delegate.clone(),
|
the_delegate_lookup,
|
||||||
Conviction::Locked1x,
|
Conviction::Locked1x,
|
||||||
delegated_balance,
|
delegated_balance,
|
||||||
)?;
|
)?;
|
||||||
@@ -642,6 +645,7 @@ benchmarks! {
|
|||||||
let r in 1 .. MAX_REFERENDUMS;
|
let r in 1 .. MAX_REFERENDUMS;
|
||||||
|
|
||||||
let locker = funded_account::<T>("locker", 0);
|
let locker = funded_account::<T>("locker", 0);
|
||||||
|
let locker_lookup = T::Lookup::unlookup(locker.clone());
|
||||||
// Populate votes so things are locked
|
// Populate votes so things are locked
|
||||||
let base_balance: BalanceOf<T> = 100u32.into();
|
let base_balance: BalanceOf<T> = 100u32.into();
|
||||||
let small_vote = account_vote::<T>(base_balance);
|
let small_vote = account_vote::<T>(base_balance);
|
||||||
@@ -654,7 +658,7 @@ benchmarks! {
|
|||||||
|
|
||||||
let caller = funded_account::<T>("caller", 0);
|
let caller = funded_account::<T>("caller", 0);
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
}: unlock(RawOrigin::Signed(caller), locker.clone())
|
}: unlock(RawOrigin::Signed(caller), locker_lookup)
|
||||||
verify {
|
verify {
|
||||||
// Note that we may want to add a `get_lock` api to actually verify
|
// Note that we may want to add a `get_lock` api to actually verify
|
||||||
let voting = VotingOf::<T>::get(&locker);
|
let voting = VotingOf::<T>::get(&locker);
|
||||||
@@ -666,6 +670,7 @@ benchmarks! {
|
|||||||
let r in 1 .. MAX_REFERENDUMS;
|
let r in 1 .. MAX_REFERENDUMS;
|
||||||
|
|
||||||
let locker = funded_account::<T>("locker", 0);
|
let locker = funded_account::<T>("locker", 0);
|
||||||
|
let locker_lookup = T::Lookup::unlookup(locker.clone());
|
||||||
// Populate votes so things are locked
|
// Populate votes so things are locked
|
||||||
let base_balance: BalanceOf<T> = 100u32.into();
|
let base_balance: BalanceOf<T> = 100u32.into();
|
||||||
let small_vote = account_vote::<T>(base_balance);
|
let small_vote = account_vote::<T>(base_balance);
|
||||||
@@ -692,7 +697,7 @@ benchmarks! {
|
|||||||
|
|
||||||
let caller = funded_account::<T>("caller", 0);
|
let caller = funded_account::<T>("caller", 0);
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
}: unlock(RawOrigin::Signed(caller), locker.clone())
|
}: unlock(RawOrigin::Signed(caller), locker_lookup)
|
||||||
verify {
|
verify {
|
||||||
let votes = match VotingOf::<T>::get(&locker) {
|
let votes = match VotingOf::<T>::get(&locker) {
|
||||||
Voting::Direct { votes, .. } => votes,
|
Voting::Direct { votes, .. } => votes,
|
||||||
@@ -738,6 +743,7 @@ benchmarks! {
|
|||||||
let r in 1 .. MAX_REFERENDUMS;
|
let r in 1 .. MAX_REFERENDUMS;
|
||||||
|
|
||||||
let caller = funded_account::<T>("caller", r);
|
let caller = funded_account::<T>("caller", r);
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
let account_vote = account_vote::<T>(100u32.into());
|
let account_vote = account_vote::<T>(100u32.into());
|
||||||
|
|
||||||
for i in 0 .. r {
|
for i in 0 .. r {
|
||||||
@@ -753,7 +759,7 @@ benchmarks! {
|
|||||||
|
|
||||||
let referendum_index = r - 1;
|
let referendum_index = r - 1;
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
}: _(RawOrigin::Signed(caller.clone()), caller.clone(), referendum_index)
|
}: _(RawOrigin::Signed(caller.clone()), caller_lookup, referendum_index)
|
||||||
verify {
|
verify {
|
||||||
let votes = match VotingOf::<T>::get(&caller) {
|
let votes = match VotingOf::<T>::get(&caller) {
|
||||||
Voting::Direct { votes, .. } => votes,
|
Voting::Direct { votes, .. } => votes,
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ use frame_support::{
|
|||||||
};
|
};
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{Bounded, Dispatchable, Hash, Saturating, Zero},
|
traits::{Bounded, Dispatchable, Hash, Saturating, StaticLookup, Zero},
|
||||||
ArithmeticError, DispatchError, DispatchResult, RuntimeDebug,
|
ArithmeticError, DispatchError, DispatchResult, RuntimeDebug,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -206,6 +206,7 @@ type BalanceOf<T> =
|
|||||||
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
|
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
|
||||||
<T as frame_system::Config>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
>>::NegativeImbalance;
|
>>::NegativeImbalance;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
|
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||||
pub enum PreimageStatus<AccountId, Balance, BlockNumber> {
|
pub enum PreimageStatus<AccountId, Balance, BlockNumber> {
|
||||||
@@ -944,11 +945,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::delegate(T::MaxVotes::get()))]
|
#[pallet::weight(T::WeightInfo::delegate(T::MaxVotes::get()))]
|
||||||
pub fn delegate(
|
pub fn delegate(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
to: T::AccountId,
|
to: AccountIdLookupOf<T>,
|
||||||
conviction: Conviction,
|
conviction: Conviction,
|
||||||
balance: BalanceOf<T>,
|
balance: BalanceOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let to = T::Lookup::lookup(to)?;
|
||||||
let votes = Self::try_delegate(who, to, conviction, balance)?;
|
let votes = Self::try_delegate(who, to, conviction, balance)?;
|
||||||
|
|
||||||
Ok(Some(T::WeightInfo::delegate(votes)).into())
|
Ok(Some(T::WeightInfo::delegate(votes)).into())
|
||||||
@@ -1127,8 +1129,9 @@ pub mod pallet {
|
|||||||
T::WeightInfo::unlock_set(T::MaxVotes::get())
|
T::WeightInfo::unlock_set(T::MaxVotes::get())
|
||||||
.max(T::WeightInfo::unlock_remove(T::MaxVotes::get()))
|
.max(T::WeightInfo::unlock_remove(T::MaxVotes::get()))
|
||||||
)]
|
)]
|
||||||
pub fn unlock(origin: OriginFor<T>, target: T::AccountId) -> DispatchResult {
|
pub fn unlock(origin: OriginFor<T>, target: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
ensure_signed(origin)?;
|
ensure_signed(origin)?;
|
||||||
|
let target = T::Lookup::lookup(target)?;
|
||||||
Self::update_lock(&target);
|
Self::update_lock(&target);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1184,10 +1187,11 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::remove_other_vote(T::MaxVotes::get()))]
|
#[pallet::weight(T::WeightInfo::remove_other_vote(T::MaxVotes::get()))]
|
||||||
pub fn remove_other_vote(
|
pub fn remove_other_vote(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
target: T::AccountId,
|
target: AccountIdLookupOf<T>,
|
||||||
index: ReferendumIndex,
|
index: ReferendumIndex,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let target = T::Lookup::lookup(target)?;
|
||||||
let scope = if target == who { UnvoteScope::Any } else { UnvoteScope::OnlyExpired };
|
let scope = if target == who { UnvoteScope::Any } else { UnvoteScope::OnlyExpired };
|
||||||
Self::try_remove_vote(&target, index, scope)?;
|
Self::try_remove_vote(&target, index, scope)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ use crate::Pallet as Elections;
|
|||||||
|
|
||||||
const BALANCE_FACTOR: u32 = 250;
|
const BALANCE_FACTOR: u32 = 250;
|
||||||
|
|
||||||
type Lookup<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
|
||||||
|
|
||||||
/// grab new account with infinite balance.
|
/// grab new account with infinite balance.
|
||||||
fn endowed_account<T: Config>(name: &'static str, index: u32) -> T::AccountId {
|
fn endowed_account<T: Config>(name: &'static str, index: u32) -> T::AccountId {
|
||||||
let account: T::AccountId = account(name, index, 0);
|
let account: T::AccountId = account(name, index, 0);
|
||||||
@@ -46,7 +44,7 @@ fn endowed_account<T: Config>(name: &'static str, index: u32) -> T::AccountId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Account to lookup type of system trait.
|
/// Account to lookup type of system trait.
|
||||||
fn as_lookup<T: Config>(account: T::AccountId) -> Lookup<T> {
|
fn as_lookup<T: Config>(account: T::AccountId) -> AccountIdLookupOf<T> {
|
||||||
T::Lookup::unlookup(account)
|
T::Lookup::unlookup(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,8 @@ pub struct SeatHolder<AccountId, Balance> {
|
|||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -508,7 +510,7 @@ pub mod pallet {
|
|||||||
})]
|
})]
|
||||||
pub fn remove_member(
|
pub fn remove_member(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
who: AccountIdLookupOf<T>,
|
||||||
slash_bond: bool,
|
slash_bond: bool,
|
||||||
rerun_election: bool,
|
rerun_election: bool,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
|
|||||||
@@ -40,9 +40,10 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
|
|||||||
fn add_registrars<T: Config>(r: u32) -> Result<(), &'static str> {
|
fn add_registrars<T: Config>(r: u32) -> Result<(), &'static str> {
|
||||||
for i in 0..r {
|
for i in 0..r {
|
||||||
let registrar: T::AccountId = account("registrar", i, SEED);
|
let registrar: T::AccountId = account("registrar", i, SEED);
|
||||||
|
let registrar_lookup = T::Lookup::unlookup(registrar.clone());
|
||||||
let _ = T::Currency::make_free_balance_be(®istrar, BalanceOf::<T>::max_value());
|
let _ = T::Currency::make_free_balance_be(®istrar, BalanceOf::<T>::max_value());
|
||||||
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
||||||
Identity::<T>::add_registrar(registrar_origin, registrar.clone())?;
|
Identity::<T>::add_registrar(registrar_origin, registrar_lookup)?;
|
||||||
Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), i, 10u32.into())?;
|
Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), i, 10u32.into())?;
|
||||||
let fields =
|
let fields =
|
||||||
IdentityFields(
|
IdentityFields(
|
||||||
@@ -130,7 +131,7 @@ benchmarks! {
|
|||||||
let caller = {
|
let caller = {
|
||||||
// The target user
|
// The target user
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let caller_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(caller.clone());
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
let caller_origin: <T as frame_system::Config>::Origin = RawOrigin::Signed(caller.clone()).into();
|
let caller_origin: <T as frame_system::Config>::Origin = RawOrigin::Signed(caller.clone()).into();
|
||||||
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
@@ -261,11 +262,12 @@ benchmarks! {
|
|||||||
|
|
||||||
set_fee {
|
set_fee {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
|
|
||||||
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
||||||
|
|
||||||
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
||||||
Identity::<T>::add_registrar(registrar_origin, caller.clone())?;
|
Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
|
||||||
let registrars = Registrars::<T>::get();
|
let registrars = Registrars::<T>::get();
|
||||||
ensure!(registrars[r as usize].as_ref().unwrap().fee == 0u32.into(), "Fee already set.");
|
ensure!(registrars[r as usize].as_ref().unwrap().fee == 0u32.into(), "Fee already set.");
|
||||||
}: _(RawOrigin::Signed(caller), r, 100u32.into())
|
}: _(RawOrigin::Signed(caller), r, 100u32.into())
|
||||||
@@ -276,12 +278,13 @@ benchmarks! {
|
|||||||
|
|
||||||
set_account_id {
|
set_account_id {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
||||||
|
|
||||||
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
||||||
Identity::<T>::add_registrar(registrar_origin, caller.clone())?;
|
Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
|
||||||
let registrars = Registrars::<T>::get();
|
let registrars = Registrars::<T>::get();
|
||||||
ensure!(registrars[r as usize].as_ref().unwrap().account == caller, "id not set.");
|
ensure!(registrars[r as usize].as_ref().unwrap().account == caller, "id not set.");
|
||||||
}: _(RawOrigin::Signed(caller), r, account("new", 0, SEED))
|
}: _(RawOrigin::Signed(caller), r, account("new", 0, SEED))
|
||||||
@@ -292,12 +295,13 @@ benchmarks! {
|
|||||||
|
|
||||||
set_fields {
|
set_fields {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
||||||
|
|
||||||
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
||||||
Identity::<T>::add_registrar(registrar_origin, caller.clone())?;
|
Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
|
||||||
let fields = IdentityFields(
|
let fields = IdentityFields(
|
||||||
IdentityField::Display | IdentityField::Legal | IdentityField::Web | IdentityField::Riot
|
IdentityField::Display | IdentityField::Legal | IdentityField::Web | IdentityField::Riot
|
||||||
| IdentityField::Email | IdentityField::PgpFingerprint | IdentityField::Image | IdentityField::Twitter
|
| IdentityField::Email | IdentityField::PgpFingerprint | IdentityField::Image | IdentityField::Twitter
|
||||||
@@ -318,6 +322,7 @@ benchmarks! {
|
|||||||
let _ = T::Currency::make_free_balance_be(&user, BalanceOf::<T>::max_value());
|
let _ = T::Currency::make_free_balance_be(&user, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
|
||||||
@@ -327,7 +332,7 @@ benchmarks! {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
let registrar_origin = T::RegistrarOrigin::successful_origin();
|
||||||
Identity::<T>::add_registrar(registrar_origin, caller.clone())?;
|
Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
|
||||||
Identity::<T>::request_judgement(user_origin, r, 10u32.into())?;
|
Identity::<T>::request_judgement(user_origin, r, 10u32.into())?;
|
||||||
}: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable)
|
}: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable)
|
||||||
verify {
|
verify {
|
||||||
@@ -341,7 +346,7 @@ benchmarks! {
|
|||||||
|
|
||||||
let target: T::AccountId = account("target", 0, SEED);
|
let target: T::AccountId = account("target", 0, SEED);
|
||||||
let target_origin: <T as frame_system::Config>::Origin = RawOrigin::Signed(target.clone()).into();
|
let target_origin: <T as frame_system::Config>::Origin = RawOrigin::Signed(target.clone()).into();
|
||||||
let target_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(target.clone());
|
let target_lookup = T::Lookup::unlookup(target.clone());
|
||||||
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
|
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let info = create_identity_info::<T>(x);
|
let info = create_identity_info::<T>(x);
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ type BalanceOf<T> =
|
|||||||
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
|
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
|
||||||
<T as frame_system::Config>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
>>::NegativeImbalance;
|
>>::NegativeImbalance;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
@@ -282,9 +283,10 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::add_registrar(T::MaxRegistrars::get()))]
|
#[pallet::weight(T::WeightInfo::add_registrar(T::MaxRegistrars::get()))]
|
||||||
pub fn add_registrar(
|
pub fn add_registrar(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
account: T::AccountId,
|
account: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
T::RegistrarOrigin::ensure_origin(origin)?;
|
T::RegistrarOrigin::ensure_origin(origin)?;
|
||||||
|
let account = T::Lookup::lookup(account)?;
|
||||||
|
|
||||||
let (i, registrar_count) = <Registrars<T>>::try_mutate(
|
let (i, registrar_count) = <Registrars<T>>::try_mutate(
|
||||||
|registrars| -> Result<(RegistrarIndex, usize), DispatchError> {
|
|registrars| -> Result<(RegistrarIndex, usize), DispatchError> {
|
||||||
@@ -672,9 +674,10 @@ pub mod pallet {
|
|||||||
pub fn set_account_id(
|
pub fn set_account_id(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] index: RegistrarIndex,
|
#[pallet::compact] index: RegistrarIndex,
|
||||||
new: T::AccountId,
|
new: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let new = T::Lookup::lookup(new)?;
|
||||||
|
|
||||||
let registrars = <Registrars<T>>::mutate(|rs| -> Result<usize, DispatchError> {
|
let registrars = <Registrars<T>>::mutate(|rs| -> Result<usize, DispatchError> {
|
||||||
rs.get_mut(index as usize)
|
rs.get_mut(index as usize)
|
||||||
@@ -760,7 +763,7 @@ pub mod pallet {
|
|||||||
pub fn provide_judgement(
|
pub fn provide_judgement(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] reg_index: RegistrarIndex,
|
#[pallet::compact] reg_index: RegistrarIndex,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
judgement: Judgement<BalanceOf<T>>,
|
judgement: Judgement<BalanceOf<T>>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let sender = ensure_signed(origin)?;
|
let sender = ensure_signed(origin)?;
|
||||||
@@ -827,7 +830,7 @@ pub mod pallet {
|
|||||||
))]
|
))]
|
||||||
pub fn kill_identity(
|
pub fn kill_identity(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
T::ForceOrigin::ensure_origin(origin)?;
|
T::ForceOrigin::ensure_origin(origin)?;
|
||||||
|
|
||||||
@@ -863,7 +866,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::add_sub(T::MaxSubAccounts::get()))]
|
#[pallet::weight(T::WeightInfo::add_sub(T::MaxSubAccounts::get()))]
|
||||||
pub fn add_sub(
|
pub fn add_sub(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
sub: <T::Lookup as StaticLookup>::Source,
|
sub: AccountIdLookupOf<T>,
|
||||||
data: Data,
|
data: Data,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let sender = ensure_signed(origin)?;
|
let sender = ensure_signed(origin)?;
|
||||||
@@ -898,7 +901,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::rename_sub(T::MaxSubAccounts::get()))]
|
#[pallet::weight(T::WeightInfo::rename_sub(T::MaxSubAccounts::get()))]
|
||||||
pub fn rename_sub(
|
pub fn rename_sub(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
sub: <T::Lookup as StaticLookup>::Source,
|
sub: AccountIdLookupOf<T>,
|
||||||
data: Data,
|
data: Data,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let sender = ensure_signed(origin)?;
|
let sender = ensure_signed(origin)?;
|
||||||
@@ -917,10 +920,7 @@ pub mod pallet {
|
|||||||
/// The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
/// The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||||
/// sub identity of `sub`.
|
/// sub identity of `sub`.
|
||||||
#[pallet::weight(T::WeightInfo::remove_sub(T::MaxSubAccounts::get()))]
|
#[pallet::weight(T::WeightInfo::remove_sub(T::MaxSubAccounts::get()))]
|
||||||
pub fn remove_sub(
|
pub fn remove_sub(origin: OriginFor<T>, sub: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
sub: <T::Lookup as StaticLookup>::Source,
|
|
||||||
) -> DispatchResult {
|
|
||||||
let sender = ensure_signed(origin)?;
|
let sender = ensure_signed(origin)?;
|
||||||
ensure!(IdentityOf::<T>::contains_key(&sender), Error::<T>::NoIdentity);
|
ensure!(IdentityOf::<T>::contains_key(&sender), Error::<T>::NoIdentity);
|
||||||
let sub = T::Lookup::lookup(sub)?;
|
let sub = T::Lookup::lookup(sub)?;
|
||||||
|
|||||||
@@ -44,10 +44,11 @@ benchmarks! {
|
|||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
T::Currency::make_free_balance_be(&recipient, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&recipient, BalanceOf::<T>::max_value());
|
||||||
// Claim the index
|
// Claim the index
|
||||||
Indices::<T>::claim(RawOrigin::Signed(caller.clone()).into(), account_index)?;
|
Indices::<T>::claim(RawOrigin::Signed(caller.clone()).into(), account_index)?;
|
||||||
}: _(RawOrigin::Signed(caller.clone()), recipient.clone(), account_index)
|
}: _(RawOrigin::Signed(caller.clone()), recipient_lookup, account_index)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(Accounts::<T>::get(account_index).unwrap().0, recipient);
|
assert_eq!(Accounts::<T>::get(account_index).unwrap().0, recipient);
|
||||||
}
|
}
|
||||||
@@ -70,10 +71,11 @@ benchmarks! {
|
|||||||
let original: T::AccountId = account("original", 0, SEED);
|
let original: T::AccountId = account("original", 0, SEED);
|
||||||
T::Currency::make_free_balance_be(&original, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&original, BalanceOf::<T>::max_value());
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
|
let recipient_lookup = T::Lookup::unlookup(recipient.clone());
|
||||||
T::Currency::make_free_balance_be(&recipient, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&recipient, BalanceOf::<T>::max_value());
|
||||||
// Claim the index
|
// Claim the index
|
||||||
Indices::<T>::claim(RawOrigin::Signed(original).into(), account_index)?;
|
Indices::<T>::claim(RawOrigin::Signed(original).into(), account_index)?;
|
||||||
}: _(RawOrigin::Root, recipient.clone(), account_index, false)
|
}: _(RawOrigin::Root, recipient_lookup, account_index, false)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(Accounts::<T>::get(account_index).unwrap().0, recipient);
|
assert_eq!(Accounts::<T>::get(account_index).unwrap().0, recipient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ pub use weights::WeightInfo;
|
|||||||
|
|
||||||
type BalanceOf<T> =
|
type BalanceOf<T> =
|
||||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
@@ -133,10 +134,11 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::transfer())]
|
#[pallet::weight(T::WeightInfo::transfer())]
|
||||||
pub fn transfer(
|
pub fn transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
new: T::AccountId,
|
new: AccountIdLookupOf<T>,
|
||||||
index: T::AccountIndex,
|
index: T::AccountIndex,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let new = T::Lookup::lookup(new)?;
|
||||||
ensure!(who != new, Error::<T>::NotTransfer);
|
ensure!(who != new, Error::<T>::NotTransfer);
|
||||||
|
|
||||||
Accounts::<T>::try_mutate(index, |maybe_value| -> DispatchResult {
|
Accounts::<T>::try_mutate(index, |maybe_value| -> DispatchResult {
|
||||||
@@ -208,11 +210,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::force_transfer())]
|
#[pallet::weight(T::WeightInfo::force_transfer())]
|
||||||
pub fn force_transfer(
|
pub fn force_transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
new: T::AccountId,
|
new: AccountIdLookupOf<T>,
|
||||||
index: T::AccountIndex,
|
index: T::AccountIndex,
|
||||||
freeze: bool,
|
freeze: bool,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
|
let new = T::Lookup::lookup(new)?;
|
||||||
|
|
||||||
Accounts::<T>::mutate(index, |maybe_value| {
|
Accounts::<T>::mutate(index, |maybe_value| {
|
||||||
if let Some((account, amount, _)) = maybe_value.take() {
|
if let Some((account, amount, _)) = maybe_value.take() {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
use super::{mock::*, *};
|
use super::{mock::*, *};
|
||||||
use frame_support::{assert_noop, assert_ok};
|
use frame_support::{assert_noop, assert_ok};
|
||||||
use pallet_balances::Error as BalancesError;
|
use pallet_balances::Error as BalancesError;
|
||||||
|
use sp_runtime::MultiAddress::Id;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn claiming_should_work() {
|
fn claiming_should_work() {
|
||||||
@@ -60,7 +61,7 @@ fn freezing_should_work() {
|
|||||||
assert_noop!(Indices::freeze(Some(1).into(), 0), Error::<Test>::Permanent);
|
assert_noop!(Indices::freeze(Some(1).into(), 0), Error::<Test>::Permanent);
|
||||||
|
|
||||||
assert_noop!(Indices::free(Some(1).into(), 0), Error::<Test>::Permanent);
|
assert_noop!(Indices::free(Some(1).into(), 0), Error::<Test>::Permanent);
|
||||||
assert_noop!(Indices::transfer(Some(1).into(), 2, 0), Error::<Test>::Permanent);
|
assert_noop!(Indices::transfer(Some(1).into(), Id(2), 0), Error::<Test>::Permanent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,9 +91,9 @@ fn reclaim_index_on_accounts_should_work() {
|
|||||||
fn transfer_index_on_accounts_should_work() {
|
fn transfer_index_on_accounts_should_work() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_ok!(Indices::claim(Some(1).into(), 0));
|
assert_ok!(Indices::claim(Some(1).into(), 0));
|
||||||
assert_noop!(Indices::transfer(Some(1).into(), 2, 1), Error::<Test>::NotAssigned);
|
assert_noop!(Indices::transfer(Some(1).into(), Id(2), 1), Error::<Test>::NotAssigned);
|
||||||
assert_noop!(Indices::transfer(Some(2).into(), 3, 0), Error::<Test>::NotOwner);
|
assert_noop!(Indices::transfer(Some(2).into(), Id(3), 0), Error::<Test>::NotOwner);
|
||||||
assert_ok!(Indices::transfer(Some(1).into(), 3, 0));
|
assert_ok!(Indices::transfer(Some(1).into(), Id(3), 0));
|
||||||
assert_eq!(Balances::reserved_balance(1), 0);
|
assert_eq!(Balances::reserved_balance(1), 0);
|
||||||
assert_eq!(Balances::reserved_balance(3), 1);
|
assert_eq!(Balances::reserved_balance(3), 1);
|
||||||
assert_eq!(Indices::lookup_index(0), Some(3));
|
assert_eq!(Indices::lookup_index(0), Some(3));
|
||||||
@@ -103,7 +104,7 @@ fn transfer_index_on_accounts_should_work() {
|
|||||||
fn force_transfer_index_on_preowned_should_work() {
|
fn force_transfer_index_on_preowned_should_work() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_ok!(Indices::claim(Some(1).into(), 0));
|
assert_ok!(Indices::claim(Some(1).into(), 0));
|
||||||
assert_ok!(Indices::force_transfer(Origin::root(), 3, 0, false));
|
assert_ok!(Indices::force_transfer(Origin::root(), Id(3), 0, false));
|
||||||
assert_eq!(Balances::reserved_balance(1), 0);
|
assert_eq!(Balances::reserved_balance(1), 0);
|
||||||
assert_eq!(Balances::reserved_balance(3), 0);
|
assert_eq!(Balances::reserved_balance(3), 0);
|
||||||
assert_eq!(Indices::lookup_index(0), Some(3));
|
assert_eq!(Indices::lookup_index(0), Some(3));
|
||||||
@@ -113,7 +114,7 @@ fn force_transfer_index_on_preowned_should_work() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn force_transfer_index_on_free_should_work() {
|
fn force_transfer_index_on_free_should_work() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_ok!(Indices::force_transfer(Origin::root(), 3, 0, false));
|
assert_ok!(Indices::force_transfer(Origin::root(), Id(3), 0, false));
|
||||||
assert_eq!(Balances::reserved_balance(3), 0);
|
assert_eq!(Balances::reserved_balance(3), 0);
|
||||||
assert_eq!(Indices::lookup_index(0), Some(3));
|
assert_eq!(Indices::lookup_index(0), Some(3));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ use frame_support::{
|
|||||||
traits::{ChangeMembers, Contains, Get, InitializeMembers, SortedMembers},
|
traits::{ChangeMembers, Contains, Get, InitializeMembers, SortedMembers},
|
||||||
BoundedVec,
|
BoundedVec,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::traits::StaticLookup;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
pub mod migrations;
|
pub mod migrations;
|
||||||
@@ -35,6 +36,8 @@ pub mod weights;
|
|||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
pub use weights::WeightInfo;
|
pub use weights::WeightInfo;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -163,8 +166,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// May only be called from `T::AddOrigin`.
|
/// May only be called from `T::AddOrigin`.
|
||||||
#[pallet::weight(50_000_000)]
|
#[pallet::weight(50_000_000)]
|
||||||
pub fn add_member(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
pub fn add_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
T::AddOrigin::ensure_origin(origin)?;
|
T::AddOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
|
|
||||||
let mut members = <Members<T, I>>::get();
|
let mut members = <Members<T, I>>::get();
|
||||||
let location = members.binary_search(&who).err().ok_or(Error::<T, I>::AlreadyMember)?;
|
let location = members.binary_search(&who).err().ok_or(Error::<T, I>::AlreadyMember)?;
|
||||||
@@ -184,8 +188,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// May only be called from `T::RemoveOrigin`.
|
/// May only be called from `T::RemoveOrigin`.
|
||||||
#[pallet::weight(50_000_000)]
|
#[pallet::weight(50_000_000)]
|
||||||
pub fn remove_member(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
pub fn remove_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
T::RemoveOrigin::ensure_origin(origin)?;
|
T::RemoveOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
|
|
||||||
let mut members = <Members<T, I>>::get();
|
let mut members = <Members<T, I>>::get();
|
||||||
let location = members.binary_search(&who).ok().ok_or(Error::<T, I>::NotMember)?;
|
let location = members.binary_search(&who).ok().ok_or(Error::<T, I>::NotMember)?;
|
||||||
@@ -208,10 +213,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(50_000_000)]
|
#[pallet::weight(50_000_000)]
|
||||||
pub fn swap_member(
|
pub fn swap_member(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
remove: T::AccountId,
|
remove: AccountIdLookupOf<T>,
|
||||||
add: T::AccountId,
|
add: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::SwapOrigin::ensure_origin(origin)?;
|
T::SwapOrigin::ensure_origin(origin)?;
|
||||||
|
let remove = T::Lookup::lookup(remove)?;
|
||||||
|
let add = T::Lookup::lookup(add)?;
|
||||||
|
|
||||||
if remove == add {
|
if remove == add {
|
||||||
return Ok(())
|
return Ok(())
|
||||||
@@ -259,8 +266,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Prime membership is passed from the origin account to `new`, if extant.
|
/// Prime membership is passed from the origin account to `new`, if extant.
|
||||||
#[pallet::weight(50_000_000)]
|
#[pallet::weight(50_000_000)]
|
||||||
pub fn change_key(origin: OriginFor<T>, new: T::AccountId) -> DispatchResult {
|
pub fn change_key(origin: OriginFor<T>, new: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
let remove = ensure_signed(origin)?;
|
let remove = ensure_signed(origin)?;
|
||||||
|
let new = T::Lookup::lookup(new)?;
|
||||||
|
|
||||||
if remove != new {
|
if remove != new {
|
||||||
let mut members = <Members<T, I>>::get();
|
let mut members = <Members<T, I>>::get();
|
||||||
@@ -292,8 +300,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// May only be called from `T::PrimeOrigin`.
|
/// May only be called from `T::PrimeOrigin`.
|
||||||
#[pallet::weight(50_000_000)]
|
#[pallet::weight(50_000_000)]
|
||||||
pub fn set_prime(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
pub fn set_prime(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
T::PrimeOrigin::ensure_origin(origin)?;
|
T::PrimeOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
Self::members().binary_search(&who).ok().ok_or(Error::<T, I>::NotMember)?;
|
Self::members().binary_search(&who).ok().ok_or(Error::<T, I>::NotMember)?;
|
||||||
Prime::<T, I>::put(&who);
|
Prime::<T, I>::put(&who);
|
||||||
T::MembershipChanged::set_prime(Some(who));
|
T::MembershipChanged::set_prime(Some(who));
|
||||||
@@ -355,7 +364,8 @@ mod benchmark {
|
|||||||
|
|
||||||
assert_ok!(<Membership<T, I>>::reset_members(reset_origin, members.clone()));
|
assert_ok!(<Membership<T, I>>::reset_members(reset_origin, members.clone()));
|
||||||
if let Some(prime) = prime.map(|i| members[i].clone()) {
|
if let Some(prime) = prime.map(|i| members[i].clone()) {
|
||||||
assert_ok!(<Membership<T, I>>::set_prime(prime_origin, prime));
|
let prime_lookup = T::Lookup::unlookup(prime);
|
||||||
|
assert_ok!(<Membership<T, I>>::set_prime(prime_origin, prime_lookup));
|
||||||
} else {
|
} else {
|
||||||
assert_ok!(<Membership<T, I>>::clear_prime(prime_origin));
|
assert_ok!(<Membership<T, I>>::clear_prime(prime_origin));
|
||||||
}
|
}
|
||||||
@@ -368,8 +378,9 @@ mod benchmark {
|
|||||||
let members = (0..m).map(|i| account("member", i, SEED)).collect::<Vec<T::AccountId>>();
|
let members = (0..m).map(|i| account("member", i, SEED)).collect::<Vec<T::AccountId>>();
|
||||||
set_members::<T, I>(members, None);
|
set_members::<T, I>(members, None);
|
||||||
let new_member = account::<T::AccountId>("add", m, SEED);
|
let new_member = account::<T::AccountId>("add", m, SEED);
|
||||||
|
let new_member_lookup = T::Lookup::unlookup(new_member.clone());
|
||||||
}: {
|
}: {
|
||||||
assert_ok!(<Membership<T, I>>::add_member(T::AddOrigin::successful_origin(), new_member.clone()));
|
assert_ok!(<Membership<T, I>>::add_member(T::AddOrigin::successful_origin(), new_member_lookup));
|
||||||
}
|
}
|
||||||
verify {
|
verify {
|
||||||
assert!(<Members<T, I>>::get().contains(&new_member));
|
assert!(<Members<T, I>>::get().contains(&new_member));
|
||||||
@@ -385,8 +396,9 @@ mod benchmark {
|
|||||||
set_members::<T, I>(members.clone(), Some(members.len() - 1));
|
set_members::<T, I>(members.clone(), Some(members.len() - 1));
|
||||||
|
|
||||||
let to_remove = members.first().cloned().unwrap();
|
let to_remove = members.first().cloned().unwrap();
|
||||||
|
let to_remove_lookup = T::Lookup::unlookup(to_remove.clone());
|
||||||
}: {
|
}: {
|
||||||
assert_ok!(<Membership<T, I>>::remove_member(T::RemoveOrigin::successful_origin(), to_remove.clone()));
|
assert_ok!(<Membership<T, I>>::remove_member(T::RemoveOrigin::successful_origin(), to_remove_lookup));
|
||||||
} verify {
|
} verify {
|
||||||
assert!(!<Members<T, I>>::get().contains(&to_remove));
|
assert!(!<Members<T, I>>::get().contains(&to_remove));
|
||||||
// prime is rejigged
|
// prime is rejigged
|
||||||
@@ -401,12 +413,14 @@ mod benchmark {
|
|||||||
let members = (0..m).map(|i| account("member", i, SEED)).collect::<Vec<T::AccountId>>();
|
let members = (0..m).map(|i| account("member", i, SEED)).collect::<Vec<T::AccountId>>();
|
||||||
set_members::<T, I>(members.clone(), Some(members.len() - 1));
|
set_members::<T, I>(members.clone(), Some(members.len() - 1));
|
||||||
let add = account::<T::AccountId>("member", m, SEED);
|
let add = account::<T::AccountId>("member", m, SEED);
|
||||||
|
let add_lookup = T::Lookup::unlookup(add.clone());
|
||||||
let remove = members.first().cloned().unwrap();
|
let remove = members.first().cloned().unwrap();
|
||||||
|
let remove_lookup = T::Lookup::unlookup(remove.clone());
|
||||||
}: {
|
}: {
|
||||||
assert_ok!(<Membership<T, I>>::swap_member(
|
assert_ok!(<Membership<T, I>>::swap_member(
|
||||||
T::SwapOrigin::successful_origin(),
|
T::SwapOrigin::successful_origin(),
|
||||||
remove.clone(),
|
remove_lookup,
|
||||||
add.clone(),
|
add_lookup,
|
||||||
));
|
));
|
||||||
} verify {
|
} verify {
|
||||||
assert!(!<Members<T, I>>::get().contains(&remove));
|
assert!(!<Members<T, I>>::get().contains(&remove));
|
||||||
@@ -442,9 +456,10 @@ mod benchmark {
|
|||||||
set_members::<T, I>(members.clone(), Some(members.len() - 1));
|
set_members::<T, I>(members.clone(), Some(members.len() - 1));
|
||||||
|
|
||||||
let add = account::<T::AccountId>("member", m, SEED);
|
let add = account::<T::AccountId>("member", m, SEED);
|
||||||
|
let add_lookup = T::Lookup::unlookup(add.clone());
|
||||||
whitelist!(prime);
|
whitelist!(prime);
|
||||||
}: {
|
}: {
|
||||||
assert_ok!(<Membership<T, I>>::change_key(RawOrigin::Signed(prime.clone()).into(), add.clone()));
|
assert_ok!(<Membership<T, I>>::change_key(RawOrigin::Signed(prime.clone()).into(), add_lookup));
|
||||||
} verify {
|
} verify {
|
||||||
assert!(!<Members<T, I>>::get().contains(&prime));
|
assert!(!<Members<T, I>>::get().contains(&prime));
|
||||||
assert!(<Members<T, I>>::get().contains(&add));
|
assert!(<Members<T, I>>::get().contains(&add));
|
||||||
@@ -457,9 +472,10 @@ mod benchmark {
|
|||||||
let m in 1 .. T::MaxMembers::get();
|
let m in 1 .. T::MaxMembers::get();
|
||||||
let members = (0..m).map(|i| account("member", i, SEED)).collect::<Vec<T::AccountId>>();
|
let members = (0..m).map(|i| account("member", i, SEED)).collect::<Vec<T::AccountId>>();
|
||||||
let prime = members.last().cloned().unwrap();
|
let prime = members.last().cloned().unwrap();
|
||||||
|
let prime_lookup = T::Lookup::unlookup(prime.clone());
|
||||||
set_members::<T, I>(members, None);
|
set_members::<T, I>(members, None);
|
||||||
}: {
|
}: {
|
||||||
assert_ok!(<Membership<T, I>>::set_prime(T::PrimeOrigin::successful_origin(), prime));
|
assert_ok!(<Membership<T, I>>::set_prime(T::PrimeOrigin::successful_origin(), prime_lookup));
|
||||||
} verify {
|
} verify {
|
||||||
assert!(<Prime<T, I>>::get().is_some());
|
assert!(<Prime<T, I>>::get().is_some());
|
||||||
assert!(<T::MembershipChanged>::get_prime().is_some());
|
assert!(<T::MembershipChanged>::get_prime().is_some());
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
|
|||||||
type BalanceOf<T> = <<T as Config>::Currency as Currency<AccountIdOf<T>>>::Balance;
|
type BalanceOf<T> = <<T as Config>::Currency as Currency<AccountIdOf<T>>>::Balance;
|
||||||
type NegativeImbalanceOf<T> =
|
type NegativeImbalanceOf<T> =
|
||||||
<<T as Config>::Currency as Currency<AccountIdOf<T>>>::NegativeImbalance;
|
<<T as Config>::Currency as Currency<AccountIdOf<T>>>::NegativeImbalance;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
@@ -193,10 +194,7 @@ pub mod pallet {
|
|||||||
/// - One event.
|
/// - One event.
|
||||||
/// # </weight>
|
/// # </weight>
|
||||||
#[pallet::weight(70_000_000)]
|
#[pallet::weight(70_000_000)]
|
||||||
pub fn kill_name(
|
pub fn kill_name(origin: OriginFor<T>, target: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
|
||||||
) -> DispatchResult {
|
|
||||||
T::ForceOrigin::ensure_origin(origin)?;
|
T::ForceOrigin::ensure_origin(origin)?;
|
||||||
|
|
||||||
// Figure out who we're meant to be clearing.
|
// Figure out who we're meant to be clearing.
|
||||||
@@ -225,7 +223,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(70_000_000)]
|
#[pallet::weight(70_000_000)]
|
||||||
pub fn force_name(
|
pub fn force_name(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
name: Vec<u8>,
|
name: Vec<u8>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::ForceOrigin::ensure_origin(origin)?;
|
T::ForceOrigin::ensure_origin(origin)?;
|
||||||
|
|||||||
@@ -46,9 +46,12 @@ pub mod weights;
|
|||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
use sp_core::OpaquePeerId as PeerId;
|
use sp_core::OpaquePeerId as PeerId;
|
||||||
|
use sp_runtime::traits::StaticLookup;
|
||||||
use sp_std::{collections::btree_set::BTreeSet, iter::FromIterator, prelude::*};
|
use sp_std::{collections::btree_set::BTreeSet, iter::FromIterator, prelude::*};
|
||||||
pub use weights::WeightInfo;
|
pub use weights::WeightInfo;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -211,9 +214,10 @@ pub mod pallet {
|
|||||||
pub fn add_well_known_node(
|
pub fn add_well_known_node(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
node: PeerId,
|
node: PeerId,
|
||||||
owner: T::AccountId,
|
owner: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::AddOrigin::ensure_origin(origin)?;
|
T::AddOrigin::ensure_origin(origin)?;
|
||||||
|
let owner = T::Lookup::lookup(owner)?;
|
||||||
ensure!(node.0.len() < T::MaxPeerIdLength::get() as usize, Error::<T>::PeerIdTooLong);
|
ensure!(node.0.len() < T::MaxPeerIdLength::get() as usize, Error::<T>::PeerIdTooLong);
|
||||||
|
|
||||||
let mut nodes = WellKnownNodes::<T>::get();
|
let mut nodes = WellKnownNodes::<T>::get();
|
||||||
@@ -355,9 +359,10 @@ pub mod pallet {
|
|||||||
pub fn transfer_node(
|
pub fn transfer_node(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
node: PeerId,
|
node: PeerId,
|
||||||
owner: T::AccountId,
|
owner: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let sender = ensure_signed(origin)?;
|
let sender = ensure_signed(origin)?;
|
||||||
|
let owner = T::Lookup::lookup(owner)?;
|
||||||
|
|
||||||
ensure!(node.0.len() < T::MaxPeerIdLength::get() as usize, Error::<T>::PeerIdTooLong);
|
ensure!(node.0.len() < T::MaxPeerIdLength::get() as usize, Error::<T>::PeerIdTooLong);
|
||||||
let pre_owner = Owners::<T>::get(&node).ok_or(Error::<T>::NotClaimed)?;
|
let pre_owner = Owners::<T>::get(&node).ok_or(Error::<T>::NotClaimed)?;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use pallet_nomination_pools::{
|
|||||||
MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond, Pallet as Pools,
|
MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond, Pallet as Pools,
|
||||||
PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage,
|
PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage,
|
||||||
};
|
};
|
||||||
use sp_runtime::traits::{Bounded, Zero};
|
use sp_runtime::traits::{Bounded, StaticLookup, Zero};
|
||||||
use sp_staking::{EraIndex, StakingInterface};
|
use sp_staking::{EraIndex, StakingInterface};
|
||||||
// `frame_benchmarking::benchmarks!` macro needs this
|
// `frame_benchmarking::benchmarks!` macro needs this
|
||||||
use pallet_nomination_pools::Call;
|
use pallet_nomination_pools::Call;
|
||||||
@@ -73,13 +73,14 @@ fn create_pool_account<T: pallet_nomination_pools::Config>(
|
|||||||
let ed = CurrencyOf::<T>::minimum_balance();
|
let ed = CurrencyOf::<T>::minimum_balance();
|
||||||
let pool_creator: T::AccountId =
|
let pool_creator: T::AccountId =
|
||||||
create_funded_user_with_balance::<T>("pool_creator", n, ed + balance * 2u32.into());
|
create_funded_user_with_balance::<T>("pool_creator", n, ed + balance * 2u32.into());
|
||||||
|
let pool_creator_lookup = T::Lookup::unlookup(pool_creator.clone());
|
||||||
|
|
||||||
Pools::<T>::create(
|
Pools::<T>::create(
|
||||||
Origin::Signed(pool_creator.clone()).into(),
|
Origin::Signed(pool_creator.clone()).into(),
|
||||||
balance,
|
balance,
|
||||||
pool_creator.clone(),
|
pool_creator_lookup.clone(),
|
||||||
pool_creator.clone(),
|
pool_creator_lookup.clone(),
|
||||||
pool_creator.clone(),
|
pool_creator_lookup,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -310,9 +311,10 @@ frame_benchmarking::benchmarks! {
|
|||||||
|
|
||||||
let scenario = scenario.add_joiner(amount);
|
let scenario = scenario.add_joiner(amount);
|
||||||
let member_id = scenario.origin1_member.unwrap().clone();
|
let member_id = scenario.origin1_member.unwrap().clone();
|
||||||
|
let member_id_lookup = T::Lookup::unlookup(member_id.clone());
|
||||||
let all_points = PoolMembers::<T>::get(&member_id).unwrap().points;
|
let all_points = PoolMembers::<T>::get(&member_id).unwrap().points;
|
||||||
whitelist_account!(member_id);
|
whitelist_account!(member_id);
|
||||||
}: _(Origin::Signed(member_id.clone()), member_id.clone(), all_points)
|
}: _(Origin::Signed(member_id.clone()), member_id_lookup, all_points)
|
||||||
verify {
|
verify {
|
||||||
let bonded_after = T::StakingInterface::active_stake(&scenario.origin1).unwrap();
|
let bonded_after = T::StakingInterface::active_stake(&scenario.origin1).unwrap();
|
||||||
// We at least went down to the destination bag
|
// We at least went down to the destination bag
|
||||||
@@ -382,6 +384,7 @@ frame_benchmarking::benchmarks! {
|
|||||||
// Add a new member
|
// Add a new member
|
||||||
let min_join_bond = MinJoinBond::<T>::get().max(CurrencyOf::<T>::minimum_balance());
|
let min_join_bond = MinJoinBond::<T>::get().max(CurrencyOf::<T>::minimum_balance());
|
||||||
let joiner = create_funded_user_with_balance::<T>("joiner", 0, min_join_bond * 2u32.into());
|
let joiner = create_funded_user_with_balance::<T>("joiner", 0, min_join_bond * 2u32.into());
|
||||||
|
let joiner_lookup = T::Lookup::unlookup(joiner.clone());
|
||||||
Pools::<T>::join(Origin::Signed(joiner.clone()).into(), min_join_bond, 1)
|
Pools::<T>::join(Origin::Signed(joiner.clone()).into(), min_join_bond, 1)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -408,7 +411,7 @@ frame_benchmarking::benchmarks! {
|
|||||||
|
|
||||||
pallet_staking::benchmarking::add_slashing_spans::<T>(&pool_account, s);
|
pallet_staking::benchmarking::add_slashing_spans::<T>(&pool_account, s);
|
||||||
whitelist_account!(joiner);
|
whitelist_account!(joiner);
|
||||||
}: withdraw_unbonded(Origin::Signed(joiner.clone()), joiner.clone(), s)
|
}: withdraw_unbonded(Origin::Signed(joiner.clone()), joiner_lookup, s)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
CurrencyOf::<T>::free_balance(&joiner),
|
CurrencyOf::<T>::free_balance(&joiner),
|
||||||
@@ -423,6 +426,7 @@ frame_benchmarking::benchmarks! {
|
|||||||
|
|
||||||
let min_create_bond = min_create_bond::<T>();
|
let min_create_bond = min_create_bond::<T>();
|
||||||
let (depositor, pool_account) = create_pool_account::<T>(0, min_create_bond);
|
let (depositor, pool_account) = create_pool_account::<T>(0, min_create_bond);
|
||||||
|
let depositor_lookup = T::Lookup::unlookup(depositor.clone());
|
||||||
|
|
||||||
// We set the pool to the destroying state so the depositor can leave
|
// We set the pool to the destroying state so the depositor can leave
|
||||||
BondedPools::<T>::try_mutate(&1, |maybe_bonded_pool| {
|
BondedPools::<T>::try_mutate(&1, |maybe_bonded_pool| {
|
||||||
@@ -465,7 +469,7 @@ frame_benchmarking::benchmarks! {
|
|||||||
assert!(frame_system::Account::<T>::contains_key(&reward_account));
|
assert!(frame_system::Account::<T>::contains_key(&reward_account));
|
||||||
|
|
||||||
whitelist_account!(depositor);
|
whitelist_account!(depositor);
|
||||||
}: withdraw_unbonded(Origin::Signed(depositor.clone()), depositor.clone(), s)
|
}: withdraw_unbonded(Origin::Signed(depositor.clone()), depositor_lookup, s)
|
||||||
verify {
|
verify {
|
||||||
// Pool removal worked
|
// Pool removal worked
|
||||||
assert!(!pallet_staking::Ledger::<T>::contains_key(&pool_account));
|
assert!(!pallet_staking::Ledger::<T>::contains_key(&pool_account));
|
||||||
@@ -487,6 +491,7 @@ frame_benchmarking::benchmarks! {
|
|||||||
create {
|
create {
|
||||||
let min_create_bond = min_create_bond::<T>();
|
let min_create_bond = min_create_bond::<T>();
|
||||||
let depositor: T::AccountId = account("depositor", USER_SEED, 0);
|
let depositor: T::AccountId = account("depositor", USER_SEED, 0);
|
||||||
|
let depositor_lookup = T::Lookup::unlookup(depositor.clone());
|
||||||
|
|
||||||
// Give the depositor some balance to bond
|
// Give the depositor some balance to bond
|
||||||
CurrencyOf::<T>::make_free_balance_be(&depositor, min_create_bond * 2u32.into());
|
CurrencyOf::<T>::make_free_balance_be(&depositor, min_create_bond * 2u32.into());
|
||||||
@@ -499,9 +504,9 @@ frame_benchmarking::benchmarks! {
|
|||||||
}: _(
|
}: _(
|
||||||
Origin::Signed(depositor.clone()),
|
Origin::Signed(depositor.clone()),
|
||||||
min_create_bond,
|
min_create_bond,
|
||||||
depositor.clone(),
|
depositor_lookup.clone(),
|
||||||
depositor.clone(),
|
depositor_lookup.clone(),
|
||||||
depositor.clone()
|
depositor_lookup
|
||||||
)
|
)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(RewardPools::<T>::count(), 1);
|
assert_eq!(RewardPools::<T>::count(), 1);
|
||||||
|
|||||||
@@ -282,7 +282,10 @@ use frame_support::{
|
|||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_core::U256;
|
use sp_core::U256;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{AccountIdConversion, Bounded, CheckedAdd, CheckedSub, Convert, Saturating, Zero},
|
traits::{
|
||||||
|
AccountIdConversion, Bounded, CheckedAdd, CheckedSub, Convert, Saturating, StaticLookup,
|
||||||
|
Zero,
|
||||||
|
},
|
||||||
FixedPointNumber, FixedPointOperand,
|
FixedPointNumber, FixedPointOperand,
|
||||||
};
|
};
|
||||||
use sp_staking::{EraIndex, OnStakerSlash, StakingInterface};
|
use sp_staking::{EraIndex, OnStakerSlash, StakingInterface};
|
||||||
@@ -321,6 +324,8 @@ pub type PoolId = u32;
|
|||||||
|
|
||||||
type UnbondingPoolsWithEra<T> = BoundedBTreeMap<EraIndex, UnbondPool<T>, TotalUnbondingPools<T>>;
|
type UnbondingPoolsWithEra<T> = BoundedBTreeMap<EraIndex, UnbondPool<T>, TotalUnbondingPools<T>>;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
pub const POINTS_TO_BALANCE_INIT_RATIO: u32 = 1;
|
pub const POINTS_TO_BALANCE_INIT_RATIO: u32 = 1;
|
||||||
|
|
||||||
/// Possible operations on the configuration values of this pallet.
|
/// Possible operations on the configuration values of this pallet.
|
||||||
@@ -1629,10 +1634,11 @@ pub mod pallet {
|
|||||||
#[transactional]
|
#[transactional]
|
||||||
pub fn unbond(
|
pub fn unbond(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
member_account: T::AccountId,
|
member_account: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] unbonding_points: BalanceOf<T>,
|
#[pallet::compact] unbonding_points: BalanceOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let member_account = T::Lookup::lookup(member_account)?;
|
||||||
let (mut member, mut bonded_pool, mut reward_pool) =
|
let (mut member, mut bonded_pool, mut reward_pool) =
|
||||||
Self::get_member_with_pools(&member_account)?;
|
Self::get_member_with_pools(&member_account)?;
|
||||||
|
|
||||||
@@ -1741,10 +1747,11 @@ pub mod pallet {
|
|||||||
#[transactional]
|
#[transactional]
|
||||||
pub fn withdraw_unbonded(
|
pub fn withdraw_unbonded(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
member_account: T::AccountId,
|
member_account: AccountIdLookupOf<T>,
|
||||||
num_slashing_spans: u32,
|
num_slashing_spans: u32,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let caller = ensure_signed(origin)?;
|
let caller = ensure_signed(origin)?;
|
||||||
|
let member_account = T::Lookup::lookup(member_account)?;
|
||||||
let mut member =
|
let mut member =
|
||||||
PoolMembers::<T>::get(&member_account).ok_or(Error::<T>::PoolMemberNotFound)?;
|
PoolMembers::<T>::get(&member_account).ok_or(Error::<T>::PoolMemberNotFound)?;
|
||||||
let current_era = T::StakingInterface::current_era();
|
let current_era = T::StakingInterface::current_era();
|
||||||
@@ -1863,11 +1870,14 @@ pub mod pallet {
|
|||||||
pub fn create(
|
pub fn create(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] amount: BalanceOf<T>,
|
#[pallet::compact] amount: BalanceOf<T>,
|
||||||
root: T::AccountId,
|
root: AccountIdLookupOf<T>,
|
||||||
nominator: T::AccountId,
|
nominator: AccountIdLookupOf<T>,
|
||||||
state_toggler: T::AccountId,
|
state_toggler: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let root = T::Lookup::lookup(root)?;
|
||||||
|
let nominator = T::Lookup::lookup(nominator)?;
|
||||||
|
let state_toggler = T::Lookup::lookup(state_toggler)?;
|
||||||
|
|
||||||
ensure!(amount >= Pallet::<T>::depositor_min_bond(), Error::<T>::MinimumBondNotMet);
|
ensure!(amount >= Pallet::<T>::depositor_min_bond(), Error::<T>::MinimumBondNotMet);
|
||||||
ensure!(
|
ensure!(
|
||||||
@@ -2461,7 +2471,8 @@ impl<T: Config> Pallet<T> {
|
|||||||
member: T::AccountId,
|
member: T::AccountId,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let points = PoolMembers::<T>::get(&member).map(|d| d.active_points()).unwrap_or_default();
|
let points = PoolMembers::<T>::get(&member).map(|d| d.active_points()).unwrap_or_default();
|
||||||
Self::unbond(origin, member, points)
|
let member_lookup = T::Lookup::unlookup(member);
|
||||||
|
Self::unbond(origin, member_lookup, points)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ fn add_announcements<T: Config>(
|
|||||||
maybe_real: Option<T::AccountId>,
|
maybe_real: Option<T::AccountId>,
|
||||||
) -> Result<(), &'static str> {
|
) -> Result<(), &'static str> {
|
||||||
let caller = maybe_who.unwrap_or_else(|| account("caller", 0, SEED));
|
let caller = maybe_who.unwrap_or_else(|| account("caller", 0, SEED));
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||||
let real = if let Some(real) = maybe_real {
|
let real = if let Some(real) = maybe_real {
|
||||||
real
|
real
|
||||||
@@ -59,16 +60,17 @@ fn add_announcements<T: Config>(
|
|||||||
T::Currency::make_free_balance_be(&real, BalanceOf::<T>::max_value() / 2u32.into());
|
T::Currency::make_free_balance_be(&real, BalanceOf::<T>::max_value() / 2u32.into());
|
||||||
Proxy::<T>::add_proxy(
|
Proxy::<T>::add_proxy(
|
||||||
RawOrigin::Signed(real.clone()).into(),
|
RawOrigin::Signed(real.clone()).into(),
|
||||||
caller.clone(),
|
caller_lookup,
|
||||||
T::ProxyType::default(),
|
T::ProxyType::default(),
|
||||||
T::BlockNumber::zero(),
|
T::BlockNumber::zero(),
|
||||||
)?;
|
)?;
|
||||||
real
|
real
|
||||||
};
|
};
|
||||||
|
let real_lookup = T::Lookup::unlookup(real);
|
||||||
for _ in 0..n {
|
for _ in 0..n {
|
||||||
Proxy::<T>::announce(
|
Proxy::<T>::announce(
|
||||||
RawOrigin::Signed(caller.clone()).into(),
|
RawOrigin::Signed(caller.clone()).into(),
|
||||||
real.clone(),
|
real_lookup.clone(),
|
||||||
T::CallHasher::hash_of(&("add_announcement", n)),
|
T::CallHasher::hash_of(&("add_announcement", n)),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@@ -83,8 +85,9 @@ benchmarks! {
|
|||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||||
// ... and "real" is the traditional caller. This is not a typo.
|
// ... and "real" is the traditional caller. This is not a typo.
|
||||||
let real: T::AccountId = whitelisted_caller();
|
let real: T::AccountId = whitelisted_caller();
|
||||||
|
let real_lookup = T::Lookup::unlookup(real);
|
||||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||||
}: _(RawOrigin::Signed(caller), real, Some(T::ProxyType::default()), Box::new(call))
|
}: _(RawOrigin::Signed(caller), real_lookup, Some(T::ProxyType::default()), Box::new(call))
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::ProxyExecuted { result: Ok(()) }.into())
|
assert_last_event::<T>(Event::ProxyExecuted { result: Ok(()) }.into())
|
||||||
}
|
}
|
||||||
@@ -95,17 +98,19 @@ benchmarks! {
|
|||||||
// In this case the caller is the "target" proxy
|
// In this case the caller is the "target" proxy
|
||||||
let caller: T::AccountId = account("anonymous", 0, SEED);
|
let caller: T::AccountId = account("anonymous", 0, SEED);
|
||||||
let delegate: T::AccountId = account("target", p - 1, SEED);
|
let delegate: T::AccountId = account("target", p - 1, SEED);
|
||||||
|
let delegate_lookup = T::Lookup::unlookup(delegate.clone());
|
||||||
T::Currency::make_free_balance_be(&delegate, BalanceOf::<T>::max_value() / 2u32.into());
|
T::Currency::make_free_balance_be(&delegate, BalanceOf::<T>::max_value() / 2u32.into());
|
||||||
// ... and "real" is the traditional caller. This is not a typo.
|
// ... and "real" is the traditional caller. This is not a typo.
|
||||||
let real: T::AccountId = whitelisted_caller();
|
let real: T::AccountId = whitelisted_caller();
|
||||||
|
let real_lookup = T::Lookup::unlookup(real);
|
||||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||||
Proxy::<T>::announce(
|
Proxy::<T>::announce(
|
||||||
RawOrigin::Signed(delegate.clone()).into(),
|
RawOrigin::Signed(delegate.clone()).into(),
|
||||||
real.clone(),
|
real_lookup.clone(),
|
||||||
T::CallHasher::hash_of(&call),
|
T::CallHasher::hash_of(&call),
|
||||||
)?;
|
)?;
|
||||||
add_announcements::<T>(a, Some(delegate.clone()), None)?;
|
add_announcements::<T>(a, Some(delegate.clone()), None)?;
|
||||||
}: _(RawOrigin::Signed(caller), delegate, real, Some(T::ProxyType::default()), Box::new(call))
|
}: _(RawOrigin::Signed(caller), delegate_lookup, real_lookup, Some(T::ProxyType::default()), Box::new(call))
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::ProxyExecuted { result: Ok(()) }.into())
|
assert_last_event::<T>(Event::ProxyExecuted { result: Ok(()) }.into())
|
||||||
}
|
}
|
||||||
@@ -118,14 +123,15 @@ benchmarks! {
|
|||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||||
// ... and "real" is the traditional caller. This is not a typo.
|
// ... and "real" is the traditional caller. This is not a typo.
|
||||||
let real: T::AccountId = whitelisted_caller();
|
let real: T::AccountId = whitelisted_caller();
|
||||||
|
let real_lookup = T::Lookup::unlookup(real);
|
||||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||||
Proxy::<T>::announce(
|
Proxy::<T>::announce(
|
||||||
RawOrigin::Signed(caller.clone()).into(),
|
RawOrigin::Signed(caller.clone()).into(),
|
||||||
real.clone(),
|
real_lookup.clone(),
|
||||||
T::CallHasher::hash_of(&call),
|
T::CallHasher::hash_of(&call),
|
||||||
)?;
|
)?;
|
||||||
add_announcements::<T>(a, Some(caller.clone()), None)?;
|
add_announcements::<T>(a, Some(caller.clone()), None)?;
|
||||||
}: _(RawOrigin::Signed(caller.clone()), real, T::CallHasher::hash_of(&call))
|
}: _(RawOrigin::Signed(caller.clone()), real_lookup, T::CallHasher::hash_of(&call))
|
||||||
verify {
|
verify {
|
||||||
let (announcements, _) = Announcements::<T>::get(&caller);
|
let (announcements, _) = Announcements::<T>::get(&caller);
|
||||||
assert_eq!(announcements.len() as u32, a);
|
assert_eq!(announcements.len() as u32, a);
|
||||||
@@ -136,17 +142,19 @@ benchmarks! {
|
|||||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||||
// In this case the caller is the "target" proxy
|
// In this case the caller is the "target" proxy
|
||||||
let caller: T::AccountId = account("target", p - 1, SEED);
|
let caller: T::AccountId = account("target", p - 1, SEED);
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||||
// ... and "real" is the traditional caller. This is not a typo.
|
// ... and "real" is the traditional caller. This is not a typo.
|
||||||
let real: T::AccountId = whitelisted_caller();
|
let real: T::AccountId = whitelisted_caller();
|
||||||
|
let real_lookup = T::Lookup::unlookup(real.clone());
|
||||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||||
Proxy::<T>::announce(
|
Proxy::<T>::announce(
|
||||||
RawOrigin::Signed(caller.clone()).into(),
|
RawOrigin::Signed(caller.clone()).into(),
|
||||||
real.clone(),
|
real_lookup,
|
||||||
T::CallHasher::hash_of(&call),
|
T::CallHasher::hash_of(&call),
|
||||||
)?;
|
)?;
|
||||||
add_announcements::<T>(a, Some(caller.clone()), None)?;
|
add_announcements::<T>(a, Some(caller.clone()), None)?;
|
||||||
}: _(RawOrigin::Signed(real), caller.clone(), T::CallHasher::hash_of(&call))
|
}: _(RawOrigin::Signed(real), caller_lookup, T::CallHasher::hash_of(&call))
|
||||||
verify {
|
verify {
|
||||||
let (announcements, _) = Announcements::<T>::get(&caller);
|
let (announcements, _) = Announcements::<T>::get(&caller);
|
||||||
assert_eq!(announcements.len() as u32, a);
|
assert_eq!(announcements.len() as u32, a);
|
||||||
@@ -160,10 +168,11 @@ benchmarks! {
|
|||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||||
// ... and "real" is the traditional caller. This is not a typo.
|
// ... and "real" is the traditional caller. This is not a typo.
|
||||||
let real: T::AccountId = whitelisted_caller();
|
let real: T::AccountId = whitelisted_caller();
|
||||||
|
let real_lookup = T::Lookup::unlookup(real.clone());
|
||||||
add_announcements::<T>(a, Some(caller.clone()), None)?;
|
add_announcements::<T>(a, Some(caller.clone()), None)?;
|
||||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||||
let call_hash = T::CallHasher::hash_of(&call);
|
let call_hash = T::CallHasher::hash_of(&call);
|
||||||
}: _(RawOrigin::Signed(caller.clone()), real.clone(), call_hash)
|
}: _(RawOrigin::Signed(caller.clone()), real_lookup, call_hash)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::Announced { real, proxy: caller, call_hash }.into());
|
assert_last_event::<T>(Event::Announced { real, proxy: caller, call_hash }.into());
|
||||||
}
|
}
|
||||||
@@ -228,6 +237,7 @@ benchmarks! {
|
|||||||
let p in 0 .. (T::MaxProxies::get() - 2);
|
let p in 0 .. (T::MaxProxies::get() - 2);
|
||||||
|
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
Pallet::<T>::anonymous(
|
Pallet::<T>::anonymous(
|
||||||
RawOrigin::Signed(whitelisted_caller()).into(),
|
RawOrigin::Signed(whitelisted_caller()).into(),
|
||||||
@@ -241,7 +251,7 @@ benchmarks! {
|
|||||||
|
|
||||||
add_proxies::<T>(p, Some(anon.clone()))?;
|
add_proxies::<T>(p, Some(anon.clone()))?;
|
||||||
ensure!(Proxies::<T>::contains_key(&anon), "anon proxy not created");
|
ensure!(Proxies::<T>::contains_key(&anon), "anon proxy not created");
|
||||||
}: _(RawOrigin::Signed(anon.clone()), caller.clone(), T::ProxyType::default(), 0, height, ext_index)
|
}: _(RawOrigin::Signed(anon.clone()), caller_lookup, T::ProxyType::default(), 0, height, ext_index)
|
||||||
verify {
|
verify {
|
||||||
assert!(!Proxies::<T>::contains_key(&anon));
|
assert!(!Proxies::<T>::contains_key(&anon));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ use frame_system::{self as system};
|
|||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_io::hashing::blake2_256;
|
use sp_io::hashing::blake2_256;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{Dispatchable, Hash, Saturating, TrailingZeroInput, Zero},
|
traits::{Dispatchable, Hash, Saturating, StaticLookup, TrailingZeroInput, Zero},
|
||||||
DispatchResult,
|
DispatchResult,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -58,6 +58,8 @@ type CallHashOf<T> = <<T as Config>::CallHasher as Hash>::Output;
|
|||||||
type BalanceOf<T> =
|
type BalanceOf<T> =
|
||||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// The parameters under which a particular account has a proxy relationship with some other
|
/// The parameters under which a particular account has a proxy relationship with some other
|
||||||
/// account.
|
/// account.
|
||||||
#[derive(
|
#[derive(
|
||||||
@@ -204,11 +206,12 @@ pub mod pallet {
|
|||||||
})]
|
})]
|
||||||
pub fn proxy(
|
pub fn proxy(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
real: T::AccountId,
|
real: AccountIdLookupOf<T>,
|
||||||
force_proxy_type: Option<T::ProxyType>,
|
force_proxy_type: Option<T::ProxyType>,
|
||||||
call: Box<<T as Config>::Call>,
|
call: Box<<T as Config>::Call>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let real = T::Lookup::lookup(real)?;
|
||||||
let def = Self::find_proxy(&real, &who, force_proxy_type)?;
|
let def = Self::find_proxy(&real, &who, force_proxy_type)?;
|
||||||
ensure!(def.delay.is_zero(), Error::<T>::Unannounced);
|
ensure!(def.delay.is_zero(), Error::<T>::Unannounced);
|
||||||
|
|
||||||
@@ -233,11 +236,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::add_proxy(T::MaxProxies::get()))]
|
#[pallet::weight(T::WeightInfo::add_proxy(T::MaxProxies::get()))]
|
||||||
pub fn add_proxy(
|
pub fn add_proxy(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
delegate: T::AccountId,
|
delegate: AccountIdLookupOf<T>,
|
||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let delegate = T::Lookup::lookup(delegate)?;
|
||||||
Self::add_proxy_delegate(&who, delegate, proxy_type, delay)
|
Self::add_proxy_delegate(&who, delegate, proxy_type, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,11 +259,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::remove_proxy(T::MaxProxies::get()))]
|
#[pallet::weight(T::WeightInfo::remove_proxy(T::MaxProxies::get()))]
|
||||||
pub fn remove_proxy(
|
pub fn remove_proxy(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
delegate: T::AccountId,
|
delegate: AccountIdLookupOf<T>,
|
||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let delegate = T::Lookup::lookup(delegate)?;
|
||||||
Self::remove_proxy_delegate(&who, delegate, proxy_type, delay)
|
Self::remove_proxy_delegate(&who, delegate, proxy_type, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,13 +364,14 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::kill_anonymous(T::MaxProxies::get()))]
|
#[pallet::weight(T::WeightInfo::kill_anonymous(T::MaxProxies::get()))]
|
||||||
pub fn kill_anonymous(
|
pub fn kill_anonymous(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
spawner: T::AccountId,
|
spawner: AccountIdLookupOf<T>,
|
||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
index: u16,
|
index: u16,
|
||||||
#[pallet::compact] height: T::BlockNumber,
|
#[pallet::compact] height: T::BlockNumber,
|
||||||
#[pallet::compact] ext_index: u32,
|
#[pallet::compact] ext_index: u32,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let spawner = T::Lookup::lookup(spawner)?;
|
||||||
|
|
||||||
let when = (height, ext_index);
|
let when = (height, ext_index);
|
||||||
let proxy = Self::anonymous_account(&spawner, &proxy_type, index, Some(when));
|
let proxy = Self::anonymous_account(&spawner, &proxy_type, index, Some(when));
|
||||||
@@ -401,10 +407,11 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::announce(T::MaxPending::get(), T::MaxProxies::get()))]
|
#[pallet::weight(T::WeightInfo::announce(T::MaxPending::get(), T::MaxProxies::get()))]
|
||||||
pub fn announce(
|
pub fn announce(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
real: T::AccountId,
|
real: AccountIdLookupOf<T>,
|
||||||
call_hash: CallHashOf<T>,
|
call_hash: CallHashOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let real = T::Lookup::lookup(real)?;
|
||||||
Proxies::<T>::get(&real)
|
Proxies::<T>::get(&real)
|
||||||
.0
|
.0
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -458,10 +465,11 @@ pub mod pallet {
|
|||||||
))]
|
))]
|
||||||
pub fn remove_announcement(
|
pub fn remove_announcement(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
real: T::AccountId,
|
real: AccountIdLookupOf<T>,
|
||||||
call_hash: CallHashOf<T>,
|
call_hash: CallHashOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let real = T::Lookup::lookup(real)?;
|
||||||
Self::edit_announcements(&who, |ann| ann.real != real || ann.call_hash != call_hash)?;
|
Self::edit_announcements(&who, |ann| ann.real != real || ann.call_hash != call_hash)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -489,10 +497,11 @@ pub mod pallet {
|
|||||||
))]
|
))]
|
||||||
pub fn reject_announcement(
|
pub fn reject_announcement(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
delegate: T::AccountId,
|
delegate: AccountIdLookupOf<T>,
|
||||||
call_hash: CallHashOf<T>,
|
call_hash: CallHashOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let delegate = T::Lookup::lookup(delegate)?;
|
||||||
Self::edit_announcements(&delegate, |ann| {
|
Self::edit_announcements(&delegate, |ann| {
|
||||||
ann.real != who || ann.call_hash != call_hash
|
ann.real != who || ann.call_hash != call_hash
|
||||||
})?;
|
})?;
|
||||||
@@ -527,12 +536,14 @@ pub mod pallet {
|
|||||||
})]
|
})]
|
||||||
pub fn proxy_announced(
|
pub fn proxy_announced(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
delegate: T::AccountId,
|
delegate: AccountIdLookupOf<T>,
|
||||||
real: T::AccountId,
|
real: AccountIdLookupOf<T>,
|
||||||
force_proxy_type: Option<T::ProxyType>,
|
force_proxy_type: Option<T::ProxyType>,
|
||||||
call: Box<<T as Config>::Call>,
|
call: Box<<T as Config>::Call>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_signed(origin)?;
|
ensure_signed(origin)?;
|
||||||
|
let delegate = T::Lookup::lookup(delegate)?;
|
||||||
|
let real = T::Lookup::lookup(real)?;
|
||||||
let def = Self::find_proxy(&real, &delegate, force_proxy_type)?;
|
let def = Self::find_proxy(&real, &delegate, force_proxy_type)?;
|
||||||
|
|
||||||
let call_hash = T::CallHasher::hash_of(&call);
|
let call_hash = T::CallHasher::hash_of(&call);
|
||||||
|
|||||||
@@ -33,11 +33,15 @@ fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::
|
|||||||
|
|
||||||
fn make_member<T: Config<I>, I: 'static>(rank: Rank) -> T::AccountId {
|
fn make_member<T: Config<I>, I: 'static>(rank: Rank) -> T::AccountId {
|
||||||
let who = account::<T::AccountId>("member", MemberCount::<T, I>::get(0), SEED);
|
let who = account::<T::AccountId>("member", MemberCount::<T, I>::get(0), SEED);
|
||||||
assert_ok!(Pallet::<T, I>::add_member(T::PromoteOrigin::successful_origin(), who.clone()));
|
let who_lookup = T::Lookup::unlookup(who.clone());
|
||||||
|
assert_ok!(Pallet::<T, I>::add_member(
|
||||||
|
T::PromoteOrigin::successful_origin(),
|
||||||
|
who_lookup.clone()
|
||||||
|
));
|
||||||
for _ in 0..rank {
|
for _ in 0..rank {
|
||||||
assert_ok!(Pallet::<T, I>::promote_member(
|
assert_ok!(Pallet::<T, I>::promote_member(
|
||||||
T::PromoteOrigin::successful_origin(),
|
T::PromoteOrigin::successful_origin(),
|
||||||
who.clone()
|
who_lookup.clone()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
who
|
who
|
||||||
@@ -46,8 +50,9 @@ fn make_member<T: Config<I>, I: 'static>(rank: Rank) -> T::AccountId {
|
|||||||
benchmarks_instance_pallet! {
|
benchmarks_instance_pallet! {
|
||||||
add_member {
|
add_member {
|
||||||
let who = account::<T::AccountId>("member", 0, SEED);
|
let who = account::<T::AccountId>("member", 0, SEED);
|
||||||
|
let who_lookup = T::Lookup::unlookup(who.clone());
|
||||||
let origin = T::PromoteOrigin::successful_origin();
|
let origin = T::PromoteOrigin::successful_origin();
|
||||||
let call = Call::<T, I>::add_member { who: who.clone() };
|
let call = Call::<T, I>::add_member { who: who_lookup };
|
||||||
}: { call.dispatch_bypass_filter(origin)? }
|
}: { call.dispatch_bypass_filter(origin)? }
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(MemberCount::<T, I>::get(0), 1);
|
assert_eq!(MemberCount::<T, I>::get(0), 1);
|
||||||
@@ -59,10 +64,11 @@ benchmarks_instance_pallet! {
|
|||||||
let rank = r as u16;
|
let rank = r as u16;
|
||||||
let first = make_member::<T, I>(rank);
|
let first = make_member::<T, I>(rank);
|
||||||
let who = make_member::<T, I>(rank);
|
let who = make_member::<T, I>(rank);
|
||||||
|
let who_lookup = T::Lookup::unlookup(who.clone());
|
||||||
let last = make_member::<T, I>(rank);
|
let last = make_member::<T, I>(rank);
|
||||||
let last_index = (0..=rank).map(|r| IdToIndex::<T, I>::get(r, &last).unwrap()).collect::<Vec<_>>();
|
let last_index = (0..=rank).map(|r| IdToIndex::<T, I>::get(r, &last).unwrap()).collect::<Vec<_>>();
|
||||||
let origin = T::DemoteOrigin::successful_origin();
|
let origin = T::DemoteOrigin::successful_origin();
|
||||||
let call = Call::<T, I>::remove_member { who: who.clone(), min_rank: rank };
|
let call = Call::<T, I>::remove_member { who: who_lookup, min_rank: rank };
|
||||||
}: { call.dispatch_bypass_filter(origin)? }
|
}: { call.dispatch_bypass_filter(origin)? }
|
||||||
verify {
|
verify {
|
||||||
for r in 0..=rank {
|
for r in 0..=rank {
|
||||||
@@ -76,8 +82,9 @@ benchmarks_instance_pallet! {
|
|||||||
let r in 0 .. 10;
|
let r in 0 .. 10;
|
||||||
let rank = r as u16;
|
let rank = r as u16;
|
||||||
let who = make_member::<T, I>(rank);
|
let who = make_member::<T, I>(rank);
|
||||||
|
let who_lookup = T::Lookup::unlookup(who.clone());
|
||||||
let origin = T::PromoteOrigin::successful_origin();
|
let origin = T::PromoteOrigin::successful_origin();
|
||||||
let call = Call::<T, I>::promote_member { who: who.clone() };
|
let call = Call::<T, I>::promote_member { who: who_lookup };
|
||||||
}: { call.dispatch_bypass_filter(origin)? }
|
}: { call.dispatch_bypass_filter(origin)? }
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(Members::<T, I>::get(&who).unwrap().rank, rank + 1);
|
assert_eq!(Members::<T, I>::get(&who).unwrap().rank, rank + 1);
|
||||||
@@ -89,10 +96,11 @@ benchmarks_instance_pallet! {
|
|||||||
let rank = r as u16;
|
let rank = r as u16;
|
||||||
let first = make_member::<T, I>(rank);
|
let first = make_member::<T, I>(rank);
|
||||||
let who = make_member::<T, I>(rank);
|
let who = make_member::<T, I>(rank);
|
||||||
|
let who_lookup = T::Lookup::unlookup(who.clone());
|
||||||
let last = make_member::<T, I>(rank);
|
let last = make_member::<T, I>(rank);
|
||||||
let last_index = IdToIndex::<T, I>::get(rank, &last).unwrap();
|
let last_index = IdToIndex::<T, I>::get(rank, &last).unwrap();
|
||||||
let origin = T::DemoteOrigin::successful_origin();
|
let origin = T::DemoteOrigin::successful_origin();
|
||||||
let call = Call::<T, I>::demote_member { who: who.clone() };
|
let call = Call::<T, I>::demote_member { who: who_lookup };
|
||||||
}: { call.dispatch_bypass_filter(origin)? }
|
}: { call.dispatch_bypass_filter(origin)? }
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(Members::<T, I>::get(&who).map(|x| x.rank), rank.checked_sub(1));
|
assert_eq!(Members::<T, I>::get(&who).map(|x| x.rank), rank.checked_sub(1));
|
||||||
@@ -106,14 +114,15 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
vote {
|
vote {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
assert_ok!(Pallet::<T, I>::add_member(T::PromoteOrigin::successful_origin(), caller.clone()));
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
|
assert_ok!(Pallet::<T, I>::add_member(T::PromoteOrigin::successful_origin(), caller_lookup.clone()));
|
||||||
// Create a poll
|
// Create a poll
|
||||||
let class = T::Polls::classes().into_iter().next().unwrap();
|
let class = T::Polls::classes().into_iter().next().unwrap();
|
||||||
let rank = T::MinRankOfClass::convert(class.clone());
|
let rank = T::MinRankOfClass::convert(class.clone());
|
||||||
for _ in 0..rank {
|
for _ in 0..rank {
|
||||||
assert_ok!(Pallet::<T, I>::promote_member(
|
assert_ok!(Pallet::<T, I>::promote_member(
|
||||||
T::PromoteOrigin::successful_origin(),
|
T::PromoteOrigin::successful_origin(),
|
||||||
caller.clone()
|
caller_lookup.clone()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,11 @@
|
|||||||
|
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_arithmetic::traits::Saturating;
|
use sp_arithmetic::traits::Saturating;
|
||||||
use sp_runtime::{traits::Convert, ArithmeticError::Overflow, Perbill, RuntimeDebug};
|
use sp_runtime::{
|
||||||
|
traits::{Convert, StaticLookup},
|
||||||
|
ArithmeticError::Overflow,
|
||||||
|
Perbill, RuntimeDebug,
|
||||||
|
};
|
||||||
use sp_std::{marker::PhantomData, prelude::*};
|
use sp_std::{marker::PhantomData, prelude::*};
|
||||||
|
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
@@ -109,6 +113,7 @@ impl<T: Config<I>, I: 'static, M: GetMaxVoters> Tally<T, I, M> {
|
|||||||
|
|
||||||
pub type TallyOf<T, I = ()> = Tally<T, I, Pallet<T, I>>;
|
pub type TallyOf<T, I = ()> = Tally<T, I, Pallet<T, I>>;
|
||||||
pub type PollIndexOf<T, I = ()> = <<T as Config<I>>::Polls as Polling<TallyOf<T, I>>>::Index;
|
pub type PollIndexOf<T, I = ()> = <<T as Config<I>>::Polls as Polling<TallyOf<T, I>>>::Index;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
impl<T: Config<I>, I: 'static, M: GetMaxVoters> VoteTally<Votes, Rank> for Tally<T, I, M> {
|
impl<T: Config<I>, I: 'static, M: GetMaxVoters> VoteTally<Votes, Rank> for Tally<T, I, M> {
|
||||||
fn new(_: Rank) -> Self {
|
fn new(_: Rank) -> Self {
|
||||||
@@ -466,8 +471,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Weight: `O(1)`
|
/// Weight: `O(1)`
|
||||||
#[pallet::weight(T::WeightInfo::add_member())]
|
#[pallet::weight(T::WeightInfo::add_member())]
|
||||||
pub fn add_member(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
pub fn add_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
let _ = T::PromoteOrigin::ensure_origin(origin)?;
|
let _ = T::PromoteOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
Self::do_add_member(who)
|
Self::do_add_member(who)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,8 +484,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Weight: `O(1)`
|
/// Weight: `O(1)`
|
||||||
#[pallet::weight(T::WeightInfo::promote_member(0))]
|
#[pallet::weight(T::WeightInfo::promote_member(0))]
|
||||||
pub fn promote_member(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
pub fn promote_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
let max_rank = T::PromoteOrigin::ensure_origin(origin)?;
|
let max_rank = T::PromoteOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
Self::do_promote_member(who, Some(max_rank))
|
Self::do_promote_member(who, Some(max_rank))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,8 +498,9 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Weight: `O(1)`, less if the member's index is highest in its rank.
|
/// Weight: `O(1)`, less if the member's index is highest in its rank.
|
||||||
#[pallet::weight(T::WeightInfo::demote_member(0))]
|
#[pallet::weight(T::WeightInfo::demote_member(0))]
|
||||||
pub fn demote_member(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
pub fn demote_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
let max_rank = T::DemoteOrigin::ensure_origin(origin)?;
|
let max_rank = T::DemoteOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
let mut record = Self::ensure_member(&who)?;
|
let mut record = Self::ensure_member(&who)?;
|
||||||
let rank = record.rank;
|
let rank = record.rank;
|
||||||
ensure!(max_rank >= rank, Error::<T, I>::NoPermission);
|
ensure!(max_rank >= rank, Error::<T, I>::NoPermission);
|
||||||
@@ -523,10 +531,11 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::remove_member(*min_rank as u32))]
|
#[pallet::weight(T::WeightInfo::remove_member(*min_rank as u32))]
|
||||||
pub fn remove_member(
|
pub fn remove_member(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: T::AccountId,
|
who: AccountIdLookupOf<T>,
|
||||||
min_rank: Rank,
|
min_rank: Rank,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let max_rank = T::DemoteOrigin::ensure_origin(origin)?;
|
let max_rank = T::DemoteOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
let MemberRecord { rank, .. } = Self::ensure_member(&who)?;
|
let MemberRecord { rank, .. } = Self::ensure_member(&who)?;
|
||||||
ensure!(min_rank >= rank, Error::<T, I>::InvalidWitness);
|
ensure!(min_rank >= rank, Error::<T, I>::InvalidWitness);
|
||||||
ensure!(max_rank >= rank, Error::<T, I>::NoPermission);
|
ensure!(max_rank >= rank, Error::<T, I>::NoPermission);
|
||||||
|
|||||||
@@ -106,22 +106,25 @@ benchmarks! {
|
|||||||
as_recovered {
|
as_recovered {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let recovered_account: T::AccountId = account("recovered_account", 0, SEED);
|
let recovered_account: T::AccountId = account("recovered_account", 0, SEED);
|
||||||
|
let recovered_account_lookup = T::Lookup::unlookup(recovered_account.clone());
|
||||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||||
|
|
||||||
Proxy::<T>::insert(&caller, &recovered_account);
|
Proxy::<T>::insert(&caller, &recovered_account);
|
||||||
}: _(
|
}: _(
|
||||||
RawOrigin::Signed(caller),
|
RawOrigin::Signed(caller),
|
||||||
recovered_account,
|
recovered_account_lookup,
|
||||||
Box::new(call)
|
Box::new(call)
|
||||||
)
|
)
|
||||||
|
|
||||||
set_recovered {
|
set_recovered {
|
||||||
let lost: T::AccountId = whitelisted_caller();
|
let lost: T::AccountId = whitelisted_caller();
|
||||||
|
let lost_lookup = T::Lookup::unlookup(lost.clone());
|
||||||
let rescuer: T::AccountId = whitelisted_caller();
|
let rescuer: T::AccountId = whitelisted_caller();
|
||||||
|
let rescuer_lookup = T::Lookup::unlookup(rescuer.clone());
|
||||||
}: _(
|
}: _(
|
||||||
RawOrigin::Root,
|
RawOrigin::Root,
|
||||||
lost.clone(),
|
lost_lookup,
|
||||||
rescuer.clone()
|
rescuer_lookup
|
||||||
) verify {
|
) verify {
|
||||||
assert_last_event::<T>(
|
assert_last_event::<T>(
|
||||||
Event::AccountRecovered {
|
Event::AccountRecovered {
|
||||||
@@ -153,11 +156,12 @@ benchmarks! {
|
|||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let lost_account: T::AccountId = account("lost_account", 0, SEED);
|
let lost_account: T::AccountId = account("lost_account", 0, SEED);
|
||||||
|
let lost_account_lookup = T::Lookup::unlookup(lost_account.clone());
|
||||||
|
|
||||||
insert_recovery_account::<T>(&caller, &lost_account);
|
insert_recovery_account::<T>(&caller, &lost_account);
|
||||||
}: _(
|
}: _(
|
||||||
RawOrigin::Signed(caller.clone()),
|
RawOrigin::Signed(caller.clone()),
|
||||||
lost_account.clone()
|
lost_account_lookup
|
||||||
) verify {
|
) verify {
|
||||||
assert_last_event::<T>(
|
assert_last_event::<T>(
|
||||||
Event::RecoveryInitiated {
|
Event::RecoveryInitiated {
|
||||||
@@ -172,7 +176,10 @@ benchmarks! {
|
|||||||
|
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let lost_account: T::AccountId = account("lost_account", 0, SEED);
|
let lost_account: T::AccountId = account("lost_account", 0, SEED);
|
||||||
|
let lost_account_lookup = T::Lookup::unlookup(lost_account.clone());
|
||||||
let rescuer_account: T::AccountId = account("rescuer_account", 0, SEED);
|
let rescuer_account: T::AccountId = account("rescuer_account", 0, SEED);
|
||||||
|
let rescuer_account_lookup = T::Lookup::unlookup(rescuer_account.clone());
|
||||||
|
|
||||||
|
|
||||||
// Create friends
|
// Create friends
|
||||||
let friends = add_caller_and_generate_friends::<T>(caller.clone(), n);
|
let friends = add_caller_and_generate_friends::<T>(caller.clone(), n);
|
||||||
@@ -206,8 +213,8 @@ benchmarks! {
|
|||||||
|
|
||||||
}: _(
|
}: _(
|
||||||
RawOrigin::Signed(caller.clone()),
|
RawOrigin::Signed(caller.clone()),
|
||||||
lost_account.clone(),
|
lost_account_lookup,
|
||||||
rescuer_account.clone()
|
rescuer_account_lookup
|
||||||
) verify {
|
) verify {
|
||||||
assert_last_event::<T>(
|
assert_last_event::<T>(
|
||||||
Event::RecoveryVouched {
|
Event::RecoveryVouched {
|
||||||
@@ -223,6 +230,7 @@ benchmarks! {
|
|||||||
|
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let lost_account: T::AccountId = account("lost_account", 0, SEED);
|
let lost_account: T::AccountId = account("lost_account", 0, SEED);
|
||||||
|
let lost_account_lookup = T::Lookup::unlookup(lost_account.clone());
|
||||||
|
|
||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
@@ -257,7 +265,7 @@ benchmarks! {
|
|||||||
<ActiveRecoveries<T>>::insert(&lost_account, &caller, recovery_status);
|
<ActiveRecoveries<T>>::insert(&lost_account, &caller, recovery_status);
|
||||||
}: _(
|
}: _(
|
||||||
RawOrigin::Signed(caller.clone()),
|
RawOrigin::Signed(caller.clone()),
|
||||||
lost_account.clone()
|
lost_account_lookup
|
||||||
) verify {
|
) verify {
|
||||||
assert_last_event::<T>(
|
assert_last_event::<T>(
|
||||||
Event::AccountRecovered {
|
Event::AccountRecovered {
|
||||||
@@ -270,6 +278,7 @@ benchmarks! {
|
|||||||
close_recovery {
|
close_recovery {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let rescuer_account: T::AccountId = account("rescuer_account", 0, SEED);
|
let rescuer_account: T::AccountId = account("rescuer_account", 0, SEED);
|
||||||
|
let rescuer_account_lookup = T::Lookup::unlookup(rescuer_account.clone());
|
||||||
|
|
||||||
let n in 1 .. T::MaxFriends::get();
|
let n in 1 .. T::MaxFriends::get();
|
||||||
|
|
||||||
@@ -307,7 +316,7 @@ benchmarks! {
|
|||||||
<ActiveRecoveries<T>>::insert(&caller, &rescuer_account, recovery_status);
|
<ActiveRecoveries<T>>::insert(&caller, &rescuer_account, recovery_status);
|
||||||
}: _(
|
}: _(
|
||||||
RawOrigin::Signed(caller.clone()),
|
RawOrigin::Signed(caller.clone()),
|
||||||
rescuer_account.clone()
|
rescuer_account_lookup
|
||||||
) verify {
|
) verify {
|
||||||
assert_last_event::<T>(
|
assert_last_event::<T>(
|
||||||
Event::RecoveryClosed {
|
Event::RecoveryClosed {
|
||||||
@@ -356,6 +365,7 @@ benchmarks! {
|
|||||||
cancel_recovered {
|
cancel_recovered {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let account: T::AccountId = account("account", 0, SEED);
|
let account: T::AccountId = account("account", 0, SEED);
|
||||||
|
let account_lookup = T::Lookup::unlookup(account.clone());
|
||||||
|
|
||||||
frame_system::Pallet::<T>::inc_providers(&caller);
|
frame_system::Pallet::<T>::inc_providers(&caller);
|
||||||
|
|
||||||
@@ -364,7 +374,7 @@ benchmarks! {
|
|||||||
Proxy::<T>::insert(&caller, &account);
|
Proxy::<T>::insert(&caller, &account);
|
||||||
}: _(
|
}: _(
|
||||||
RawOrigin::Signed(caller),
|
RawOrigin::Signed(caller),
|
||||||
account
|
account_lookup
|
||||||
)
|
)
|
||||||
|
|
||||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||||
|
|||||||
@@ -156,7 +156,7 @@
|
|||||||
|
|
||||||
use codec::{Decode, Encode, MaxEncodedLen};
|
use codec::{Decode, Encode, MaxEncodedLen};
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_runtime::traits::{CheckedAdd, CheckedMul, Dispatchable, SaturatedConversion};
|
use sp_runtime::traits::{CheckedAdd, CheckedMul, Dispatchable, SaturatedConversion, StaticLookup};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
@@ -182,6 +182,7 @@ type BalanceOf<T> =
|
|||||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
|
|
||||||
type FriendsOf<T> = BoundedVec<<T as frame_system::Config>::AccountId, <T as Config>::MaxFriends>;
|
type FriendsOf<T> = BoundedVec<<T as frame_system::Config>::AccountId, <T as Config>::MaxFriends>;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// An active recovery process.
|
/// An active recovery process.
|
||||||
#[derive(Clone, Eq, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
#[derive(Clone, Eq, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||||
@@ -382,10 +383,11 @@ pub mod pallet {
|
|||||||
)})]
|
)})]
|
||||||
pub fn as_recovered(
|
pub fn as_recovered(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
account: T::AccountId,
|
account: AccountIdLookupOf<T>,
|
||||||
call: Box<<T as Config>::Call>,
|
call: Box<<T as Config>::Call>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let account = T::Lookup::lookup(account)?;
|
||||||
// Check `who` is allowed to make a call on behalf of `account`
|
// Check `who` is allowed to make a call on behalf of `account`
|
||||||
let target = Self::proxy(&who).ok_or(Error::<T>::NotAllowed)?;
|
let target = Self::proxy(&who).ok_or(Error::<T>::NotAllowed)?;
|
||||||
ensure!(target == account, Error::<T>::NotAllowed);
|
ensure!(target == account, Error::<T>::NotAllowed);
|
||||||
@@ -405,10 +407,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::set_recovered())]
|
#[pallet::weight(T::WeightInfo::set_recovered())]
|
||||||
pub fn set_recovered(
|
pub fn set_recovered(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
lost: T::AccountId,
|
lost: AccountIdLookupOf<T>,
|
||||||
rescuer: T::AccountId,
|
rescuer: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
|
let lost = T::Lookup::lookup(lost)?;
|
||||||
|
let rescuer = T::Lookup::lookup(rescuer)?;
|
||||||
// Create the recovery storage item.
|
// Create the recovery storage item.
|
||||||
<Proxy<T>>::insert(&rescuer, &lost);
|
<Proxy<T>>::insert(&rescuer, &lost);
|
||||||
Self::deposit_event(Event::<T>::AccountRecovered {
|
Self::deposit_event(Event::<T>::AccountRecovered {
|
||||||
@@ -486,8 +490,12 @@ pub mod pallet {
|
|||||||
/// - `account`: The lost account that you want to recover. This account needs to be
|
/// - `account`: The lost account that you want to recover. This account needs to be
|
||||||
/// recoverable (i.e. have a recovery configuration).
|
/// recoverable (i.e. have a recovery configuration).
|
||||||
#[pallet::weight(T::WeightInfo::initiate_recovery())]
|
#[pallet::weight(T::WeightInfo::initiate_recovery())]
|
||||||
pub fn initiate_recovery(origin: OriginFor<T>, account: T::AccountId) -> DispatchResult {
|
pub fn initiate_recovery(
|
||||||
|
origin: OriginFor<T>,
|
||||||
|
account: AccountIdLookupOf<T>,
|
||||||
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let account = T::Lookup::lookup(account)?;
|
||||||
// Check that the account is recoverable
|
// Check that the account is recoverable
|
||||||
ensure!(<Recoverable<T>>::contains_key(&account), Error::<T>::NotRecoverable);
|
ensure!(<Recoverable<T>>::contains_key(&account), Error::<T>::NotRecoverable);
|
||||||
// Check that the recovery process has not already been started
|
// Check that the recovery process has not already been started
|
||||||
@@ -528,10 +536,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::vouch_recovery(T::MaxFriends::get()))]
|
#[pallet::weight(T::WeightInfo::vouch_recovery(T::MaxFriends::get()))]
|
||||||
pub fn vouch_recovery(
|
pub fn vouch_recovery(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
lost: T::AccountId,
|
lost: AccountIdLookupOf<T>,
|
||||||
rescuer: T::AccountId,
|
rescuer: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let lost = T::Lookup::lookup(lost)?;
|
||||||
|
let rescuer = T::Lookup::lookup(rescuer)?;
|
||||||
// Get the recovery configuration for the lost account.
|
// Get the recovery configuration for the lost account.
|
||||||
let recovery_config = Self::recovery_config(&lost).ok_or(Error::<T>::NotRecoverable)?;
|
let recovery_config = Self::recovery_config(&lost).ok_or(Error::<T>::NotRecoverable)?;
|
||||||
// Get the active recovery process for the rescuer.
|
// Get the active recovery process for the rescuer.
|
||||||
@@ -567,8 +577,12 @@ pub mod pallet {
|
|||||||
/// - `account`: The lost account that you want to claim has been successfully recovered by
|
/// - `account`: The lost account that you want to claim has been successfully recovered by
|
||||||
/// you.
|
/// you.
|
||||||
#[pallet::weight(T::WeightInfo::claim_recovery(T::MaxFriends::get()))]
|
#[pallet::weight(T::WeightInfo::claim_recovery(T::MaxFriends::get()))]
|
||||||
pub fn claim_recovery(origin: OriginFor<T>, account: T::AccountId) -> DispatchResult {
|
pub fn claim_recovery(
|
||||||
|
origin: OriginFor<T>,
|
||||||
|
account: AccountIdLookupOf<T>,
|
||||||
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let account = T::Lookup::lookup(account)?;
|
||||||
// Get the recovery configuration for the lost account
|
// Get the recovery configuration for the lost account
|
||||||
let recovery_config =
|
let recovery_config =
|
||||||
Self::recovery_config(&account).ok_or(Error::<T>::NotRecoverable)?;
|
Self::recovery_config(&account).ok_or(Error::<T>::NotRecoverable)?;
|
||||||
@@ -610,8 +624,12 @@ pub mod pallet {
|
|||||||
/// Parameters:
|
/// Parameters:
|
||||||
/// - `rescuer`: The account trying to rescue this recoverable account.
|
/// - `rescuer`: The account trying to rescue this recoverable account.
|
||||||
#[pallet::weight(T::WeightInfo::close_recovery(T::MaxFriends::get()))]
|
#[pallet::weight(T::WeightInfo::close_recovery(T::MaxFriends::get()))]
|
||||||
pub fn close_recovery(origin: OriginFor<T>, rescuer: T::AccountId) -> DispatchResult {
|
pub fn close_recovery(
|
||||||
|
origin: OriginFor<T>,
|
||||||
|
rescuer: AccountIdLookupOf<T>,
|
||||||
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let rescuer = T::Lookup::lookup(rescuer)?;
|
||||||
// Take the active recovery process started by the rescuer for this account.
|
// Take the active recovery process started by the rescuer for this account.
|
||||||
let active_recovery =
|
let active_recovery =
|
||||||
<ActiveRecoveries<T>>::take(&who, &rescuer).ok_or(Error::<T>::NotStarted)?;
|
<ActiveRecoveries<T>>::take(&who, &rescuer).ok_or(Error::<T>::NotStarted)?;
|
||||||
@@ -665,8 +683,12 @@ pub mod pallet {
|
|||||||
/// Parameters:
|
/// Parameters:
|
||||||
/// - `account`: The recovered account you are able to call on-behalf-of.
|
/// - `account`: The recovered account you are able to call on-behalf-of.
|
||||||
#[pallet::weight(T::WeightInfo::cancel_recovered())]
|
#[pallet::weight(T::WeightInfo::cancel_recovered())]
|
||||||
pub fn cancel_recovered(origin: OriginFor<T>, account: T::AccountId) -> DispatchResult {
|
pub fn cancel_recovered(
|
||||||
|
origin: OriginFor<T>,
|
||||||
|
account: AccountIdLookupOf<T>,
|
||||||
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
let account = T::Lookup::lookup(account)?;
|
||||||
// Check `who` is allowed to make a call on behalf of `account`
|
// Check `who` is allowed to make a call on behalf of `account`
|
||||||
ensure!(Self::proxy(&who) == Some(account), Error::<T>::NotAllowed);
|
ensure!(Self::proxy(&who) == Some(account), Error::<T>::NotAllowed);
|
||||||
Proxy::<T>::remove(&who);
|
Proxy::<T>::remove(&who);
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ use sp_std::{fmt::Debug, prelude::*};
|
|||||||
type BalanceOf<T, I> =
|
type BalanceOf<T, I> =
|
||||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
type PoolT<T, I> = Vec<(<T as frame_system::Config>::AccountId, Option<<T as Config<I>>::Score>)>;
|
type PoolT<T, I> = Vec<(<T as frame_system::Config>::AccountId, Option<<T as Config<I>>::Score>)>;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// The enum is supplied when refreshing the members set.
|
/// The enum is supplied when refreshing the members set.
|
||||||
/// Depending on the enum variant the corresponding associated
|
/// Depending on the enum variant the corresponding associated
|
||||||
@@ -346,7 +347,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(0)]
|
#[pallet::weight(0)]
|
||||||
pub fn kick(
|
pub fn kick(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
index: u32,
|
index: u32,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::KickOrigin::ensure_origin(origin)?;
|
T::KickOrigin::ensure_origin(origin)?;
|
||||||
@@ -370,7 +371,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(0)]
|
#[pallet::weight(0)]
|
||||||
pub fn score(
|
pub fn score(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
index: u32,
|
index: u32,
|
||||||
score: T::Score,
|
score: T::Score,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
|
|||||||
@@ -281,6 +281,7 @@ type BalanceOf<T, I> =
|
|||||||
type NegativeImbalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<
|
type NegativeImbalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<
|
||||||
<T as frame_system::Config>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
>>::NegativeImbalance;
|
>>::NegativeImbalance;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// A vote by a member on a candidate application.
|
/// A vote by a member on a candidate application.
|
||||||
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||||
@@ -823,11 +824,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
||||||
pub fn vouch(
|
pub fn vouch(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: T::AccountId,
|
who: AccountIdLookupOf<T>,
|
||||||
value: BalanceOf<T, I>,
|
value: BalanceOf<T, I>,
|
||||||
tip: BalanceOf<T, I>,
|
tip: BalanceOf<T, I>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let voucher = ensure_signed(origin)?;
|
let voucher = ensure_signed(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
// Check user is not suspended.
|
// Check user is not suspended.
|
||||||
ensure!(!<SuspendedCandidates<T, I>>::contains_key(&who), Error::<T, I>::Suspended);
|
ensure!(!<SuspendedCandidates<T, I>>::contains_key(&who), Error::<T, I>::Suspended);
|
||||||
ensure!(!<SuspendedMembers<T, I>>::contains_key(&who), Error::<T, I>::Suspended);
|
ensure!(!<SuspendedMembers<T, I>>::contains_key(&who), Error::<T, I>::Suspended);
|
||||||
@@ -914,7 +916,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
||||||
pub fn vote(
|
pub fn vote(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
candidate: <T::Lookup as StaticLookup>::Source,
|
candidate: AccountIdLookupOf<T>,
|
||||||
approve: bool,
|
approve: bool,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let voter = ensure_signed(origin)?;
|
let voter = ensure_signed(origin)?;
|
||||||
@@ -1026,11 +1028,12 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
||||||
pub fn found(
|
pub fn found(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
founder: T::AccountId,
|
founder: AccountIdLookupOf<T>,
|
||||||
max_members: u32,
|
max_members: u32,
|
||||||
rules: Vec<u8>,
|
rules: Vec<u8>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::FounderSetOrigin::ensure_origin(origin)?;
|
T::FounderSetOrigin::ensure_origin(origin)?;
|
||||||
|
let founder = T::Lookup::lookup(founder)?;
|
||||||
ensure!(!<Head<T, I>>::exists(), Error::<T, I>::AlreadyFounded);
|
ensure!(!<Head<T, I>>::exists(), Error::<T, I>::AlreadyFounded);
|
||||||
ensure!(max_members > 1, Error::<T, I>::MaxMembers);
|
ensure!(max_members > 1, Error::<T, I>::MaxMembers);
|
||||||
// This should never fail in the context of this function...
|
// This should never fail in the context of this function...
|
||||||
@@ -1104,10 +1107,11 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
||||||
pub fn judge_suspended_member(
|
pub fn judge_suspended_member(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: T::AccountId,
|
who: AccountIdLookupOf<T>,
|
||||||
forgive: bool,
|
forgive: bool,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
|
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
ensure!(<SuspendedMembers<T, I>>::contains_key(&who), Error::<T, I>::NotSuspended);
|
ensure!(<SuspendedMembers<T, I>>::contains_key(&who), Error::<T, I>::NotSuspended);
|
||||||
|
|
||||||
if forgive {
|
if forgive {
|
||||||
@@ -1180,10 +1184,11 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
|
||||||
pub fn judge_suspended_candidate(
|
pub fn judge_suspended_candidate(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: T::AccountId,
|
who: AccountIdLookupOf<T>,
|
||||||
judgement: Judgement,
|
judgement: Judgement,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
|
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
if let Some((value, kind)) = <SuspendedCandidates<T, I>>::get(&who) {
|
if let Some((value, kind)) = <SuspendedCandidates<T, I>>::get(&who) {
|
||||||
match judgement {
|
match judgement {
|
||||||
Judgement::Approve => {
|
Judgement::Approve => {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ pub fn create_validator_with_nominators<T: Config>(
|
|||||||
let validator_prefs =
|
let validator_prefs =
|
||||||
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
||||||
Staking::<T>::validate(RawOrigin::Signed(v_controller).into(), validator_prefs)?;
|
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_total += 10;
|
||||||
points_individual.push((v_stash.clone(), 10));
|
points_individual.push((v_stash.clone(), 10));
|
||||||
@@ -217,8 +217,7 @@ benchmarks! {
|
|||||||
bond {
|
bond {
|
||||||
let stash = create_funded_user::<T>("stash", USER_SEED, 100);
|
let stash = create_funded_user::<T>("stash", USER_SEED, 100);
|
||||||
let controller = create_funded_user::<T>("controller", USER_SEED, 100);
|
let controller = create_funded_user::<T>("controller", USER_SEED, 100);
|
||||||
let controller_lookup: <T::Lookup as StaticLookup>::Source
|
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||||
= T::Lookup::unlookup(controller.clone());
|
|
||||||
let reward_destination = RewardDestination::Staked;
|
let reward_destination = RewardDestination::Staked;
|
||||||
let amount = T::Currency::minimum_balance() * 10u32.into();
|
let amount = T::Currency::minimum_balance() * 10u32.into();
|
||||||
whitelist_account!(stash);
|
whitelist_account!(stash);
|
||||||
@@ -365,7 +364,7 @@ benchmarks! {
|
|||||||
100,
|
100,
|
||||||
Default::default(),
|
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.
|
// they start validating.
|
||||||
Staking::<T>::validate(RawOrigin::Signed(controller.clone()).into(), Default::default())?;
|
Staking::<T>::validate(RawOrigin::Signed(controller.clone()).into(), Default::default())?;
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ use frame_support::{
|
|||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
curve::PiecewiseLinear,
|
curve::PiecewiseLinear,
|
||||||
traits::{AtLeast32BitUnsigned, Convert, Saturating, Zero},
|
traits::{AtLeast32BitUnsigned, Convert, Saturating, StaticLookup, Zero},
|
||||||
Perbill, Perquintill, RuntimeDebug,
|
Perbill, Perquintill, RuntimeDebug,
|
||||||
};
|
};
|
||||||
use sp_staking::{
|
use sp_staking::{
|
||||||
@@ -347,6 +347,8 @@ type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
|
|||||||
<T as frame_system::Config>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
>>::NegativeImbalance;
|
>>::NegativeImbalance;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub MaxUnlockingChunks: u32 = 32;
|
pub MaxUnlockingChunks: u32 = 32;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ mod impls;
|
|||||||
pub use impls::*;
|
pub use impls::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, EraPayout, EraRewardPoints, Exposure,
|
slashing, weights::WeightInfo, AccountIdLookupOf, ActiveEraInfo, BalanceOf, EraPayout,
|
||||||
Forcing, MaxUnlockingChunks, NegativeImbalanceOf, Nominations, PositiveImbalanceOf, Releases,
|
EraRewardPoints, Exposure, Forcing, MaxUnlockingChunks, NegativeImbalanceOf, Nominations,
|
||||||
RewardDestination, SessionInterface, StakingLedger, UnappliedSlash, UnlockChunk,
|
PositiveImbalanceOf, Releases, RewardDestination, SessionInterface, StakingLedger,
|
||||||
ValidatorPrefs,
|
UnappliedSlash, UnlockChunk, ValidatorPrefs,
|
||||||
};
|
};
|
||||||
|
|
||||||
const STAKING_ID: LockIdentifier = *b"staking ";
|
const STAKING_ID: LockIdentifier = *b"staking ";
|
||||||
@@ -768,7 +768,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::bond())]
|
#[pallet::weight(T::WeightInfo::bond())]
|
||||||
pub fn bond(
|
pub fn bond(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
controller: <T::Lookup as StaticLookup>::Source,
|
controller: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] value: BalanceOf<T>,
|
#[pallet::compact] value: BalanceOf<T>,
|
||||||
payee: RewardDestination<T::AccountId>,
|
payee: RewardDestination<T::AccountId>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
@@ -1055,7 +1055,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::nominate(targets.len() as u32))]
|
#[pallet::weight(T::WeightInfo::nominate(targets.len() as u32))]
|
||||||
pub fn nominate(
|
pub fn nominate(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
targets: Vec<<T::Lookup as StaticLookup>::Source>,
|
targets: Vec<AccountIdLookupOf<T>>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let controller = ensure_signed(origin)?;
|
let controller = ensure_signed(origin)?;
|
||||||
|
|
||||||
@@ -1175,7 +1175,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::set_controller())]
|
#[pallet::weight(T::WeightInfo::set_controller())]
|
||||||
pub fn set_controller(
|
pub fn set_controller(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
controller: <T::Lookup as StaticLookup>::Source,
|
controller: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let stash = ensure_signed(origin)?;
|
let stash = ensure_signed(origin)?;
|
||||||
let old_controller = Self::bonded(&stash).ok_or(Error::<T>::NotStash)?;
|
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
|
/// Note: Making this call only makes sense if you first set the validator preferences to
|
||||||
/// block any further nominations.
|
/// block any further nominations.
|
||||||
#[pallet::weight(T::WeightInfo::kick(who.len() as u32))]
|
#[pallet::weight(T::WeightInfo::kick(who.len() as u32))]
|
||||||
pub fn kick(
|
pub fn kick(origin: OriginFor<T>, who: Vec<AccountIdLookupOf<T>>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
who: Vec<<T::Lookup as StaticLookup>::Source>,
|
|
||||||
) -> DispatchResult {
|
|
||||||
let controller = ensure_signed(origin)?;
|
let controller = ensure_signed(origin)?;
|
||||||
let ledger = Self::ledger(&controller).ok_or(Error::<T>::NotController)?;
|
let ledger = Self::ledger(&controller).ok_or(Error::<T>::NotController)?;
|
||||||
let stash = &ledger.stash;
|
let stash = &ledger.stash;
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ pub fn create_stash_controller<T: Config>(
|
|||||||
) -> Result<(T::AccountId, T::AccountId), &'static str> {
|
) -> Result<(T::AccountId, T::AccountId), &'static str> {
|
||||||
let stash = create_funded_user::<T>("stash", n, balance_factor);
|
let stash = create_funded_user::<T>("stash", n, balance_factor);
|
||||||
let controller = create_funded_user::<T>("controller", n, balance_factor);
|
let controller = create_funded_user::<T>("controller", n, balance_factor);
|
||||||
let controller_lookup: <T::Lookup as StaticLookup>::Source =
|
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||||
T::Lookup::unlookup(controller.clone());
|
|
||||||
let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into();
|
let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into();
|
||||||
Staking::<T>::bond(
|
Staking::<T>::bond(
|
||||||
RawOrigin::Signed(stash.clone()).into(),
|
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> {
|
) -> Result<(T::AccountId, T::AccountId), &'static str> {
|
||||||
let stash = create_funded_user_with_balance::<T>("stash", n, balance);
|
let stash = create_funded_user_with_balance::<T>("stash", n, balance);
|
||||||
let controller = create_funded_user_with_balance::<T>("controller", n, balance);
|
let controller = create_funded_user_with_balance::<T>("controller", n, balance);
|
||||||
let controller_lookup: <T::Lookup as StaticLookup>::Source =
|
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||||
T::Lookup::unlookup(controller.clone());
|
|
||||||
|
|
||||||
Staking::<T>::bond(
|
Staking::<T>::bond(
|
||||||
RawOrigin::Signed(stash.clone()).into(),
|
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);
|
let stash = create_funded_user::<T>("stash", n, balance_factor);
|
||||||
// controller has no funds
|
// controller has no funds
|
||||||
let controller = create_funded_user::<T>("controller", n, 0);
|
let controller = create_funded_user::<T>("controller", n, 0);
|
||||||
let controller_lookup: <T::Lookup as StaticLookup>::Source =
|
let controller_lookup = T::Lookup::unlookup(controller.clone());
|
||||||
T::Lookup::unlookup(controller.clone());
|
|
||||||
let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into();
|
let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into();
|
||||||
Staking::<T>::bond(
|
Staking::<T>::bond(
|
||||||
RawOrigin::Signed(stash.clone()).into(),
|
RawOrigin::Signed(stash.clone()).into(),
|
||||||
@@ -136,7 +133,7 @@ pub fn create_stash_and_dead_controller<T: Config>(
|
|||||||
pub fn create_validators<T: Config>(
|
pub fn create_validators<T: Config>(
|
||||||
max: u32,
|
max: u32,
|
||||||
balance_factor: 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)
|
create_validators_with_seed::<T>(max, balance_factor, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,15 +142,15 @@ pub fn create_validators_with_seed<T: Config>(
|
|||||||
max: u32,
|
max: u32,
|
||||||
balance_factor: u32,
|
balance_factor: u32,
|
||||||
seed: u32,
|
seed: u32,
|
||||||
) -> Result<Vec<<T::Lookup as StaticLookup>::Source>, &'static str> {
|
) -> Result<Vec<AccountIdLookupOf<T>>, &'static str> {
|
||||||
let mut validators: Vec<<T::Lookup as StaticLookup>::Source> = Vec::with_capacity(max as usize);
|
let mut validators: Vec<AccountIdLookupOf<T>> = Vec::with_capacity(max as usize);
|
||||||
for i in 0..max {
|
for i in 0..max {
|
||||||
let (stash, controller) =
|
let (stash, controller) =
|
||||||
create_stash_controller::<T>(i + seed, balance_factor, RewardDestination::Staked)?;
|
create_stash_controller::<T>(i + seed, balance_factor, RewardDestination::Staked)?;
|
||||||
let validator_prefs =
|
let validator_prefs =
|
||||||
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
||||||
Staking::<T>::validate(RawOrigin::Signed(controller).into(), validator_prefs)?;
|
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);
|
validators.push(stash_lookup);
|
||||||
}
|
}
|
||||||
Ok(validators)
|
Ok(validators)
|
||||||
@@ -180,11 +177,10 @@ pub fn create_validators_with_nominators_for_era<T: Config>(
|
|||||||
edge_per_nominator: usize,
|
edge_per_nominator: usize,
|
||||||
randomize_stake: bool,
|
randomize_stake: bool,
|
||||||
to_nominate: Option<u32>,
|
to_nominate: Option<u32>,
|
||||||
) -> Result<Vec<<T::Lookup as StaticLookup>::Source>, &'static str> {
|
) -> Result<Vec<AccountIdLookupOf<T>>, &'static str> {
|
||||||
clear_validators_and_nominators::<T>();
|
clear_validators_and_nominators::<T>();
|
||||||
|
|
||||||
let mut validators_stash: Vec<<T::Lookup as StaticLookup>::Source> =
|
let mut validators_stash: Vec<AccountIdLookupOf<T>> = Vec::with_capacity(validators as usize);
|
||||||
Vec::with_capacity(validators as usize);
|
|
||||||
let mut rng = ChaChaRng::from_seed(SEED.using_encoded(blake2_256));
|
let mut rng = ChaChaRng::from_seed(SEED.using_encoded(blake2_256));
|
||||||
|
|
||||||
// Create validators
|
// Create validators
|
||||||
@@ -195,8 +191,7 @@ pub fn create_validators_with_nominators_for_era<T: Config>(
|
|||||||
let validator_prefs =
|
let validator_prefs =
|
||||||
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
|
||||||
Staking::<T>::validate(RawOrigin::Signed(v_controller.clone()).into(), validator_prefs)?;
|
Staking::<T>::validate(RawOrigin::Signed(v_controller.clone()).into(), validator_prefs)?;
|
||||||
let stash_lookup: <T::Lookup as StaticLookup>::Source =
|
let stash_lookup = T::Lookup::unlookup(v_stash.clone());
|
||||||
T::Lookup::unlookup(v_stash.clone());
|
|
||||||
validators_stash.push(stash_lookup.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
|
// Have them randomly validate
|
||||||
let mut available_validators = validator_chosen.clone();
|
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);
|
Vec::with_capacity(edge_per_nominator);
|
||||||
|
|
||||||
for _ in 0..validators.min(edge_per_nominator as u32) {
|
for _ in 0..validators.min(edge_per_nominator as u32) {
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ mod tests;
|
|||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::{DispatchResult, *};
|
use super::{DispatchResult, *};
|
||||||
@@ -192,7 +194,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(0)]
|
#[pallet::weight(0)]
|
||||||
pub fn set_key(
|
pub fn set_key(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
new: <T::Lookup as StaticLookup>::Source,
|
new: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
// This is a public call, so we ensure that the origin is some signed account.
|
// This is a public call, so we ensure that the origin is some signed account.
|
||||||
let sender = ensure_signed(origin)?;
|
let sender = ensure_signed(origin)?;
|
||||||
@@ -228,7 +230,7 @@ pub mod pallet {
|
|||||||
})]
|
})]
|
||||||
pub fn sudo_as(
|
pub fn sudo_as(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
who: <T::Lookup as StaticLookup>::Source,
|
who: AccountIdLookupOf<T>,
|
||||||
call: Box<<T as Config>::Call>,
|
call: Box<<T as Config>::Call>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
// This is a public call, so we ensure that the origin is some signed account.
|
// This is a public call, so we ensure that the origin is some signed account.
|
||||||
|
|||||||
@@ -92,18 +92,20 @@ benchmarks_instance_pallet! {
|
|||||||
report_awesome {
|
report_awesome {
|
||||||
let r in 0 .. T::MaximumReasonLength::get();
|
let r in 0 .. T::MaximumReasonLength::get();
|
||||||
let (caller, reason, awesome_person) = setup_awesome::<T, I>(r);
|
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.
|
// Whitelist caller account from further DB operations.
|
||||||
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
||||||
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
||||||
}: _(RawOrigin::Signed(caller), reason, awesome_person)
|
}: _(RawOrigin::Signed(caller), reason, awesome_person_lookup)
|
||||||
|
|
||||||
retract_tip {
|
retract_tip {
|
||||||
let r = T::MaximumReasonLength::get();
|
let r = T::MaximumReasonLength::get();
|
||||||
let (caller, reason, awesome_person) = setup_awesome::<T, I>(r);
|
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(
|
TipsMod::<T, I>::report_awesome(
|
||||||
RawOrigin::Signed(caller.clone()).into(),
|
RawOrigin::Signed(caller.clone()).into(),
|
||||||
reason.clone(),
|
reason.clone(),
|
||||||
awesome_person.clone()
|
awesome_person_lookup
|
||||||
)?;
|
)?;
|
||||||
let reason_hash = T::Hashing::hash(&reason[..]);
|
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||||
let hash = T::Hashing::hash_of(&(&reason_hash, &awesome_person));
|
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 t in 1 .. T::Tippers::max_len() as u32;
|
||||||
|
|
||||||
let (caller, reason, beneficiary, value) = setup_tip::<T, I>(r, t)?;
|
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.
|
// Whitelist caller account from further DB operations.
|
||||||
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
||||||
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
||||||
}: _(RawOrigin::Signed(caller), reason, beneficiary, value)
|
}: _(RawOrigin::Signed(caller), reason, beneficiary_lookup, value)
|
||||||
|
|
||||||
tip {
|
tip {
|
||||||
let t in 1 .. T::Tippers::max_len() as u32;
|
let t in 1 .. T::Tippers::max_len() as u32;
|
||||||
let (member, reason, beneficiary, value) = setup_tip::<T, I>(0, t)?;
|
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());
|
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||||
TipsMod::<T, I>::tip_new(
|
TipsMod::<T, I>::tip_new(
|
||||||
RawOrigin::Signed(member).into(),
|
RawOrigin::Signed(member).into(),
|
||||||
reason.clone(),
|
reason.clone(),
|
||||||
beneficiary.clone(),
|
beneficiary_lookup,
|
||||||
value
|
value
|
||||||
)?;
|
)?;
|
||||||
let reason_hash = T::Hashing::hash(&reason[..]);
|
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||||
@@ -150,11 +154,12 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
// Set up a new tip proposal
|
// Set up a new tip proposal
|
||||||
let (member, reason, beneficiary, value) = setup_tip::<T, I>(0, t)?;
|
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());
|
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||||
TipsMod::<T, I>::tip_new(
|
TipsMod::<T, I>::tip_new(
|
||||||
RawOrigin::Signed(member).into(),
|
RawOrigin::Signed(member).into(),
|
||||||
reason.clone(),
|
reason.clone(),
|
||||||
beneficiary.clone(),
|
beneficiary_lookup,
|
||||||
value
|
value
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -179,11 +184,12 @@ benchmarks_instance_pallet! {
|
|||||||
|
|
||||||
// Set up a new tip proposal
|
// Set up a new tip proposal
|
||||||
let (member, reason, beneficiary, value) = setup_tip::<T, I>(0, t)?;
|
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());
|
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||||
TipsMod::<T, I>::tip_new(
|
TipsMod::<T, I>::tip_new(
|
||||||
RawOrigin::Signed(member).into(),
|
RawOrigin::Signed(member).into(),
|
||||||
reason.clone(),
|
reason.clone(),
|
||||||
beneficiary.clone(),
|
beneficiary_lookup,
|
||||||
value
|
value
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub mod migrations;
|
|||||||
pub mod weights;
|
pub mod weights;
|
||||||
|
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{AccountIdConversion, BadOrigin, Hash, TrailingZeroInput, Zero},
|
traits::{AccountIdConversion, BadOrigin, Hash, StaticLookup, TrailingZeroInput, Zero},
|
||||||
Percent, RuntimeDebug,
|
Percent, RuntimeDebug,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -80,6 +80,7 @@ pub use weights::WeightInfo;
|
|||||||
|
|
||||||
pub type BalanceOf<T, I = ()> = pallet_treasury::BalanceOf<T, I>;
|
pub type BalanceOf<T, I = ()> = pallet_treasury::BalanceOf<T, I>;
|
||||||
pub type NegativeImbalanceOf<T, I = ()> = pallet_treasury::NegativeImbalanceOf<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
|
/// An open tipping "motion". Retains all details of a tip including information on the finder
|
||||||
/// and the members who have voted.
|
/// and the members who have voted.
|
||||||
@@ -237,9 +238,10 @@ pub mod pallet {
|
|||||||
pub fn report_awesome(
|
pub fn report_awesome(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
reason: Vec<u8>,
|
reason: Vec<u8>,
|
||||||
who: T::AccountId,
|
who: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let finder = ensure_signed(origin)?;
|
let finder = ensure_signed(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
|
|
||||||
ensure!(
|
ensure!(
|
||||||
reason.len() <= T::MaximumReasonLength::get() as usize,
|
reason.len() <= T::MaximumReasonLength::get() as usize,
|
||||||
@@ -331,10 +333,11 @@ pub mod pallet {
|
|||||||
pub fn tip_new(
|
pub fn tip_new(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
reason: Vec<u8>,
|
reason: Vec<u8>,
|
||||||
who: T::AccountId,
|
who: AccountIdLookupOf<T>,
|
||||||
#[pallet::compact] tip_value: BalanceOf<T, I>,
|
#[pallet::compact] tip_value: BalanceOf<T, I>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let tipper = ensure_signed(origin)?;
|
let tipper = ensure_signed(origin)?;
|
||||||
|
let who = T::Lookup::lookup(who)?;
|
||||||
ensure!(T::Tippers::contains(&tipper), BadOrigin);
|
ensure!(T::Tippers::contains(&tipper), BadOrigin);
|
||||||
let reason_hash = T::Hashing::hash(&reason[..]);
|
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||||
ensure!(!Reasons::<T, I>::contains_key(&reason_hash), Error::<T, I>::AlreadyKnown);
|
ensure!(!Reasons::<T, I>::contains_key(&reason_hash), Error::<T, I>::AlreadyKnown);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const SEED: u32 = 0;
|
|||||||
// Create the pre-requisite information needed to create a treasury `propose_spend`.
|
// Create the pre-requisite information needed to create a treasury `propose_spend`.
|
||||||
fn setup_proposal<T: Config<I>, I: 'static>(
|
fn setup_proposal<T: Config<I>, I: 'static>(
|
||||||
u: u32,
|
u: u32,
|
||||||
) -> (T::AccountId, BalanceOf<T, I>, <T::Lookup as StaticLookup>::Source) {
|
) -> (T::AccountId, BalanceOf<T, I>, AccountIdLookupOf<T>) {
|
||||||
let caller = account("caller", u, SEED);
|
let caller = account("caller", u, SEED);
|
||||||
let value: BalanceOf<T, I> = T::ProposalBondMinimum::get().saturating_mul(100u32.into());
|
let value: BalanceOf<T, I> = T::ProposalBondMinimum::get().saturating_mul(100u32.into());
|
||||||
let _ = T::Currency::make_free_balance_be(&caller, value);
|
let _ = T::Currency::make_free_balance_be(&caller, value);
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ pub type PositiveImbalanceOf<T, I = ()> = <<T as Config<I>>::Currency as Currenc
|
|||||||
pub type NegativeImbalanceOf<T, I = ()> = <<T as Config<I>>::Currency as Currency<
|
pub type NegativeImbalanceOf<T, I = ()> = <<T as Config<I>>::Currency as Currency<
|
||||||
<T as frame_system::Config>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
>>::NegativeImbalance;
|
>>::NegativeImbalance;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
/// A trait to allow the Treasury Pallet to spend it's funds for other purposes.
|
/// A trait to allow the Treasury Pallet to spend it's funds for other purposes.
|
||||||
/// There is an expectation that the implementer of this trait will correctly manage
|
/// There is an expectation that the implementer of this trait will correctly manage
|
||||||
@@ -338,7 +339,7 @@ pub mod pallet {
|
|||||||
pub fn propose_spend(
|
pub fn propose_spend(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] value: BalanceOf<T, I>,
|
#[pallet::compact] value: BalanceOf<T, I>,
|
||||||
beneficiary: <T::Lookup as StaticLookup>::Source,
|
beneficiary: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let proposer = ensure_signed(origin)?;
|
let proposer = ensure_signed(origin)?;
|
||||||
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
||||||
@@ -419,7 +420,7 @@ pub mod pallet {
|
|||||||
pub fn spend(
|
pub fn spend(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
#[pallet::compact] amount: BalanceOf<T, I>,
|
#[pallet::compact] amount: BalanceOf<T, I>,
|
||||||
beneficiary: <T::Lookup as StaticLookup>::Source,
|
beneficiary: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let max_amount = T::SpendOrigin::ensure_origin(origin)?;
|
let max_amount = T::SpendOrigin::ensure_origin(origin)?;
|
||||||
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ use crate::Pallet as Uniques;
|
|||||||
const SEED: u32 = 0;
|
const SEED: u32 = 0;
|
||||||
|
|
||||||
fn create_collection<T: Config<I>, I: 'static>(
|
fn create_collection<T: Config<I>, I: 'static>(
|
||||||
) -> (T::CollectionId, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
) -> (T::CollectionId, T::AccountId, AccountIdLookupOf<T>) {
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
let collection = T::Helper::collection(0);
|
let collection = T::Helper::collection(0);
|
||||||
@@ -49,8 +49,7 @@ fn create_collection<T: Config<I>, I: 'static>(
|
|||||||
(collection, caller, caller_lookup)
|
(collection, caller, caller_lookup)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_collection_metadata<T: Config<I>, I: 'static>(
|
fn add_collection_metadata<T: Config<I>, I: 'static>() -> (T::AccountId, AccountIdLookupOf<T>) {
|
||||||
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
|
||||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
||||||
if caller != whitelisted_caller() {
|
if caller != whitelisted_caller() {
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
@@ -68,7 +67,7 @@ fn add_collection_metadata<T: Config<I>, I: 'static>(
|
|||||||
|
|
||||||
fn mint_item<T: Config<I>, I: 'static>(
|
fn mint_item<T: Config<I>, I: 'static>(
|
||||||
index: u16,
|
index: u16,
|
||||||
) -> (T::ItemId, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
) -> (T::ItemId, T::AccountId, AccountIdLookupOf<T>) {
|
||||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().admin;
|
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().admin;
|
||||||
if caller != whitelisted_caller() {
|
if caller != whitelisted_caller() {
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
@@ -87,7 +86,7 @@ fn mint_item<T: Config<I>, I: 'static>(
|
|||||||
|
|
||||||
fn add_item_metadata<T: Config<I>, I: 'static>(
|
fn add_item_metadata<T: Config<I>, I: 'static>(
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
) -> (T::AccountId, AccountIdLookupOf<T>) {
|
||||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
||||||
if caller != whitelisted_caller() {
|
if caller != whitelisted_caller() {
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
@@ -106,7 +105,7 @@ fn add_item_metadata<T: Config<I>, I: 'static>(
|
|||||||
|
|
||||||
fn add_item_attribute<T: Config<I>, I: 'static>(
|
fn add_item_attribute<T: Config<I>, I: 'static>(
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
) -> (BoundedVec<u8, T::KeyLimit>, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
) -> (BoundedVec<u8, T::KeyLimit>, T::AccountId, AccountIdLookupOf<T>) {
|
||||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
||||||
if caller != whitelisted_caller() {
|
if caller != whitelisted_caller() {
|
||||||
whitelist_account!(caller);
|
whitelist_account!(caller);
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ pub use pallet::*;
|
|||||||
pub use types::*;
|
pub use types::*;
|
||||||
pub use weights::WeightInfo;
|
pub use weights::WeightInfo;
|
||||||
|
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -463,10 +465,7 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Weight: `O(1)`
|
/// Weight: `O(1)`
|
||||||
#[pallet::weight(T::WeightInfo::create())]
|
#[pallet::weight(T::WeightInfo::create())]
|
||||||
pub fn create(
|
pub fn create(origin: OriginFor<T>, admin: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
admin: <T::Lookup as StaticLookup>::Source,
|
|
||||||
) -> DispatchResult {
|
|
||||||
let collection = NextCollectionId::<T, I>::get();
|
let collection = NextCollectionId::<T, I>::get();
|
||||||
|
|
||||||
let owner = T::CreateOrigin::ensure_origin(origin, &collection)?;
|
let owner = T::CreateOrigin::ensure_origin(origin, &collection)?;
|
||||||
@@ -501,7 +500,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::force_create())]
|
#[pallet::weight(T::WeightInfo::force_create())]
|
||||||
pub fn force_create(
|
pub fn force_create(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
free_holding: bool,
|
free_holding: bool,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
T::ForceOrigin::ensure_origin(origin)?;
|
T::ForceOrigin::ensure_origin(origin)?;
|
||||||
@@ -599,7 +598,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let owner = T::Lookup::lookup(owner)?;
|
let owner = T::Lookup::lookup(owner)?;
|
||||||
@@ -628,7 +627,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
check_owner: Option<<T::Lookup as StaticLookup>::Source>,
|
check_owner: Option<AccountIdLookupOf<T>>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let check_owner = check_owner.map(T::Lookup::lookup).transpose()?;
|
let check_owner = check_owner.map(T::Lookup::lookup).transpose()?;
|
||||||
@@ -664,7 +663,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
dest: <T::Lookup as StaticLookup>::Source,
|
dest: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let dest = T::Lookup::lookup(dest)?;
|
let dest = T::Lookup::lookup(dest)?;
|
||||||
@@ -876,7 +875,7 @@ pub mod pallet {
|
|||||||
pub fn transfer_ownership(
|
pub fn transfer_ownership(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let owner = T::Lookup::lookup(owner)?;
|
let owner = T::Lookup::lookup(owner)?;
|
||||||
@@ -924,9 +923,9 @@ pub mod pallet {
|
|||||||
pub fn set_team(
|
pub fn set_team(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
issuer: <T::Lookup as StaticLookup>::Source,
|
issuer: AccountIdLookupOf<T>,
|
||||||
admin: <T::Lookup as StaticLookup>::Source,
|
admin: AccountIdLookupOf<T>,
|
||||||
freezer: <T::Lookup as StaticLookup>::Source,
|
freezer: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let issuer = T::Lookup::lookup(issuer)?;
|
let issuer = T::Lookup::lookup(issuer)?;
|
||||||
@@ -962,7 +961,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
delegate: <T::Lookup as StaticLookup>::Source,
|
delegate: AccountIdLookupOf<T>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let maybe_check: Option<T::AccountId> = T::ForceOrigin::try_origin(origin)
|
let maybe_check: Option<T::AccountId> = T::ForceOrigin::try_origin(origin)
|
||||||
.map(|_| None)
|
.map(|_| None)
|
||||||
@@ -1015,7 +1014,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
maybe_check_delegate: Option<<T::Lookup as StaticLookup>::Source>,
|
maybe_check_delegate: Option<AccountIdLookupOf<T>>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let maybe_check: Option<T::AccountId> = T::ForceOrigin::try_origin(origin)
|
let maybe_check: Option<T::AccountId> = T::ForceOrigin::try_origin(origin)
|
||||||
.map(|_| None)
|
.map(|_| None)
|
||||||
@@ -1066,10 +1065,10 @@ pub mod pallet {
|
|||||||
pub fn force_item_status(
|
pub fn force_item_status(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
owner: <T::Lookup as StaticLookup>::Source,
|
owner: AccountIdLookupOf<T>,
|
||||||
issuer: <T::Lookup as StaticLookup>::Source,
|
issuer: AccountIdLookupOf<T>,
|
||||||
admin: <T::Lookup as StaticLookup>::Source,
|
admin: AccountIdLookupOf<T>,
|
||||||
freezer: <T::Lookup as StaticLookup>::Source,
|
freezer: AccountIdLookupOf<T>,
|
||||||
free_holding: bool,
|
free_holding: bool,
|
||||||
is_frozen: bool,
|
is_frozen: bool,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
@@ -1507,7 +1506,7 @@ pub mod pallet {
|
|||||||
collection: T::CollectionId,
|
collection: T::CollectionId,
|
||||||
item: T::ItemId,
|
item: T::ItemId,
|
||||||
price: Option<ItemPrice<T, I>>,
|
price: Option<ItemPrice<T, I>>,
|
||||||
whitelisted_buyer: Option<<T::Lookup as StaticLookup>::Source>,
|
whitelisted_buyer: Option<AccountIdLookupOf<T>>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin = ensure_signed(origin)?;
|
let origin = ensure_signed(origin)?;
|
||||||
let whitelisted_buyer = whitelisted_buyer.map(T::Lookup::lookup).transpose()?;
|
let whitelisted_buyer = whitelisted_buyer.map(T::Lookup::lookup).transpose()?;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ fn add_locks<T: Config>(who: &T::AccountId, n: u8) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_vesting_schedules<T: Config>(
|
fn add_vesting_schedules<T: Config>(
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
n: u32,
|
n: u32,
|
||||||
) -> Result<BalanceOf<T>, &'static str> {
|
) -> Result<BalanceOf<T>, &'static str> {
|
||||||
let min_transfer = T::MinVestedTransfer::get();
|
let min_transfer = T::MinVestedTransfer::get();
|
||||||
@@ -52,7 +52,7 @@ fn add_vesting_schedules<T: Config>(
|
|||||||
let starting_block = 1u32;
|
let starting_block = 1u32;
|
||||||
|
|
||||||
let source: T::AccountId = account("source", 0, SEED);
|
let source: T::AccountId = account("source", 0, SEED);
|
||||||
let source_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(source.clone());
|
let source_lookup = T::Lookup::unlookup(source.clone());
|
||||||
T::Currency::make_free_balance_be(&source, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&source, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
System::<T>::set_block_number(T::BlockNumber::zero());
|
System::<T>::set_block_number(T::BlockNumber::zero());
|
||||||
@@ -81,7 +81,7 @@ benchmarks! {
|
|||||||
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
||||||
|
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let caller_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(caller.clone());
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());
|
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());
|
||||||
|
|
||||||
add_locks::<T>(&caller, l as u8);
|
add_locks::<T>(&caller, l as u8);
|
||||||
@@ -109,7 +109,7 @@ benchmarks! {
|
|||||||
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
||||||
|
|
||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
let caller_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(caller.clone());
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());
|
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());
|
||||||
|
|
||||||
add_locks::<T>(&caller, l as u8);
|
add_locks::<T>(&caller, l as u8);
|
||||||
@@ -137,7 +137,7 @@ benchmarks! {
|
|||||||
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
||||||
|
|
||||||
let other: T::AccountId = account("other", 0, SEED);
|
let other: T::AccountId = account("other", 0, SEED);
|
||||||
let other_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(other.clone());
|
let other_lookup = T::Lookup::unlookup(other.clone());
|
||||||
|
|
||||||
add_locks::<T>(&other, l as u8);
|
add_locks::<T>(&other, l as u8);
|
||||||
let expected_balance = add_vesting_schedules::<T>(other_lookup.clone(), s)?;
|
let expected_balance = add_vesting_schedules::<T>(other_lookup.clone(), s)?;
|
||||||
@@ -166,7 +166,7 @@ benchmarks! {
|
|||||||
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
let s in 1 .. T::MAX_VESTING_SCHEDULES;
|
||||||
|
|
||||||
let other: T::AccountId = account("other", 0, SEED);
|
let other: T::AccountId = account("other", 0, SEED);
|
||||||
let other_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(other.clone());
|
let other_lookup = T::Lookup::unlookup(other.clone());
|
||||||
|
|
||||||
add_locks::<T>(&other, l as u8);
|
add_locks::<T>(&other, l as u8);
|
||||||
add_vesting_schedules::<T>(other_lookup.clone(), s)?;
|
add_vesting_schedules::<T>(other_lookup.clone(), s)?;
|
||||||
@@ -198,7 +198,7 @@ benchmarks! {
|
|||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let target: T::AccountId = account("target", 0, SEED);
|
let target: T::AccountId = account("target", 0, SEED);
|
||||||
let target_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(target.clone());
|
let target_lookup = T::Lookup::unlookup(target.clone());
|
||||||
// Give target existing locks
|
// Give target existing locks
|
||||||
add_locks::<T>(&target, l as u8);
|
add_locks::<T>(&target, l as u8);
|
||||||
// Add one vesting schedules.
|
// Add one vesting schedules.
|
||||||
@@ -232,11 +232,11 @@ benchmarks! {
|
|||||||
let s in 0 .. T::MAX_VESTING_SCHEDULES - 1;
|
let s in 0 .. T::MAX_VESTING_SCHEDULES - 1;
|
||||||
|
|
||||||
let source: T::AccountId = account("source", 0, SEED);
|
let source: T::AccountId = account("source", 0, SEED);
|
||||||
let source_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(source.clone());
|
let source_lookup = T::Lookup::unlookup(source.clone());
|
||||||
T::Currency::make_free_balance_be(&source, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&source, BalanceOf::<T>::max_value());
|
||||||
|
|
||||||
let target: T::AccountId = account("target", 0, SEED);
|
let target: T::AccountId = account("target", 0, SEED);
|
||||||
let target_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(target.clone());
|
let target_lookup = T::Lookup::unlookup(target.clone());
|
||||||
// Give target existing locks
|
// Give target existing locks
|
||||||
add_locks::<T>(&target, l as u8);
|
add_locks::<T>(&target, l as u8);
|
||||||
// Add one less than max vesting schedules
|
// Add one less than max vesting schedules
|
||||||
@@ -270,7 +270,7 @@ benchmarks! {
|
|||||||
let s in 2 .. T::MAX_VESTING_SCHEDULES;
|
let s in 2 .. T::MAX_VESTING_SCHEDULES;
|
||||||
|
|
||||||
let caller: T::AccountId = account("caller", 0, SEED);
|
let caller: T::AccountId = account("caller", 0, SEED);
|
||||||
let caller_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(caller.clone());
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
// Give target existing locks.
|
// Give target existing locks.
|
||||||
add_locks::<T>(&caller, l as u8);
|
add_locks::<T>(&caller, l as u8);
|
||||||
// Add max vesting schedules.
|
// Add max vesting schedules.
|
||||||
@@ -320,7 +320,7 @@ benchmarks! {
|
|||||||
let test_dest: T::AccountId = account("test_dest", 0, SEED);
|
let test_dest: T::AccountId = account("test_dest", 0, SEED);
|
||||||
|
|
||||||
let caller: T::AccountId = account("caller", 0, SEED);
|
let caller: T::AccountId = account("caller", 0, SEED);
|
||||||
let caller_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(caller.clone());
|
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||||
// Give target other locks.
|
// Give target other locks.
|
||||||
add_locks::<T>(&caller, l as u8);
|
add_locks::<T>(&caller, l as u8);
|
||||||
// Add max vesting schedules.
|
// Add max vesting schedules.
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ type BalanceOf<T> =
|
|||||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
type MaxLocksOf<T> =
|
type MaxLocksOf<T> =
|
||||||
<<T as Config>::Currency as LockableCurrency<<T as frame_system::Config>::AccountId>>::MaxLocks;
|
<<T as Config>::Currency as LockableCurrency<<T as frame_system::Config>::AccountId>>::MaxLocks;
|
||||||
|
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
|
||||||
|
|
||||||
const VESTING_ID: LockIdentifier = *b"vesting ";
|
const VESTING_ID: LockIdentifier = *b"vesting ";
|
||||||
|
|
||||||
@@ -321,10 +322,7 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::vest_other_locked(MaxLocksOf::<T>::get(), T::MAX_VESTING_SCHEDULES)
|
#[pallet::weight(T::WeightInfo::vest_other_locked(MaxLocksOf::<T>::get(), T::MAX_VESTING_SCHEDULES)
|
||||||
.max(T::WeightInfo::vest_other_unlocked(MaxLocksOf::<T>::get(), T::MAX_VESTING_SCHEDULES))
|
.max(T::WeightInfo::vest_other_unlocked(MaxLocksOf::<T>::get(), T::MAX_VESTING_SCHEDULES))
|
||||||
)]
|
)]
|
||||||
pub fn vest_other(
|
pub fn vest_other(origin: OriginFor<T>, target: AccountIdLookupOf<T>) -> DispatchResult {
|
||||||
origin: OriginFor<T>,
|
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
|
||||||
) -> DispatchResult {
|
|
||||||
ensure_signed(origin)?;
|
ensure_signed(origin)?;
|
||||||
let who = T::Lookup::lookup(target)?;
|
let who = T::Lookup::lookup(target)?;
|
||||||
Self::do_vest(who)
|
Self::do_vest(who)
|
||||||
@@ -352,7 +350,7 @@ pub mod pallet {
|
|||||||
)]
|
)]
|
||||||
pub fn vested_transfer(
|
pub fn vested_transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
|
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let transactor = ensure_signed(origin)?;
|
let transactor = ensure_signed(origin)?;
|
||||||
@@ -383,8 +381,8 @@ pub mod pallet {
|
|||||||
)]
|
)]
|
||||||
pub fn force_vested_transfer(
|
pub fn force_vested_transfer(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
source: <T::Lookup as StaticLookup>::Source,
|
source: AccountIdLookupOf<T>,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
|
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
@@ -494,8 +492,8 @@ impl<T: Config> Pallet<T> {
|
|||||||
|
|
||||||
// Execute a vested transfer from `source` to `target` with the given `schedule`.
|
// Execute a vested transfer from `source` to `target` with the given `schedule`.
|
||||||
fn do_vested_transfer(
|
fn do_vested_transfer(
|
||||||
source: <T::Lookup as StaticLookup>::Source,
|
source: AccountIdLookupOf<T>,
|
||||||
target: <T::Lookup as StaticLookup>::Source,
|
target: AccountIdLookupOf<T>,
|
||||||
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
|
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
// Validate user inputs.
|
// Validate user inputs.
|
||||||
|
|||||||
Reference in New Issue
Block a user