Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pallet::getter usage from all pallet-tips #4871

Merged
14 changes: 14 additions & 0 deletions prdoc/pr_4871.prdoc
Original file line number Diff line number Diff line change
@@ -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::<T, I>::get()`.

crates:
- name: pallet-tips
bump: minor
Aideepakchaudhary marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 12 additions & 2 deletions substrate/frame/tips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Twox64Concat,
Expand All @@ -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<T: Config<I>, I: 'static = ()> =
StorageMap<_, Identity, T::Hash, Vec<u8>, OptionQuery>;

Expand Down Expand Up @@ -492,6 +490,18 @@ pub mod pallet {
impl<T: Config<I>, I: 'static> Pallet<T, I> {
// Add public immutables and private mutables.

/// Access tips storage from outside
pub fn tips(
hash: T::Hash,
) -> Option<OpenTip<T::AccountId, BalanceOf<T, I>, BlockNumberFor<T>, T::Hash>> {
Tips::<T, I>::get(hash)
}

/// Access reasons storage from outside
pub fn reasons(hash: T::Hash) -> Option<Vec<u8>> {
Reasons::<T, I>::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
Expand Down
Loading