Skip to content

Commit 5236c19

Browse files
committed
don't fail on zero fee rate
1 parent 558b538 commit 5236c19

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

asset-registry/src/lib.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use sp_runtime::traits::Bounded;
1313
use sp_runtime::{traits::Member, DispatchResult};
1414
use sp_std::prelude::*;
1515
use xcm::latest::prelude::*;
16+
use xcm::VersionedMultiLocation;
1617
use xcm_builder::TakeRevenue;
1718
use xcm_executor::{traits::WeightTrader, Assets};
1819

@@ -26,7 +27,7 @@ pub struct AssetMetadata<Balance, CustomMetadata: Parameter + Member + TypeInfo>
2627
pub name: Vec<u8>,
2728
pub symbol: Vec<u8>,
2829
pub existential_deposit: Balance,
29-
pub location: Option<MultiLocation>,
30+
pub location: Option<VersionedMultiLocation>,
3031
pub additional: CustomMetadata,
3132
}
3233

@@ -62,6 +63,9 @@ pub mod module {
6263
pub enum Error<T> {
6364
/// Asset was not found
6465
AssetNotFound,
66+
/// The version of the `Versioned` value used is not able to be
67+
/// interpreted.
68+
BadVersion,
6569
}
6670

6771
#[pallet::event]
@@ -128,11 +132,15 @@ pub mod module {
128132
) -> DispatchResult {
129133
let _ = T::AuthorityOrigin::ensure_origin(origin)?;
130134

135+
let location: Option<MultiLocation> = metadata
136+
.location
137+
.map(|location| location.try_into().map_err(|()| Error::<T>::BadVersion))
138+
.transpose()?;
139+
131140
// if assetid is explicitly passed, use that. Otherwise, if the location is
132141
// already registered, use the existing id
133142
let unprocessed_asset_id = asset_id.or_else(|| {
134-
metadata
135-
.location
143+
location
136144
.as_ref()
137145
.and_then(|location| MultiLocationLookup::<T>::get(location))
138146
});
@@ -142,7 +150,7 @@ pub mod module {
142150
Metadata::<T>::insert(&processed_asset_id, &metadata);
143151

144152
// If it included a multilocation, add it to the lookup
145-
if let Some(ref location) = metadata.location {
153+
if let Some(ref location) = location {
146154
MultiLocationLookup::<T>::insert(location, &processed_asset_id);
147155
}
148156

@@ -158,7 +166,7 @@ pub mod module {
158166
pub fn set_asset_location(
159167
origin: OriginFor<T>,
160168
asset_id: T::AssetId,
161-
location: MultiLocation,
169+
location: VersionedMultiLocation,
162170
) -> DispatchResult {
163171
let _ = T::AuthorityOrigin::ensure_origin(origin)?;
164172

0 commit comments

Comments
 (0)