File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,16 @@ impl<T: Config> Pallet<T> {
249
249
Metadata :: < T > :: get ( asset_id)
250
250
}
251
251
252
+ pub fn multilocation ( asset_id : & T :: AssetId ) -> Result < Option < MultiLocation > , DispatchError > {
253
+ Metadata :: < T > :: get ( asset_id)
254
+ . and_then ( |metadata| {
255
+ metadata
256
+ . location
257
+ . map ( |location| location. try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion . into ( ) ) )
258
+ } )
259
+ . transpose ( )
260
+ }
261
+
252
262
pub fn do_insert_location ( asset_id : T :: AssetId , location : VersionedMultiLocation ) -> DispatchResult {
253
263
// if the metadata contains a location, set the LocationToAssetId
254
264
let location: MultiLocation = location. try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
Original file line number Diff line number Diff line change @@ -47,9 +47,7 @@ impl Convert<CurrencyId, Option<MultiLocation>> for CurrencyIdConvert {
47
47
CurrencyId :: B1 => Some ( ( Parent , Parachain ( 2 ) , GeneralKey ( "B1" . into ( ) ) ) . into ( ) ) ,
48
48
CurrencyId :: B2 => Some ( ( Parent , Parachain ( 2 ) , GeneralKey ( "B2" . into ( ) ) ) . into ( ) ) ,
49
49
CurrencyId :: D => Some ( ( Parent , Parachain ( 4 ) , GeneralKey ( "D" . into ( ) ) ) . into ( ) ) ,
50
- CurrencyId :: RegisteredAsset ( id) => {
51
- AssetRegistry :: metadata ( id) . and_then ( |x| x. location . and_then ( |x| x. try_into ( ) . ok ( ) ) )
52
- }
50
+ CurrencyId :: RegisteredAsset ( id) => AssetRegistry :: multilocation ( & id) . unwrap_or_default ( ) ,
53
51
}
54
52
}
55
53
}
You can’t perform that action at this time.
0 commit comments