From 5e5dd9227b0d86306c9fe6d86133e10bcbb03c7c Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 8 Jul 2022 09:10:00 +0200 Subject: [PATCH 1/4] feat: force version upgrade --- pallets/nonfungible/src/lib.rs | 56 +--------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/pallets/nonfungible/src/lib.rs b/pallets/nonfungible/src/lib.rs index 76f647326c..273ec03418 100644 --- a/pallets/nonfungible/src/lib.rs +++ b/pallets/nonfungible/src/lib.rs @@ -183,61 +183,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_runtime_upgrade() -> Weight { - if StorageVersion::get::>() < StorageVersion::new(1) { - let mut had_consts = BTreeSet::new(); - >::translate::, _>( - |(collection, token), v| { - let mut props = vec![]; - if !v.const_data.is_empty() { - props.push(Property { - key: b"_old_constData".to_vec().try_into().unwrap(), - value: v - .const_data - .clone() - .into_inner() - .try_into() - .expect("const too long"), - }); - had_consts.insert(collection); - } - if !v.variable_data.is_empty() { - props.push(Property { - key: b"_old_variableData".to_vec().try_into().unwrap(), - value: v - .variable_data - .clone() - .into_inner() - .try_into() - .expect("variable too long"), - }) - } - if !props.is_empty() { - Self::set_scoped_token_properties( - collection, - token, - PropertyScope::None, - props.into_iter(), - ) - .expect("existing token data exceeds property storage"); - } - Some(>::from(v)) - }, - ); - for collection in had_consts { - >::set_property_permission_unchecked( - collection, - PropertyKeyPermission { - key: b"_old_constData".to_vec().try_into().unwrap(), - permission: PropertyPermission { - mutable: false, - collection_admin: true, - token_owner: false, - }, - }, - ) - .expect("failed to configure permission"); - } - } + StorageVersion::new(1).put::>(); 0 } From 71d423f2794b7e57631185de981865e28cf7aec1 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 8 Jul 2022 09:16:28 +0200 Subject: [PATCH 2/4] feat(refungible): force storage version --- pallets/refungible/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pallets/refungible/src/lib.rs b/pallets/refungible/src/lib.rs index 78fb1417ad..3265f04e0a 100644 --- a/pallets/refungible/src/lib.rs +++ b/pallets/refungible/src/lib.rs @@ -159,11 +159,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_runtime_upgrade() -> Weight { - if StorageVersion::get::>() < StorageVersion::new(1) { - >::translate_values::(|v| { - Some(::from(v)) - }) - } + StorageVersion::new(1).put::>(); 0 } From 9fdfa5809f1e494473deeb5eb42c61990fd094ab Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 8 Jul 2022 09:17:18 +0200 Subject: [PATCH 3/4] feat(common): force storage version --- pallets/common/src/lib.rs | 60 +-------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 668f6dbd15..0525ebf78d 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -553,65 +553,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_runtime_upgrade() -> Weight { - if StorageVersion::get::>() < StorageVersion::new(1) { - use up_data_structs::{CollectionVersion1, CollectionVersion2}; - >::translate::, _>(|id, v| { - let mut props = Vec::new(); - if !v.offchain_schema.is_empty() { - props.push(Property { - key: b"_old_offchainSchema".to_vec().try_into().unwrap(), - value: v - .offchain_schema - .clone() - .into_inner() - .try_into() - .expect("offchain schema too big"), - }); - } - if !v.variable_on_chain_schema.is_empty() { - props.push(Property { - key: b"_old_variableOnChainSchema".to_vec().try_into().unwrap(), - value: v - .variable_on_chain_schema - .clone() - .into_inner() - .try_into() - .expect("offchain schema too big"), - }); - } - if !v.const_on_chain_schema.is_empty() { - props.push(Property { - key: b"_old_constOnChainSchema".to_vec().try_into().unwrap(), - value: v - .const_on_chain_schema - .clone() - .into_inner() - .try_into() - .expect("offchain schema too big"), - }); - } - props.push(Property { - key: b"_old_schemaVersion".to_vec().try_into().unwrap(), - value: match v.schema_version { - SchemaVersion::ImageURL => b"ImageUrl".as_slice(), - SchemaVersion::Unique => b"Unique".as_slice(), - } - .to_vec() - .try_into() - .unwrap(), - }); - Self::set_scoped_collection_properties( - id, - PropertyScope::None, - props.into_iter(), - ) - .expect("existing data larger than properties"); - let mut new = CollectionVersion2::from(v.clone()); - new.permissions.access = Some(v.access); - new.permissions.mint_mode = Some(v.mint_mode); - Some(new) - }); - } + StorageVersion::new(1).put::>(); 0 } From 846700d71437ca594d6ac988af068b06645d97f9 Mon Sep 17 00:00:00 2001 From: Igor Kozyrev Date: Fri, 8 Jul 2022 07:28:42 +0000 Subject: [PATCH 4/4] up version --- runtime/opal/src/lib.rs | 2 +- runtime/quartz/src/lib.rs | 2 +- runtime/unique/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/opal/src/lib.rs b/runtime/opal/src/lib.rs index bded4eb54b..e3d4a69386 100644 --- a/runtime/opal/src/lib.rs +++ b/runtime/opal/src/lib.rs @@ -192,7 +192,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!(RUNTIME_NAME), impl_name: create_runtime_str!(RUNTIME_NAME), authoring_version: 1, - spec_version: 924010, + spec_version: 924011, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/quartz/src/lib.rs b/runtime/quartz/src/lib.rs index a322cc0654..cb29a56c5b 100644 --- a/runtime/quartz/src/lib.rs +++ b/runtime/quartz/src/lib.rs @@ -191,7 +191,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!(RUNTIME_NAME), impl_name: create_runtime_str!(RUNTIME_NAME), authoring_version: 1, - spec_version: 924010, + spec_version: 924011, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/unique/src/lib.rs b/runtime/unique/src/lib.rs index 63634c5717..4b4f21bd49 100644 --- a/runtime/unique/src/lib.rs +++ b/runtime/unique/src/lib.rs @@ -190,7 +190,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!(RUNTIME_NAME), impl_name: create_runtime_str!(RUNTIME_NAME), authoring_version: 1, - spec_version: 924010, + spec_version: 924011, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1,