Skip to content

Commit 5074049

Browse files
committed
asset-registry: Implement Inspect & Mutate
1 parent 4b53b3c commit 5074049

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

asset-registry/src/impls.rs

+55-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use crate::{module::*, AssetMetadata};
1+
use crate::module::*;
22
use frame_support::{log, pallet_prelude::*, weights::constants::WEIGHT_PER_SECOND};
33
use orml_traits::{
4-
asset_registry::{AssetProcessor, FixedConversionRateProvider, WeightToFeeConverter},
4+
asset_registry::{
5+
AssetMetadata, AssetProcessor, FixedConversionRateProvider, Inspect, Mutate, WeightToFeeConverter,
6+
},
57
GetByKey,
68
};
79
use sp_runtime::FixedPointNumber;
@@ -169,3 +171,54 @@ impl<T: Config> GetByKey<T::AssetId, T::Balance> for ExistentialDeposits<T> {
169171
}
170172
}
171173
}
174+
175+
impl<T: Config> Inspect for Pallet<T> {
176+
type AssetId = T::AssetId;
177+
type Balance = T::Balance;
178+
type CustomMetadata = T::CustomMetadata;
179+
180+
fn asset_id(location: &MultiLocation) -> Option<Self::AssetId> {
181+
Pallet::<T>::location_to_asset_id(location)
182+
}
183+
184+
fn metadata(id: &Self::AssetId) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata>> {
185+
Pallet::<T>::metadata(id)
186+
}
187+
188+
fn metadata_by_location(location: &MultiLocation) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata>> {
189+
Pallet::<T>::fetch_metadata_by_location(location)
190+
}
191+
192+
fn location(asset_id: &Self::AssetId) -> Result<Option<MultiLocation>, DispatchError> {
193+
Pallet::<T>::multilocation(asset_id)
194+
}
195+
}
196+
197+
impl<T: Config> Mutate for Pallet<T> {
198+
fn register_asset(
199+
asset_id: Option<Self::AssetId>,
200+
metadata: AssetMetadata<Self::Balance, Self::CustomMetadata>,
201+
) -> DispatchResult {
202+
Pallet::<T>::do_register_asset(metadata, asset_id)
203+
}
204+
205+
fn update_asset(
206+
asset_id: Self::AssetId,
207+
decimals: Option<u32>,
208+
name: Option<Vec<u8>>,
209+
symbol: Option<Vec<u8>>,
210+
existential_deposit: Option<Self::Balance>,
211+
location: Option<Option<xcm::VersionedMultiLocation>>,
212+
additional: Option<Self::CustomMetadata>,
213+
) -> DispatchResult {
214+
Pallet::<T>::do_update_asset(
215+
asset_id,
216+
decimals,
217+
name,
218+
symbol,
219+
existential_deposit,
220+
location,
221+
additional,
222+
)
223+
}
224+
}

0 commit comments

Comments
 (0)