mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Migrate frame-system to pallet attribute macro (#7898)
* PRINT_PALLET_UPGRADE=1 cargo check -p frame-system * Copy attributes, imports, mods and type defs * Copy Config trait * Annotate constants * Tabify * Migrate hooks * Upgrade template rename interface to hooks * Migrate pallet call * Migrate Event * Migrate Error * Migrate Origin * Remove optional validate_unsigned * Remove remaining TODO_MAYBE_WHERE_CLAUSE * Overwrite original lib.rs with migrated lib2.rs. * Add required Event IsType constraint * Add disable supertrait check * Fix leftover Trait trait * Add missing pallet prefix for weight attributes * Add missing Error type parameter * Add missing Hooks type parameter * Private call visibility, restore original helper types and helpers etc * Fix hooks type parameter * Rename RawEvent to Event * Add missing storage type annotations * Remove unused imports * Add GenesisConfig helpers for compat * Fix unused import warnings * Update frame/support/procedural/src/storage/print_pallet_upgrade.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fix test errors and warnings * Fix remaining errors and warnings * Apply review suggestion: fix formatting Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply review suggestion: annotate BlockLength as constant Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply review suggestion: add triling comma Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply review suggestion: add triling comma Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply review suggestion: add trailing comma Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply review suggestion: fix storage type indentation * Apply review suggestion: remove redundant Origin type alias * Add missing codec derives for BlockLength * Restore module docs * Module -> Pallet renamel * Revert "Update frame/support/procedural/src/storage/print_pallet_upgrade.rs" This reverts commit d2a2d5b6 * Apply review suggestion: merge crate imports Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Revert "Upgrade template rename interface to hooks" This reverts commit 306f0239 * Single line import * Refactor generated genesis build * Import sp_io::storage * Revert previous, fully qualify sp_io::storage * Fix ui tests * Fix errors after merge, missing changes * Set UpgradedToDualRefCount to true in genesis build * Annotated Runtime version with constant, exposing it via metadata * Add metadata attribute Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -117,7 +117,7 @@
|
||||
|
||||
use sp_std::{prelude::*, marker::PhantomData};
|
||||
use frame_support::{
|
||||
StorageValue, StorageMap, weights::{GetDispatchInfo, DispatchInfo, DispatchClass},
|
||||
weights::{GetDispatchInfo, DispatchInfo, DispatchClass},
|
||||
traits::{OnInitialize, OnFinalize, OnRuntimeUpgrade, OffchainWorker},
|
||||
dispatch::PostDispatchInfo,
|
||||
};
|
||||
@@ -261,11 +261,11 @@ where
|
||||
|
||||
/// Returns if the runtime was upgraded since the last time this function was called.
|
||||
fn runtime_upgraded() -> bool {
|
||||
let last = frame_system::LastRuntimeUpgrade::get();
|
||||
let last = frame_system::LastRuntimeUpgrade::<System>::get();
|
||||
let current = <System::Version as frame_support::traits::Get<_>>::get();
|
||||
|
||||
if last.map(|v| v.was_upgraded(¤t)).unwrap_or(true) {
|
||||
frame_system::LastRuntimeUpgrade::put(
|
||||
frame_system::LastRuntimeUpgrade::<System>::put(
|
||||
frame_system::LastRuntimeUpgradeInfo::from(current),
|
||||
);
|
||||
true
|
||||
@@ -998,7 +998,7 @@ mod tests {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
RUNTIME_VERSION.with(|v| *v.borrow_mut() = Default::default());
|
||||
// It should be added at genesis
|
||||
assert!(frame_system::LastRuntimeUpgrade::exists());
|
||||
assert!(frame_system::LastRuntimeUpgrade::<Runtime>::exists());
|
||||
assert!(!Executive::runtime_upgraded());
|
||||
|
||||
RUNTIME_VERSION.with(|v| *v.borrow_mut() = sp_version::RuntimeVersion {
|
||||
@@ -1008,7 +1008,7 @@ mod tests {
|
||||
assert!(Executive::runtime_upgraded());
|
||||
assert_eq!(
|
||||
Some(LastRuntimeUpgradeInfo { spec_version: 1.into(), spec_name: "".into() }),
|
||||
frame_system::LastRuntimeUpgrade::get(),
|
||||
frame_system::LastRuntimeUpgrade::<Runtime>::get(),
|
||||
);
|
||||
|
||||
RUNTIME_VERSION.with(|v| *v.borrow_mut() = sp_version::RuntimeVersion {
|
||||
@@ -1019,7 +1019,7 @@ mod tests {
|
||||
assert!(Executive::runtime_upgraded());
|
||||
assert_eq!(
|
||||
Some(LastRuntimeUpgradeInfo { spec_version: 1.into(), spec_name: "test".into() }),
|
||||
frame_system::LastRuntimeUpgrade::get(),
|
||||
frame_system::LastRuntimeUpgrade::<Runtime>::get(),
|
||||
);
|
||||
|
||||
RUNTIME_VERSION.with(|v| *v.borrow_mut() = sp_version::RuntimeVersion {
|
||||
@@ -1030,11 +1030,11 @@ mod tests {
|
||||
});
|
||||
assert!(!Executive::runtime_upgraded());
|
||||
|
||||
frame_system::LastRuntimeUpgrade::take();
|
||||
frame_system::LastRuntimeUpgrade::<Runtime>::take();
|
||||
assert!(Executive::runtime_upgraded());
|
||||
assert_eq!(
|
||||
Some(LastRuntimeUpgradeInfo { spec_version: 1.into(), spec_name: "test".into() }),
|
||||
frame_system::LastRuntimeUpgrade::get(),
|
||||
frame_system::LastRuntimeUpgrade::<Runtime>::get(),
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user