difftreelog
rename: use rmrk-core as proxy-rmrk-core in runtime
in: master
12 files changed
pallets/proxy-rmrk-core/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/pallets/proxy-rmrk-core/Cargo.toml
@@ -0,0 +1,49 @@
+[package]
+name = "pallet-rmrk-core"
+version = "0.1.0"
+license = "GPLv3"
+edition = "2021"
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '3.1.2'
+
+[dependencies]
+frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
+frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
+sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
+sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
+sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
+pallet-common = { default-features = false, path = '../common' }
+pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
+# pallet-structure = { default-features = false, path = '../structure' }
+up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
+# evm-coder = { default-features = false, path = '../../crates/evm-coder' }
+# pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
+scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
+
+[features]
+default = ["std"]
+std = [
+ "frame-support/std",
+ "frame-system/std",
+ "sp-runtime/std",
+ "sp-std/std",
+ "up-data-structs/std",
+ "pallet-common/std",
+ "pallet-nonfungible/std",
+ "pallet-evm/std",
+ # "pallet-structure/std",
+ # "evm-coder/std",
+ # "pallet-evm-coder-substrate/std",
+ 'frame-benchmarking/std',
+]
+runtime-benchmarks = [
+ 'frame-benchmarking',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system/runtime-benchmarks',
+]
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -0,0 +1,235 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+
+use frame_support::{pallet_prelude::*, transactional, BoundedVec, traits::ConstU32, dispatch::DispatchResult};
+use frame_system::{pallet_prelude::*, ensure_signed};
+use sp_runtime::DispatchError;
+use up_data_structs::*;
+use pallet_common::{Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations};
+use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle};
+use pallet_evm::account::CrossAccountId;
+
+pub use pallet::*;
+
+pub mod misc;
+pub mod property;
+
+use misc::*;
+pub use property::*;
+
+#[frame_support::pallet]
+pub mod pallet {
+ use super::*;
+ use pallet_evm::account;
+
+ #[pallet::config]
+ pub trait Config: frame_system::Config
+ + pallet_common::Config
+ + pallet_nonfungible::Config
+ + account::Config {
+ type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
+ }
+
+ #[pallet::pallet]
+ #[pallet::generate_store(pub(super) trait Store)]
+ pub struct Pallet<T>(_);
+
+ #[pallet::event]
+ #[pallet::generate_deposit(pub(super) fn deposit_event)]
+ pub enum Event<T: Config> {
+ CollectionCreated {
+ issuer: T::AccountId,
+ collection_id: CollectionId,
+ },
+ CollectionDestroyed {
+ issuer: T::AccountId,
+ collection_id: CollectionId,
+ },
+ CollectionLocked {
+ issuer: T::AccountId,
+ collection_id: CollectionId,
+ },
+ }
+
+ #[pallet::error]
+ pub enum Error<T> {
+ /* Unique-specific events */
+ CorruptedCollectionType,
+ NotRmrkCollection,
+ RmrkPropertyIsTooLong,
+
+ /* RMRK compatible events */
+ CollectionNotEmpty,
+ NoAvailableCollectionId,
+ CollectionUnknown,
+ }
+
+ #[pallet::call]
+ impl<T: Config> Pallet<T> {
+ #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+ #[transactional]
+ pub fn create_collection(
+ origin: OriginFor<T>,
+ metadata: PropertyValue,
+ max: Option<u32>,
+ symbol: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,
+ ) -> DispatchResult {
+ let sender = ensure_signed(origin)?;
+
+ let limits = max.map(|max| CollectionLimits {
+ token_limit: Some(max),
+ ..Default::default()
+ });
+
+ let data = CreateCollectionData {
+ limits,
+ token_prefix: symbol,
+ ..Default::default()
+ };
+
+ let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);
+
+ if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {
+ return Err(<Error<T>>::NoAvailableCollectionId.into());
+ }
+
+ let collection_id = collection_id_res?;
+
+ let collection = Self::get_nft_collection(collection_id)?.into_inner();
+
+ <PalletCommon<T>>::set_scoped_collection_properties(
+ &collection,
+ PropertyScope::Rmrk,
+ [
+ rmrk_property!(Config=T, Metadata: metadata)?,
+ rmrk_property!(Config=T, CollectionType: CollectionType::Regular)?,
+ ].into_iter()
+ )?;
+
+ Self::deposit_event(Event::CollectionCreated { issuer: sender, collection_id });
+
+ Ok(())
+ }
+
+ #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+ #[transactional]
+ pub fn destroy_collection(
+ origin: OriginFor<T>,
+ collection_id: CollectionId,
+ ) -> DispatchResult {
+ let sender = ensure_signed(origin)?;
+ let cross_sender = T::CrossAccountId::from_sub(sender.clone());
+
+ let collection = Self::get_nft_collection(collection_id)?;
+
+ Self::check_collection_type(collection_id, CollectionType::Regular)?;
+
+ ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);
+
+ <PalletNft<T>>::destroy_collection(collection, &cross_sender)?;
+
+ Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });
+
+ Ok(())
+ }
+
+ #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+ #[transactional]
+ pub fn change_collection_issuer(
+ origin: OriginFor<T>,
+ collection_id: CollectionId,
+ new_issuer: T::AccountId,
+ ) -> DispatchResult {
+ let sender = ensure_signed(origin)?;
+
+ Self::change_collection_owner(
+ collection_id,
+ CollectionType::Regular,
+ sender,
+ new_issuer
+ )?;
+
+ Ok(())
+ }
+
+ #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+ #[transactional]
+ pub fn lock_collection(
+ origin: OriginFor<T>,
+ collection_id: CollectionId,
+ ) -> DispatchResult {
+ let sender = ensure_signed(origin)?;
+ let cross_sender = T::CrossAccountId::from_sub(sender.clone());
+
+ let collection = Self::get_nft_collection(collection_id)?;
+ collection.check_is_owner(&cross_sender)?;
+
+ let token_count = collection.total_supply();
+
+ let mut collection = collection.into_inner();
+ collection.limits.token_limit = Some(token_count);
+ collection.save()?;
+
+ Self::deposit_event(Event::CollectionLocked { issuer: sender, collection_id });
+
+ Ok(())
+ }
+ }
+}
+
+impl<T: Config> Pallet<T> {
+ fn change_collection_owner(
+ collection_id: CollectionId,
+ collection_type: CollectionType,
+ sender: T::AccountId,
+ new_owner: T::AccountId,
+ ) -> DispatchResult {
+ let mut collection = Self::get_nft_collection(collection_id)?.into_inner();
+ collection.check_is_owner(&T::CrossAccountId::from_sub(sender))?;
+
+ Self::check_collection_type(collection_id, collection_type)?;
+
+ collection.owner = new_owner;
+ collection.save()
+ }
+
+ fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {
+ let collection = <CollectionHandle<T>>::try_get(collection_id)
+ .map_err(|_| <Error<T>>::CollectionUnknown)?
+ .into_nft_collection()?;
+
+ Ok(collection)
+ }
+
+ fn get_collection_type(collection_id: CollectionId) -> Result<CollectionType, DispatchError> {
+ let collection_type: CollectionType = <PalletCommon<T>>::collection_properties(collection_id)
+ .get(&rmrk_property!(Config=T, CollectionType)?)
+ .ok_or(<Error<T>>::NotRmrkCollection)?
+ .try_into()
+ .map_err(<Error<T>>::from)?;
+
+ Ok(collection_type)
+ }
+
+ fn check_collection_type(collection_id: CollectionId, collection_type: CollectionType) -> DispatchResult {
+ let actual_type = Self::get_collection_type(collection_id)?;
+ ensure!(actual_type == collection_type, <CommonError<T>>::NoPermission);
+
+ Ok(())
+ }
+}
pallets/proxy-rmrk-core/src/misc.rsdiffbeforeafterbothno changes
pallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/proxy-rmrk-core/src/property.rs
@@ -0,0 +1,92 @@
+use super::*;
+use core::convert::AsRef;
+
+pub enum RmrkProperty {
+ Metadata,
+ CollectionType,
+ Recipient,
+ Royalty,
+ Equipped,
+ Pending,
+ ResourceCollection,
+ ResourcePriorities,
+ PendingRemoval,
+ Parts,
+ Base,
+ Src,
+ Slot,
+ License,
+ Thumb,
+ EquippedNft,
+ BaseType,
+ // // RmrkPartId(/* Id type? */)
+ EquippableList,
+ ZIndex,
+ ThemeName,
+ ThemeProperty(RmrkString),
+ ThemeInherit,
+}
+
+impl RmrkProperty {
+ pub fn to_key<T: Config>(self) -> Result<PropertyKey, Error<T>> {
+ fn get_bytes<T: AsRef<[u8]>>(container: &T) -> &[u8] {
+ container.as_ref()
+ }
+
+ macro_rules! key {
+ ($($component:expr),+) => {
+ PropertyKey::try_from([$(key!(@ &$component)),+].concat())
+ .map_err(|_| <Error<T>>::RmrkPropertyIsTooLong)
+ };
+
+ (@ $key:expr) => {
+ get_bytes($key)
+ };
+ }
+
+ match self {
+ Self::Metadata => key!("metadata"),
+ Self::CollectionType => key!("collection-type"),
+ Self::Recipient => key!("recipient"),
+ Self::Royalty => key!("royalty"),
+ Self::Equipped => key!("equipped"),
+ Self::Pending => key!("pending"),
+ Self::ResourceCollection => key!("resource-collection"),
+ Self::ResourcePriorities => key!("resource-priorities"),
+ Self::PendingRemoval => key!("pending-removal"),
+ Self::Parts => key!("parts"),
+ Self::Base => key!("base"),
+ Self::Src => key!("src"),
+ Self::Slot => key!("slot"),
+ Self::License => key!("license"),
+ Self::Thumb => key!("thumb"),
+ Self::EquippedNft => key!("equipped-nft"),
+ Self::BaseType => key!("base-type"),
+ // RmrkPartId(/* Id type? */)
+ Self::EquippableList => key!("equippable-list"),
+ Self::ZIndex => key!("z-index"),
+ Self::ThemeName => key!("theme-name"),
+ Self::ThemeProperty(name) => key!("theme-property-", name),
+ Self::ThemeInherit => key!("theme-inherit"),
+ }
+ }
+}
+
+#[macro_export]
+macro_rules! rmrk_property {
+ (Config=$cfg:ty, $key:ident: $value:expr) => {
+ rmrk_property!(@$cfg, $key).map(|key| Property {
+ key,
+ value: $value.into()
+ })
+ };
+
+ (@$cfg:ty, $key:ident) => {
+ $crate::RmrkProperty::$key.to_key::<$cfg>()
+ };
+
+ (Config=$cfg:ty, $key:ident) => {
+ PropertyScope::Rmrk.apply(rmrk_property!(@$cfg, $key)?)
+ .map_err(|_| <$crate::Error<$cfg>>::RmrkPropertyIsTooLong)
+ };
+}
pallets/rmrk-core-proxy/Cargo.tomldiffbeforeafterboth--- a/pallets/rmrk-core-proxy/Cargo.toml
+++ /dev/null
@@ -1,49 +0,0 @@
-[package]
-name = "pallet-rmrk-core"
-version = "0.1.0"
-license = "GPLv3"
-edition = "2021"
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '3.1.2'
-
-[dependencies]
-frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-common = { default-features = false, path = '../common' }
-pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
-# pallet-structure = { default-features = false, path = '../structure' }
-up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
-# evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-# pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
-frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
-
-[features]
-default = ["std"]
-std = [
- "frame-support/std",
- "frame-system/std",
- "sp-runtime/std",
- "sp-std/std",
- "up-data-structs/std",
- "pallet-common/std",
- "pallet-nonfungible/std",
- "pallet-evm/std",
- # "pallet-structure/std",
- # "evm-coder/std",
- # "pallet-evm-coder-substrate/std",
- 'frame-benchmarking/std',
-]
-runtime-benchmarks = [
- 'frame-benchmarking',
- 'frame-support/runtime-benchmarks',
- 'frame-system/runtime-benchmarks',
-]
pallets/rmrk-core-proxy/src/lib.rsdiffbeforeafterboth--- a/pallets/rmrk-core-proxy/src/lib.rs
+++ /dev/null
@@ -1,235 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-#![cfg_attr(not(feature = "std"), no_std)]
-
-use frame_support::{pallet_prelude::*, transactional, BoundedVec, traits::ConstU32, dispatch::DispatchResult};
-use frame_system::{pallet_prelude::*, ensure_signed};
-use sp_runtime::DispatchError;
-use up_data_structs::*;
-use pallet_common::{Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations};
-use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle};
-use pallet_evm::account::CrossAccountId;
-
-pub use pallet::*;
-
-pub mod misc;
-pub mod property;
-
-use misc::*;
-pub use property::*;
-
-#[frame_support::pallet]
-pub mod pallet {
- use super::*;
- use pallet_evm::account;
-
- #[pallet::config]
- pub trait Config: frame_system::Config
- + pallet_common::Config
- + pallet_nonfungible::Config
- + account::Config {
- type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
- }
-
- #[pallet::pallet]
- #[pallet::generate_store(pub(super) trait Store)]
- pub struct Pallet<T>(_);
-
- #[pallet::event]
- #[pallet::generate_deposit(pub(super) fn deposit_event)]
- pub enum Event<T: Config> {
- CollectionCreated {
- issuer: T::AccountId,
- collection_id: CollectionId,
- },
- CollectionDestroyed {
- issuer: T::AccountId,
- collection_id: CollectionId,
- },
- CollectionLocked {
- issuer: T::AccountId,
- collection_id: CollectionId,
- },
- }
-
- #[pallet::error]
- pub enum Error<T> {
- /* Unique-specific events */
- CorruptedCollectionType,
- NotRmrkCollection,
- RmrkPropertyIsTooLong,
-
- /* RMRK compatible events */
- CollectionNotEmpty,
- NoAvailableCollectionId,
- CollectionUnknown,
- }
-
- #[pallet::call]
- impl<T: Config> Pallet<T> {
- #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
- #[transactional]
- pub fn create_collection(
- origin: OriginFor<T>,
- metadata: PropertyValue,
- max: Option<u32>,
- symbol: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,
- ) -> DispatchResult {
- let sender = ensure_signed(origin)?;
-
- let limits = max.map(|max| CollectionLimits {
- token_limit: Some(max),
- ..Default::default()
- });
-
- let data = CreateCollectionData {
- limits,
- token_prefix: symbol,
- ..Default::default()
- };
-
- let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);
-
- if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {
- return Err(<Error<T>>::NoAvailableCollectionId.into());
- }
-
- let collection_id = collection_id_res?;
-
- let collection = Self::get_nft_collection(collection_id)?.into_inner();
-
- <PalletCommon<T>>::set_scoped_collection_properties(
- &collection,
- PropertyScope::Rmrk,
- [
- rmrk_property!(Config=T, Metadata: metadata)?,
- rmrk_property!(Config=T, CollectionType: CollectionType::Regular)?,
- ].into_iter()
- )?;
-
- Self::deposit_event(Event::CollectionCreated { issuer: sender, collection_id });
-
- Ok(())
- }
-
- #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
- #[transactional]
- pub fn destroy_collection(
- origin: OriginFor<T>,
- collection_id: CollectionId,
- ) -> DispatchResult {
- let sender = ensure_signed(origin)?;
- let cross_sender = T::CrossAccountId::from_sub(sender.clone());
-
- let collection = Self::get_nft_collection(collection_id)?;
-
- Self::check_collection_type(collection_id, CollectionType::Regular)?;
-
- ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);
-
- <PalletNft<T>>::destroy_collection(collection, &cross_sender)?;
-
- Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });
-
- Ok(())
- }
-
- #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
- #[transactional]
- pub fn change_collection_issuer(
- origin: OriginFor<T>,
- collection_id: CollectionId,
- new_issuer: T::AccountId,
- ) -> DispatchResult {
- let sender = ensure_signed(origin)?;
-
- Self::change_collection_owner(
- collection_id,
- CollectionType::Regular,
- sender,
- new_issuer
- )?;
-
- Ok(())
- }
-
- #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
- #[transactional]
- pub fn lock_collection(
- origin: OriginFor<T>,
- collection_id: CollectionId,
- ) -> DispatchResult {
- let sender = ensure_signed(origin)?;
- let cross_sender = T::CrossAccountId::from_sub(sender.clone());
-
- let collection = Self::get_nft_collection(collection_id)?;
- collection.check_is_owner(&cross_sender)?;
-
- let token_count = collection.total_supply();
-
- let mut collection = collection.into_inner();
- collection.limits.token_limit = Some(token_count);
- collection.save()?;
-
- Self::deposit_event(Event::CollectionLocked { issuer: sender, collection_id });
-
- Ok(())
- }
- }
-}
-
-impl<T: Config> Pallet<T> {
- fn change_collection_owner(
- collection_id: CollectionId,
- collection_type: CollectionType,
- sender: T::AccountId,
- new_owner: T::AccountId,
- ) -> DispatchResult {
- let mut collection = Self::get_nft_collection(collection_id)?.into_inner();
- collection.check_is_owner(&T::CrossAccountId::from_sub(sender))?;
-
- Self::check_collection_type(collection_id, collection_type)?;
-
- collection.owner = new_owner;
- collection.save()
- }
-
- fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {
- let collection = <CollectionHandle<T>>::try_get(collection_id)
- .map_err(|_| <Error<T>>::CollectionUnknown)?
- .into_nft_collection()?;
-
- Ok(collection)
- }
-
- fn get_collection_type(collection_id: CollectionId) -> Result<CollectionType, DispatchError> {
- let collection_type: CollectionType = <PalletCommon<T>>::collection_properties(collection_id)
- .get(&rmrk_property!(Config=T, CollectionType)?)
- .ok_or(<Error<T>>::NotRmrkCollection)?
- .try_into()
- .map_err(<Error<T>>::from)?;
-
- Ok(collection_type)
- }
-
- fn check_collection_type(collection_id: CollectionId, collection_type: CollectionType) -> DispatchResult {
- let actual_type = Self::get_collection_type(collection_id)?;
- ensure!(actual_type == collection_type, <CommonError<T>>::NoPermission);
-
- Ok(())
- }
-}
pallets/rmrk-core-proxy/src/misc.rsdiffbeforeafterboth--- a/pallets/rmrk-core-proxy/src/misc.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-use super::*;
-use codec::{Encode, Decode};
-use pallet_nonfungible::NonfungibleHandle;
-
-macro_rules! impl_rmrk_value {
- ($enum_name:path, decode_error: $error:ident) => {
- impl From<$enum_name> for PropertyValue {
- fn from(e: $enum_name) -> Self {
- e.encode().try_into().unwrap()
- }
- }
-
- impl TryFrom<&PropertyValue> for $enum_name {
- type Error = MiscError;
-
- fn try_from(value: &PropertyValue) -> Result<Self, Self::Error> {
- let mut value = value.as_slice();
-
- <$enum_name>::decode(&mut value)
- .map_err(|_| MiscError::$error)
- }
- }
-
- };
-}
-
-pub enum MiscError {
- CorruptedCollectionType,
-}
-
-impl<T: Config> From<MiscError> for Error<T> {
- fn from(error: MiscError) -> Self {
- match error {
- MiscError::CorruptedCollectionType => Self::CorruptedCollectionType,
- }
- }
-}
-
-pub trait IntoNftCollection<T: Config> {
- fn into_nft_collection(self) -> Result<NonfungibleHandle<T>, Error<T>>;
-}
-
-impl<T: Config> IntoNftCollection<T> for CollectionHandle<T> {
- fn into_nft_collection(self) -> Result<NonfungibleHandle<T>, Error<T>> {
- match self.mode {
- CollectionMode::NFT => Ok(NonfungibleHandle::cast(self)),
- _ => Err(<Error<T>>::NotRmrkCollection)
- }
- }
-}
-
-#[derive(Encode, Decode, PartialEq, Eq)]
-pub enum CollectionType {
- Regular,
- Resource,
- Base,
-}
-
-impl_rmrk_value!(CollectionType, decode_error: CorruptedCollectionType);
pallets/rmrk-core-proxy/src/property.rsdiffbeforeafterboth--- a/pallets/rmrk-core-proxy/src/property.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-use super::*;
-use core::convert::AsRef;
-
-pub enum RmrkProperty {
- Metadata,
- CollectionType,
- Recipient,
- Royalty,
- Equipped,
- Pending,
- ResourceCollection,
- ResourcePriorities,
- PendingRemoval,
- Parts,
- Base,
- Src,
- Slot,
- License,
- Thumb,
- EquippedNft,
- BaseType,
- // // RmrkPartId(/* Id type? */)
- EquippableList,
- ZIndex,
- ThemeName,
- ThemeProperty(RmrkString),
- ThemeInherit,
-}
-
-impl RmrkProperty {
- pub fn to_key<T: Config>(self) -> Result<PropertyKey, Error<T>> {
- fn get_bytes<T: AsRef<[u8]>>(container: &T) -> &[u8] {
- container.as_ref()
- }
-
- macro_rules! key {
- ($($component:expr),+) => {
- PropertyKey::try_from([$(key!(@ &$component)),+].concat())
- .map_err(|_| <Error<T>>::RmrkPropertyIsTooLong)
- };
-
- (@ $key:expr) => {
- get_bytes($key)
- };
- }
-
- match self {
- Self::Metadata => key!("metadata"),
- Self::CollectionType => key!("collection-type"),
- Self::Recipient => key!("recipient"),
- Self::Royalty => key!("royalty"),
- Self::Equipped => key!("equipped"),
- Self::Pending => key!("pending"),
- Self::ResourceCollection => key!("resource-collection"),
- Self::ResourcePriorities => key!("resource-priorities"),
- Self::PendingRemoval => key!("pending-removal"),
- Self::Parts => key!("parts"),
- Self::Base => key!("base"),
- Self::Src => key!("src"),
- Self::Slot => key!("slot"),
- Self::License => key!("license"),
- Self::Thumb => key!("thumb"),
- Self::EquippedNft => key!("equipped-nft"),
- Self::BaseType => key!("base-type"),
- // RmrkPartId(/* Id type? */)
- Self::EquippableList => key!("equippable-list"),
- Self::ZIndex => key!("z-index"),
- Self::ThemeName => key!("theme-name"),
- Self::ThemeProperty(name) => key!("theme-property-", name),
- Self::ThemeInherit => key!("theme-inherit"),
- }
- }
-}
-
-#[macro_export]
-macro_rules! rmrk_property {
- (Config=$cfg:ty, $key:ident: $value:expr) => {
- rmrk_property!(@$cfg, $key).map(|key| Property {
- key,
- value: $value.into()
- })
- };
-
- (@$cfg:ty, $key:ident) => {
- $crate::RmrkProperty::$key.to_key::<$cfg>()
- };
-
- (Config=$cfg:ty, $key:ident) => {
- PropertyScope::Rmrk.apply(rmrk_property!(@$cfg, $key)?)
- .map_err(|_| <$crate::Error<$cfg>>::RmrkPropertyIsTooLong)
- };
-}
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -33,7 +33,7 @@
'pallet-fungible/runtime-benchmarks',
'pallet-refungible/runtime-benchmarks',
'pallet-nonfungible/runtime-benchmarks',
- 'pallet-rmrk-proxy/runtime-benchmarks',
+ 'pallet-proxy-rmrk-core/runtime-benchmarks',
'pallet-unique/runtime-benchmarks',
'pallet-inflation/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
@@ -90,7 +90,7 @@
'pallet-fungible/std',
'pallet-refungible/std',
'pallet-nonfungible/std',
- 'pallet-rmrk-proxy/std',
+ 'pallet-proxy-rmrk-core/std',
'pallet-unique/std',
'pallet-unq-scheduler/std',
'pallet-charge-transaction/std',
@@ -417,7 +417,7 @@
pallet-fungible = { default-features = false, path = "../../pallets/fungible" }
pallet-refungible = { default-features = false, path = "../../pallets/refungible" }
pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
-pallet-rmrk-proxy = { default-features = false, path = "../../pallets/rmrk-core-proxy", package = "pallet-rmrk-core" }
+pallet-proxy-rmrk-core = { default-features = false, path = "../../pallets/proxy-rmrk-core", package = "pallet-rmrk-core" }
pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }
# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -901,7 +901,7 @@
type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
}
-impl pallet_rmrk_proxy::Config for Runtime {
+impl pallet_proxy_rmrk_core::Config for Runtime {
type Event = Event;
}
@@ -1017,7 +1017,7 @@
Refungible: pallet_refungible::{Pallet, Storage} = 68,
Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
- RmrkProxy: pallet_rmrk_proxy::{Pallet, Call, Storage, Event<T>} = 71,
+ ProxyRmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
// Frontier
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -33,6 +33,7 @@
'pallet-fungible/runtime-benchmarks',
'pallet-refungible/runtime-benchmarks',
'pallet-nonfungible/runtime-benchmarks',
+ 'pallet-proxy-rmrk-core/runtime-benchmarks',
'pallet-unique/runtime-benchmarks',
'pallet-inflation/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
@@ -89,6 +90,7 @@
'pallet-fungible/std',
'pallet-refungible/std',
'pallet-nonfungible/std',
+ 'pallet-proxy-rmrk-core/std',
'pallet-unique/std',
'pallet-unq-scheduler/std',
'pallet-charge-transaction/std',
@@ -414,6 +416,7 @@
pallet-fungible = { default-features = false, path = "../../pallets/fungible" }
pallet-refungible = { default-features = false, path = "../../pallets/refungible" }
pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
+pallet-proxy-rmrk-core = { default-features = false, path = "../../pallets/proxy-rmrk-core", package = "pallet-rmrk-core" }
pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }
# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -33,6 +33,7 @@
'pallet-fungible/runtime-benchmarks',
'pallet-refungible/runtime-benchmarks',
'pallet-nonfungible/runtime-benchmarks',
+ 'pallet-proxy-rmrk-core/runtime-benchmarks',
'pallet-unique/runtime-benchmarks',
'pallet-inflation/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
@@ -89,6 +90,7 @@
'pallet-fungible/std',
'pallet-refungible/std',
'pallet-nonfungible/std',
+ 'pallet-proxy-rmrk-core/std',
'pallet-unique/std',
'pallet-unq-scheduler/std',
'pallet-charge-transaction/std',
@@ -413,6 +415,7 @@
pallet-fungible = { default-features = false, path = "../../pallets/fungible" }
pallet-refungible = { default-features = false, path = "../../pallets/refungible" }
pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
+pallet-proxy-rmrk-core = { default-features = false, path = "../../pallets/proxy-rmrk-core", package = "pallet-rmrk-core" }
pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }
# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }