Skip to content

Commit

Permalink
Remove pallet::getter macro from pallet-identity (paritytech#4586)
Browse files Browse the repository at this point in the history
As per paritytech#3326, removes pallet::getter macro usage from the
pallet-identity. The syntax `StorageItem::<T, I>::get()` should be used
instead.

Also makes all storage values public

cc @muraca

---------

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: command-bot <>
  • Loading branch information
3 people authored and TarekkMA committed Aug 2, 2024
1 parent 86ebcb1 commit ff90d30
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ mod imports {
genesis::ED as PEOPLE_ROCOCO_ED,
people_rococo_runtime::{
people, xcm_config::XcmConfig as PeopleRococoXcmConfig,
ExistentialDeposit as PeopleRococoExistentialDeposit,
ExistentialDeposit as PeopleRococoExistentialDeposit, Runtime as PeopleRuntime,
},
PeopleRococoParaPallet as PeopleRococoPallet,
},
rococo_emulated_chain::{
genesis::ED as ROCOCO_ED,
rococo_runtime::{
xcm_config::XcmConfig as RococoXcmConfig, BasicDeposit, ByteDeposit,
MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin,
SubAccountDeposit,
MaxAdditionalFields, MaxSubAccounts, Runtime as RococoRuntime,
RuntimeOrigin as RococoOrigin, SubAccountDeposit,
},
RococoRelayPallet as RococoPallet,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
use crate::imports::*;
use frame_support::BoundedVec;
use pallet_balances::Event as BalancesEvent;
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent};
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf};
use people::{
BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain,
IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain,
Expand Down Expand Up @@ -266,9 +266,9 @@ fn assert_set_id_parachain(id: &Identity) {
// No amount should be reserved as deposit amounts are set to 0.
let reserved_balance = PeopleRococoBalances::reserved_balance(PeopleRococoSender::get());
assert_eq!(reserved_balance, 0);
assert!(PeopleRococoIdentity::identity(PeopleRococoSender::get()).is_some());
assert!(IdentityOf::<PeopleRuntime>::get(PeopleRococoSender::get()).is_some());

let (_, sub_accounts) = PeopleRococoIdentity::subs_of(PeopleRococoSender::get());
let (_, sub_accounts) = SubsOf::<PeopleRuntime>::get(PeopleRococoSender::get());

match id.subs {
Subs::Zero => assert_eq!(sub_accounts.len(), 0),
Expand Down Expand Up @@ -314,10 +314,10 @@ fn assert_reap_id_relay(total_deposit: Balance, id: &Identity) {
]
);
// Identity should be gone.
assert!(PeopleRococoIdentity::identity(RococoRelaySender::get()).is_none());
assert!(IdentityOf::<PeopleRuntime>::get(RococoRelaySender::get()).is_none());

// Subs should be gone.
let (_, sub_accounts) = RococoIdentity::subs_of(RococoRelaySender::get());
let (_, sub_accounts) = SubsOf::<RococoRuntime>::get(RococoRelaySender::get());
assert_eq!(sub_accounts.len(), 0);

let reserved_balance = RococoBalances::reserved_balance(RococoRelaySender::get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ mod imports {
genesis::ED as PEOPLE_WESTEND_ED,
people_westend_runtime::{
people, xcm_config::XcmConfig as PeopleWestendXcmConfig,
ExistentialDeposit as PeopleWestendExistentialDeposit,
ExistentialDeposit as PeopleWestendExistentialDeposit, Runtime as PeopleRuntime,
},
PeopleWestendParaPallet as PeopleWestendPallet,
},
westend_emulated_chain::{
genesis::ED as WESTEND_ED,
westend_runtime::{
xcm_config::XcmConfig as WestendXcmConfig, BasicDeposit, ByteDeposit,
MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin,
SubAccountDeposit,
MaxAdditionalFields, MaxSubAccounts, Runtime as WestendRuntime,
RuntimeOrigin as WestendOrigin, SubAccountDeposit,
},
WestendRelayPallet as WestendPallet,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
use crate::imports::*;
use frame_support::BoundedVec;
use pallet_balances::Event as BalancesEvent;
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent};
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf};
use people::{
BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain,
IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain,
Expand Down Expand Up @@ -266,9 +266,9 @@ fn assert_set_id_parachain(id: &Identity) {
// No amount should be reserved as deposit amounts are set to 0.
let reserved_balance = PeopleWestendBalances::reserved_balance(PeopleWestendSender::get());
assert_eq!(reserved_balance, 0);
assert!(PeopleWestendIdentity::identity(PeopleWestendSender::get()).is_some());
assert!(IdentityOf::<PeopleRuntime>::get(PeopleWestendSender::get()).is_some());

let (_, sub_accounts) = PeopleWestendIdentity::subs_of(PeopleWestendSender::get());
let (_, sub_accounts) = SubsOf::<PeopleRuntime>::get(PeopleWestendSender::get());

match id.subs {
Subs::Zero => assert_eq!(sub_accounts.len(), 0),
Expand Down Expand Up @@ -314,10 +314,10 @@ fn assert_reap_id_relay(total_deposit: Balance, id: &Identity) {
]
);
// Identity should be gone.
assert!(PeopleWestendIdentity::identity(WestendRelaySender::get()).is_none());
assert!(IdentityOf::<PeopleRuntime>::get(WestendRelaySender::get()).is_none());

// Subs should be gone.
let (_, sub_accounts) = WestendIdentity::subs_of(WestendRelaySender::get());
let (_, sub_accounts) = SubsOf::<WestendRuntime>::get(WestendRelaySender::get());
assert_eq!(sub_accounts.len(), 0);

let reserved_balance = WestendBalances::reserved_balance(WestendRelaySender::get());
Expand Down
22 changes: 22 additions & 0 deletions prdoc/pr_4586.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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-identity

doc:
- audience: Runtime Dev
description: |
This PR removed the `pallet::getter`s from `pallet-identity`.
The syntax `StorageItem::<T, I>::get()` should be used instead.

crates:
- name: pallet-identity
bump: minor
- name: pallet-alliance
bump: none
- name: kitchensink-runtime
bump: none
- name: people-rococo-integration-tests
bump: none
- name: people-westend-integration-tests
bump: none
7 changes: 4 additions & 3 deletions substrate/bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
}

fn has_good_judgement(who: &AccountId) -> bool {
use pallet_identity::Judgement;
crate::Identity::identity(who)
use pallet_identity::{IdentityOf, Judgement};
IdentityOf::<Runtime>::get(who)
.map(|(registration, _)| registration.judgements)
.map_or(false, |judgements| {
judgements
Expand All @@ -74,7 +74,8 @@ impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
}

fn super_account_id(who: &AccountId) -> Option<AccountId> {
crate::Identity::super_of(who).map(|parent| parent.0)
use pallet_identity::SuperOf;
SuperOf::<Runtime>::get(who).map(|parent| parent.0)
}
}

Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub use frame_support::{
use frame_system::{EnsureRoot, EnsureSignedBy};
use pallet_identity::{
legacy::{IdentityField, IdentityInfo},
Data, Judgement,
Data, IdentityOf, Judgement, SuperOf,
};

pub use crate as pallet_alliance;
Expand Down Expand Up @@ -146,7 +146,7 @@ impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {

fn has_good_judgement(who: &AccountId) -> bool {
if let Some(judgements) =
Identity::identity(who).map(|(registration, _)| registration.judgements)
IdentityOf::<Test>::get(who).map(|(registration, _)| registration.judgements)
{
judgements
.iter()
Expand All @@ -157,7 +157,7 @@ impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
}

fn super_account_id(who: &AccountId) -> Option<AccountId> {
Identity::super_of(who).map(|parent| parent.0)
SuperOf::<Test>::get(who).map(|parent| parent.0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/identity/src/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<FieldLimit: Get<u32>> Default for IdentityInfo<FieldLimit> {

impl<FieldLimit: Get<u32>> IdentityInfo<FieldLimit> {
pub(crate) fn fields(&self) -> BitFlags<IdentityField> {
let mut res = <BitFlags<IdentityField>>::empty();
let mut res = BitFlags::<IdentityField>::empty();
if !self.display.is_none() {
res.insert(IdentityField::Display);
}
Expand Down
Loading

0 comments on commit ff90d30

Please sign in to comment.