diff --git a/Cargo.lock b/Cargo.lock index 6d1b19e701a50..db2f04867ae32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6426,6 +6426,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "pallet-balances", "parity-scale-codec", "scale-info", diff --git a/frame/identity/Cargo.toml b/frame/identity/Cargo.toml index 942fba9053294..2f388cdc894e1 100644 --- a/frame/identity/Cargo.toml +++ b/frame/identity/Cargo.toml @@ -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" } diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index aa400e4f0c52f..f1e1a918c2356 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -218,24 +218,33 @@ pub mod pallet { impl BuildGenesisConfig for GenesisConfig { fn build(&self) { for (account, name) in &self.identities { - >::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) => { + >::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)" + ); + }, + } } } }