Purify Contains, add IsInVec, All and SortedMembers (#8589)

* IsInVec

* Purify `Contains`, introduce SortedMembers
This commit is contained in:
Gavin Wood
2021-04-11 00:04:02 +02:00
committed by GitHub
parent fe775ab954
commit 29864b255c
9 changed files with 60 additions and 15 deletions
+2 -2
View File
@@ -68,7 +68,7 @@ use frame_support::traits::{
use sp_runtime::{ Percent, RuntimeDebug, traits::{
Zero, AccountIdConversion, Hash, BadOrigin
}};
use frame_support::traits::{Contains, ContainsLengthBound, OnUnbalanced, EnsureOrigin};
use frame_support::traits::{SortedMembers, ContainsLengthBound, OnUnbalanced, EnsureOrigin};
use codec::{Encode, Decode};
use frame_system::{self as system, ensure_signed};
pub use weights::WeightInfo;
@@ -86,7 +86,7 @@ pub trait Config: frame_system::Config + pallet_treasury::Config {
/// Origin from which tippers must come.
///
/// `ContainsLengthBound::max_len` must be cost free (i.e. no storage read or heavy operation).
type Tippers: Contains<Self::AccountId> + ContainsLengthBound;
type Tippers: SortedMembers<Self::AccountId> + ContainsLengthBound;
/// The period for which a tip remains open after is has achieved threshold tippers.
type TipCountdown: Get<Self::BlockNumber>;
+2 -2
View File
@@ -24,7 +24,7 @@ use super::*;
use std::cell::RefCell;
use frame_support::{
assert_noop, assert_ok, parameter_types,
weights::Weight, traits::Contains,
weights::Weight, traits::SortedMembers,
PalletId
};
use sp_runtime::Permill;
@@ -98,7 +98,7 @@ thread_local! {
static TEN_TO_FOURTEEN: RefCell<Vec<u128>> = RefCell::new(vec![10,11,12,13,14]);
}
pub struct TenToFourteen;
impl Contains<u128> for TenToFourteen {
impl SortedMembers<u128> for TenToFourteen {
fn sorted_members() -> Vec<u128> {
TEN_TO_FOURTEEN.with(|v| {
v.borrow().clone()