1// This file is part of Substrate.23// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.4// SPDX-License-Identifier: Apache-2.056// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.1718use crate::{Config, Weight, CurrentSchedule, Pallet, Schedule};19use frame_support::traits::{GetPalletVersion, PalletVersion, Get};2021pub fn migrate<T: Config>() -> Weight {22 let mut weight: Weight = 0;2324 match <Pallet<T>>::storage_version() {25 // Replace the schedule with the new default and increment its version.26 Some(version) if version == PalletVersion::new(3, 0, 0) => {27 weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));28 let _ = <CurrentSchedule<T>>::translate::<u32, _>(|version| {29 version.map(|version| Schedule {30 version: version.saturating_add(1),31 // Default limits were not decreased. Therefore it is OK to overwrite32 // the schedule with the new defaults.33 ..Default::default()34 })35 });36 }37 _ => (),38 }3940 weight41}difftreelog
source
pallets/contracts/src/migration.rs1.4 KiBsourcehistory