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.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_unique4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-03-01, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-unique14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/unique/src/weights.rs2425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_unique.34pub trait WeightInfo {35 fn create_collection() -> Weight;36 fn destroy_collection() -> Weight;37 fn add_to_allow_list() -> Weight;38 fn remove_from_allow_list() -> Weight;39 fn set_public_access_mode() -> Weight;40 fn set_mint_permission() -> Weight;41 fn change_collection_owner() -> Weight;42 fn add_collection_admin() -> Weight;43 fn remove_collection_admin() -> Weight;44 fn set_collection_sponsor() -> Weight;45 fn confirm_sponsorship() -> Weight;46 fn remove_collection_sponsor() -> Weight;47 fn set_transfers_enabled_flag() -> Weight;48 fn set_offchain_schema(b: u32, ) -> Weight;49 fn set_const_on_chain_schema(b: u32, ) -> Weight;50 fn set_variable_on_chain_schema(b: u32, ) -> Weight;51 fn set_schema_version() -> Weight;52 fn set_collection_limits() -> Weight;53 fn set_meta_update_permission_flag() -> Weight;54}5556/// Weights for pallet_unique using the Substrate node and recommended hardware.57pub struct SubstrateWeight<T>(PhantomData<T>);58impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {59 // Storage: Common CreatedCollectionCount (r:1 w:1)60 // Storage: Common DestroyedCollectionCount (r:1 w:0)61 // Storage: System Account (r:2 w:2)62 // Storage: Common CollectionById (r:0 w:1)63 fn create_collection() -> Weight {64 (28_929_000 as Weight)65 .saturating_add(T::DbWeight::get().reads(4 as Weight))66 .saturating_add(T::DbWeight::get().writes(4 as Weight))67 }68 // Storage: Common CollectionById (r:1 w:1)69 // Storage: Common DestroyedCollectionCount (r:1 w:1)70 // Storage: Nonfungible TokensMinted (r:0 w:1)71 // Storage: Nonfungible TokensBurnt (r:0 w:1)72 // Storage: Common AdminAmount (r:0 w:1)73 fn destroy_collection() -> Weight {74 (40_303_000 as Weight)75 .saturating_add(T::DbWeight::get().reads(2 as Weight))76 .saturating_add(T::DbWeight::get().writes(5 as Weight))77 }78 // Storage: Common CollectionById (r:1 w:0)79 // Storage: Common Allowlist (r:0 w:1)80 fn add_to_allow_list() -> Weight {81 (15_989_000 as Weight)82 .saturating_add(T::DbWeight::get().reads(1 as Weight))83 .saturating_add(T::DbWeight::get().writes(1 as Weight))84 }85 // Storage: Common CollectionById (r:1 w:0)86 // Storage: Common Allowlist (r:0 w:1)87 fn remove_from_allow_list() -> Weight {88 (15_582_000 as Weight)89 .saturating_add(T::DbWeight::get().reads(1 as Weight))90 .saturating_add(T::DbWeight::get().writes(1 as Weight))91 }92 // Storage: Common CollectionById (r:1 w:1)93 fn set_public_access_mode() -> Weight {94 (14_846_000 as Weight)95 .saturating_add(T::DbWeight::get().reads(1 as Weight))96 .saturating_add(T::DbWeight::get().writes(1 as Weight))97 }98 // Storage: Common CollectionById (r:1 w:1)99 fn set_mint_permission() -> Weight {100 (14_534_000 as Weight)101 .saturating_add(T::DbWeight::get().reads(1 as Weight))102 .saturating_add(T::DbWeight::get().writes(1 as Weight))103 }104 // Storage: Common CollectionById (r:1 w:1)105 fn change_collection_owner() -> Weight {106 (14_990_000 as Weight)107 .saturating_add(T::DbWeight::get().reads(1 as Weight))108 .saturating_add(T::DbWeight::get().writes(1 as Weight))109 }110 // Storage: Common CollectionById (r:1 w:0)111 // Storage: Common IsAdmin (r:1 w:1)112 // Storage: Common AdminAmount (r:1 w:1)113 fn add_collection_admin() -> Weight {114 (19_957_000 as Weight)115 .saturating_add(T::DbWeight::get().reads(3 as Weight))116 .saturating_add(T::DbWeight::get().writes(2 as Weight))117 }118 // Storage: Common CollectionById (r:1 w:0)119 // Storage: Common IsAdmin (r:1 w:1)120 // Storage: Common AdminAmount (r:1 w:1)121 fn remove_collection_admin() -> Weight {122 (21_209_000 as Weight)123 .saturating_add(T::DbWeight::get().reads(3 as Weight))124 .saturating_add(T::DbWeight::get().writes(2 as Weight))125 }126 // Storage: Common CollectionById (r:1 w:1)127 fn set_collection_sponsor() -> Weight {128 (14_963_000 as Weight)129 .saturating_add(T::DbWeight::get().reads(1 as Weight))130 .saturating_add(T::DbWeight::get().writes(1 as Weight))131 }132 // Storage: Common CollectionById (r:1 w:1)133 fn confirm_sponsorship() -> Weight {134 (14_478_000 as Weight)135 .saturating_add(T::DbWeight::get().reads(1 as Weight))136 .saturating_add(T::DbWeight::get().writes(1 as Weight))137 }138 // Storage: Common CollectionById (r:1 w:1)139 fn remove_collection_sponsor() -> Weight {140 (14_393_000 as Weight)141 .saturating_add(T::DbWeight::get().reads(1 as Weight))142 .saturating_add(T::DbWeight::get().writes(1 as Weight))143 }144 // Storage: Common CollectionById (r:1 w:1)145 fn set_transfers_enabled_flag() -> Weight {146 (7_309_000 as Weight)147 .saturating_add(T::DbWeight::get().reads(1 as Weight))148 .saturating_add(T::DbWeight::get().writes(1 as Weight))149 }150 // Storage: Common CollectionById (r:1 w:1)151 fn set_offchain_schema(_b: u32, ) -> Weight {152 (15_220_000 as Weight)153 .saturating_add(T::DbWeight::get().reads(1 as Weight))154 .saturating_add(T::DbWeight::get().writes(1 as Weight))155 }156 // Storage: Common CollectionById (r:1 w:1)157 fn set_const_on_chain_schema(_b: u32, ) -> Weight {158 (14_984_000 as Weight)159 .saturating_add(T::DbWeight::get().reads(1 as Weight))160 .saturating_add(T::DbWeight::get().writes(1 as Weight))161 }162 // Storage: Common CollectionById (r:1 w:1)163 fn set_variable_on_chain_schema(_b: u32, ) -> Weight {164 (15_196_000 as Weight)165 .saturating_add(T::DbWeight::get().reads(1 as Weight))166 .saturating_add(T::DbWeight::get().writes(1 as Weight))167 }168 // Storage: Common CollectionById (r:1 w:1)169 fn set_schema_version() -> Weight {170 (14_596_000 as Weight)171 .saturating_add(T::DbWeight::get().reads(1 as Weight))172 .saturating_add(T::DbWeight::get().writes(1 as Weight))173 }174 // Storage: Common CollectionById (r:1 w:1)175 fn set_collection_limits() -> Weight {176 (15_339_000 as Weight)177 .saturating_add(T::DbWeight::get().reads(1 as Weight))178 .saturating_add(T::DbWeight::get().writes(1 as Weight))179 }180 // Storage: Common CollectionById (r:1 w:1)181 fn set_meta_update_permission_flag() -> Weight {182 (7_214_000 as Weight)183 .saturating_add(T::DbWeight::get().reads(1 as Weight))184 .saturating_add(T::DbWeight::get().writes(1 as Weight))185 }186}187188// For backwards compatibility and tests189impl WeightInfo for () {190 // Storage: Common CreatedCollectionCount (r:1 w:1)191 // Storage: Common DestroyedCollectionCount (r:1 w:0)192 // Storage: System Account (r:2 w:2)193 // Storage: Common CollectionById (r:0 w:1)194 fn create_collection() -> Weight {195 (28_929_000 as Weight)196 .saturating_add(RocksDbWeight::get().reads(4 as Weight))197 .saturating_add(RocksDbWeight::get().writes(4 as Weight))198 }199 // Storage: Common CollectionById (r:1 w:1)200 // Storage: Common DestroyedCollectionCount (r:1 w:1)201 // Storage: Nonfungible TokensMinted (r:0 w:1)202 // Storage: Nonfungible TokensBurnt (r:0 w:1)203 // Storage: Common AdminAmount (r:0 w:1)204 fn destroy_collection() -> Weight {205 (40_303_000 as Weight)206 .saturating_add(RocksDbWeight::get().reads(2 as Weight))207 .saturating_add(RocksDbWeight::get().writes(5 as Weight))208 }209 // Storage: Common CollectionById (r:1 w:0)210 // Storage: Common Allowlist (r:0 w:1)211 fn add_to_allow_list() -> Weight {212 (15_989_000 as Weight)213 .saturating_add(RocksDbWeight::get().reads(1 as Weight))214 .saturating_add(RocksDbWeight::get().writes(1 as Weight))215 }216 // Storage: Common CollectionById (r:1 w:0)217 // Storage: Common Allowlist (r:0 w:1)218 fn remove_from_allow_list() -> Weight {219 (15_582_000 as Weight)220 .saturating_add(RocksDbWeight::get().reads(1 as Weight))221 .saturating_add(RocksDbWeight::get().writes(1 as Weight))222 }223 // Storage: Common CollectionById (r:1 w:1)224 fn set_public_access_mode() -> Weight {225 (14_846_000 as Weight)226 .saturating_add(RocksDbWeight::get().reads(1 as Weight))227 .saturating_add(RocksDbWeight::get().writes(1 as Weight))228 }229 // Storage: Common CollectionById (r:1 w:1)230 fn set_mint_permission() -> Weight {231 (14_534_000 as Weight)232 .saturating_add(RocksDbWeight::get().reads(1 as Weight))233 .saturating_add(RocksDbWeight::get().writes(1 as Weight))234 }235 // Storage: Common CollectionById (r:1 w:1)236 fn change_collection_owner() -> Weight {237 (14_990_000 as Weight)238 .saturating_add(RocksDbWeight::get().reads(1 as Weight))239 .saturating_add(RocksDbWeight::get().writes(1 as Weight))240 }241 // Storage: Common CollectionById (r:1 w:0)242 // Storage: Common IsAdmin (r:1 w:1)243 // Storage: Common AdminAmount (r:1 w:1)244 fn add_collection_admin() -> Weight {245 (19_957_000 as Weight)246 .saturating_add(RocksDbWeight::get().reads(3 as Weight))247 .saturating_add(RocksDbWeight::get().writes(2 as Weight))248 }249 // Storage: Common CollectionById (r:1 w:0)250 // Storage: Common IsAdmin (r:1 w:1)251 // Storage: Common AdminAmount (r:1 w:1)252 fn remove_collection_admin() -> Weight {253 (21_209_000 as Weight)254 .saturating_add(RocksDbWeight::get().reads(3 as Weight))255 .saturating_add(RocksDbWeight::get().writes(2 as Weight))256 }257 // Storage: Common CollectionById (r:1 w:1)258 fn set_collection_sponsor() -> Weight {259 (14_963_000 as Weight)260 .saturating_add(RocksDbWeight::get().reads(1 as Weight))261 .saturating_add(RocksDbWeight::get().writes(1 as Weight))262 }263 // Storage: Common CollectionById (r:1 w:1)264 fn confirm_sponsorship() -> Weight {265 (14_478_000 as Weight)266 .saturating_add(RocksDbWeight::get().reads(1 as Weight))267 .saturating_add(RocksDbWeight::get().writes(1 as Weight))268 }269 // Storage: Common CollectionById (r:1 w:1)270 fn remove_collection_sponsor() -> Weight {271 (14_393_000 as Weight)272 .saturating_add(RocksDbWeight::get().reads(1 as Weight))273 .saturating_add(RocksDbWeight::get().writes(1 as Weight))274 }275 // Storage: Common CollectionById (r:1 w:1)276 fn set_transfers_enabled_flag() -> Weight {277 (7_309_000 as Weight)278 .saturating_add(RocksDbWeight::get().reads(1 as Weight))279 .saturating_add(RocksDbWeight::get().writes(1 as Weight))280 }281 // Storage: Common CollectionById (r:1 w:1)282 fn set_offchain_schema(_b: u32, ) -> Weight {283 (15_220_000 as Weight)284 .saturating_add(RocksDbWeight::get().reads(1 as Weight))285 .saturating_add(RocksDbWeight::get().writes(1 as Weight))286 }287 // Storage: Common CollectionById (r:1 w:1)288 fn set_const_on_chain_schema(_b: u32, ) -> Weight {289 (14_984_000 as Weight)290 .saturating_add(RocksDbWeight::get().reads(1 as Weight))291 .saturating_add(RocksDbWeight::get().writes(1 as Weight))292 }293 // Storage: Common CollectionById (r:1 w:1)294 fn set_variable_on_chain_schema(_b: u32, ) -> Weight {295 (15_196_000 as Weight)296 .saturating_add(RocksDbWeight::get().reads(1 as Weight))297 .saturating_add(RocksDbWeight::get().writes(1 as Weight))298 }299 // Storage: Common CollectionById (r:1 w:1)300 fn set_schema_version() -> Weight {301 (14_596_000 as Weight)302 .saturating_add(RocksDbWeight::get().reads(1 as Weight))303 .saturating_add(RocksDbWeight::get().writes(1 as Weight))304 }305 // Storage: Common CollectionById (r:1 w:1)306 fn set_collection_limits() -> Weight {307 (15_339_000 as Weight)308 .saturating_add(RocksDbWeight::get().reads(1 as Weight))309 .saturating_add(RocksDbWeight::get().writes(1 as Weight))310 }311 // Storage: Common CollectionById (r:1 w:1)312 fn set_meta_update_permission_flag() -> Weight {313 (7_214_000 as Weight)314 .saturating_add(RocksDbWeight::get().reads(1 as Weight))315 .saturating_add(RocksDbWeight::get().writes(1 as Weight))316 }317}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;
}