diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index e010fc67c60d1ca5231a3f51791c56a7553e8026..798fe3daea02c1224f62561ec0722eb95b5b1a82 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 0000000000000000000000000000000000000000..fb82240168ba0bc64a6a1e8f95ba90a30faf8ab9 --- /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(()) + } +}