difftreelog
feat xcm nft support
in: master
5 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -2351,6 +2351,11 @@
/// Is the collection a foreign one?
fn is_foreign(&self) -> bool;
+ /// Does the token have children?
+ fn token_has_children(&self, _token: TokenId) -> bool {
+ false
+ }
+
/// Create a collection's item using a transaction.
///
/// This function performs additional XCM-related checks before the actual creation.
pallets/foreign-assets/src/lib.rsdiffbeforeafterboth364364365 fn check_out(_dest: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {}365 fn check_out(_dest: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {}366366367 fn deposit_asset(what: &MultiAsset, to: &MultiLocation, context: &XcmContext) -> XcmResult {367 fn deposit_asset(what: &MultiAsset, to: &MultiLocation, _context: &XcmContext) -> XcmResult {368 let collection_id = Self::multiasset_to_collection(what)?;368 let collection_id = Self::multiasset_to_collection(what)?;369 let dispatch =369 let dispatch =370 T::CollectionDispatch::dispatch(collection_id).map_err(|_| XcmError::AssetNotFound)?;370 T::CollectionDispatch::dispatch(collection_id).map_err(|_| XcmError::AssetNotFound)?;397 from: &MultiLocation,397 from: &MultiLocation,398 _maybe_context: Option<&XcmContext>,398 _maybe_context: Option<&XcmContext>,399 ) -> Result<staging_xcm_executor::Assets, XcmError> {399 ) -> Result<staging_xcm_executor::Assets, XcmError> {400 let from = T::LocationToAccountId::convert_location(from)401 .ok_or(XcmExecutorError::AccountIdConversionFailed)?;402403 let collection_id = Self::multiasset_to_collection(what)?;404 let dispatch =405 T::CollectionDispatch::dispatch(collection_id).map_err(|_| XcmError::AssetNotFound)?;406407 let collection = dispatch.as_dyn();408 let xcm_ext = collection.xcm_extensions().ok_or(XcmError::NoPermission)?;409410 match what.fun {411 Fungibility::Fungible(amount) => xcm_ext412 .burn_item(from, TokenId::default(), amount)413 .map_err(|_| XcmError::FailedToTransactAsset("fungible item withdraw failed"))?,414415 Fungibility::NonFungible(asset_instance) => {416 let token_id =417 Self::asset_instance_to_token_id(xcm_ext, collection_id, &asset_instance)?418 .ok_or(XcmError::AssetNotFound)?;419420 if xcm_ext.token_has_children(token_id) {400 Err(XcmError::Unimplemented)421 return Err(XcmError::Unimplemented);422 }423424 let depositor = &from;425 let to = Self::pallet_account();426 let amount = 1;427 xcm_ext428 .transfer_item(depositor, &from, &to, token_id, amount, &ZeroBudget)429 .map_err(|_| {430 XcmError::FailedToTransactAsset("nonfungible item withdraw failed")431 })?;432 }433 }434435 Ok(what.clone().into())401 }436 }402437403 fn internal_transfer_asset(438 fn internal_transfer_asset(406 to: &MultiLocation,441 to: &MultiLocation,407 _context: &XcmContext,442 _context: &XcmContext,408 ) -> Result<staging_xcm_executor::Assets, XcmError> {443 ) -> Result<staging_xcm_executor::Assets, XcmError> {444 let collection_id = Self::multiasset_to_collection(what)?;445446 let dispatch =447 T::CollectionDispatch::dispatch(collection_id).map_err(|_| XcmError::AssetNotFound)?;448 let collection = dispatch.as_dyn();409 Err(XcmError::Unimplemented)449 let xcm_ext = collection.xcm_extensions().ok_or(XcmError::NoPermission)?;450451 let from = T::LocationToAccountId::convert_location(from)452 .ok_or(XcmExecutorError::AccountIdConversionFailed)?;453454 let to = T::LocationToAccountId::convert_location(to)455 .ok_or(XcmExecutorError::AccountIdConversionFailed)?;456457 let depositor = &from;458459 match what.fun {460 Fungibility::Fungible(amount) => xcm_ext461 .transfer_item(462 depositor,463 &from,464 &to,465 TokenId::default(),466 amount,467 &ZeroBudget,468 )469 .map_err(|_| XcmError::FailedToTransactAsset("fungible item transfer failed"))?,470471 Fungibility::NonFungible(asset_instance) => {472 let token_id =473 Self::asset_instance_to_token_id(xcm_ext, collection_id, &asset_instance)?474 .ok_or(XcmError::AssetNotFound)?;475476 let amount = 1;477478 xcm_ext479 .transfer_item(depositor, &from, &to, token_id, amount, &ZeroBudget)480 .map_err(|_| {481 XcmError::FailedToTransactAsset("nonfungible item transfer failed")482 })?;483 }484 }485486 Ok(what.clone().into())410 }487 }411}488}412489pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -95,9 +95,8 @@
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
use up_data_structs::{
- budget::{Budget, ZeroBudget},
- mapping::TokenAddressMapping,
- AccessMode, CollectionId, CreateCollectionData, Property, PropertyKey, TokenId,
+ budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId, Property, PropertyKey,
+ TokenId,
};
use weights::WeightInfo;
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -576,6 +576,10 @@
self.flags.foreign
}
+ fn token_has_children(&self, token: TokenId) -> bool {
+ <Pallet<T>>::token_has_children(self.id, token)
+ }
+
fn create_item_internal(
&self,
depositor: &<T>::CrossAccountId,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -117,8 +117,8 @@
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
use up_data_structs::{
budget::Budget, mapping::TokenAddressMapping, AccessMode, AuxPropertyValue, CollectionId,
- CreateCollectionData, CreateNftExData, CustomDataLimit, PropertiesPermissionMap, Property,
- PropertyKey, PropertyKeyPermission, PropertyScope, PropertyValue, TokenChild, TokenId,
+ CreateNftExData, CustomDataLimit, PropertiesPermissionMap, Property, PropertyKey,
+ PropertyKeyPermission, PropertyScope, PropertyValue, TokenChild, TokenId,
TokenProperties as TokenPropertiesT,
};
use weights::WeightInfo;