Unverified Commit c406f7b7 authored by ferrell-code's avatar ferrell-code Committed by GitHub
Browse files

Substrate Companion for #9566 (#3704)



* runtime migrations

* clean up

* cargo fmt

* companion

* add _ to satisfy trait

* fix try-runtime

* update substrate
Co-authored-by: thiolliere's avatarthiolliere <gui.thiolliere@gmail.com>
parent 25cb1582
Pipeline #158396 passed with stages
in 45 minutes and 37 seconds
This diff is collapsed.
......@@ -1555,12 +1555,50 @@ pub type Executive = frame_executive::Executive<
TechnicalCommitteeStoragePrefixMigration,
TechnicalMembershipStoragePrefixMigration,
MigrateTipsPalletPrefix,
BountiesPrefixMigration,
StakingBagsListMigrationV8,
),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
const BOUNTIES_OLD_PREFIX: &str = "Treasury";
/// Migrate from 'Treasury' to the new prefix 'Bounties'
pub struct BountiesPrefixMigration;
impl OnRuntimeUpgrade for BountiesPrefixMigration {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::migrate::<Runtime, Bounties, _>(BOUNTIES_OLD_PREFIX, name)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::pre_migration::<Runtime, Bounties, _>(
BOUNTIES_OLD_PREFIX,
name,
);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::post_migration::<Runtime, Bounties, _>(
BOUNTIES_OLD_PREFIX,
name,
);
Ok(())
}
}
const COUNCIL_OLD_PREFIX: &str = "Instance1Collective";
/// Migrate from `Instance1Collective` to the new pallet prefix `Council`
pub struct CouncilStoragePrefixMigration;
......
......@@ -1156,6 +1156,7 @@ pub type Executive = frame_executive::Executive<
Runtime,
AllPallets,
(
BountiesPrefixMigration,
CouncilStoragePrefixMigration,
TechnicalCommitteeStoragePrefixMigration,
TechnicalMembershipStoragePrefixMigration,
......@@ -1165,6 +1166,44 @@ pub type Executive = frame_executive::Executive<
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
const BOUNTIES_OLD_PREFIX: &str = "Treasury";
/// Migrate from 'Treasury' to the new prefix 'Bounties'
pub struct BountiesPrefixMigration;
impl OnRuntimeUpgrade for BountiesPrefixMigration {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::migrate::<Runtime, Bounties, _>(BOUNTIES_OLD_PREFIX, name)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::pre_migration::<Runtime, Bounties, _>(
BOUNTIES_OLD_PREFIX,
name,
);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::post_migration::<Runtime, Bounties, _>(
BOUNTIES_OLD_PREFIX,
name,
);
Ok(())
}
}
const COUNCIL_OLD_PREFIX: &str = "Instance1Collective";
/// Migrate from `Instance1Collective` to the new pallet prefix `Council`
pub struct CouncilStoragePrefixMigration;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment