From 1ac58ab4b91654018ccdbcfdb4fa182de6a93c92 Mon Sep 17 00:00:00 2001 From: PraetorP Date: Mon, 30 Oct 2023 12:38:38 +0000 Subject: [PATCH] trefactor --- xnft/src/impl_matches.rs | 6 +++++- xnft/src/lib.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xnft/src/impl_matches.rs b/xnft/src/impl_matches.rs index 8740d9f36..a41863572 100644 --- a/xnft/src/impl_matches.rs +++ b/xnft/src/impl_matches.rs @@ -1,5 +1,6 @@ use crate::*; use frame_support::traits::Incrementable; +use xcm::v3::Fungibility; use xcm_executor::traits::{Error as MatchError, MatchesNonFungibles}; impl MatchesNonFungibles, ItemIdOf> for Pallet @@ -10,8 +11,11 @@ where fn matches_nonfungibles( foreign_asset: &MultiAsset, ) -> core::result::Result<(CollectionIdOf, ItemIdOf), MatchError> { + let Fungibility::NonFungible(asset_instance) = foreign_asset.fun else { + return Err(MatchError::AssetNotHandled); + }; let asset = Self::assets(foreign_asset.id).ok_or(MatchError::AssetNotHandled)?; - let item = Self::items(&asset, &foreign_asset.fun).unwrap_or(Self::get_next_item_of(&asset)?); + let item = Self::items(&asset, asset_instance).unwrap_or(Self::get_next_item_of(&asset)?); Ok((asset, item)) } } diff --git a/xnft/src/lib.rs b/xnft/src/lib.rs index b9d0c4e14..e43820ad1 100644 --- a/xnft/src/lib.rs +++ b/xnft/src/lib.rs @@ -12,7 +12,7 @@ use frame_system::Config as SystemConfig; use scale_info::TypeInfo; use sp_runtime::{traits::AccountIdConversion, DispatchError, DispatchResult, RuntimeDebug}; use sp_std::{boxed::Box, vec::Vec}; -use xcm::v3::{AssetId, MultiAsset}; +use xcm::v3::{AssetId, AssetInstance, MultiAsset}; pub mod impl_matches; pub mod impl_nonfungibles; @@ -69,7 +69,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn items)] pub type ItemsMapping = - StorageDoubleMap<_, Twox64Concat, CollectionIdOf, Twox64Concat, Fungibility, ItemIdOf, OptionQuery>; + StorageDoubleMap<_, Twox64Concat, CollectionIdOf, Twox64Concat, AssetInstance, ItemIdOf, OptionQuery>; #[pallet::storage] pub type NextItemId = StorageMap<_, Twox64Concat, CollectionIdOf, ItemIdOf, OptionQuery>;