Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
log error when failing to create identity
Browse files Browse the repository at this point in the history
  • Loading branch information
grw-ms committed Aug 16, 2023
1 parent 232fdf0 commit 035b752
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frame/identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
enumflags2 = { version = "0.7.7" }
log = { version = "0.4", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
Expand Down
43 changes: 26 additions & 17 deletions frame/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,33 @@ pub mod pallet {
impl<T: Config> BuildGenesisConfig 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()),
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(),
deposit: Zero::zero(),
match BoundedVec::try_from(name.encode()) {
Ok(b) => {
<IdentityOf<T>>::insert(
account,
Registration {
info: IdentityInfo {
display: Data::Raw(b),
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(),
deposit: Zero::zero(),
},
);
},
);
Err(_e) => {
log::error!(
"Error inserting identity: data exceeds maximum size (32 bytes)"
);
},
}
}
}
}
Expand Down

0 comments on commit 035b752

Please sign in to comment.