From fb3c7ce6d30c95365ef0dd5506f2e2bcba24c5b2 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Sat, 22 Jun 2024 16:16:52 +0530 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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}; From 87dd56f5c5148851f9a83b0514b7aaaaf106f216 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Mon, 24 Jun 2024 22:55:51 +0530 Subject: [PATCH 05/10] remove getter --- substrate/frame/tips/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/substrate/frame/tips/src/lib.rs b/substrate/frame/tips/src/lib.rs index e16ee041fcdf..7a055a3515a9 100644 --- a/substrate/frame/tips/src/lib.rs +++ b/substrate/frame/tips/src/lib.rs @@ -180,7 +180,6 @@ pub mod pallet { /// This has the insecure enumerable hash function since the key itself is already /// guaranteed to be a secure hash. #[pallet::storage] - #[pallet::getter(fn tips)] pub type Tips, I: 'static = ()> = StorageMap< _, Twox64Concat, @@ -192,7 +191,6 @@ pub mod pallet { /// Simple preimage lookup from the reason's hash to the original data. Again, has an /// insecure enumerable hash since the key is guaranteed to be the result of a secure hash. #[pallet::storage] - #[pallet::getter(fn reasons)] pub type Reasons, I: 'static = ()> = StorageMap<_, Identity, T::Hash, Vec, OptionQuery>; From 2746e129bd4bf0e49611ee441f2960cd0ec51562 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Mon, 24 Jun 2024 23:01:20 +0530 Subject: [PATCH 06/10] added prdoc --- prdoc/pr_4866.prdoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 prdoc/pr_4866.prdoc diff --git a/prdoc/pr_4866.prdoc b/prdoc/pr_4866.prdoc new file mode 100644 index 000000000000..b3014d727e37 --- /dev/null +++ b/prdoc/pr_4866.prdoc @@ -0,0 +1,14 @@ + 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: Removed `pallet::getter` usage from the pallet-tips + +doc: + - audience: Runtime Dev + description: | + This PR removed `pallet::getter`s from `pallet-tips`s storage items. + When accessed inside the pallet, use the syntax `StorageItem::::get()`. + +crates: + - name: pallet-tips + bump: minor From 7818551f4fcc4e2599f38158ee7cdbd6110a3198 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Mon, 24 Jun 2024 23:08:38 +0530 Subject: [PATCH 07/10] rename prdoc --- prdoc/{pr_4866.prdoc => pr_4871.prdoc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename prdoc/{pr_4866.prdoc => pr_4871.prdoc} (100%) diff --git a/prdoc/pr_4866.prdoc b/prdoc/pr_4871.prdoc similarity index 100% rename from prdoc/pr_4866.prdoc rename to prdoc/pr_4871.prdoc From c07b226f49f23261a871e83e01d0557c50d9cd19 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Mon, 24 Jun 2024 23:17:09 +0530 Subject: [PATCH 08/10] refactoring in prdoc --- prdoc/pr_4871.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_4871.prdoc b/prdoc/pr_4871.prdoc index b3014d727e37..6ff36f59d700 100644 --- a/prdoc/pr_4871.prdoc +++ b/prdoc/pr_4871.prdoc @@ -1,4 +1,4 @@ - Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# 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: Removed `pallet::getter` usage from the pallet-tips From 249d5b785f6600ff118801a3d54978ded0c91ec3 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Tue, 25 Jun 2024 22:35:22 +0530 Subject: [PATCH 09/10] add public function to access storage --- substrate/frame/tips/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/substrate/frame/tips/src/lib.rs b/substrate/frame/tips/src/lib.rs index 7a055a3515a9..b9732a56f2f5 100644 --- a/substrate/frame/tips/src/lib.rs +++ b/substrate/frame/tips/src/lib.rs @@ -490,6 +490,16 @@ pub mod pallet { impl, I: 'static> Pallet { // Add public immutables and private mutables. + /// Access tips storage from outside + pub fn tips(hash: T::Hash) -> Option, BlockNumberFor, T::Hash>> { + Tips::::get(hash) + } + + /// Access reasons storage from outside + pub fn reasons(hash: T::Hash) -> Option> { + Reasons::::get(hash) + } + /// The account ID of the treasury pot. /// /// This actually does computation. If you need to keep using it, then make sure you cache the From 7d60af85a98a75f3c347022f29dab2bd7a151a0f Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Tue, 25 Jun 2024 22:48:53 +0530 Subject: [PATCH 10/10] fmt --- substrate/frame/tips/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/substrate/frame/tips/src/lib.rs b/substrate/frame/tips/src/lib.rs index b9732a56f2f5..a75aed89d0b4 100644 --- a/substrate/frame/tips/src/lib.rs +++ b/substrate/frame/tips/src/lib.rs @@ -491,7 +491,9 @@ impl, I: 'static> Pallet { // Add public immutables and private mutables. /// Access tips storage from outside - pub fn tips(hash: T::Hash) -> Option, BlockNumberFor, T::Hash>> { + pub fn tips( + hash: T::Hash, + ) -> Option, BlockNumberFor, T::Hash>> { Tips::::get(hash) }