Skip to content

Commit 84d6437

Browse files
authored
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
1 parent a993513 commit 84d6437

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

prdoc/pr_4417.prdoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
2+
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
3+
4+
title: Removed `pallet::getter` usage from pallet-contracts-mock-network
5+
6+
doc:
7+
- audience: Runtime Dev
8+
description: |
9+
This PR removed the `pallet::getter`s from `pallet-contracts-mock-network`s storage items.
10+
11+
crates:
12+
- name: pallet-contracts-mock-network
13+
bump: minor

substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,15 @@ pub mod pallet {
4747
pub struct Pallet<T>(_);
4848

4949
#[pallet::storage]
50-
#[pallet::getter(fn parachain_id)]
5150
pub(super) type ParachainId<T: Config> = StorageValue<_, ParaId, ValueQuery>;
5251

5352
#[pallet::storage]
54-
#[pallet::getter(fn received_dmp)]
5553
/// A queue of received DMP messages
5654
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::RuntimeCall>>, ValueQuery>;
5755

5856
impl<T: Config> Get<ParaId> for Pallet<T> {
5957
fn get() -> ParaId {
60-
Self::parachain_id()
58+
ParachainId::<T>::get()
6159
}
6260
}
6361

@@ -89,6 +87,14 @@ pub mod pallet {
8987
ParachainId::<T>::put(para_id);
9088
}
9189

90+
pub fn parachain_id() -> ParaId {
91+
ParachainId::<T>::get()
92+
}
93+
94+
pub fn received_dmp() -> Vec<Xcm<T::RuntimeCall>> {
95+
ReceivedDmp::<T>::get()
96+
}
97+
9298
fn handle_xcmp_message(
9399
sender: ParaId,
94100
_sent_at: RelayBlockNumber,
@@ -169,7 +175,7 @@ pub mod pallet {
169175
limit,
170176
Weight::zero(),
171177
);
172-
<ReceivedDmp<T>>::append(x);
178+
ReceivedDmp::<T>::append(x);
173179
Self::deposit_event(Event::ExecutedDownward(id, outcome));
174180
},
175181
},

0 commit comments

Comments
 (0)