From d964e318b6a667be8c2f0a1af068974c39bd39b9 Mon Sep 17 00:00:00 2001 From: Polkaverse Date: Sat, 6 Jul 2024 22:37:32 +0530 Subject: [PATCH 1/5] remove getter from lib --- substrate/frame/proxy/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index 2b3fac5f59e4..d4f73c9a686f 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -1,4 +1,3 @@ -// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 @@ -568,7 +567,6 @@ pub mod pallet { /// The set of account proxies. Maps the account which has delegated to the accounts /// which are being delegated to, together with the amount held on deposit. #[pallet::storage] - #[pallet::getter(fn proxies)] pub type Proxies = StorageMap< _, Twox64Concat, @@ -585,7 +583,6 @@ pub mod pallet { /// The announcements made by the proxy (key). #[pallet::storage] - #[pallet::getter(fn announcements)] pub type Announcements = StorageMap< _, Twox64Concat, From 4a87a716eace9d8676b5ac318e103c1dab8e3224 Mon Sep 17 00:00:00 2001 From: Polkaverse Date: Sat, 6 Jul 2024 22:51:53 +0530 Subject: [PATCH 2/5] added public function for starages --- substrate/frame/proxy/src/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index d4f73c9a686f..a3a8c09b6c8a 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -1,4 +1,3 @@ - // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 @@ -596,6 +595,20 @@ pub mod pallet { } impl Pallet { + /// Public function to proxies storage. + pub fn proxies() -> ( + BoundedVec>, T::MaxProxies>, + BalanceOf, + ) { + Proxies::::get() + } + /// Public function to announcements storage. + pub fn announcements() -> ( + BoundedVec, BlockNumberFor>, T::MaxPending>, + BalanceOf, + ) { + Announcements::::get() + } /// Calculate the address of an pure account. /// /// - `who`: The spawner account. From 3e7e8d948bab7671292fe5c796edfd2fbc2aa269 Mon Sep 17 00:00:00 2001 From: Polkaverse Date: Sat, 6 Jul 2024 23:08:10 +0530 Subject: [PATCH 3/5] refactored code --- substrate/frame/proxy/src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index a3a8c09b6c8a..17486e678a64 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -36,6 +36,7 @@ use frame_support::{ dispatch::GetDispatchInfo, ensure, traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency}, + BoundedVec, }; use frame_system::{self as system, ensure_signed, pallet_prelude::BlockNumberFor}; pub use pallet::*; @@ -596,18 +597,22 @@ pub mod pallet { impl Pallet { /// Public function to proxies storage. - pub fn proxies() -> ( + pub fn proxies( + account: T::AccountId, + ) -> ( BoundedVec>, T::MaxProxies>, BalanceOf, ) { - Proxies::::get() + Proxies::::get(account) } /// Public function to announcements storage. - pub fn announcements() -> ( + pub fn announcements( + account: T::AccountId, + ) -> ( BoundedVec, BlockNumberFor>, T::MaxPending>, BalanceOf, ) { - Announcements::::get() + Announcements::::get(account) } /// Calculate the address of an pure account. /// From 5f47c79a5bc0c76663d40bb50b28278e80043d68 Mon Sep 17 00:00:00 2001 From: Polkaverse Date: Sun, 7 Jul 2024 01:04:37 +0530 Subject: [PATCH 4/5] refactored code --- substrate/frame/proxy/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index 17486e678a64..17203fa6bdcf 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -1,3 +1,5 @@ +// This file is part of Substrate. + // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 @@ -605,6 +607,7 @@ impl Pallet { ) { Proxies::::get(account) } + /// Public function to announcements storage. pub fn announcements( account: T::AccountId, @@ -614,6 +617,7 @@ impl Pallet { ) { Announcements::::get(account) } + /// Calculate the address of an pure account. /// /// - `who`: The spawner account. From 33ca762a1a9167a6ac1d347e0e0820b0e83cd130 Mon Sep 17 00:00:00 2001 From: Polkaverse Date: Sun, 7 Jul 2024 01:12:41 +0530 Subject: [PATCH 5/5] added prdoc --- prdoc/pr_4963.prdoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 prdoc/pr_4963.prdoc diff --git a/prdoc/pr_4963.prdoc b/prdoc/pr_4963.prdoc new file mode 100644 index 000000000000..e274d2cbb689 --- /dev/null +++ b/prdoc/pr_4963.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-proxy + +doc: + - audience: Runtime Dev + description: | + This PR removed `pallet::getter`s from `pallet-proxy`s storage items. + When accessed inside the pallet, use the syntax `StorageItem::::get()`. + +crates: + - name: pallet-proxy + bump: minor \ No newline at end of file