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 macro from pallet-identity #4586

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
66f1557
To turbo
PolkadotDom May 25, 2024
a3d5668
Remove identity getter
PolkadotDom May 25, 2024
5813a55
Remove super of getter
PolkadotDom May 25, 2024
e334986
Remove subs of getter
PolkadotDom May 25, 2024
d94cbaf
Remove registrars getter
PolkadotDom May 25, 2024
a0b41f8
Remove authority getter
PolkadotDom May 25, 2024
4e614bf
Remove username getter
PolkadotDom May 25, 2024
c05163f
Remove preapproved_usernames getter
PolkadotDom May 25, 2024
8e90b02
Fix missing >
PolkadotDom May 25, 2024
510d0a5
Make storage public
PolkadotDom May 25, 2024
53b7abc
remove getter usage from kitchen sink
PolkadotDom May 25, 2024
7155548
Update identity usage in kitchen sink
PolkadotDom May 25, 2024
cf404ec
fmt
PolkadotDom May 25, 2024
6361ae3
Create pr_9999.prdoc
PolkadotDom May 25, 2024
86df6c6
Update prdoc number
PolkadotDom May 25, 2024
0fa9bb6
Update prdoc/pr_4586.prdoc
PolkadotDom May 27, 2024
cec64b1
Fix system chain integration tests
PolkadotDom May 28, 2024
ff47fdd
Fix pallet alliance issues
PolkadotDom May 28, 2024
858bd86
fmt
PolkadotDom May 28, 2024
a121ed4
Merge branch 'master' into dom/remove-getters-pallet-identity
PolkadotDom Jun 22, 2024
063a83d
Remove unnecessary semver bumps
PolkadotDom Jun 24, 2024
f47c967
Merge branch 'master' into dom/remove-getters-pallet-identity
PolkadotDom Jun 24, 2024
9b724ef
Replace macro getters with explicit ones
PolkadotDom Jul 6, 2024
6b1f932
fmt
PolkadotDom Jul 6, 2024
0302e61
Update semver bump to minor
PolkadotDom Jul 6, 2024
1fa8245
Merge remote-tracking branch 'upstream/master' into dom/remove-getter…
PolkadotDom Jul 8, 2024
03d34ea
Export people runtime dependency
PolkadotDom Jul 8, 2024
6584281
re-export rococo dependencies
PolkadotDom Jul 8, 2024
f3e943a
re-export westend runtime
PolkadotDom Jul 8, 2024
bc8c275
fmt
PolkadotDom Jul 9, 2024
7615790
Set semver bumps to none
PolkadotDom Jul 9, 2024
7612058
Merge branch 'master' into dom/remove-getters-pallet-identity
PolkadotDom Jul 17, 2024
8d37b52
Merge branch 'master' into dom/remove-getters-pallet-identity
bkchr Jul 23, 2024
b455a80
".git/.scripts/commands/fmt/fmt.sh"
Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@
use crate::imports::*;
use frame_support::BoundedVec;
use pallet_balances::Event as BalancesEvent;
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent};
use people_rococo_runtime::people::{
BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain,
IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain,
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf};
use people_rococo_runtime::{
people::{
BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain,
IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain,
},
Runtime as PeopleRuntime,
};
use rococo_runtime::{
BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin,
SubAccountDeposit,
BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, Runtime as RococoRuntime,
RuntimeOrigin as RococoOrigin, SubAccountDeposit,
};
use rococo_runtime_constants::currency::*;
use rococo_system_emulated_network::{
Expand Down Expand Up @@ -270,9 +273,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 @@ -318,10 +321,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 @@ -41,14 +41,17 @@
use crate::imports::*;
use frame_support::BoundedVec;
use pallet_balances::Event as BalancesEvent;
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent};
use people_westend_runtime::people::{
BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain,
IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain,
use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf};
use people_westend_runtime::{
people::{
BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain,
IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain,
},
Runtime as PeopleRuntime,
};
use westend_runtime::{
BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin,
SubAccountDeposit,
BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, Runtime as WestendRuntime,
RuntimeOrigin as WestendOrigin, SubAccountDeposit,
};
use westend_runtime_constants::currency::*;
use westend_system_emulated_network::{
Expand Down Expand Up @@ -270,9 +273,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 @@ -318,10 +321,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: major
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also needs to mention pallet-alliance with a patch, since it was modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xlc getting conflicting comments here. @ggwpez In a comment above was told to remove the semver bumps since they don't change in a 'semver' sense.

I'd say I agree with xlc since there's really no functionality added/bugs fixed, but I'm happy to do whatever!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not modified. the tests are not published

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hadn't seen there was a none option. Have set the bumps to that.

PolkadotDom marked this conversation as resolved.
Show resolved Hide resolved
- name: pallet-alliance
bump: patch
- name: kitchensink-runtime
bump: patch
- name: people-rococo-integration-tests
bump: patch
- name: people-westend-integration-tests
bump: patch
PolkadotDom marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -64,8 +64,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 @@ -75,7 +75,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 @@ -172,7 +172,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
Loading