From d4987172d810027e7aefff9717082632659572a8 Mon Sep 17 00:00:00 2001 From: librelois <c@elo.tf> Date: Sat, 27 Aug 2022 21:56:55 +0200 Subject: [PATCH] migration v400 --- runtime/gdev/src/lib.rs | 3 ++ runtime/gdev/src/migrations_v400.rs | 45 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 runtime/gdev/src/migrations_v400.rs diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index e010fc67c..798fe3dae 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -28,6 +28,8 @@ extern crate frame_benchmarking; pub mod parameters; +mod migrations_v400; + pub use self::parameters::*; pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, @@ -127,6 +129,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem, + migrations_v400::MigrationsV400, >; pub type TechnicalCommitteeInstance = Instance2; diff --git a/runtime/gdev/src/migrations_v400.rs b/runtime/gdev/src/migrations_v400.rs new file mode 100644 index 000000000..fb8224016 --- /dev/null +++ b/runtime/gdev/src/migrations_v400.rs @@ -0,0 +1,45 @@ +// Copyright 2021-2022 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +use crate::*; + +pub struct MigrationsV400; +impl frame_support::traits::OnRuntimeUpgrade for MigrationsV400 { + fn on_runtime_upgrade() -> Weight { + let mut weight = 1_000_000_000; // Safety margin + + type OldvalueType = AccountId; + + pallet_membership::PendingMembership::<Runtime, Instance1>::translate_values( + |_: OldvalueType| { + weight += <Runtime as frame_system::Config>::DbWeight::get().write; + Some(()) + }, + ); + + weight + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + Ok(()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + Ok(()) + } +} -- GitLab