--- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -22,7 +22,7 @@ use pallet_evm::account::CrossAccountId; use frame_support::{ dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Weight, PostDispatchInfo}, - ensure, fail, + ensure, traits::{Imbalance, Get, Currency, WithdrawReasons, ExistenceRequirement}, BoundedVec, weights::Pays, @@ -30,7 +30,7 @@ use pallet_evm::GasWeightMapping; use up_data_structs::{ COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, CollectionId, CreateItemData, - MAX_TOKEN_PREFIX_LENGTH, COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, + MAX_TOKEN_PREFIX_LENGTH, COLLECTION_ADMINS_LIMIT, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP, CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits, CreateCollectionData, SponsorshipState, @@ -134,21 +134,6 @@ >::AddressNotInAllowlist ); Ok(()) - } - - pub fn check_can_update_meta( - &self, - subject: &T::CrossAccountId, - item_owner: &T::CrossAccountId, - ) -> DispatchResult { - match self.meta_update_permission { - MetaUpdatePermission::ItemOwner => { - ensure!(subject == item_owner, >::NoPermission); - Ok(()) - } - MetaUpdatePermission::Admin => self.check_is_owner_or_admin(subject), - MetaUpdatePermission::None => fail!(>::NoPermission), - } } } @@ -565,7 +550,6 @@ schema_version, sponsorship, limits, - meta_update_permission, } = >::get(collection)?; let token_property_permissions = >::get(collection) @@ -595,7 +579,6 @@ schema_version, sponsorship, limits, - meta_update_permission, offchain_schema: >::get(( collection, CollectionField::OffchainSchema, @@ -656,7 +639,6 @@ .limits .map(|limits| Self::clamp_limits(data.mode.clone(), &Default::default(), limits)) .unwrap_or_else(|| Ok(CollectionLimits::default()))?, - meta_update_permission: data.meta_update_permission.unwrap_or_default(), }; let mut collection_properties = up_data_structs::CollectionProperties::get(); --- a/pallets/unique/src/benchmarking.rs +++ b/pallets/unique/src/benchmarking.rs @@ -168,9 +168,4 @@ nesting_rule: None, }; }: set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl) - - set_meta_update_permission_flag { - let caller: T::AccountId = account("caller", 0, SEED); - let collection = create_nft_collection::(caller.clone())?; - }: _(RawOrigin::Signed(caller.clone()), collection, MetaUpdatePermission::Admin) } --- a/pallets/unique/src/lib.rs +++ b/pallets/unique/src/lib.rs @@ -38,12 +38,12 @@ CONST_ON_CHAIN_SCHEMA_LIMIT, OFFCHAIN_SCHEMA_LIMIT, MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, AccessMode, CreateItemData, CollectionLimits, CollectionId, CollectionMode, TokenId, - SchemaVersion, SponsorshipState, MetaUpdatePermission, CreateCollectionData, + SchemaVersion, SponsorshipState, CreateCollectionData, CreateItemExData, budget, CollectionField, Property, PropertyKey, PropertyKeyPermission, }; use pallet_evm::account::CrossAccountId; use pallet_common::{ - CollectionHandle, Pallet as PalletCommon, Error as CommonError, CommonWeightInfo, + CollectionHandle, Pallet as PalletCommon, CommonWeightInfo, dispatch::dispatch_call, dispatch::CollectionDispatch, }; @@ -925,34 +925,6 @@ let budget = budget::Value::new(2); dispatch_call::(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget)) - } - - /// Set meta_update_permission value for particular collection - /// - /// # Permissions - /// - /// * Collection Owner. - /// - /// # Arguments - /// - /// * collection_id: ID of the collection. - /// - /// * value: New flag value. - #[weight = >::set_meta_update_permission_flag()] - #[transactional] - pub fn set_meta_update_permission_flag(origin, collection_id: CollectionId, value: MetaUpdatePermission) -> DispatchResult { - let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?); - let mut target_collection = >::try_get(collection_id)?; - - ensure!( - target_collection.meta_update_permission != MetaUpdatePermission::None, - >::MetadataFlagFrozen, - ); - target_collection.check_is_owner(&sender)?; - - target_collection.meta_update_permission = value; - - target_collection.save() } /// Set schema standard --- a/pallets/unique/src/weights.rs +++ b/pallets/unique/src/weights.rs @@ -49,7 +49,6 @@ fn set_const_on_chain_schema(b: u32, ) -> Weight; fn set_schema_version() -> Weight; fn set_collection_limits() -> Weight; - fn set_meta_update_permission_flag() -> Weight; } /// Weights for pallet_unique using the Substrate node and recommended hardware. @@ -167,12 +166,6 @@ // Storage: Common CollectionById (r:1 w:1) fn set_collection_limits() -> Weight { (15_339_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_meta_update_permission_flag() -> Weight { - (7_214_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -292,12 +285,6 @@ // Storage: Common CollectionById (r:1 w:1) fn set_collection_limits() -> Weight { (15_339_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_meta_update_permission_flag() -> Weight { - (7_214_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } --- a/primitives/data-structs/src/lib.rs +++ b/primitives/data-structs/src/lib.rs @@ -308,6 +308,7 @@ #[version(..2)] pub const_on_chain_schema: BoundedVec>, + #[version(..2)] pub meta_update_permission: MetaUpdatePermission, } @@ -327,7 +328,6 @@ pub sponsorship: SponsorshipState, pub limits: CollectionLimits, pub const_on_chain_schema: Vec, - pub meta_update_permission: MetaUpdatePermission, pub token_property_permissions: Vec, pub properties: Vec, } @@ -353,7 +353,6 @@ pub pending_sponsor: Option, pub limits: Option, pub const_on_chain_schema: BoundedVec>, - pub meta_update_permission: Option, pub token_property_permissions: CollectionPropertiesPermissionsVec, pub properties: CollectionPropertiesVec, } @@ -493,17 +492,10 @@ } #[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum MetaUpdatePermission { ItemOwner, Admin, None, -} - -impl Default for MetaUpdatePermission { - fn default() -> Self { - Self::ItemOwner - } } #[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)] --- a/runtime/tests/src/tests.rs +++ b/runtime/tests/src/tests.rs @@ -18,7 +18,7 @@ use crate::{Test, TestCrossAccountId, CollectionCreationPrice, Origin, Unique, new_test_ext}; use up_data_structs::{ COLLECTION_NUMBER_LIMIT, CollectionId, CreateItemData, CreateFungibleData, CreateNftData, - CreateReFungibleData, MAX_DECIMAL_POINTS, COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, + CreateReFungibleData, MAX_DECIMAL_POINTS, COLLECTION_ADMINS_LIMIT, TokenId, MAX_TOKEN_OWNERSHIP, CreateCollectionData, CollectionField, SchemaVersion, CollectionMode, AccessMode, }; @@ -2467,32 +2467,6 @@ assert_eq!( >::get((collection_id, account(2))), 1 - ); - }); -} - -#[test] -fn set_variable_meta_flag_after_freeze() { - new_test_ext().execute_with(|| { - // default_limits(); - - let collection_id = - create_test_collection_for_owner(&CollectionMode::NFT, 2, CollectionId(1)); - - let origin2 = Origin::signed(2); - - assert_ok!(Unique::set_meta_update_permission_flag( - origin2.clone(), - collection_id, - MetaUpdatePermission::None, - )); - assert_noop!( - Unique::set_meta_update_permission_flag( - origin2.clone(), - collection_id, - MetaUpdatePermission::Admin - ), - CommonError::::MetadataFlagFrozen ); }); } --- a/tests/src/createCollection.test.ts +++ b/tests/src/createCollection.test.ts @@ -74,7 +74,6 @@ accountTokenOwnershipLimit: 3, }, constOnChainSchema: '0x333333', - metaUpdatePermission: 'Admin', }); const events = await submitTransactionAsync(alice, tx); const result = getCreateCollectionResult(events); @@ -91,7 +90,6 @@ expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address); expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3); expect(collection.constOnChainSchema.toString()).to.equal('0x333333'); - expect(collection.metaUpdatePermission.isAdmin).to.be.true; }); }); }); --- a/tests/src/eth/nonFungible.test.ts +++ b/tests/src/eth/nonFungible.test.ts @@ -15,7 +15,7 @@ // along with Unique Network. If not, see . import privateKey from '../substrate/privateKey'; -import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE, setMetadataUpdatePermissionFlagExpectSuccess} from '../util/helpers'; +import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers'; import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers'; import nonFungibleAbi from './nonFungibleAbi.json'; import {expect} from 'chai'; --- a/tests/src/eth/proxy/nonFungibleProxy.test.ts +++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts @@ -15,7 +15,7 @@ // along with Unique Network. If not, see . import privateKey from '../../substrate/privateKey'; -import {createCollectionExpectSuccess, createItemExpectSuccess, setMetadataUpdatePermissionFlagExpectSuccess} from '../../util/helpers'; +import {createCollectionExpectSuccess, createItemExpectSuccess} from '../../util/helpers'; import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers'; import nonFungibleAbi from '../nonFungibleAbi.json'; import {expect} from 'chai'; --- a/tests/src/nesting/migration-check.test.ts +++ b/tests/src/nesting/migration-check.test.ts @@ -37,7 +37,6 @@ accountTokenOwnershipLimit: 3, }, constOnChainSchema: '0x333333', - metaUpdatePermission: 'Admin', }); const events = await submitTransactionAsync(alice, tx); const result = getCreateCollectionResult(events); --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -650,28 +650,6 @@ }); } -export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) { - - await usingApi(async (api) => { - const tx = api.tx.unique.setMetaUpdatePermissionFlag(collectionId, flag as any); - const events = await submitTransactionAsync(sender, tx); - const result = getGenericResult(events); - - expect(result.success).to.be.true; - }); -} - -export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) { - - await usingApi(async (api) => { - const tx = api.tx.unique.setMetaUpdatePermissionFlag(collectionId, flag as any); - const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected; - const result = getGenericResult(events); - - expect(result.success).to.be.false; - }); -} - export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) { await usingApi(async (api) => { const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);