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.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -35,7 +35,7 @@
use frame_system::{self as system, ensure_signed};
use sp_runtime::{sp_std::prelude::Vec};
use up_data_structs::{
- VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT, OFFCHAIN_SCHEMA_LIMIT,
+ 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, CustomDataLimit,
@@ -191,13 +191,6 @@
///
/// * collection_id: Globally unique collection identifier.
SchemaVersionSet(CollectionId),
-
- /// Variable on chain schema was set
- ///
- /// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- VariableOnChainSchemaSet(CollectionId),
}
}
@@ -1083,38 +1076,6 @@
<PalletCommon<T>>::set_field(&collection, &sender, CollectionField::ConstOnChainSchema, schema.into_inner())?;
<Pallet<T>>::deposit_event(Event::<T>::ConstOnChainSchemaSet(
- collection_id
- ));
- Ok(())
- }
-
- /// Set variable on-chain data schema.
- ///
- /// # Permissions
- ///
- /// * Collection Owner
- /// * Collection Admin
- ///
- /// # Arguments
- ///
- /// * collection_id.
- ///
- /// * schema: String representing the variable on-chain data schema.
- #[weight = <SelfWeightOf<T>>::set_const_on_chain_schema(schema.len() as u32)]
- #[transactional]
- pub fn set_variable_on_chain_schema (
- origin,
- collection_id: CollectionId,
- schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>
- ) -> DispatchResult {
- let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let collection = <CollectionHandle<T>>::try_get(collection_id)?;
-
- // =========
-
- <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::VariableOnChainSchema, schema.into_inner())?;
-
- <Pallet<T>>::deposit_event(Event::<T>::VariableOnChainSchemaSet(
collection_id
));
Ok(())
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.tsdiffbeforeafterboth1// 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/>.1617import {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';20import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';2122describe('integration test: ext. createCollection():', () => {23 it('Create new NFT collection', async () => {24 await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});25 });26 it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {27 await createCollectionExpectSuccess({name: 'A'.repeat(64)});28 });29 it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {30 await createCollectionExpectSuccess({description: 'A'.repeat(256)});31 });32 it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {33 await createCollectionExpectSuccess({tokenPrefix: 'A'.repeat(16)});34 });35 it('Create new Fungible collection', async () => {36 await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});37 });38 it('Create new ReFungible collection', async () => {39 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});40 });4142 it('create new collection with properties #1', async () => {43 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, 44 properties: [{key: 'key1', value: 'val1'}], 45 propPerm: [{key: 'key1', tokenOwner: true, mutable: false, collectionAdmin: true}]});46 });4748 it('create new collection with properties #2', async () => {49 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, 50 properties: [{key: 'key1', value: 'val1'}], 51 propPerm: [{key: 'key1', tokenOwner: false, mutable: true, collectionAdmin: false}]});52 });5354 it('create new collection with properties #3', async () => {55 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, 56 properties: [{key: 'key1', value: 'val1'}], 57 propPerm: [{key: 'key1', tokenOwner: true, mutable: false, collectionAdmin: false}]});58 });5960 it('Create new collection with extra fields', async () => {61 await usingApi(async api => {62 const alice = privateKey('//Alice');63 const bob = privateKey('//Bob');64 const tx = api.tx.unique.createCollectionEx({65 mode: {Fungible: 8},66 access: 'AllowList',67 name: [1],68 description: [2],69 tokenPrefix: '0x000000',70 offchainSchema: '0x111111',71 schemaVersion: 'Unique',72 pendingSponsor: bob.address,73 limits: {74 accountTokenOwnershipLimit: 3,75 },76 variableOnChainSchema: '0x222222',77 constOnChainSchema: '0x333333',78 metaUpdatePermission: 'Admin',79 });80 const events = await submitTransactionAsync(alice, tx);81 const result = getCreateCollectionResult(events);8283 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;84 expect(collection.owner.toString()).to.equal(alice.address);85 expect(collection.mode.asFungible.toNumber()).to.equal(8);86 expect(collection.access.isAllowList).to.be.true;87 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);88 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);89 expect(collection.tokenPrefix.toString()).to.equal('0x000000');90 expect(collection.offchainSchema.toString()).to.equal('0x111111');91 expect(collection.schemaVersion.isUnique).to.be.true;92 expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);93 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);94 expect(collection.variableOnChainSchema.toString()).to.equal('0x222222');95 expect(collection.constOnChainSchema.toString()).to.equal('0x333333');96 expect(collection.metaUpdatePermission.isAdmin).to.be.true;97 });98 });99});100101describe('(!negative test!) integration test: ext. createCollection():', () => {102 it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {103 await createCollectionExpectFailure({name: 'A'.repeat(65), mode: {type: 'NFT'}});104 });105 it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {106 await createCollectionExpectFailure({description: 'A'.repeat(257), mode: {type: 'NFT'}});107 });108 it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {109 await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});110 });111 it('fails when bad limits are set', async () => {112 await usingApi(async api => {113 const alice = privateKey('//Alice');114 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});115 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);116 });117 });118119 it('(!negative test!) create collection with incorrect property limit (64 elements)', async () => {120 const props = [];121122 for (let i = 0; i < 65; i++) {123 props.push({key: `key${i}`, value: `value${i}`});124 }125126 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});127 });128129 it('(!negative test!) create collection with incorrect property limit (40 kb)', async () => {130 const props = [];131132 for (let i = 0; i < 32; i++) {133 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});134 }135136 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});137 });138});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/>.1617import {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';20import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';2122describe('integration test: ext. createCollection():', () => {23 it('Create new NFT collection', async () => {24 await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});25 });26 it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {27 await createCollectionExpectSuccess({name: 'A'.repeat(64)});28 });29 it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {30 await createCollectionExpectSuccess({description: 'A'.repeat(256)});31 });32 it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {33 await createCollectionExpectSuccess({tokenPrefix: 'A'.repeat(16)});34 });35 it('Create new Fungible collection', async () => {36 await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});37 });38 it('Create new ReFungible collection', async () => {39 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});40 });4142 it('create new collection with properties #1', async () => {43 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},44 properties: [{key: 'key1', value: 'val1'}],45 propPerm: [{key: 'key1', tokenOwner: true, mutable: false, collectionAdmin: true}]});46 });4748 it('create new collection with properties #2', async () => {49 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},50 properties: [{key: 'key1', value: 'val1'}],51 propPerm: [{key: 'key1', tokenOwner: false, mutable: true, collectionAdmin: false}]});52 });5354 it('create new collection with properties #3', async () => {55 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},56 properties: [{key: 'key1', value: 'val1'}],57 propPerm: [{key: 'key1', tokenOwner: true, mutable: false, collectionAdmin: false}]});58 });5960 it('Create new collection with extra fields', async () => {61 await usingApi(async api => {62 const alice = privateKey('//Alice');63 const bob = privateKey('//Bob');64 const tx = api.tx.unique.createCollectionEx({65 mode: {Fungible: 8},66 access: 'AllowList',67 name: [1],68 description: [2],69 tokenPrefix: '0x000000',70 offchainSchema: '0x111111',71 schemaVersion: 'Unique',72 pendingSponsor: bob.address,73 limits: {74 accountTokenOwnershipLimit: 3,75 },76 constOnChainSchema: '0x333333',77 metaUpdatePermission: 'Admin',78 });79 const events = await submitTransactionAsync(alice, tx);80 const result = getCreateCollectionResult(events);8182 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;83 expect(collection.owner.toString()).to.equal(alice.address);84 expect(collection.mode.asFungible.toNumber()).to.equal(8);85 expect(collection.access.isAllowList).to.be.true;86 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);87 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);88 expect(collection.tokenPrefix.toString()).to.equal('0x000000');89 expect(collection.offchainSchema.toString()).to.equal('0x111111');90 expect(collection.schemaVersion.isUnique).to.be.true;91 expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);92 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);93 expect(collection.constOnChainSchema.toString()).to.equal('0x333333');94 expect(collection.metaUpdatePermission.isAdmin).to.be.true;95 });96 });97});9899describe('(!negative test!) integration test: ext. createCollection():', () => {100 it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {101 await createCollectionExpectFailure({name: 'A'.repeat(65), mode: {type: 'NFT'}});102 });103 it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {104 await createCollectionExpectFailure({description: 'A'.repeat(257), mode: {type: 'NFT'}});105 });106 it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {107 await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});108 });109 it('fails when bad limits are set', async () => {110 await usingApi(async api => {111 const alice = privateKey('//Alice');112 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});113 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);114 });115 });116117 it('(!negative test!) create collection with incorrect property limit (64 elements)', async () => {118 const props = [];119120 for (let i = 0; i < 65; i++) {121 props.push({key: `key${i}`, value: `value${i}`});122 }123124 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});125 });126127 it('(!negative test!) create collection with incorrect property limit (40 kb)', async () => {128 const props = [];129130 for (let i = 0; i < 32; i++) {131 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});132 }133134 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});135 });136});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;
}