diff --git a/bridges/snowbridge/pallets/system/src/lib.rs b/bridges/snowbridge/pallets/system/src/lib.rs index b777edfe4ea6..abe2897924ff 100644 --- a/bridges/snowbridge/pallets/system/src/lib.rs +++ b/bridges/snowbridge/pallets/system/src/lib.rs @@ -625,7 +625,10 @@ pub mod pallet { metadata: AssetMetadata, ) -> DispatchResultWithPostInfo { ensure_root(origin)?; - ensure!(metadata.validate(), Error::::InvalidMetadata); + ensure!( + metadata.decimals > 0 && metadata.name.len() > 0 && metadata.symbol.len() > 0, + Error::::InvalidMetadata + ); let location: Location = (*location).try_into().map_err(|_| Error::::UnsupportedLocationVersion)?; diff --git a/bridges/snowbridge/pallets/system/src/tests.rs b/bridges/snowbridge/pallets/system/src/tests.rs index 1734f3148465..8e11ecc0075d 100644 --- a/bridges/snowbridge/pallets/system/src/tests.rs +++ b/bridges/snowbridge/pallets/system/src/tests.rs @@ -744,3 +744,25 @@ fn register_ethereum_native_token_fails() { ); }); } + +#[test] +fn register_token_with_invalid_meta_data_fails() { + new_test_ext(true).execute_with(|| { + let origin = RuntimeOrigin::root(); + let location = Location::new( + 2, + [ + GlobalConsensus(Ethereum { chain_id: 11155111 }), + AccountKey20 { + network: None, + key: hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d"), + }, + ], + ); + let versioned_location: Box = Box::new(location.clone().into()); + assert_noop!( + EthereumSystem::register_token(origin, versioned_location, AssetMetadata::default()), + Error::::InvalidMetadata + ); + }); +} diff --git a/bridges/snowbridge/primitives/core/src/lib.rs b/bridges/snowbridge/primitives/core/src/lib.rs index ab194e2ec599..7ad129a52542 100644 --- a/bridges/snowbridge/primitives/core/src/lib.rs +++ b/bridges/snowbridge/primitives/core/src/lib.rs @@ -159,12 +159,6 @@ pub struct AssetMetadata { pub decimals: u8, } -impl AssetMetadata { - pub fn validate(&self) -> bool { - self.decimals > 0 && self.name.len() > 0 && self.symbol.len() > 0 - } -} - #[cfg(any(test, feature = "std", feature = "runtime-benchmarks"))] impl Default for AssetMetadata { fn default() -> Self {