Skip to content
Snippets Groups Projects
Unverified Commit 84d64374 authored by polka.dom's avatar polka.dom Committed by GitHub
Browse files

Remove pallet::getter usage from pallet-contracts-mock-network (#4417)

A part of #3326 

Removes all #[pallet::getter] usage from the contracts mock network
pallet. As the storage values were pub(super), read-only visibility was
lost external to the crate upon the removal of the macros. I have
implemented custom getters as a replacement, keeping the api the same.

If we care very much about consistency of the
storagevalue::<T>::get() syntax, the other option would be to set
the storage values to pub. Though I find preserving data authority
better myself.

@muraca
parent a993513c
No related merge requests found
Pipeline #473877 waiting for manual action with stages
in 25 minutes and 38 seconds
# 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 pallet-contracts-mock-network
doc:
- audience: Runtime Dev
description: |
This PR removed the `pallet::getter`s from `pallet-contracts-mock-network`s storage items.
crates:
- name: pallet-contracts-mock-network
bump: minor
......@@ -47,17 +47,15 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[pallet::storage]
#[pallet::getter(fn parachain_id)]
pub(super) type ParachainId<T: Config> = StorageValue<_, ParaId, ValueQuery>;
#[pallet::storage]
#[pallet::getter(fn received_dmp)]
/// A queue of received DMP messages
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::RuntimeCall>>, ValueQuery>;
impl<T: Config> Get<ParaId> for Pallet<T> {
fn get() -> ParaId {
Self::parachain_id()
ParachainId::<T>::get()
}
}
......@@ -89,6 +87,14 @@ pub mod pallet {
ParachainId::<T>::put(para_id);
}
pub fn parachain_id() -> ParaId {
ParachainId::<T>::get()
}
pub fn received_dmp() -> Vec<Xcm<T::RuntimeCall>> {
ReceivedDmp::<T>::get()
}
fn handle_xcmp_message(
sender: ParaId,
_sent_at: RelayBlockNumber,
......@@ -169,7 +175,7 @@ pub mod pallet {
limit,
Weight::zero(),
);
<ReceivedDmp<T>>::append(x);
ReceivedDmp::<T>::append(x);
Self::deposit_event(Event::ExecutedDownward(id, outcome));
},
},
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment