-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add GenesisConfig to identity pallet #14774
base: master
Are you sure you want to change the base?
Changes from 2 commits
3a6de3a
55ba65c
232fdf0
6a03dc6
587a6fc
89774f9
b52f93e
b5eae62
d35a8d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -79,6 +79,7 @@ mod types; | |||||||||
pub mod weights; | ||||||||||
|
||||||||||
use frame_support::traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency}; | ||||||||||
use scale_info::prelude::string::String; | ||||||||||
use sp_runtime::traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero}; | ||||||||||
use sp_std::prelude::*; | ||||||||||
pub use weights::WeightInfo; | ||||||||||
|
@@ -201,6 +202,44 @@ pub mod pallet { | |||||||||
ValueQuery, | ||||||||||
>; | ||||||||||
|
||||||||||
#[pallet::genesis_config] | ||||||||||
pub struct GenesisConfig<T: Config> { | ||||||||||
pub identities: Vec<(T::AccountId, String)>, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want this
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this was done to not require trait bounds on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even so, it seems much more preferable to be able to specify all other identity-related fields in genesis config, so let's figure out what the trait bounds should be here... Oh, it's just
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for comments both, I didn't use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is what i meant with trait bounds. Normally we just use POD types here to not having to use Serde from within the runtime. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll probably need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx, uses |
||||||||||
} | ||||||||||
|
||||||||||
#[cfg(feature = "std")] | ||||||||||
impl<T: Config> Default for GenesisConfig<T> { | ||||||||||
fn default() -> Self { | ||||||||||
GenesisConfig { identities: Default::default() } | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
#[pallet::genesis_build] | ||||||||||
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> { | ||||||||||
fn build(&self) { | ||||||||||
for (account, name) in &self.identities { | ||||||||||
<IdentityOf<T>>::insert( | ||||||||||
account, | ||||||||||
Registration { | ||||||||||
info: IdentityInfo { | ||||||||||
display: Data::Raw(BoundedVec::try_from(name.encode()).unwrap()), | ||||||||||
ggwpez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
twitter: Data::None, | ||||||||||
riot: Data::None, | ||||||||||
email: Data::None, | ||||||||||
pgp_fingerprint: None, | ||||||||||
image: Data::None, | ||||||||||
legal: Data::None, | ||||||||||
web: Data::None, | ||||||||||
additional: BoundedVec::default(), | ||||||||||
}, | ||||||||||
judgements: BoundedVec::default(), | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How much sense does it make not to provide any judgments? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you suggested it, we are now depending upon you to implement a genesis identity judge :) |
||||||||||
deposit: Zero::zero(), | ||||||||||
}, | ||||||||||
); | ||||||||||
} | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
#[pallet::error] | ||||||||||
pub enum Error<T> { | ||||||||||
/// Too many subs-accounts. | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be mindful that
Data
inIdentityInfo
is truncated to 32 bytes (see docs), so it is recommended to pass a hash of the data rather than the data itself for stuff likedisplay
.