difftreelog
feat add rmrk proxy create_base
in: master
12 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5513,6 +5513,7 @@
"pallet-randomness-collective-flip",
"pallet-refungible",
"pallet-rmrk-core",
+ "pallet-rmrk-equip",
"pallet-structure",
"pallet-sudo",
"pallet-template-transaction-payment",
@@ -6533,6 +6534,25 @@
]
[[package]]
+name = "pallet-rmrk-equip"
+version = "0.1.0"
+dependencies = [
+ "frame-benchmarking",
+ "frame-support",
+ "frame-system",
+ "pallet-common",
+ "pallet-evm",
+ "pallet-nonfungible",
+ "pallet-rmrk-core",
+ "parity-scale-codec 3.1.2",
+ "scale-info",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+ "up-data-structs",
+]
+
+[[package]]
name = "pallet-scheduler"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.21#563f4820d8f36d256ada7ea3fef46b2e94c4cd5a"
pallets/proxy-rmrk-core/Cargo.tomldiffbeforeafterboth--- a/pallets/proxy-rmrk-core/Cargo.toml
+++ b/pallets/proxy-rmrk-core/Cargo.toml
@@ -18,10 +18,7 @@
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"] }
@@ -37,9 +34,6 @@
"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 = [
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};20use frame_system::{pallet_prelude::*, ensure_signed};21use sp_runtime::{DispatchError, Permill, traits::StaticLookup};22use sp_std::vec::Vec;23use up_data_structs::*;24use pallet_common::{Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations};25use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle, TokenData};26use pallet_evm::account::CrossAccountId;2728pub use pallet::*;2930pub mod misc;31pub mod property;3233use misc::*;34pub use property::*;3536#[frame_support::pallet]37pub mod pallet {38 use super::*;39 use pallet_evm::account;4041 #[pallet::config]42 pub trait Config: frame_system::Config43 + pallet_common::Config44 + pallet_nonfungible::Config45 + account::Config {46 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;47 }4849 #[pallet::storage]50 #[pallet::getter(fn collection_index)]51 pub type CollectionIndex<T: Config> = StorageValue<_, RmrkCollectionId, ValueQuery>;5253 #[pallet::pallet]54 #[pallet::generate_store(pub(super) trait Store)]55 pub struct Pallet<T>(_);5657 #[pallet::event]58 #[pallet::generate_deposit(pub(super) fn deposit_event)]59 pub enum Event<T: Config> {60 CollectionCreated {61 issuer: T::AccountId,62 collection_id: RmrkCollectionId,63 },64 CollectionDestroyed {65 issuer: T::AccountId,66 collection_id: RmrkCollectionId,67 },68 IssuerChanged {69 old_issuer: T::AccountId,70 new_issuer: T::AccountId,71 collection_id: RmrkCollectionId,72 },73 CollectionLocked {74 issuer: T::AccountId,75 collection_id: RmrkCollectionId,76 },77 NftMinted {78 owner: T::AccountId,79 collection_id: RmrkCollectionId,80 nft_id: RmrkNftId,81 },82 NFTBurned {83 owner: T::AccountId,84 nft_id: RmrkNftId,85 },86 }8788 #[pallet::error]89 pub enum Error<T> {90 /* Unique-specific events */91 CorruptedCollectionType,92 NftTypeEncodeError,93 RmrkPropertyKeyIsTooLong,94 RmrkPropertyValueIsTooLong,9596 /* RMRK compatible events */97 CollectionNotEmpty,98 NoAvailableCollectionId,99 NoAvailableNftId,100 CollectionUnknown,101 NoPermission,102 CollectionFullOrLocked,103 }104105 #[pallet::call]106 impl<T: Config> Pallet<T> {107 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]108 #[transactional]109 pub fn create_collection(110 origin: OriginFor<T>,111 metadata: RmrkString,112 max: Option<u32>,113 symbol: RmrkCollectionSymbol,114 ) -> DispatchResult {115 let sender = ensure_signed(origin)?;116117 let limits = CollectionLimits {118 owner_can_transfer: Some(false),119 token_limit: max,120 ..Default::default()121 };122123 let data = CreateCollectionData {124 limits: Some(limits),125 token_prefix: symbol.into_inner()126 .try_into()127 .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,128 ..Default::default()129 };130131 let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);132133 if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {134 return Err(<Error<T>>::NoAvailableCollectionId.into());135 }136137 let collection_id = collection_id_res?;138139 let collection = Self::get_nft_collection(collection_id)?.into_inner();140141 <PalletCommon<T>>::set_scoped_collection_properties(142 &collection,143 PropertyScope::Rmrk,144 [145 rmrk_property!(Config=T, Metadata: metadata)?,146 rmrk_property!(Config=T, CollectionType: CollectionType::Regular)?,147 ].into_iter()148 )?;149150 <CollectionIndex<T>>::mutate(|n| *n += 1);151152 Self::deposit_event(Event::CollectionCreated {153 issuer: sender,154 collection_id: collection_id.0155 });156157 Ok(())158 }159160 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]161 #[transactional]162 pub fn destroy_collection(163 origin: OriginFor<T>,164 collection_id: RmrkCollectionId,165 ) -> DispatchResult {166 let sender = ensure_signed(origin)?;167 let cross_sender = T::CrossAccountId::from_sub(sender.clone());168169 let unique_collection_id = collection_id.into();170171 let collection = Self::get_typed_nft_collection(unique_collection_id, CollectionType::Regular)?;172173 ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);174175 <PalletNft<T>>::destroy_collection(collection, &cross_sender)176 .map_err(Self::map_common_err_to_proxy)?;177178 Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });179180 Ok(())181 }182183 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]184 #[transactional]185 pub fn change_collection_issuer(186 origin: OriginFor<T>,187 collection_id: RmrkCollectionId,188 new_issuer: <T::Lookup as StaticLookup>::Source,189 ) -> DispatchResult {190 let sender = ensure_signed(origin)?;191192 let new_issuer = T::Lookup::lookup(new_issuer)?;193194 Self::change_collection_owner(195 collection_id.into(),196 CollectionType::Regular,197 sender.clone(),198 new_issuer.clone()199 )?;200201 Self::deposit_event(Event::IssuerChanged {202 old_issuer: sender,203 new_issuer,204 collection_id,205 });206207 Ok(())208 }209210 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]211 #[transactional]212 pub fn lock_collection(213 origin: OriginFor<T>,214 collection_id: RmrkCollectionId,215 ) -> DispatchResult {216 let sender = ensure_signed(origin)?;217 let cross_sender = T::CrossAccountId::from_sub(sender.clone());218219 let collection = Self::get_typed_nft_collection(220 collection_id.into(),221 CollectionType::Regular222 )?;223224 Self::check_collection_owner(&collection, &cross_sender)?;225226 let token_count = collection.total_supply();227228 let mut collection = collection.into_inner();229 collection.limits.token_limit = Some(token_count);230 collection.save()?;231232 Self::deposit_event(Event::CollectionLocked { issuer: sender, collection_id });233234 Ok(())235 }236237 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]238 #[transactional]239 pub fn mint_nft(240 origin: OriginFor<T>,241 owner: T::AccountId,242 collection_id: RmrkCollectionId,243 recipient: Option<T::AccountId>,244 royalty_amount: Option<Permill>,245 metadata: RmrkString,246 ) -> DispatchResult {247 let sender = ensure_signed(origin)?;248 let sender = T::CrossAccountId::from_sub(sender);249 let cross_owner = T::CrossAccountId::from_sub(owner.clone());250251 let royalty_info = royalty_amount.map(|amount| rmrk::RoyaltyInfo {252 recipient: recipient.unwrap_or_else(|| owner.clone()),253 amount254 });255256 let nft_id = Self::create_nft(257 sender,258 cross_owner,259 collection_id.into(),260 CollectionType::Regular,261 NftType::Regular,262 [263 rmrk_property!(Config=T, RoyaltyInfo: royalty_info)?,264 rmrk_property!(Config=T, Metadata: metadata)?,265 rmrk_property!(Config=T, Equipped: false)?,266 rmrk_property!(Config=T, ResourceCollection: None::<CollectionId>)?,267 rmrk_property!(Config=T, ResourcePriorities: <Vec<u8>>::new())?,268 ].into_iter()269 )?;270271 Self::deposit_event(Event::NftMinted {272 owner,273 collection_id,274 nft_id: nft_id.0275 });276277 Ok(())278 }279280 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]281 #[transactional]282 pub fn burn_nft(283 origin: OriginFor<T>,284 collection_id: RmrkCollectionId,285 nft_id: RmrkNftId,286 ) -> DispatchResult {287 let sender = ensure_signed(origin.clone())?;288 let cross_sender = T::CrossAccountId::from_sub(sender.clone());289290 Self::destroy_nft(291 cross_sender,292 collection_id.into(),293 CollectionType::Regular,294 nft_id.into()295 )?;296297 Self::deposit_event(Event::NFTBurned { owner: sender, nft_id });298299 Ok(())300 }301 }302}303304impl<T: Config> Pallet<T> {305 fn create_nft(306 sender: T::CrossAccountId,307 owner: T::CrossAccountId,308 collection_id: CollectionId,309 collection_type: CollectionType,310 nft_type: NftType,311 properties: impl Iterator<Item=Property>312 ) -> Result<TokenId, DispatchError> {313 let collection = Self::get_typed_nft_collection(314 collection_id,315 collection_type316 )?;317318 let data = CreateNftExData {319 const_data: nft_type.encode()320 .try_into()321 .map_err(|_| <Error<T>>::NftTypeEncodeError)?,322 properties: BoundedVec::default(),323 owner,324 };325326 let budget = budget::Value::new(2);327328 <PalletNft<T>>::create_item(329 &collection,330 &sender,331 data,332 &budget,333 ).map_err(Self::map_common_err_to_proxy)?;334335 let nft_id = <PalletNft<T>>::current_token_id(&collection);336337 <PalletNft<T>>::set_scoped_token_properties(338 &collection,339 nft_id,340 PropertyScope::Rmrk,341 properties342 )?;343344 Ok(nft_id)345 }346347 fn destroy_nft(348 sender: T::CrossAccountId,349 collection_id: CollectionId,350 collection_type: CollectionType,351 token_id: TokenId352 ) -> DispatchResult {353 let collection = Self::get_typed_nft_collection(354 collection_id,355 collection_type356 )?;357358 <PalletNft<T>>::burn(&collection, &sender, token_id)359 .map_err(Self::map_common_err_to_proxy)?;360361 Ok(())362 }363364 fn change_collection_owner(365 collection_id: CollectionId,366 collection_type: CollectionType,367 sender: T::AccountId,368 new_owner: T::AccountId,369 ) -> DispatchResult {370 let collection = Self::get_typed_nft_collection(371 collection_id,372 collection_type373 )?;374 Self::check_collection_owner(&collection, &T::CrossAccountId::from_sub(sender))?;375376 let mut collection = collection.into_inner();377378 collection.owner = new_owner;379 collection.save()380 }381382 fn check_collection_owner(collection: &NonfungibleHandle<T>, account: &T::CrossAccountId) -> DispatchResult {383 collection.check_is_owner(account)384 .map_err(Self::map_common_err_to_proxy)385 }386387 pub fn last_collection_idx() -> RmrkCollectionId {388 <CollectionIndex<T>>::get()389 }390391 pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {392 let collection = <CollectionHandle<T>>::try_get(collection_id)393 .map_err(|_| <Error<T>>::CollectionUnknown)?394 .into_nft_collection()?;395396 Ok(collection)397 }398399 // should this even be here, might displace it to common/nonfungible -- but they did not need it, only rmrk does400 pub fn collection_exists(collection_id: CollectionId) -> bool {401 <pallet_common::CollectionById<T>>::contains_key(collection_id)402 }403404 pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {405 <TokenData<T>>::contains_key((collection_id, nft_id))406 }407408 pub fn get_collection_property(collection_id: CollectionId, key: RmrkProperty) -> Result<PropertyValue, DispatchError> {409 let collection_property = <PalletCommon<T>>::collection_properties(collection_id)410 .get(&rmrk_property!(Config=T, key)?)411 .ok_or(<Error<T>>::CollectionUnknown)?412 .clone();413414 Ok(collection_property)415 }416417 pub fn get_collection_type(collection_id: CollectionId) -> Result<CollectionType, DispatchError> {418 let value = Self::get_collection_property(collection_id, RmrkProperty::CollectionType)?;419 let collection_type: CollectionType = (&value)420 .try_into()421 .map_err(<Error<T>>::from)?;422423 Ok(collection_type)424 }425426 pub fn ensure_collection_type(collection_id: CollectionId, collection_type: CollectionType) -> DispatchResult {427 let actual_type = Self::get_collection_type(collection_id)?;428 ensure!(actual_type == collection_type, <CommonError<T>>::NoPermission);429430 Ok(())431 }432433 pub fn get_nft_property(collection_id: CollectionId, nft_id: TokenId, key: RmrkProperty) -> Result<PropertyValue, DispatchError> {434 let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))435 .get(&rmrk_property!(Config=T, key)?)436 .ok_or(<Error<T>>::NoAvailableNftId)?437 .clone();438439 Ok(nft_property)440 }441442 pub fn get_nft_type(collection_id: CollectionId, token_id: TokenId) -> Result<NftType, DispatchError> {443 <TokenData<T>>::get((collection_id, token_id))444 .unwrap()445 .rmrk_nft_type()446 .ok_or_else(|| <Error<T>>::NoAvailableNftId.into())447 }448449 pub fn ensure_nft_type(collection_id: CollectionId, token_id: TokenId, nft_type: NftType) -> DispatchResult {450 let actual_type = Self::get_nft_type(collection_id, token_id)?;451 ensure!(actual_type == nft_type, <CommonError<T>>::NoPermission);452453 Ok(())454 }455456 pub fn filter_theme_properties(457 collection_id: CollectionId,458 token_id: TokenId,459 filter_keys: Option<Vec<RmrkPropertyKey>>460 ) -> Result<Vec<RmrkThemeProperty>, DispatchError> {461 filter_keys.map(|keys| {462 let properties = keys.into_iter()463 .filter_map(|key| {464 let key: RmrkString = key.try_into().ok()?;465466 let value = Self::get_nft_property(467 collection_id,468 token_id,469 RmrkProperty::ThemeProperty(&key)470 ).ok()?.decode_or_default();471472 let property = RmrkThemeProperty {473 key,474 value475 };476477 Some(property)478 })479 .collect();480481 Ok(properties)482 }).unwrap_or_else(|| {483 let properties = Self::iterate_theme_properties(collection_id, token_id)?484 .collect();485486 Ok(properties)487 })488 }489490 pub fn iterate_theme_properties(491 collection_id: CollectionId,492 token_id: TokenId493 ) -> Result<impl Iterator<Item=RmrkThemeProperty>, DispatchError> {494 let key_prefix = rmrk_property!(Config=T, key: ThemeProperty(&RmrkString::default()))?;495496 let properties = <PalletNft<T>>::token_properties((collection_id, token_id))497 .into_iter()498 .filter_map(move |(key, value)| {499 let key = key.as_slice().strip_prefix(key_prefix.as_slice())?;500501 let key: RmrkString = key.to_vec().try_into().ok()?;502 let value: RmrkString = value.decode_or_default();503504 let property = RmrkThemeProperty {505 key,506 value507 };508509 Some(property)510 });511512 Ok(properties)513 }514515 pub fn get_typed_nft_collection(516 collection_id: CollectionId,517 collection_type: CollectionType518 ) -> Result<NonfungibleHandle<T>, DispatchError> {519 Self::ensure_collection_type(collection_id, collection_type)?;520521 Self::get_nft_collection(collection_id)522 }523524 fn map_common_err_to_proxy(err: DispatchError) -> DispatchError {525 map_common_err_to_proxy! {526 match err {527 NoPermission => NoPermission,528 CollectionTokenLimitExceeded => CollectionFullOrLocked,529 PublicMintingNotAllowed => NoPermission,530 TokenNotFound => NoAvailableNftId531 }532 }533 }534}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};20use frame_system::{pallet_prelude::*, ensure_signed};21use sp_runtime::{DispatchError, Permill, traits::StaticLookup};22use sp_std::vec::Vec;23use up_data_structs::*;24use pallet_common::{Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations};25use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle, TokenData};26use pallet_evm::account::CrossAccountId;2728pub use pallet::*;2930pub mod misc;31pub mod property;3233use misc::*;34pub use property::*;3536#[frame_support::pallet]37pub mod pallet {38 use super::*;39 use pallet_evm::account;4041 #[pallet::config]42 pub trait Config: frame_system::Config43 + pallet_common::Config44 + pallet_nonfungible::Config45 + account::Config {46 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;47 }4849 #[pallet::storage]50 #[pallet::getter(fn collection_index)]51 pub type CollectionIndex<T: Config> = StorageValue<_, RmrkCollectionId, ValueQuery>;5253 #[pallet::pallet]54 #[pallet::generate_store(pub(super) trait Store)]55 pub struct Pallet<T>(_);5657 #[pallet::event]58 #[pallet::generate_deposit(pub(super) fn deposit_event)]59 pub enum Event<T: Config> {60 CollectionCreated {61 issuer: T::AccountId,62 collection_id: RmrkCollectionId,63 },64 CollectionDestroyed {65 issuer: T::AccountId,66 collection_id: RmrkCollectionId,67 },68 IssuerChanged {69 old_issuer: T::AccountId,70 new_issuer: T::AccountId,71 collection_id: RmrkCollectionId,72 },73 CollectionLocked {74 issuer: T::AccountId,75 collection_id: RmrkCollectionId,76 },77 NftMinted {78 owner: T::AccountId,79 collection_id: RmrkCollectionId,80 nft_id: RmrkNftId,81 },82 NFTBurned {83 owner: T::AccountId,84 nft_id: RmrkNftId,85 },86 }8788 #[pallet::error]89 pub enum Error<T> {90 /* Unique-specific events */91 CorruptedCollectionType,92 NftTypeEncodeError,93 RmrkPropertyKeyIsTooLong,94 RmrkPropertyValueIsTooLong,9596 /* RMRK compatible events */97 CollectionNotEmpty,98 NoAvailableCollectionId,99 NoAvailableNftId,100 CollectionUnknown,101 NoPermission,102 CollectionFullOrLocked,103 }104105 #[pallet::call]106 impl<T: Config> Pallet<T> {107 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]108 #[transactional]109 pub fn create_collection(110 origin: OriginFor<T>,111 metadata: RmrkString,112 max: Option<u32>,113 symbol: RmrkCollectionSymbol,114 ) -> DispatchResult {115 let sender = ensure_signed(origin)?;116117 let limits = CollectionLimits {118 owner_can_transfer: Some(false),119 token_limit: max,120 ..Default::default()121 };122123 let data = CreateCollectionData {124 limits: Some(limits),125 token_prefix: symbol.into_inner()126 .try_into()127 .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,128 ..Default::default()129 };130131 let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);132133 if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {134 return Err(<Error<T>>::NoAvailableCollectionId.into());135 }136137 let collection_id = collection_id_res?;138139 let collection = Self::get_nft_collection(collection_id)?.into_inner();140141 <PalletCommon<T>>::set_scoped_collection_properties(142 &collection,143 PropertyScope::Rmrk,144 [145 rmrk_property!(Config=T, Metadata: metadata)?,146 rmrk_property!(Config=T, CollectionType: CollectionType::Regular)?,147 ].into_iter()148 )?;149150 <CollectionIndex<T>>::mutate(|n| *n += 1);151152 Self::deposit_event(Event::CollectionCreated {153 issuer: sender,154 collection_id: collection_id.0155 });156157 Ok(())158 }159160 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]161 #[transactional]162 pub fn destroy_collection(163 origin: OriginFor<T>,164 collection_id: RmrkCollectionId,165 ) -> DispatchResult {166 let sender = ensure_signed(origin)?;167 let cross_sender = T::CrossAccountId::from_sub(sender.clone());168169 let unique_collection_id = collection_id.into();170171 let collection = Self::get_typed_nft_collection(unique_collection_id, CollectionType::Regular)?;172173 ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);174175 <PalletNft<T>>::destroy_collection(collection, &cross_sender)176 .map_err(Self::map_common_err_to_proxy)?;177178 Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });179180 Ok(())181 }182183 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]184 #[transactional]185 pub fn change_collection_issuer(186 origin: OriginFor<T>,187 collection_id: RmrkCollectionId,188 new_issuer: <T::Lookup as StaticLookup>::Source,189 ) -> DispatchResult {190 let sender = ensure_signed(origin)?;191192 let new_issuer = T::Lookup::lookup(new_issuer)?;193194 Self::change_collection_owner(195 collection_id.into(),196 CollectionType::Regular,197 sender.clone(),198 new_issuer.clone()199 )?;200201 Self::deposit_event(Event::IssuerChanged {202 old_issuer: sender,203 new_issuer,204 collection_id,205 });206207 Ok(())208 }209210 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]211 #[transactional]212 pub fn lock_collection(213 origin: OriginFor<T>,214 collection_id: RmrkCollectionId,215 ) -> DispatchResult {216 let sender = ensure_signed(origin)?;217 let cross_sender = T::CrossAccountId::from_sub(sender.clone());218219 let collection = Self::get_typed_nft_collection(220 collection_id.into(),221 CollectionType::Regular222 )?;223224 Self::check_collection_owner(&collection, &cross_sender)?;225226 let token_count = collection.total_supply();227228 let mut collection = collection.into_inner();229 collection.limits.token_limit = Some(token_count);230 collection.save()?;231232 Self::deposit_event(Event::CollectionLocked { issuer: sender, collection_id });233234 Ok(())235 }236237 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]238 #[transactional]239 pub fn mint_nft(240 origin: OriginFor<T>,241 owner: T::AccountId,242 collection_id: RmrkCollectionId,243 recipient: Option<T::AccountId>,244 royalty_amount: Option<Permill>,245 metadata: RmrkString,246 ) -> DispatchResult {247 let sender = ensure_signed(origin)?;248 let sender = T::CrossAccountId::from_sub(sender);249 let cross_owner = T::CrossAccountId::from_sub(owner.clone());250251 let royalty_info = royalty_amount.map(|amount| rmrk::RoyaltyInfo {252 recipient: recipient.unwrap_or_else(|| owner.clone()),253 amount254 });255256 let nft_id = Self::create_nft(257 &sender,258 &cross_owner,259 collection_id.into(),260 CollectionType::Regular,261 NftType::Regular,262 [263 rmrk_property!(Config=T, RoyaltyInfo: royalty_info)?,264 rmrk_property!(Config=T, Metadata: metadata)?,265 rmrk_property!(Config=T, Equipped: false)?,266 rmrk_property!(Config=T, ResourceCollection: None::<CollectionId>)?,267 rmrk_property!(Config=T, ResourcePriorities: <Vec<u8>>::new())?,268 ].into_iter()269 )?;270271 Self::deposit_event(Event::NftMinted {272 owner,273 collection_id,274 nft_id: nft_id.0275 });276277 Ok(())278 }279280 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]281 #[transactional]282 pub fn burn_nft(283 origin: OriginFor<T>,284 collection_id: RmrkCollectionId,285 nft_id: RmrkNftId,286 ) -> DispatchResult {287 let sender = ensure_signed(origin.clone())?;288 let cross_sender = T::CrossAccountId::from_sub(sender.clone());289290 Self::destroy_nft(291 cross_sender,292 collection_id.into(),293 CollectionType::Regular,294 nft_id.into()295 )?;296297 Self::deposit_event(Event::NFTBurned { owner: sender, nft_id });298299 Ok(())300 }301 }302}303304impl<T: Config> Pallet<T> {305 pub fn create_nft(306 sender: &T::CrossAccountId,307 owner: &T::CrossAccountId,308 collection_id: CollectionId,309 collection_type: CollectionType,310 nft_type: NftType,311 properties: impl Iterator<Item=Property>312 ) -> Result<TokenId, DispatchError> {313 let collection = Self::get_typed_nft_collection(314 collection_id,315 collection_type316 )?;317318 let data = CreateNftExData {319 const_data: nft_type.encode()320 .try_into()321 .map_err(|_| <Error<T>>::NftTypeEncodeError)?,322 properties: BoundedVec::default(),323 owner: owner.clone(),324 };325326 let budget = budget::Value::new(2);327328 <PalletNft<T>>::create_item(329 &collection,330 sender,331 data,332 &budget,333 ).map_err(Self::map_common_err_to_proxy)?;334335 let nft_id = <PalletNft<T>>::current_token_id(&collection);336337 <PalletNft<T>>::set_scoped_token_properties(338 &collection,339 nft_id,340 PropertyScope::Rmrk,341 properties342 )?;343344 Ok(nft_id)345 }346347 fn destroy_nft(348 sender: T::CrossAccountId,349 collection_id: CollectionId,350 collection_type: CollectionType,351 token_id: TokenId352 ) -> DispatchResult {353 let collection = Self::get_typed_nft_collection(354 collection_id,355 collection_type356 )?;357358 <PalletNft<T>>::burn(&collection, &sender, token_id)359 .map_err(Self::map_common_err_to_proxy)?;360361 Ok(())362 }363364 fn change_collection_owner(365 collection_id: CollectionId,366 collection_type: CollectionType,367 sender: T::AccountId,368 new_owner: T::AccountId,369 ) -> DispatchResult {370 let collection = Self::get_typed_nft_collection(371 collection_id,372 collection_type373 )?;374 Self::check_collection_owner(&collection, &T::CrossAccountId::from_sub(sender))?;375376 let mut collection = collection.into_inner();377378 collection.owner = new_owner;379 collection.save()380 }381382 fn check_collection_owner(collection: &NonfungibleHandle<T>, account: &T::CrossAccountId) -> DispatchResult {383 collection.check_is_owner(account)384 .map_err(Self::map_common_err_to_proxy)385 }386387 pub fn last_collection_idx() -> RmrkCollectionId {388 <CollectionIndex<T>>::get()389 }390391 pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {392 let collection = <CollectionHandle<T>>::try_get(collection_id)393 .map_err(|_| <Error<T>>::CollectionUnknown)?394 .into_nft_collection()?;395396 Ok(collection)397 }398399 // should this even be here, might displace it to common/nonfungible -- but they did not need it, only rmrk does400 pub fn collection_exists(collection_id: CollectionId) -> bool {401 <pallet_common::CollectionById<T>>::contains_key(collection_id)402 }403404 pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {405 <TokenData<T>>::contains_key((collection_id, nft_id))406 }407408 pub fn get_collection_property(collection_id: CollectionId, key: RmrkProperty) -> Result<PropertyValue, DispatchError> {409 let collection_property = <PalletCommon<T>>::collection_properties(collection_id)410 .get(&rmrk_property!(Config=T, key)?)411 .ok_or(<Error<T>>::CollectionUnknown)?412 .clone();413414 Ok(collection_property)415 }416417 pub fn get_collection_type(collection_id: CollectionId) -> Result<CollectionType, DispatchError> {418 let value = Self::get_collection_property(collection_id, RmrkProperty::CollectionType)?;419 let collection_type: CollectionType = (&value)420 .try_into()421 .map_err(<Error<T>>::from)?;422423 Ok(collection_type)424 }425426 pub fn ensure_collection_type(collection_id: CollectionId, collection_type: CollectionType) -> DispatchResult {427 let actual_type = Self::get_collection_type(collection_id)?;428 ensure!(actual_type == collection_type, <CommonError<T>>::NoPermission);429430 Ok(())431 }432433 pub fn get_nft_property(collection_id: CollectionId, nft_id: TokenId, key: RmrkProperty) -> Result<PropertyValue, DispatchError> {434 let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))435 .get(&rmrk_property!(Config=T, key)?)436 .ok_or(<Error<T>>::NoAvailableNftId)?437 .clone();438439 Ok(nft_property)440 }441442 pub fn get_nft_type(collection_id: CollectionId, token_id: TokenId) -> Result<NftType, DispatchError> {443 <TokenData<T>>::get((collection_id, token_id))444 .unwrap()445 .rmrk_nft_type()446 .ok_or_else(|| <Error<T>>::NoAvailableNftId.into())447 }448449 pub fn ensure_nft_type(collection_id: CollectionId, token_id: TokenId, nft_type: NftType) -> DispatchResult {450 let actual_type = Self::get_nft_type(collection_id, token_id)?;451 ensure!(actual_type == nft_type, <CommonError<T>>::NoPermission);452453 Ok(())454 }455456 pub fn filter_theme_properties(457 collection_id: CollectionId,458 token_id: TokenId,459 filter_keys: Option<Vec<RmrkPropertyKey>>460 ) -> Result<Vec<RmrkThemeProperty>, DispatchError> {461 filter_keys.map(|keys| {462 let properties = keys.into_iter()463 .filter_map(|key| {464 let key: RmrkString = key.try_into().ok()?;465466 let value = Self::get_nft_property(467 collection_id,468 token_id,469 RmrkProperty::ThemeProperty(&key)470 ).ok()?.decode_or_default();471472 let property = RmrkThemeProperty {473 key,474 value475 };476477 Some(property)478 })479 .collect();480481 Ok(properties)482 }).unwrap_or_else(|| {483 let properties = Self::iterate_theme_properties(collection_id, token_id)?484 .collect();485486 Ok(properties)487 })488 }489490 pub fn iterate_theme_properties(491 collection_id: CollectionId,492 token_id: TokenId493 ) -> Result<impl Iterator<Item=RmrkThemeProperty>, DispatchError> {494 let key_prefix = rmrk_property!(Config=T, key: ThemeProperty(&RmrkString::default()))?;495496 let properties = <PalletNft<T>>::token_properties((collection_id, token_id))497 .into_iter()498 .filter_map(move |(key, value)| {499 let key = key.as_slice().strip_prefix(key_prefix.as_slice())?;500501 let key: RmrkString = key.to_vec().try_into().ok()?;502 let value: RmrkString = value.decode_or_default();503504 let property = RmrkThemeProperty {505 key,506 value507 };508509 Some(property)510 });511512 Ok(properties)513 }514515 pub fn get_typed_nft_collection(516 collection_id: CollectionId,517 collection_type: CollectionType518 ) -> Result<NonfungibleHandle<T>, DispatchError> {519 Self::ensure_collection_type(collection_id, collection_type)?;520521 Self::get_nft_collection(collection_id)522 }523524 fn map_common_err_to_proxy(err: DispatchError) -> DispatchError {525 map_common_err_to_proxy! {526 match err {527 NoPermission => NoPermission,528 CollectionTokenLimitExceeded => CollectionFullOrLocked,529 PublicMintingNotAllowed => NoPermission,530 TokenNotFound => NoAvailableNftId531 }532 }533 }534}pallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/property.rs
+++ b/pallets/proxy-rmrk-core/src/property.rs
@@ -19,7 +19,7 @@
Thumb,
EquippedNft,
BaseType,
- // // RmrkPartId(/* Id type? */)
+ ExternalPartId,
EquippableList,
ZIndex,
ThemeName,
@@ -62,8 +62,7 @@
Self::Thumb => key!("thumb"),
Self::EquippedNft => key!("equipped-nft"),
Self::BaseType => key!("base-type"),
- // RmrkResourceId(/* Id type? */)
- // RmrkPartId(/* Id type? */)
+ Self::ExternalPartId => key!("ext-part-id"),
Self::EquippableList => key!("equippable-list"),
Self::ZIndex => key!("z-index"),
Self::ThemeName => key!("theme-name"),
pallets/proxy-rmrk-equip/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/pallets/proxy-rmrk-equip/Cargo.toml
@@ -0,0 +1,45 @@
+[package]
+name = "pallet-rmrk-equip"
+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" }
+up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
+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"] }
+pallet-rmrk-core = { default-features = false, path = "../proxy-rmrk-core" }
+
+[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-rmrk-core/std",
+ "pallet-evm/std",
+ 'frame-benchmarking/std',
+]
+runtime-benchmarks = [
+ 'frame-benchmarking',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system/runtime-benchmarks',
+]
pallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/proxy-rmrk-equip/src/lib.rs
@@ -0,0 +1,173 @@
+// 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, 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};
+use pallet_rmrk_core::{Pallet as PalletCore, rmrk_property, misc::*};
+use pallet_nonfungible::{Pallet as PalletNft};
+use pallet_evm::account::CrossAccountId;
+
+pub use pallet::*;
+
+#[frame_support::pallet]
+pub mod pallet {
+ use super::*;
+
+ #[pallet::config]
+ pub trait Config: frame_system::Config
+ + pallet_rmrk_core::Config {
+ type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
+ }
+
+ #[pallet::storage]
+ #[pallet::getter(fn internal_part_id)]
+ pub type InernalPartId<T: Config> = StorageDoubleMap<
+ _,
+ Twox64Concat,
+ CollectionId,
+ Twox64Concat,
+ RmrkPartId,
+ TokenId
+ >;
+
+ #[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> {
+ BaseCreated {
+ issuer: T::AccountId,
+ base_id: RmrkBaseId,
+ },
+ }
+
+ #[pallet::error]
+ pub enum Error<T> {
+ NoAvailableBaseId,
+ }
+
+ #[pallet::call]
+ impl<T: Config> Pallet<T> {
+ #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+ #[transactional]
+ pub fn create_base(
+ origin: OriginFor<T>,
+ base_type: RmrkString,
+ symbol: RmrkString,
+ parts: BoundedVec<RmrkPartType, RmrkPartsLimit>,
+ ) -> DispatchResult {
+ let sender = ensure_signed(origin)?;
+ let cross_sender = T::CrossAccountId::from_sub(sender.clone());
+
+ let data = CreateCollectionData {
+ limits: None,
+ token_prefix: symbol.into_inner()
+ .try_into()
+ .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,
+ ..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>>::NoAvailableBaseId.into());
+ }
+
+ let collection_id = collection_id_res?;
+
+ let collection = <PalletCore<T>>::get_nft_collection(collection_id)?.into_inner();
+
+ <PalletCommon<T>>::set_scoped_collection_properties(
+ &collection,
+ PropertyScope::Rmrk,
+ [
+ rmrk_property!(Config=T, CollectionType: CollectionType::Base)?,
+ rmrk_property!(Config=T, BaseType: base_type)?,
+ ].into_iter()
+ )?;
+
+ for part in parts {
+ let part_id = part.id();
+ let part_token_id = Self::create_part(
+ &cross_sender,
+ &collection,
+ part
+ )?;
+
+ <InernalPartId<T>>::insert(collection_id, part_id, part_token_id);
+
+ <PalletNft<T>>::set_scoped_token_property(
+ &collection,
+ part_token_id,
+ PropertyScope::Rmrk,
+ rmrk_property!(Config=T, ExternalPartId: part_id)?
+ )?;
+ }
+
+ Self::deposit_event(Event::BaseCreated { issuer: sender, base_id: collection_id.0 });
+
+ Ok(())
+ }
+ }
+}
+
+impl<T: Config> Pallet<T> {
+ fn create_part(
+ sender: &T::CrossAccountId,
+ collection: &CollectionHandle<T>,
+ part: RmrkPartType
+ ) -> Result<TokenId, DispatchError> {
+ let owner = sender;
+
+ let src = part.src();
+ let z_index = part.z_index();
+
+ let nft_type = match part {
+ RmrkPartType::FixedPart(_) => NftType::FixedPart,
+ RmrkPartType::SlotPart(_) => NftType::SlotPart,
+ };
+
+ let token_id = <PalletCore<T>>::create_nft(
+ sender,
+ owner,
+ collection.id,
+ CollectionType::Base,
+ nft_type,
+ [
+ rmrk_property!(Config=T, Src: src)?,
+ rmrk_property!(Config=T, ZIndex: z_index)?
+ ].into_iter()
+ )?;
+
+ if let RmrkPartType::SlotPart(part) = part {
+ <PalletNft<T>>::set_scoped_token_property(
+ collection,
+ token_id,
+ PropertyScope::Rmrk,
+ rmrk_property!(Config=T, EquippableList: part.equippable)?
+ )?;
+ }
+
+ Ok(token_id)
+ }
+}
primitives/data-structs/src/rmrk.rsdiffbeforeafterboth--- a/primitives/data-structs/src/rmrk.rs
+++ b/primitives/data-structs/src/rmrk.rs
@@ -416,6 +416,29 @@
SlotPart(SlotPart<BoundedString, BoundedCollectionList>),
}
+impl<BoundedString, BoundedCollectionList> PartType<BoundedString, BoundedCollectionList> {
+ pub fn id(&self) -> PartId {
+ match self {
+ Self::FixedPart(part) => part.id,
+ Self::SlotPart(part) => part.id
+ }
+ }
+
+ pub fn src(&self) -> &BoundedString {
+ match self {
+ Self::FixedPart(part) => &part.src,
+ Self::SlotPart(part) => &part.src
+ }
+ }
+
+ pub fn z_index(&self) -> ZIndex {
+ match self {
+ Self::FixedPart(part) => part.z,
+ Self::SlotPart(part) => part.z
+ }
+ }
+}
+
#[cfg_attr(feature = "std", derive(Eq, Serialize))]
#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]
#[cfg_attr(
runtime/common/src/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -347,27 +347,27 @@
fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
use frame_support::BoundedVec;
- use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkNft, RmrkDecode}};
+ use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkNft, RmrkDecode}};
let collection_id = CollectionId(base_id);
if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() { return Ok(Vec::new()); }
- let parts = (dispatch_unique_runtime!(collection_id.collection_tokens()) as Result<Vec<TokenId>, DispatchError>)?
- .iter()
+ let parts = (dispatch_unique_runtime!(collection_id.collection_tokens()))?
+ .into_iter()
.filter_map(|token_id| {
- let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).unwrap();
+ let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;
match nft_type {
- FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {
- id: token_id.0,
- src: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::Src).unwrap().decode_or_default(),
- z: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ZIndex).unwrap().decode_or_default(),
+ NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {
+ id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
+ src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
+ z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
})),
- SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {
- id: token_id.0,
- src: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::Src).unwrap().decode_or_default(),
- z: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ZIndex).unwrap().decode_or_default(),
- equippable: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::EquippableList).unwrap().decode_or_default(),
+ NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {
+ id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
+ src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
+ z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
+ equippable: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::EquippableList).ok()?.decode_or_default(),
})),
_ => None
}
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -91,6 +91,7 @@
'pallet-refungible/std',
'pallet-nonfungible/std',
'pallet-proxy-rmrk-core/std',
+ 'pallet-proxy-rmrk-equip/std',
'pallet-unique/std',
'pallet-unq-scheduler/std',
'pallet-charge-transaction/std',
@@ -410,6 +411,7 @@
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-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
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
@@ -906,6 +906,10 @@
type Event = Event;
}
+impl pallet_proxy_rmrk_equip::Config for Runtime {
+ type Event = Event;
+}
+
impl pallet_unique::Config for Runtime {
type Event = Event;
type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
@@ -1019,6 +1023,7 @@
Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
+ RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
// Frontier
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
runtime/quartz/src/lib.rsdiffbeforeafterboth--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -880,6 +880,14 @@
type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
}
+impl pallet_proxy_rmrk_core::Config for Runtime {
+ type Event = Event;
+}
+
+impl pallet_proxy_rmrk_equip::Config for Runtime {
+ type Event = Event;
+}
+
impl pallet_unique::Config for Runtime {
type Event = Event;
type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
@@ -992,6 +1000,7 @@
Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
+ RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
// Frontier
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
runtime/unique/src/lib.rsdiffbeforeafterboth--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -884,6 +884,14 @@
type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
}
+impl pallet_proxy_rmrk_core::Config for Runtime {
+ type Event = Event;
+}
+
+impl pallet_proxy_rmrk_equip::Config for Runtime {
+ type Event = Event;
+}
+
impl pallet_unique::Config for Runtime {
type Event = Event;
type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
@@ -997,6 +1005,7 @@
Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
+ RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
// Frontier
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,