difftreelog
rename: rmrk-proxy to rmrk-core
in: master
9 files changed
pallets/rmrk-core-proxy/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/pallets/rmrk-core-proxy/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/rmrk-core-proxy/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/rmrk-core-proxy/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/rmrk-core-proxy/src/misc.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/rmrk-core-proxy/src/misc.rs
@@ -0,0 +1,59 @@
+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--- /dev/null
+++ b/pallets/rmrk-core-proxy/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(|_| <Error<T>>::RmrkPropertyIsTooLong)
+ };
+}
pallets/rmrk-proxy/Cargo.tomldiffbeforeafterboth--- a/pallets/rmrk-proxy/Cargo.toml
+++ /dev/null
@@ -1,49 +0,0 @@
-[package]
-name = "pallet-rmrk-proxy"
-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-proxy/src/lib.rsdiffbeforeafterboth--- a/pallets/rmrk-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-proxy/src/misc.rsdiffbeforeafterboth--- a/pallets/rmrk-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-proxy/src/property.rsdiffbeforeafterboth--- a/pallets/rmrk-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(|_| <Error<T>>::RmrkPropertyIsTooLong)
- };
-}
runtime/opal/Cargo.tomldiffbeforeafterboth1################################################################################2# Package34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Opal Runtime'8edition = '2021'9homepage = 'https://unique.network'10license = 'GPLv3'11name = 'opal-runtime'12repository = 'https://github.com/UniqueNetwork/unique-chain'13version = '0.9.20'1415[package.metadata.docs.rs]16targets = ['x86_64-unknown-linux-gnu']1718[features]19default = ['std']20runtime-benchmarks = [21 'hex-literal',22 'frame-benchmarking',23 'frame-support/runtime-benchmarks',24 'frame-system-benchmarking',25 'frame-system/runtime-benchmarks',26 'pallet-ethereum/runtime-benchmarks',27 'pallet-evm-migration/runtime-benchmarks',28 'pallet-evm-coder-substrate/runtime-benchmarks',29 'pallet-balances/runtime-benchmarks',30 'pallet-timestamp/runtime-benchmarks',31 'pallet-common/runtime-benchmarks',32 'pallet-structure/runtime-benchmarks',33 'pallet-fungible/runtime-benchmarks',34 'pallet-refungible/runtime-benchmarks',35 'pallet-nonfungible/runtime-benchmarks',36 'pallet-rmrk-proxy/runtime-benchmarks',37 'pallet-unique/runtime-benchmarks',38 'pallet-inflation/runtime-benchmarks',39 'pallet-xcm/runtime-benchmarks',40 'sp-runtime/runtime-benchmarks',41 'xcm-builder/runtime-benchmarks',42]43try-runtime = [44 'frame-try-runtime',45 'frame-executive/try-runtime',46 'frame-system/try-runtime',47]48std = [49 'codec/std',50 'cumulus-pallet-aura-ext/std',51 'cumulus-pallet-parachain-system/std',52 'cumulus-pallet-xcm/std',53 'cumulus-pallet-xcmp-queue/std',54 'cumulus-primitives-core/std',55 'cumulus-primitives-utility/std',56 'frame-try-runtime/std',57 'frame-executive/std',58 'frame-support/std',59 'frame-system/std',60 'frame-system-rpc-runtime-api/std',61 'pallet-aura/std',62 'pallet-balances/std',63 # 'pallet-contracts/std',64 # 'pallet-contracts-primitives/std',65 # 'pallet-contracts-rpc-runtime-api/std',66 # 'pallet-contract-helpers/std',67 'pallet-randomness-collective-flip/std',68 'pallet-sudo/std',69 'pallet-timestamp/std',70 'pallet-transaction-payment/std',71 'pallet-transaction-payment-rpc-runtime-api/std',72 'pallet-treasury/std',73 # 'pallet-vesting/std',74 'pallet-evm/std',75 'pallet-evm-migration/std',76 'pallet-evm-contract-helpers/std',77 'pallet-evm-transaction-payment/std',78 'pallet-evm-coder-substrate/std',79 'pallet-ethereum/std',80 'pallet-base-fee/std',81 'fp-rpc/std',82 'up-rpc/std',83 'fp-evm-mapping/std',84 'fp-self-contained/std',85 'parachain-info/std',86 'serde',87 'pallet-inflation/std',88 'pallet-common/std',89 'pallet-structure/std',90 'pallet-fungible/std',91 'pallet-refungible/std',92 'pallet-nonfungible/std',93 'pallet-rmrk-proxy/std',94 'pallet-unique/std',95 'pallet-unq-scheduler/std',96 'pallet-charge-transaction/std',97 'up-data-structs/std',98 'sp-api/std',99 'sp-block-builder/std',100 "sp-consensus-aura/std",101 'sp-core/std',102 'sp-inherents/std',103 'sp-io/std',104 'sp-offchain/std',105 'sp-runtime/std',106 'sp-session/std',107 'sp-std/std',108 'sp-transaction-pool/std',109 'sp-version/std',110 'xcm/std',111 'xcm-builder/std',112 'xcm-executor/std',113 'unique-runtime-common/std',114 'rmrk-rpc/std',115116 "orml-vesting/std",117]118limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']119120################################################################################121# Substrate Dependencies122123[dependencies.codec]124default-features = false125features = ['derive']126package = 'parity-scale-codec'127version = '3.1.2'128129[dependencies.frame-benchmarking]130default-features = false131git = "https://github.com/paritytech/substrate"132optional = true133branch = "polkadot-v0.9.21"134135[dependencies.frame-try-runtime]136default-features = false137git = 'https://github.com/paritytech/substrate'138optional = true139branch = 'polkadot-v0.9.21'140141[dependencies.frame-executive]142default-features = false143git = "https://github.com/paritytech/substrate"144branch = "polkadot-v0.9.21"145146[dependencies.frame-support]147default-features = false148git = "https://github.com/paritytech/substrate"149branch = "polkadot-v0.9.21"150151[dependencies.frame-system]152default-features = false153git = "https://github.com/paritytech/substrate"154branch = "polkadot-v0.9.21"155156[dependencies.frame-system-benchmarking]157default-features = false158git = "https://github.com/paritytech/substrate"159optional = true160branch = "polkadot-v0.9.21"161162[dependencies.frame-system-rpc-runtime-api]163default-features = false164git = "https://github.com/paritytech/substrate"165branch = "polkadot-v0.9.21"166167[dependencies.hex-literal]168optional = true169version = '0.3.3'170171[dependencies.serde]172default-features = false173features = ['derive']174optional = true175version = '1.0.130'176177[dependencies.pallet-aura]178default-features = false179git = "https://github.com/paritytech/substrate"180branch = "polkadot-v0.9.21"181182[dependencies.pallet-balances]183default-features = false184git = "https://github.com/paritytech/substrate"185branch = "polkadot-v0.9.21"186187# Contracts specific packages188# [dependencies.pallet-contracts]189# git = 'https://github.com/paritytech/substrate'190# default-features = false191# branch = 'master'192# version = '4.0.0-dev'193194# [dependencies.pallet-contracts-primitives]195# git = 'https://github.com/paritytech/substrate'196# default-features = false197# branch = 'master'198# version = '4.0.0-dev'199200# [dependencies.pallet-contracts-rpc-runtime-api]201# git = 'https://github.com/paritytech/substrate'202# default-features = false203# branch = 'master'204# version = '4.0.0-dev'205206[dependencies.pallet-randomness-collective-flip]207default-features = false208git = "https://github.com/paritytech/substrate"209branch = "polkadot-v0.9.21"210211[dependencies.pallet-sudo]212default-features = false213git = "https://github.com/paritytech/substrate"214branch = "polkadot-v0.9.21"215216[dependencies.pallet-timestamp]217default-features = false218git = "https://github.com/paritytech/substrate"219branch = "polkadot-v0.9.21"220221[dependencies.pallet-transaction-payment]222default-features = false223git = "https://github.com/paritytech/substrate"224branch = "polkadot-v0.9.21"225226[dependencies.pallet-transaction-payment-rpc-runtime-api]227default-features = false228git = "https://github.com/paritytech/substrate"229branch = "polkadot-v0.9.21"230231[dependencies.pallet-treasury]232default-features = false233git = "https://github.com/paritytech/substrate"234branch = "polkadot-v0.9.21"235236# [dependencies.pallet-vesting]237# default-features = false238# git = 'https://github.com/paritytech/substrate'239# branch = 'master'240241[dependencies.sp-arithmetic]242default-features = false243git = "https://github.com/paritytech/substrate"244branch = "polkadot-v0.9.21"245246[dependencies.sp-api]247default-features = false248git = "https://github.com/paritytech/substrate"249branch = "polkadot-v0.9.21"250251[dependencies.sp-block-builder]252default-features = false253git = "https://github.com/paritytech/substrate"254branch = "polkadot-v0.9.21"255256[dependencies.sp-core]257default-features = false258git = "https://github.com/paritytech/substrate"259branch = "polkadot-v0.9.21"260261[dependencies.sp-consensus-aura]262default-features = false263git = "https://github.com/paritytech/substrate"264branch = "polkadot-v0.9.21"265266[dependencies.sp-inherents]267default-features = false268git = "https://github.com/paritytech/substrate"269branch = "polkadot-v0.9.21"270271[dependencies.sp-io]272default-features = false273git = "https://github.com/paritytech/substrate"274branch = "polkadot-v0.9.21"275276[dependencies.sp-offchain]277default-features = false278git = "https://github.com/paritytech/substrate"279branch = "polkadot-v0.9.21"280281[dependencies.sp-runtime]282default-features = false283git = "https://github.com/paritytech/substrate"284branch = "polkadot-v0.9.21"285286[dependencies.sp-session]287default-features = false288git = "https://github.com/paritytech/substrate"289branch = "polkadot-v0.9.21"290291[dependencies.sp-std]292default-features = false293git = "https://github.com/paritytech/substrate"294branch = "polkadot-v0.9.21"295296[dependencies.sp-transaction-pool]297default-features = false298git = "https://github.com/paritytech/substrate"299branch = "polkadot-v0.9.21"300301[dependencies.sp-version]302default-features = false303git = "https://github.com/paritytech/substrate"304branch = "polkadot-v0.9.21"305306[dependencies.smallvec]307version = '1.6.1'308309################################################################################310# Cumulus dependencies311312[dependencies.parachain-info]313default-features = false314git = "https://github.com/uniquenetwork/cumulus"315branch = "polkadot-v0.9.21"316317[dependencies.cumulus-pallet-aura-ext]318git = "https://github.com/uniquenetwork/cumulus"319branch = "polkadot-v0.9.21"320default-features = false321322[dependencies.cumulus-pallet-parachain-system]323git = "https://github.com/uniquenetwork/cumulus"324branch = "polkadot-v0.9.21"325default-features = false326327[dependencies.cumulus-primitives-core]328git = "https://github.com/uniquenetwork/cumulus"329branch = "polkadot-v0.9.21"330default-features = false331332[dependencies.cumulus-pallet-xcm]333git = "https://github.com/uniquenetwork/cumulus"334branch = "polkadot-v0.9.21"335default-features = false336337[dependencies.cumulus-pallet-dmp-queue]338git = "https://github.com/uniquenetwork/cumulus"339branch = "polkadot-v0.9.21"340default-features = false341342[dependencies.cumulus-pallet-xcmp-queue]343git = "https://github.com/uniquenetwork/cumulus"344branch = "polkadot-v0.9.21"345default-features = false346347[dependencies.cumulus-primitives-utility]348git = "https://github.com/uniquenetwork/cumulus"349branch = "polkadot-v0.9.21"350default-features = false351352[dependencies.cumulus-primitives-timestamp]353git = "https://github.com/uniquenetwork/cumulus"354branch = "polkadot-v0.9.21"355default-features = false356357################################################################################358# Polkadot dependencies359360[dependencies.polkadot-parachain]361git = "https://github.com/paritytech/polkadot"362branch = "release-v0.9.21"363default-features = false364365[dependencies.xcm]366git = "https://github.com/paritytech/polkadot"367branch = "release-v0.9.21"368default-features = false369370[dependencies.xcm-builder]371git = "https://github.com/paritytech/polkadot"372branch = "release-v0.9.21"373default-features = false374375[dependencies.xcm-executor]376git = "https://github.com/paritytech/polkadot"377branch = "release-v0.9.21"378default-features = false379380[dependencies.pallet-xcm]381git = "https://github.com/paritytech/polkadot"382branch = "release-v0.9.21"383default-features = false384385[dependencies.orml-vesting]386git = "https://github.com/uniquenetwork/open-runtime-module-library"387branch = "unique-polkadot-v0.9.21"388version = "0.4.1-dev"389default-features = false390391################################################################################392# RMRK dependencies393394# todo git395[dependencies.rmrk-rpc]396default-features = false397git = "https://github.com/UniqueNetwork/rmrk-substrate.git"398branch = "feature/separate-types-and-traits"399400################################################################################401# local dependencies402403[dependencies]404log = { version = "0.4.16", default-features = false }405unique-runtime-common = { path = "../common", default-features = false }406scale-info = { version = "2.0.1", default-features = false, features = [407 "derive",408] }409derivative = "2.2.0"410pallet-unique = { path = '../../pallets/unique', default-features = false }411up-rpc = { path = "../../primitives/rpc", default-features = false }412fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }413pallet-inflation = { path = '../../pallets/inflation', default-features = false }414up-data-structs = { path = '../../primitives/data-structs', default-features = false }415pallet-common = { default-features = false, path = "../../pallets/common" }416pallet-structure = { default-features = false, path = "../../pallets/structure" }417pallet-fungible = { default-features = false, path = "../../pallets/fungible" }418pallet-refungible = { default-features = false, path = "../../pallets/refungible" }419pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }420pallet-rmrk-proxy = { default-features = false, path = "../../pallets/rmrk-core-proxy", package = "pallet-rmrk-core" }421pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }422# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }423pallet-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" }424pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }425pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }426pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }427pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }428pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }429pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }430pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }431fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }432fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }433434################################################################################435# Build Dependencies436437[build-dependencies.substrate-wasm-builder]438git = "https://github.com/paritytech/substrate"439branch = "polkadot-v0.9.21"