diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index bc17fcada23fb..961296060f569 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -31,7 +31,7 @@ use assets_common::{ foreign_creators::ForeignCreators, local_and_foreign_assets::{LocalAndForeignAssets, MultiLocationConverter}, matching::FromSiblingParachain, - AssetIdForTrustBackedAssetsConvert, MultiLocationForAssetId, + AssetIdForTrustBackedAssetsConvert, CollectionId, ItemId, MultiLocationForAssetId, }; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use cumulus_primitives_core::ParaId; @@ -57,8 +57,8 @@ use frame_support::{ genesis_builder_helper::{build_config, create_default_config}, ord_parameter_types, parameter_types, traits::{ - AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, EitherOfDiverse, - InstanceFilter, + tokens::nonfungibles_v2::Inspect, AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, + ConstU64, ConstU8, EitherOfDiverse, InstanceFilter, }, weights::{ConstantMultiplier, Weight}, BoundedVec, PalletId, @@ -734,8 +734,8 @@ parameter_types! { impl pallet_uniques::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CollectionId = u32; - type ItemId = u32; + type CollectionId = CollectionId; + type ItemId = ItemId; type Currency = Balances; type ForceOrigin = AssetsForceOrigin; type CollectionDeposit = UniquesCollectionDeposit; @@ -792,8 +792,8 @@ parameter_types! { impl pallet_nfts::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CollectionId = u32; - type ItemId = u32; + type CollectionId = CollectionId; + type ItemId = ItemId; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = AssetsForceOrigin; @@ -1030,6 +1030,50 @@ impl_runtime_apis! { } } + impl pallet_nfts_runtime_api::NftsApi for Runtime { + fn owner(collection: CollectionId, item: ItemId) -> Option { + >::owner(&collection, &item) + } + + fn collection_owner(collection: CollectionId) -> Option { + >::collection_owner(&collection) + } + + fn attribute( + collection: CollectionId, + item: ItemId, + key: Vec, + ) -> Option> { + >::attribute(&collection, &item, &key) + } + + fn custom_attribute( + account: AccountId, + collection: CollectionId, + item: ItemId, + key: Vec, + ) -> Option> { + >::custom_attribute( + &account, + &collection, + &item, + &key, + ) + } + + fn system_attribute( + collection: CollectionId, + item: Option, + key: Vec, + ) -> Option> { + >::system_attribute(&collection, item.as_ref(), &key) + } + + fn collection_attribute(collection: CollectionId, key: Vec) -> Option> { + >::collection_attribute(&collection, &key) + } + } + impl pallet_asset_conversion::AssetConversionApi< Block, Balance, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs index 7033e1c2dcace..be6dd29941ba6 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs @@ -63,7 +63,8 @@ mod weights; pub mod xcm_config; use assets_common::{ - foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId, + foreign_creators::ForeignCreators, matching::FromSiblingParachain, CollectionId, ItemId, + MultiLocationForAssetId, }; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use cumulus_primitives_core::ParaId; @@ -89,8 +90,8 @@ use frame_support::{ genesis_builder_helper::{build_config, create_default_config}, parameter_types, traits::{ - AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, - InstanceFilter, + tokens::nonfungibles_v2::Inspect, AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, + ConstU8, EitherOfDiverse, InstanceFilter, }, weights::{ConstantMultiplier, Weight}, PalletId, @@ -674,8 +675,8 @@ parameter_types! { impl pallet_uniques::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CollectionId = u32; - type ItemId = u32; + type CollectionId = CollectionId; + type ItemId = ItemId; type Currency = Balances; type ForceOrigin = AssetsForceOrigin; type CollectionDeposit = UniquesCollectionDeposit; @@ -706,8 +707,8 @@ parameter_types! { impl pallet_nfts::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CollectionId = u32; - type ItemId = u32; + type CollectionId = CollectionId; + type ItemId = ItemId; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = AssetsForceOrigin; @@ -934,6 +935,49 @@ impl_runtime_apis! { } } + impl pallet_nfts_runtime_api::NftsApi for Runtime { + fn owner(collection: CollectionId, item: ItemId) -> Option { + >::owner(&collection, &item) + } + + fn collection_owner(collection: CollectionId) -> Option { + >::collection_owner(&collection) + } + + fn attribute( + collection: CollectionId, + item: ItemId, + key: Vec, + ) -> Option> { + >::attribute(&collection, &item, &key) + } + + fn custom_attribute( + account: AccountId, + collection: CollectionId, + item: ItemId, + key: Vec, + ) -> Option> { + >::custom_attribute( + &account, + &collection, + &item, + &key, + ) + } + + fn system_attribute( + collection: CollectionId, + item: Option, + key: Vec, + ) -> Option> { + >::system_attribute(&collection, item.as_ref(), &key) + } + + fn collection_attribute(collection: CollectionId, key: Vec) -> Option> { + >::collection_attribute(&collection, &key) + } + } impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { fn query_info( uxt: ::Extrinsic, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 30d3842224223..e967b621d3328 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -32,7 +32,7 @@ use crate::xcm_config::{ }; use assets_common::{ local_and_foreign_assets::{LocalAndForeignAssets, MultiLocationConverter}, - AssetIdForTrustBackedAssetsConvert, + AssetIdForTrustBackedAssetsConvert, CollectionId, ItemId, }; use codec::{Decode, Encode, MaxEncodedLen}; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; @@ -709,8 +709,8 @@ parameter_types! { impl pallet_uniques::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CollectionId = u32; - type ItemId = u32; + type CollectionId = CollectionId; + type ItemId = ItemId; type Currency = Balances; type ForceOrigin = AssetsForceOrigin; type CollectionDeposit = UniquesCollectionDeposit; @@ -767,8 +767,8 @@ parameter_types! { impl pallet_nfts::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CollectionId = u32; - type ItemId = u32; + type CollectionId = CollectionId; + type ItemId = ItemId; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = AssetsForceOrigin; @@ -1048,18 +1048,18 @@ impl_runtime_apis! { } } - impl pallet_nfts_runtime_api::NftsApi for Runtime { - fn owner(collection: u32, item: u32) -> Option { + impl pallet_nfts_runtime_api::NftsApi for Runtime { + fn owner(collection: CollectionId, item: ItemId) -> Option { >::owner(&collection, &item) } - fn collection_owner(collection: u32) -> Option { + fn collection_owner(collection: CollectionId) -> Option { >::collection_owner(&collection) } fn attribute( - collection: u32, - item: u32, + collection: CollectionId, + item: ItemId, key: Vec, ) -> Option> { >::attribute(&collection, &item, &key) @@ -1067,8 +1067,8 @@ impl_runtime_apis! { fn custom_attribute( account: AccountId, - collection: u32, - item: u32, + collection: CollectionId, + item: ItemId, key: Vec, ) -> Option> { >::custom_attribute( @@ -1080,14 +1080,14 @@ impl_runtime_apis! { } fn system_attribute( - collection: u32, - item: Option, + collection: CollectionId, + item: Option, key: Vec, ) -> Option> { >::system_attribute(&collection, item.as_ref(), &key) } - fn collection_attribute(collection: u32, key: Vec) -> Option> { + fn collection_attribute(collection: CollectionId, key: Vec) -> Option> { >::collection_attribute(&collection, &key) } } diff --git a/cumulus/parachains/runtimes/assets/common/src/lib.rs b/cumulus/parachains/runtimes/assets/common/src/lib.rs index f45c3289aab49..c2f73e72f68ee 100644 --- a/cumulus/parachains/runtimes/assets/common/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/common/src/lib.rs @@ -93,6 +93,12 @@ pub type PoolAssetsConvertedConcreteId = JustTry, >; +/// Type to identify a particular NFT collection. +pub type CollectionId = u32; + +/// Type to identify a particular NFT in a collection. +pub type ItemId = u32; + #[cfg(test)] mod tests { use super::*;