Skip to content

Commit

Permalink
trefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
PraetorP committed Oct 30, 2023
1 parent 36fe63b commit 1ac58ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion xnft/src/impl_matches.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::*;
use frame_support::traits::Incrementable;
use xcm::v3::Fungibility;
use xcm_executor::traits::{Error as MatchError, MatchesNonFungibles};

impl<T: Config> MatchesNonFungibles<CollectionIdOf<T>, ItemIdOf<T>> for Pallet<T>
Expand All @@ -10,8 +11,11 @@ where
fn matches_nonfungibles(
foreign_asset: &MultiAsset,
) -> core::result::Result<(CollectionIdOf<T>, ItemIdOf<T>), 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))
}
}
Expand Down
4 changes: 2 additions & 2 deletions xnft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,7 +69,7 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn items)]
pub type ItemsMapping<T: Config> =
StorageDoubleMap<_, Twox64Concat, CollectionIdOf<T>, Twox64Concat, Fungibility, ItemIdOf<T>, OptionQuery>;
StorageDoubleMap<_, Twox64Concat, CollectionIdOf<T>, Twox64Concat, AssetInstance, ItemIdOf<T>, OptionQuery>;

#[pallet::storage]
pub type NextItemId<T: Config> = StorageMap<_, Twox64Concat, CollectionIdOf<T>, ItemIdOf<T>, OptionQuery>;
Expand Down

0 comments on commit 1ac58ab

Please sign in to comment.