difftreelog
Remove variableOnChainSchema
in: master
12 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -19,7 +19,7 @@
use up_data_structs::{
CollectionMode, CreateCollectionData, CollectionId, MAX_COLLECTION_NAME_LENGTH,
MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, OFFCHAIN_SCHEMA_LIMIT,
- VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT,
+ CONST_ON_CHAIN_SCHEMA_LIMIT,
};
use frame_support::{
traits::{Currency, Get},
@@ -67,7 +67,6 @@
let description = create_u16_data::<MAX_COLLECTION_DESCRIPTION_LENGTH>();
let token_prefix = create_data::<MAX_TOKEN_PREFIX_LENGTH>();
let offchain_schema = create_data::<OFFCHAIN_SCHEMA_LIMIT>();
- let variable_on_chain_schema = create_data::<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>();
let const_on_chain_schema = create_data::<CONST_ON_CHAIN_SCHEMA_LIMIT>();
handler(
owner,
@@ -77,7 +76,6 @@
description,
token_prefix,
offchain_schema,
- variable_on_chain_schema,
const_on_chain_schema,
..Default::default()
},
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -482,12 +482,6 @@
.expect("data has lower bounds than field");
Self::set_field_raw(
id,
- CollectionField::VariableOnChainSchema,
- v.variable_on_chain_schema.clone().into_inner(),
- )
- .expect("data has lower bounds than field");
- Self::set_field_raw(
- id,
CollectionField::ConstOnChainSchema,
v.const_on_chain_schema.clone().into_inner(),
)
@@ -621,11 +615,6 @@
CollectionField::ConstOnChainSchema,
))
.into_inner(),
- variable_on_chain_schema: <CollectionData<T>>::get((
- collection,
- CollectionField::VariableOnChainSchema,
- ))
- .into_inner(),
token_property_permissions,
properties,
})
@@ -723,12 +712,6 @@
id,
CollectionField::OffchainSchema,
data.offchain_schema.into_inner(),
- )
- .expect("data has lower bounds than field");
- Self::set_field_raw(
- id,
- CollectionField::VariableOnChainSchema,
- data.variable_on_chain_schema.into_inner(),
)
.expect("data has lower bounds than field");
Self::set_field_raw(
pallets/unique/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/unique/src/benchmarking.rs
+++ b/pallets/unique/src/benchmarking.rs
@@ -146,14 +146,6 @@
let data = create_var_data(b);
}: set_const_on_chain_schema(RawOrigin::Signed(caller.clone()), collection, data)
- set_variable_on_chain_schema {
- let b in 0..VARIABLE_ON_CHAIN_SCHEMA_LIMIT;
-
- let caller: T::AccountId = account("caller", 0, SEED);
- let collection = create_nft_collection::<T>(caller.clone())?;
- let data = create_var_data(b);
- }: set_variable_on_chain_schema(RawOrigin::Signed(caller.clone()), collection, data)
-
set_schema_version {
let caller: T::AccountId = account("caller", 0, SEED);
let collection = create_nft_collection::<T>(caller.clone())?;
pallets/unique/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#![recursion_limit = "1024"]18#![cfg_attr(not(feature = "std"), no_std)]19#![allow(20 clippy::too_many_arguments,21 clippy::unnecessary_mut_passed,22 clippy::unused_unit23)]2425use frame_support::{26 decl_module, decl_storage, decl_error, decl_event,27 dispatch::DispatchResult,28 ensure,29 weights::{Weight},30 transactional,31 pallet_prelude::{DispatchResultWithPostInfo, ConstU32},32 BoundedVec,33};34use scale_info::TypeInfo;35use frame_system::{self as system, ensure_signed};36use sp_runtime::{sp_std::prelude::Vec};37use up_data_structs::{38 CONST_ON_CHAIN_SCHEMA_LIMIT, OFFCHAIN_SCHEMA_LIMIT,39 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,40 AccessMode, CreateItemData, CollectionLimits, CollectionId, CollectionMode, TokenId,41 SchemaVersion, SponsorshipState, MetaUpdatePermission, CreateCollectionData, CustomDataLimit,42 CreateItemExData, budget, CollectionField, Property, PropertyKey, PropertyKeyPermission,43};44use pallet_evm::account::CrossAccountId;45use pallet_common::{46 CollectionHandle, Pallet as PalletCommon, Error as CommonError, CommonWeightInfo,47 dispatch::dispatch_call, dispatch::CollectionDispatch,48};4950#[cfg(feature = "runtime-benchmarks")]51mod benchmarking;52pub mod weights;53use weights::WeightInfo;5455decl_error! {56 /// Error for non-fungible-token module.57 pub enum Error for Module<T: Config> {58 /// Decimal_points parameter must be lower than MAX_DECIMAL_POINTS constant, currently it is 30.59 CollectionDecimalPointLimitExceeded,60 /// This address is not set as sponsor, use setCollectionSponsor first.61 ConfirmUnsetSponsorFail,62 /// Length of items properties must be greater than 0.63 EmptyArgument,64 }65}6667pub trait Config: system::Config + pallet_common::Config + Sized + TypeInfo {68 type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;6970 /// Weight information for extrinsics in this pallet.71 type WeightInfo: WeightInfo;72 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;73}7475decl_event! {76 pub enum Event<T>77 where78 <T as frame_system::Config>::AccountId,79 <T as pallet_evm::account::Config>::CrossAccountId,80 {81 /// Collection sponsor was removed82 ///83 /// # Arguments84 ///85 /// * collection_id: Globally unique collection identifier.86 CollectionSponsorRemoved(CollectionId),8788 /// Collection admin was added89 ///90 /// # Arguments91 ///92 /// * collection_id: Globally unique collection identifier.93 ///94 /// * admin: Admin address.95 CollectionAdminAdded(CollectionId, CrossAccountId),9697 /// Collection owned was change98 ///99 /// # Arguments100 ///101 /// * collection_id: Globally unique collection identifier.102 ///103 /// * owner: New owner address.104 CollectionOwnedChanged(CollectionId, AccountId),105106 /// Collection sponsor was set107 ///108 /// # Arguments109 ///110 /// * collection_id: Globally unique collection identifier.111 ///112 /// * owner: New sponsor address.113 CollectionSponsorSet(CollectionId, AccountId),114115 /// const on chain schema was set116 ///117 /// # Arguments118 ///119 /// * collection_id: Globally unique collection identifier.120 ConstOnChainSchemaSet(CollectionId),121122 /// New sponsor was confirm123 ///124 /// # Arguments125 ///126 /// * collection_id: Globally unique collection identifier.127 ///128 /// * sponsor: New sponsor address.129 SponsorshipConfirmed(CollectionId, AccountId),130131 /// Collection admin was removed132 ///133 /// # Arguments134 ///135 /// * collection_id: Globally unique collection identifier.136 ///137 /// * admin: Admin address.138 CollectionAdminRemoved(CollectionId, CrossAccountId),139140 /// Address was remove from allow list141 ///142 /// # Arguments143 ///144 /// * collection_id: Globally unique collection identifier.145 ///146 /// * user: Address.147 AllowListAddressRemoved(CollectionId, CrossAccountId),148149 /// Address was add to allow list150 ///151 /// # Arguments152 ///153 /// * collection_id: Globally unique collection identifier.154 ///155 /// * user: Address.156 AllowListAddressAdded(CollectionId, CrossAccountId),157158 /// Collection limits was set159 ///160 /// # Arguments161 ///162 /// * collection_id: Globally unique collection identifier.163 CollectionLimitSet(CollectionId),164165 /// Mint permission was set166 ///167 /// # Arguments168 ///169 /// * collection_id: Globally unique collection identifier.170 MintPermissionSet(CollectionId),171172 /// Offchain schema was set173 ///174 /// # Arguments175 ///176 /// * collection_id: Globally unique collection identifier.177 OffchainSchemaSet(CollectionId),178179 /// Public access mode was set180 ///181 /// # Arguments182 ///183 /// * collection_id: Globally unique collection identifier.184 ///185 /// * mode: New access state.186 PublicAccessModeSet(CollectionId, AccessMode),187188 /// Schema version was set189 ///190 /// # Arguments191 ///192 /// * collection_id: Globally unique collection identifier.193 SchemaVersionSet(CollectionId),194 }195}196197type SelfWeightOf<T> = <T as Config>::WeightInfo;198199// # Used definitions200//201// ## User control levels202//203// chain-controlled - key is uncontrolled by user204// i.e autoincrementing index205// can use non-cryptographic hash206// real - key is controlled by user207// but it is hard to generate enough colliding values, i.e owner of signed txs208// can use non-cryptographic hash209// controlled - key is completly controlled by users210// i.e maps with mutable keys211// should use cryptographic hash212//213// ## User control level downgrade reasons214//215// ?1 - chain-controlled -> controlled216// collections/tokens can be destroyed, resulting in massive holes217// ?2 - chain-controlled -> controlled218// same as ?1, but can be only added, resulting in easier exploitation219// ?3 - real -> controlled220// no confirmation required, so addresses can be easily generated221decl_storage! {222 trait Store for Module<T: Config> as Unique {223224 //#region Private members225 /// Used for migrations226 ChainVersion: u64;227 //#endregion228229 //#region Tokens transfer rate limit baskets230 /// (Collection id (controlled?2), who created (real))231 /// TODO: Off chain worker should remove from this map when collection gets removed232 pub CreateItemBasket get(fn create_item_basket): map hasher(blake2_128_concat) (CollectionId, T::AccountId) => Option<T::BlockNumber>;233 /// Collection id (controlled?2), token id (controlled?2)234 pub NftTransferBasket get(fn nft_transfer_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;235 /// Collection id (controlled?2), owning user (real)236 pub FungibleTransferBasket get(fn fungible_transfer_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;237 /// Collection id (controlled?2), token id (controlled?2)238 pub ReFungibleTransferBasket get(fn refungible_transfer_basket): nmap hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;239 //#endregion240241 /// Variable metadata sponsoring242 /// Collection id (controlled?2), token id (controlled?2)243 pub VariableMetaDataBasket get(fn variable_meta_data_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;244 /// Approval sponsoring245 pub NftApproveBasket get(fn nft_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;246 pub FungibleApproveBasket get(fn fungible_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;247 pub RefungibleApproveBasket get(fn refungible_approve_basket): nmap hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;248 }249}250251decl_module! {252 pub struct Module<T: Config> for enum Call253 where254 origin: T::Origin255 {256 type Error = Error<T>;257258 fn deposit_event() = default;259260 fn on_initialize(_now: T::BlockNumber) -> Weight {261 0262 }263264 /// This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of certain length. The initial owner of the collection is set to the address that signed the transaction and can be changed later.265 ///266 /// # Permissions267 ///268 /// * Anyone.269 ///270 /// # Arguments271 ///272 /// * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.273 ///274 /// * collection_description: UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.275 ///276 /// * token_prefix: UTF-8 string with token prefix.277 ///278 /// * mode: [CollectionMode] collection type and type dependent data.279 // returns collection ID280 #[weight = <SelfWeightOf<T>>::create_collection()]281 #[transactional]282 #[deprecated]283 pub fn create_collection(origin,284 collection_name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,285 collection_description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,286 token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,287 mode: CollectionMode) -> DispatchResult {288 let data: CreateCollectionData<T::AccountId> = CreateCollectionData {289 name: collection_name,290 description: collection_description,291 token_prefix,292 mode,293 ..Default::default()294 };295 Self::create_collection_ex(origin, data)296 }297298 /// This method creates a collection299 ///300 /// Prefer it to deprecated [`created_collection`] method301 #[weight = <SelfWeightOf<T>>::create_collection()]302 #[transactional]303 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {304 let sender = ensure_signed(origin)?;305306 // =========307308 T::CollectionDispatch::create(sender, data)?;309310 Ok(())311 }312313 /// **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.314 ///315 /// # Permissions316 ///317 /// * Collection Owner.318 ///319 /// # Arguments320 ///321 /// * collection_id: collection to destroy.322 #[weight = <SelfWeightOf<T>>::destroy_collection()]323 #[transactional]324 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {325 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);326 let collection = <CollectionHandle<T>>::try_get(collection_id)?;327328 // =========329330 T::CollectionDispatch::destroy(sender, collection)?;331332 <NftTransferBasket<T>>::remove_prefix(collection_id, None);333 <FungibleTransferBasket<T>>::remove_prefix(collection_id, None);334 <ReFungibleTransferBasket<T>>::remove_prefix((collection_id,), None);335336 <VariableMetaDataBasket<T>>::remove_prefix(collection_id, None);337 <NftApproveBasket<T>>::remove_prefix(collection_id, None);338 <FungibleApproveBasket<T>>::remove_prefix(collection_id, None);339 <RefungibleApproveBasket<T>>::remove_prefix((collection_id,), None);340341 Ok(())342 }343344 /// Add an address to allow list.345 ///346 /// # Permissions347 ///348 /// * Collection Owner349 /// * Collection Admin350 ///351 /// # Arguments352 ///353 /// * collection_id.354 ///355 /// * address.356 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]357 #[transactional]358 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{359360 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);361 let collection = <CollectionHandle<T>>::try_get(collection_id)?;362363 <PalletCommon<T>>::toggle_allowlist(364 &collection,365 &sender,366 &address,367 true,368 )?;369370 Self::deposit_event(Event::<T>::AllowListAddressAdded(371 collection_id,372 address373 ));374375 Ok(())376 }377378 /// Remove an address from allow list.379 ///380 /// # Permissions381 ///382 /// * Collection Owner383 /// * Collection Admin384 ///385 /// # Arguments386 ///387 /// * collection_id.388 ///389 /// * address.390 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]391 #[transactional]392 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{393394 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);395 let collection = <CollectionHandle<T>>::try_get(collection_id)?;396397 <PalletCommon<T>>::toggle_allowlist(398 &collection,399 &sender,400 &address,401 false,402 )?;403404 <Pallet<T>>::deposit_event(Event::<T>::AllowListAddressRemoved(405 collection_id,406 address407 ));408409 Ok(())410 }411412 /// Toggle between normal and allow list access for the methods with access for `Anyone`.413 ///414 /// # Permissions415 ///416 /// * Collection Owner.417 ///418 /// # Arguments419 ///420 /// * collection_id.421 ///422 /// * mode: [AccessMode]423 #[weight = <SelfWeightOf<T>>::set_public_access_mode()]424 #[transactional]425 pub fn set_public_access_mode(origin, collection_id: CollectionId, mode: AccessMode) -> DispatchResult426 {427 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);428429 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;430 target_collection.check_is_owner(&sender)?;431432 target_collection.access = mode.clone();433434 <Pallet<T>>::deposit_event(Event::<T>::PublicAccessModeSet(435 collection_id,436 mode437 ));438439 target_collection.save()440 }441442 /// Allows Anyone to create tokens if:443 /// * Allow List is enabled, and444 /// * Address is added to allow list, and445 /// * This method was called with True parameter446 ///447 /// # Permissions448 /// * Collection Owner449 ///450 /// # Arguments451 ///452 /// * collection_id.453 ///454 /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.455 #[weight = <SelfWeightOf<T>>::set_mint_permission()]456 #[transactional]457 pub fn set_mint_permission(origin, collection_id: CollectionId, mint_permission: bool) -> DispatchResult458 {459 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);460461 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;462 target_collection.check_is_owner(&sender)?;463464 target_collection.mint_mode = mint_permission;465466 <Pallet<T>>::deposit_event(Event::<T>::MintPermissionSet(467 collection_id468 ));469470 target_collection.save()471 }472473 /// Change the owner of the collection.474 ///475 /// # Permissions476 ///477 /// * Collection Owner.478 ///479 /// # Arguments480 ///481 /// * collection_id.482 ///483 /// * new_owner.484 #[weight = <SelfWeightOf<T>>::change_collection_owner()]485 #[transactional]486 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {487488 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);489490 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;491 target_collection.check_is_owner(&sender)?;492493 target_collection.owner = new_owner.clone();494 <Pallet<T>>::deposit_event(Event::<T>::CollectionOwnedChanged(495 collection_id,496 new_owner497 ));498499 target_collection.save()500 }501502 /// Adds an admin of the Collection.503 /// NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.504 ///505 /// # Permissions506 ///507 /// * Collection Owner.508 /// * Collection Admin.509 ///510 /// # Arguments511 ///512 /// * collection_id: ID of the Collection to add admin for.513 ///514 /// * new_admin_id: Address of new admin to add.515 #[weight = <SelfWeightOf<T>>::add_collection_admin()]516 #[transactional]517 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::CrossAccountId) -> DispatchResult {518 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);519 let collection = <CollectionHandle<T>>::try_get(collection_id)?;520521 <Pallet<T>>::deposit_event(Event::<T>::CollectionAdminAdded(522 collection_id,523 new_admin_id.clone()524 ));525526 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)527 }528529 /// Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.530 ///531 /// # Permissions532 ///533 /// * Collection Owner.534 /// * Collection Admin.535 ///536 /// # Arguments537 ///538 /// * collection_id: ID of the Collection to remove admin for.539 ///540 /// * account_id: Address of admin to remove.541 #[weight = <SelfWeightOf<T>>::remove_collection_admin()]542 #[transactional]543 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {544 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);545 let collection = <CollectionHandle<T>>::try_get(collection_id)?;546547 <Pallet<T>>::deposit_event(Event::<T>::CollectionAdminRemoved(548 collection_id,549 account_id.clone()550 ));551552 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)553 }554555 /// # Permissions556 ///557 /// * Collection Owner558 ///559 /// # Arguments560 ///561 /// * collection_id.562 ///563 /// * new_sponsor.564 #[weight = <SelfWeightOf<T>>::set_collection_sponsor()]565 #[transactional]566 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {567 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);568569 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;570 target_collection.check_is_owner(&sender)?;571572 target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor.clone());573574 <Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorSet(575 collection_id,576 new_sponsor577 ));578579 target_collection.save()580 }581582 /// # Permissions583 ///584 /// * Sponsor.585 ///586 /// # Arguments587 ///588 /// * collection_id.589 #[weight = <SelfWeightOf<T>>::confirm_sponsorship()]590 #[transactional]591 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {592 let sender = ensure_signed(origin)?;593594 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;595 ensure!(596 target_collection.sponsorship.pending_sponsor() == Some(&sender),597 Error::<T>::ConfirmUnsetSponsorFail598 );599600 target_collection.sponsorship = SponsorshipState::Confirmed(sender.clone());601602 <Pallet<T>>::deposit_event(Event::<T>::SponsorshipConfirmed(603 collection_id,604 sender605 ));606607 target_collection.save()608 }609610 /// Switch back to pay-per-own-transaction model.611 ///612 /// # Permissions613 ///614 /// * Collection owner.615 ///616 /// # Arguments617 ///618 /// * collection_id.619 #[weight = <SelfWeightOf<T>>::remove_collection_sponsor()]620 #[transactional]621 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {622 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);623624 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;625 target_collection.check_is_owner(&sender)?;626627 target_collection.sponsorship = SponsorshipState::Disabled;628629 <Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorRemoved(630 collection_id631 ));632 target_collection.save()633 }634635 /// This method creates a concrete instance of NFT Collection created with CreateCollection method.636 ///637 /// # Permissions638 ///639 /// * Collection Owner.640 /// * Collection Admin.641 /// * Anyone if642 /// * Allow List is enabled, and643 /// * Address is added to allow list, and644 /// * MintPermission is enabled (see SetMintPermission method)645 ///646 /// # Arguments647 ///648 /// * collection_id: ID of the collection.649 ///650 /// * owner: Address, initial owner of the NFT.651 ///652 /// * data: Token data to store on chain.653 #[weight = T::CommonWeightInfo::create_item()]654 #[transactional]655 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {656 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);657 let budget = budget::Value::new(2);658659 dispatch_call::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))660 }661662 /// This method creates multiple items in a collection created with CreateCollection method.663 ///664 /// # Permissions665 ///666 /// * Collection Owner.667 /// * Collection Admin.668 /// * Anyone if669 /// * Allow List is enabled, and670 /// * Address is added to allow list, and671 /// * MintPermission is enabled (see SetMintPermission method)672 ///673 /// # Arguments674 ///675 /// * collection_id: ID of the collection.676 ///677 /// * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].678 ///679 /// * owner: Address, initial owner of the NFT.680 #[weight = T::CommonWeightInfo::create_multiple_items(items_data.len() as u32)]681 #[transactional]682 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {683 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);684 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);685 let budget = budget::Value::new(2);686687 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))688 }689690 #[weight = T::CommonWeightInfo::set_collection_properties(properties.len() as u32)]691 #[transactional]692 pub fn set_collection_properties(693 origin,694 collection_id: CollectionId,695 properties: Vec<Property>696 ) -> DispatchResultWithPostInfo {697 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);698699 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);700701 dispatch_call::<T, _>(collection_id, |d| d.set_collection_properties(sender, properties))702 }703704 #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]705 #[transactional]706 pub fn delete_collection_properties(707 origin,708 collection_id: CollectionId,709 property_keys: Vec<PropertyKey>,710 ) -> DispatchResultWithPostInfo {711 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);712713 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);714715 dispatch_call::<T, _>(collection_id, |d| d.delete_collection_properties(&sender, property_keys))716 }717718 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]719 #[transactional]720 pub fn set_token_properties(721 origin,722 collection_id: CollectionId,723 token_id: TokenId,724 properties: Vec<Property>725 ) -> DispatchResultWithPostInfo {726 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);727728 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);729730 dispatch_call::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties))731 }732733 #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]734 #[transactional]735 pub fn delete_token_properties(736 origin,737 collection_id: CollectionId,738 token_id: TokenId,739 property_keys: Vec<PropertyKey>740 ) -> DispatchResultWithPostInfo {741 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);742743 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);744745 dispatch_call::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, property_keys))746 }747748 #[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]749 #[transactional]750 pub fn set_property_permissions(751 origin,752 collection_id: CollectionId,753 property_permissions: Vec<PropertyKeyPermission>,754 ) -> DispatchResultWithPostInfo {755 ensure!(!property_permissions.is_empty(), Error::<T>::EmptyArgument);756757 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);758759 dispatch_call::<T, _>(collection_id, |d| d.set_property_permissions(&sender, property_permissions))760 }761762 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]763 #[transactional]764 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {765 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);766 let budget = budget::Value::new(2);767768 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))769 }770771 // TODO! transaction weight772773 /// Set transfers_enabled value for particular collection774 ///775 /// # Permissions776 ///777 /// * Collection Owner.778 ///779 /// # Arguments780 ///781 /// * collection_id: ID of the collection.782 ///783 /// * value: New flag value.784 #[weight = <SelfWeightOf<T>>::set_transfers_enabled_flag()]785 #[transactional]786 pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {787 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);788 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;789 target_collection.check_is_owner(&sender)?;790791 // =========792793 target_collection.limits.transfers_enabled = Some(value);794 target_collection.save()795 }796797 /// Destroys a concrete instance of NFT.798 ///799 /// # Permissions800 ///801 /// * Collection Owner.802 /// * Collection Admin.803 /// * Current NFT Owner.804 ///805 /// # Arguments806 ///807 /// * collection_id: ID of the collection.808 ///809 /// * item_id: ID of NFT to burn.810 #[weight = T::CommonWeightInfo::burn_item()]811 #[transactional]812 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {813 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);814815 let post_info = dispatch_call::<T, _>(collection_id, |d| d.burn_item(sender, item_id, value))?;816 if value == 1 {817 <NftTransferBasket<T>>::remove(collection_id, item_id);818 <NftApproveBasket<T>>::remove(collection_id, item_id);819 }820 // Those maps should be cleared only if token disappears completly, need to move this part of logic to pallets?821 // <FungibleApproveBasket<T>>::remove(collection_id, sender.as_sub());822 // <RefungibleApproveBasket<T>>::remove((collection_id, item_id, sender.as_sub()));823 Ok(post_info)824 }825826 /// Destroys a concrete instance of NFT on behalf of the owner827 /// See also: [`approve`]828 ///829 /// # Permissions830 ///831 /// * Collection Owner.832 /// * Collection Admin.833 /// * Current NFT Owner.834 ///835 /// # Arguments836 ///837 /// * collection_id: ID of the collection.838 ///839 /// * item_id: ID of NFT to burn.840 ///841 /// * from: owner of item842 #[weight = T::CommonWeightInfo::burn_from()]843 #[transactional]844 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {845 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);846 let budget = budget::Value::new(2);847848 dispatch_call::<T, _>(collection_id, |d| d.burn_from(sender, from, item_id, value, &budget))849 }850851 /// Change ownership of the token.852 ///853 /// # Permissions854 ///855 /// * Collection Owner856 /// * Collection Admin857 /// * Current NFT owner858 ///859 /// # Arguments860 ///861 /// * recipient: Address of token recipient.862 ///863 /// * collection_id.864 ///865 /// * item_id: ID of the item866 /// * Non-Fungible Mode: Required.867 /// * Fungible Mode: Ignored.868 /// * Re-Fungible Mode: Required.869 ///870 /// * value: Amount to transfer.871 /// * Non-Fungible Mode: Ignored872 /// * Fungible Mode: Must specify transferred amount873 /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)874 #[weight = T::CommonWeightInfo::transfer()]875 #[transactional]876 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {877 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);878 let budget = budget::Value::new(2);879880 dispatch_call::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))881 }882883 /// Set, change, or remove approved address to transfer the ownership of the NFT.884 ///885 /// # Permissions886 ///887 /// * Collection Owner888 /// * Collection Admin889 /// * Current NFT owner890 ///891 /// # Arguments892 ///893 /// * approved: Address that is approved to transfer this NFT or zero (if needed to remove approval).894 ///895 /// * collection_id.896 ///897 /// * item_id: ID of the item.898 #[weight = T::CommonWeightInfo::approve()]899 #[transactional]900 pub fn approve(origin, spender: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {901 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);902903 dispatch_call::<T, _>(collection_id, |d| d.approve(sender, spender, item_id, amount))904 }905906 /// Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this owner.907 ///908 /// # Permissions909 /// * Collection Owner910 /// * Collection Admin911 /// * Current NFT owner912 /// * Address approved by current NFT owner913 ///914 /// # Arguments915 ///916 /// * from: Address that owns token.917 ///918 /// * recipient: Address of token recipient.919 ///920 /// * collection_id.921 ///922 /// * item_id: ID of the item.923 ///924 /// * value: Amount to transfer.925 #[weight = T::CommonWeightInfo::transfer_from()]926 #[transactional]927 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {928 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);929 let budget = budget::Value::new(2);930931 dispatch_call::<T, _>(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget))932 }933934 /// Set off-chain data schema.935 ///936 /// # Permissions937 ///938 /// * Collection Owner939 /// * Collection Admin940 ///941 /// # Arguments942 ///943 /// * collection_id.944 ///945 /// * schema: String representing the offchain data schema.946 #[weight = T::CommonWeightInfo::set_variable_metadata(data.len() as u32)]947 #[transactional]948 pub fn set_variable_meta_data (949 origin,950 collection_id: CollectionId,951 item_id: TokenId,952 data: BoundedVec<u8, CustomDataLimit>,953 ) -> DispatchResultWithPostInfo {954 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);955956 dispatch_call::<T, _>(collection_id, |d| d.set_variable_metadata(sender, item_id, data))957 }958959 /// Set meta_update_permission value for particular collection960 ///961 /// # Permissions962 ///963 /// * Collection Owner.964 ///965 /// # Arguments966 ///967 /// * collection_id: ID of the collection.968 ///969 /// * value: New flag value.970 #[weight = <SelfWeightOf<T>>::set_meta_update_permission_flag()]971 #[transactional]972 pub fn set_meta_update_permission_flag(origin, collection_id: CollectionId, value: MetaUpdatePermission) -> DispatchResult {973 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);974 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;975976 ensure!(977 target_collection.meta_update_permission != MetaUpdatePermission::None,978 <CommonError<T>>::MetadataFlagFrozen,979 );980 target_collection.check_is_owner(&sender)?;981982 target_collection.meta_update_permission = value;983984 target_collection.save()985 }986987 /// Set schema standard988 /// ImageURL989 /// Unique990 ///991 /// # Permissions992 ///993 /// * Collection Owner994 /// * Collection Admin995 ///996 /// # Arguments997 ///998 /// * collection_id.999 ///1000 /// * schema: SchemaVersion: enum1001 #[weight = <SelfWeightOf<T>>::set_schema_version()]1002 #[transactional]1003 pub fn set_schema_version(1004 origin,1005 collection_id: CollectionId,1006 version: SchemaVersion1007 ) -> DispatchResult {1008 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1009 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1010 target_collection.check_is_owner_or_admin(&sender)?;1011 target_collection.schema_version = version;10121013 <Pallet<T>>::deposit_event(Event::<T>::SchemaVersionSet(1014 collection_id1015 ));10161017 target_collection.save()1018 }10191020 /// Set off-chain data schema.1021 ///1022 /// # Permissions1023 ///1024 /// * Collection Owner1025 /// * Collection Admin1026 ///1027 /// # Arguments1028 ///1029 /// * collection_id.1030 ///1031 /// * schema: String representing the offchain data schema.1032 #[weight = <SelfWeightOf<T>>::set_offchain_schema(schema.len() as u32)]1033 #[transactional]1034 pub fn set_offchain_schema(1035 origin,1036 collection_id: CollectionId,1037 schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,1038 ) -> DispatchResult {1039 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1040 let collection = <CollectionHandle<T>>::try_get(collection_id)?;10411042 // =========10431044 <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::OffchainSchema, schema.into_inner())?;10451046 <Pallet<T>>::deposit_event(Event::<T>::OffchainSchemaSet(1047 collection_id1048 ));1049 Ok(())1050 }10511052 /// Set const on-chain data schema.1053 ///1054 /// # Permissions1055 ///1056 /// * Collection Owner1057 /// * Collection Admin1058 ///1059 /// # Arguments1060 ///1061 /// * collection_id.1062 ///1063 /// * schema: String representing the const on-chain data schema.1064 #[weight = <SelfWeightOf<T>>::set_const_on_chain_schema(schema.len() as u32)]1065 #[transactional]1066 pub fn set_const_on_chain_schema (1067 origin,1068 collection_id: CollectionId,1069 schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>1070 ) -> DispatchResult {1071 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1072 let collection = <CollectionHandle<T>>::try_get(collection_id)?;10731074 // =========10751076 <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::ConstOnChainSchema, schema.into_inner())?;10771078 <Pallet<T>>::deposit_event(Event::<T>::ConstOnChainSchemaSet(1079 collection_id1080 ));1081 Ok(())1082 }10831084 #[weight = <SelfWeightOf<T>>::set_collection_limits()]1085 #[transactional]1086 pub fn set_collection_limits(1087 origin,1088 collection_id: CollectionId,1089 new_limit: CollectionLimits,1090 ) -> DispatchResult {1091 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1092 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1093 target_collection.check_is_owner(&sender)?;1094 let old_limit = &target_collection.limits;10951096 target_collection.limits = <PalletCommon<T>>::clamp_limits(target_collection.mode.clone(), &old_limit, new_limit)?;10971098 <Pallet<T>>::deposit_event(Event::<T>::CollectionLimitSet(1099 collection_id1100 ));11011102 target_collection.save()1103 }1104 }1105}pallets/unique/src/weights.rsdiffbeforeafterboth--- a/pallets/unique/src/weights.rs
+++ b/pallets/unique/src/weights.rs
@@ -47,7 +47,6 @@
fn set_transfers_enabled_flag() -> Weight;
fn set_offchain_schema(b: u32, ) -> Weight;
fn set_const_on_chain_schema(b: u32, ) -> Weight;
- fn set_variable_on_chain_schema(b: u32, ) -> Weight;
fn set_schema_version() -> Weight;
fn set_collection_limits() -> Weight;
fn set_meta_update_permission_flag() -> Weight;
@@ -156,12 +155,6 @@
// Storage: Common CollectionById (r:1 w:1)
fn set_const_on_chain_schema(_b: u32, ) -> Weight {
(14_984_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(1 as Weight))
- .saturating_add(T::DbWeight::get().writes(1 as Weight))
- }
- // Storage: Common CollectionById (r:1 w:1)
- fn set_variable_on_chain_schema(_b: u32, ) -> Weight {
- (15_196_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -287,12 +280,6 @@
// Storage: Common CollectionById (r:1 w:1)
fn set_const_on_chain_schema(_b: u32, ) -> Weight {
(14_984_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(1 as Weight))
- .saturating_add(RocksDbWeight::get().writes(1 as Weight))
- }
- // Storage: Common CollectionById (r:1 w:1)
- fn set_variable_on_chain_schema(_b: u32, ) -> Weight {
- (15_196_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -76,11 +76,9 @@
// Schema limits
pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 8192;
-pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;
pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;
pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;
-// u32::max is not const: OFFCHAIN_SCHEMA_LIMIT.max(VARIABLE_ON_CHAIN_SCHEMA_LIMIT).max(CONST_ON_CHAIN_SCHEMA_LIMIT);
pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;
pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;
@@ -303,8 +301,6 @@
#[version(2.., upper(limits.into()))]
pub limits: CollectionLimitsVersion2,
- #[version(..2)]
- pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,
#[version(..2)]
pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,
@@ -326,7 +322,6 @@
pub schema_version: SchemaVersion,
pub sponsorship: SponsorshipState<AccountId>,
pub limits: CollectionLimits,
- pub variable_on_chain_schema: Vec<u8>,
pub const_on_chain_schema: Vec<u8>,
pub meta_update_permission: MetaUpdatePermission,
pub token_property_permissions: Vec<PropertyKeyPermission>,
@@ -336,7 +331,6 @@
#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum CollectionField {
- VariableOnChainSchema,
ConstOnChainSchema,
OffchainSchema,
}
@@ -354,7 +348,6 @@
pub schema_version: Option<SchemaVersion>,
pub pending_sponsor: Option<AccountId>,
pub limits: Option<CollectionLimits>,
- pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,
pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,
pub meta_update_permission: Option<MetaUpdatePermission>,
pub token_property_permissions: CollectionPropertiesPermissionsVec,
runtime/tests/src/tests.rsdiffbeforeafterboth--- a/runtime/tests/src/tests.rs
+++ b/runtime/tests/src/tests.rs
@@ -2423,45 +2423,6 @@
)),
b"test const on chain schema".to_vec()
);
- assert_eq!(
- <pallet_common::CollectionData<Test>>::get((
- collection_id,
- CollectionField::VariableOnChainSchema
- )),
- b"".to_vec()
- );
- });
-}
-
-#[test]
-fn set_variable_on_chain_schema() {
- new_test_ext().execute_with(|| {
- let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));
-
- let origin1 = Origin::signed(1);
- assert_ok!(Unique::set_variable_on_chain_schema(
- origin1,
- collection_id,
- b"test variable on chain schema"
- .to_vec()
- .try_into()
- .unwrap()
- ));
-
- assert_eq!(
- <pallet_common::CollectionData<Test>>::get((
- collection_id,
- CollectionField::ConstOnChainSchema
- )),
- b"".to_vec()
- );
- assert_eq!(
- <pallet_common::CollectionData<Test>>::get((
- collection_id,
- CollectionField::VariableOnChainSchema
- )),
- b"test variable on chain schema".to_vec()
- );
});
}
tests/src/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -40,20 +40,20 @@
});
it('create new collection with properties #1', async () => {
- await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},
- properties: [{key: 'key1', value: 'val1'}],
+ await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},
+ properties: [{key: 'key1', value: 'val1'}],
propPerm: [{key: 'key1', tokenOwner: true, mutable: false, collectionAdmin: true}]});
});
it('create new collection with properties #2', async () => {
- await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},
- properties: [{key: 'key1', value: 'val1'}],
+ await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},
+ properties: [{key: 'key1', value: 'val1'}],
propPerm: [{key: 'key1', tokenOwner: false, mutable: true, collectionAdmin: false}]});
});
it('create new collection with properties #3', async () => {
- await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},
- properties: [{key: 'key1', value: 'val1'}],
+ await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},
+ properties: [{key: 'key1', value: 'val1'}],
propPerm: [{key: 'key1', tokenOwner: true, mutable: false, collectionAdmin: false}]});
});
@@ -73,7 +73,6 @@
limits: {
accountTokenOwnershipLimit: 3,
},
- variableOnChainSchema: '0x222222',
constOnChainSchema: '0x333333',
metaUpdatePermission: 'Admin',
});
@@ -91,7 +90,6 @@
expect(collection.schemaVersion.isUnique).to.be.true;
expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);
expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);
- expect(collection.variableOnChainSchema.toString()).to.equal('0x222222');
expect(collection.constOnChainSchema.toString()).to.equal('0x333333');
expect(collection.metaUpdatePermission.isAdmin).to.be.true;
});
tests/src/nesting/migration-check.test.tsdiffbeforeafterboth--- a/tests/src/nesting/migration-check.test.ts
+++ b/tests/src/nesting/migration-check.test.ts
@@ -11,7 +11,7 @@
// todo skip
describe('Migration testing for pallet-common', () => {
let alice: IKeyringPair;
-
+
before(async() => {
await usingApi(async () => {
alice = privateKey('//Alice');
@@ -36,7 +36,6 @@
limits: {
accountTokenOwnershipLimit: 3,
},
- variableOnChainSchema: '0x222222',
constOnChainSchema: '0x333333',
metaUpdatePermission: 'Admin',
});
@@ -78,13 +77,11 @@
await usingApi(async api => {
const collectionNew = (await api.query.common.collectionById(collectionId)).toJSON() as any;
-
+
// Make sure the extra fields are what they should be
- const variableOnChainSchema = await api.query.common.collectionData(collectionId, 'VariableOnChainSchema');
const constOnChainSchema = await api.query.common.collectionData(collectionId, 'ConstOnChainSchema');
const offchainSchema = await api.query.common.collectionData(collectionId, 'OffchainSchema');
- expect(variableOnChainSchema.toHex()).to.be.deep.equal((collectionOld.variableOnChainSchema));
expect(constOnChainSchema.toHex()).to.be.deep.equal(collectionOld.constOnChainSchema);
expect(offchainSchema.toHex()).to.be.deep.equal(collectionOld.offchainSchema);
expect(collectionNew).to.have.nested.property('limits.nestingRule');
@@ -93,10 +90,8 @@
delete collectionNew.limits.nestingRule;
delete collectionOld.constOnChainSchema;
delete collectionOld.offchainSchema;
- delete collectionOld.variableOnChainSchema;
expect(collectionNew).to.be.deep.equal(collectionOld);
});
});
});
-
\ No newline at end of file
tests/src/setChainLimits.test.tsdiffbeforeafterboth--- a/tests/src/setChainLimits.test.ts
+++ b/tests/src/setChainLimits.test.ts
@@ -44,7 +44,6 @@
fungibleSponsorTransferTimeout: 1,
refungibleSponsorTransferTimeout: 1,
offchainSchemaLimit: 1,
- variableOnChainSchemaLimit: 1,
constOnChainSchemaLimit: 1,
};
});
tests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setVariableOnChainSchema.test.ts
+++ /dev/null
@@ -1,136 +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/>.
-
-import {Keyring} from '@polkadot/api';
-import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import {
- createCollectionExpectSuccess,
- destroyCollectionExpectSuccess,
- addCollectionAdminExpectSuccess,
- queryCollectionExpectSuccess,
- getCreatedCollectionCount,
-} from './util/helpers';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
-let alice: IKeyringPair;
-let bob: IKeyringPair;
-let schema: any;
-let largeSchema: any;
-
-before(async () => {
- await usingApi(async () => {
- const keyring = new Keyring({type: 'sr25519'});
- alice = keyring.addFromUri('//Alice');
- bob = keyring.addFromUri('//Bob');
- schema = '0x31';
- largeSchema = new Array(8 * 1024 + 10).fill(0xff);
-
- });
-});
-describe('Integration Test ext. setVariableOnChainSchema()', () => {
-
- it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
- await usingApi(async (api) => {
- const collectionId = await createCollectionExpectSuccess();
- const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.owner.toString()).to.be.eq(alice.address);
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
- await submitTransactionAsync(alice, setSchema);
- });
- });
-
- it('Checking collection data using the setVariableOnChainSchema parameter', async () => {
- await usingApi(async (api) => {
- const collectionId = await createCollectionExpectSuccess();
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
- await submitTransactionAsync(alice, setSchema);
- const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);
-
- });
- });
-});
-
-describe('Integration Test ext. collection admin setVariableOnChainSchema()', () => {
-
- it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
- await usingApi(async (api) => {
- const collectionId = await createCollectionExpectSuccess();
- const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.owner.toString()).to.be.eq(alice.address);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
- await submitTransactionAsync(bob, setSchema);
- });
- });
-
- it('Checking collection data using the setVariableOnChainSchema parameter', async () => {
- await usingApi(async (api) => {
- const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
- await submitTransactionAsync(bob, setSchema);
- const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);
-
- });
- });
-});
-
-describe('Negative Integration Test ext. setVariableOnChainSchema()', () => {
-
- it('Set a non-existent collection', async () => {
- await usingApi(async (api) => {
- // tslint:disable-next-line: radix
- const collectionId = await getCreatedCollectionCount(api) + 1;
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
- await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
- });
- });
-
- it('Set a previously deleted collection', async () => {
- await usingApi(async (api) => {
- const collectionId = await createCollectionExpectSuccess();
- await destroyCollectionExpectSuccess(collectionId);
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
- await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
- });
- });
-
- it('Set invalid data in schema (size too large:> 8kB)', async () => {
- await usingApi(async (api) => {
- const collectionId = await createCollectionExpectSuccess();
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, largeSchema);
- await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
- });
- });
-
- it('Execute method not on behalf of the collection owner', async () => {
- await usingApi(async (api) => {
- const collectionId = await createCollectionExpectSuccess();
- const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.owner.toString()).to.be.eq(alice.address);
- const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
- await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;
- });
- });
-
-});
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -136,7 +136,6 @@
fungibleSponsorTransferTimeout: number;
refungibleSponsorTransferTimeout: number;
offchainSchemaLimit: number;
- variableOnChainSchemaLimit: number;
constOnChainSchemaLimit: number;
}