From fb3c7ce6d30c95365ef0dd5506f2e2bcba24c5b2 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Sat, 22 Jun 2024 16:16:52 +0530 Subject: [PATCH 1/4] added-implementation-of-ContainsLengthBound --- substrate/frame/membership/src/lib.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index aa6be6497eea..9a8afde52961 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -24,7 +24,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ - traits::{ChangeMembers, Contains, Get, InitializeMembers, SortedMembers}, + traits::{ChangeMembers, Contains, Get, InitializeMembers, SortedMembers, ContainsLengthBound}, BoundedVec, }; use sp_runtime::traits::{StaticLookup, UniqueSaturatedInto}; @@ -361,6 +361,17 @@ impl, I: 'static> Contains for Pallet { } } +impl ContainsLengthBound for Pallet { + fn min_len() -> usize { + 0 + } + + /// Implementation uses a parameter type so calling is cost-free. + fn max_len() -> usize { + T::MaxMembers::get() as usize + } +} + impl, I: 'static> SortedMembers for Pallet { fn sorted_members() -> Vec { Self::members().to_vec() From 2af23e7757b8c23d0b7eaaa79424e3e9d186e587 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Sat, 22 Jun 2024 17:09:47 +0530 Subject: [PATCH 2/4] added pr_doc --- prdoc/pr_4803.prdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 prdoc/pr_4803.prdoc diff --git a/prdoc/pr_4803.prdoc b/prdoc/pr_4803.prdoc new file mode 100644 index 000000000000..d94c958bd029 --- /dev/null +++ b/prdoc/pr_4803.prdoc @@ -0,0 +1,12 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Implement trait `ContainsLengthBound` for pallet-membership + +doc: + - audience: Runtime Dev + description: | + Implement trait ContainsLengthBound for pallet membership otherwise we can't use it with pallet-tips without wrapper + +crates: + - name: pallet-membership From 0c8e3ba7b1e0737a5d52b9d1eb950e0d62bac4b8 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Sat, 22 Jun 2024 17:38:10 +0530 Subject: [PATCH 3/4] change the name of doc --- prdoc/{pr_4803.prdoc => pr_4865.prdoc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename prdoc/{pr_4803.prdoc => pr_4865.prdoc} (100%) diff --git a/prdoc/pr_4803.prdoc b/prdoc/pr_4865.prdoc similarity index 100% rename from prdoc/pr_4803.prdoc rename to prdoc/pr_4865.prdoc From fdd02bcf86ddd8a4ea66c4ac31e5a820993c181e Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Mon, 24 Jun 2024 15:36:51 +0530 Subject: [PATCH 4/4] some refactor --- prdoc/pr_4865.prdoc | 1 + substrate/frame/membership/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/prdoc/pr_4865.prdoc b/prdoc/pr_4865.prdoc index d94c958bd029..48ffd04219cf 100644 --- a/prdoc/pr_4865.prdoc +++ b/prdoc/pr_4865.prdoc @@ -10,3 +10,4 @@ doc: crates: - name: pallet-membership + bump: minor diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index 9a8afde52961..8deb4fc022f3 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -24,7 +24,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ - traits::{ChangeMembers, Contains, Get, InitializeMembers, SortedMembers, ContainsLengthBound}, + traits::{ChangeMembers, Contains, ContainsLengthBound, Get, InitializeMembers, SortedMembers}, BoundedVec, }; use sp_runtime::traits::{StaticLookup, UniqueSaturatedInto};