mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
GenesisBuild<T,I> deprecated. BuildGenesisConfig added. (#14306)
* frame::support: GenesisConfig types for Runtime enabled * frame::support: macro generating GenesisBuild::build for RuntimeGenesisConfig * frame: ambiguity BuildStorage vs GenesisBuild fixed * fix * RuntimeGenesisBuild added * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed" This reverts commit 950f3d019d0e21c55a739c44cc19cdabd3ff0293. * Revert "fix" This reverts commit a2f76dd24e9a16cf9230d45825ed28787211118b. * Revert "RuntimeGenesisBuild added" This reverts commit 3c131b618138ced29c01ab8d15d8c6410c9e128b. * Revert "Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed"" This reverts commit 2b1ecd467231eddec69f8d328039ba48a380da3d. * Revert "Revert "fix"" This reverts commit fd7fa629adf579d83e30e6ae9fd162637fc45e30. * Code review suggestions * frame: BuildGenesisConfig added, BuildGenesis deprecated * frame: some pallets updated with BuildGenesisConfig * constuct_runtime: support for BuildGenesisConfig * frame::support: genesis_build macro supports BuildGenesisConfig * frame: BuildGenesisConfig added, BuildGenesis deprecated * Cargo.lock update * test-runtime: fixes * Revert "fix" This reverts commit a2f76dd24e9a16cf9230d45825ed28787211118b. * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed" This reverts commit 950f3d019d0e21c55a739c44cc19cdabd3ff0293. * self review * doc fixed * ui tests fixed * fmt * tests fixed * genesis_build macrto fixed for non-generic GenesisConfig * BuildGenesisConfig constraints added * warning fixed * some duplication removed * fmt * fix * doc tests fix * doc fix * cleanup: remove BuildModuleGenesisStorage * self review comments * fix * Update frame/treasury/src/tests.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * Update frame/support/src/traits/hooks.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * doc fix: GenesisBuild exposed * ".git/.scripts/commands/fmt/fmt.sh" * frame: more serde(skip) + cleanup * Update frame/support/src/traits/hooks.rs Co-authored-by: Davide Galassi <davxy@datawok.net> * frame: phantom fields moved to the end of structs * chain-spec: Default::default cleanup * test-runtime: phantom at the end * merge master fixes * fix * fix * fix * fix * fix (facepalm) * Update frame/support/procedural/src/pallet/expand/genesis_build.rs Co-authored-by: Bastian Köcher <git@kchr.de> * fmt * fix * fix --------- Co-authored-by: parity-processbot <> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Davide Galassi <davxy@datawok.net> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
committed by
GitHub
parent
49150ee583
commit
87d41d0a89
@@ -166,8 +166,6 @@ mod types;
|
||||
pub mod weights;
|
||||
|
||||
use codec::{Codec, MaxEncodedLen};
|
||||
#[cfg(feature = "std")]
|
||||
use frame_support::traits::GenesisBuild;
|
||||
use frame_support::{
|
||||
ensure,
|
||||
pallet_prelude::DispatchResult,
|
||||
@@ -465,7 +463,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
|
||||
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
|
||||
fn build(&self) {
|
||||
let total = self.balances.iter().fold(Zero::zero(), |acc: T::Balance, &(_, n)| acc + n);
|
||||
|
||||
@@ -499,23 +497,6 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Config<I>, I: 'static> GenesisConfig<T, I> {
|
||||
/// Direct implementation of `GenesisBuild::build_storage`.
|
||||
///
|
||||
/// Kept in order not to break dependency.
|
||||
pub fn build_storage(&self) -> Result<sp_runtime::Storage, String> {
|
||||
<Self as GenesisBuild<T, I>>::build_storage(self)
|
||||
}
|
||||
|
||||
/// Direct implementation of `GenesisBuild::assimilate_storage`.
|
||||
///
|
||||
/// Kept in order not to break dependency.
|
||||
pub fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> Result<(), String> {
|
||||
<Self as GenesisBuild<T, I>>::assimilate_storage(self, storage)
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config<I>, I: 'static> Hooks<T::BlockNumber> for Pallet<T, I> {
|
||||
#[cfg(not(feature = "insecure_zero_ed"))]
|
||||
|
||||
@@ -666,7 +666,7 @@ fn burn_must_work() {
|
||||
#[should_panic = "the balance of any account should always be at least the existential deposit."]
|
||||
fn cannot_set_genesis_value_below_ed() {
|
||||
EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = 11);
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
let _ = crate::GenesisConfig::<Test> { balances: vec![(1, 10)] }
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
@@ -675,7 +675,7 @@ fn cannot_set_genesis_value_below_ed() {
|
||||
#[test]
|
||||
#[should_panic = "duplicate balances in genesis."]
|
||||
fn cannot_set_genesis_value_twice() {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
let _ = crate::GenesisConfig::<Test> { balances: vec![(1, 10), (2, 20), (1, 15)] }
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
@@ -40,7 +40,7 @@ use sp_io;
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BadOrigin, IdentityLookup, SignedExtension, Zero},
|
||||
ArithmeticError, DispatchError, DispatchResult, FixedPointNumber, TokenError,
|
||||
ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, TokenError,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
@@ -78,7 +78,7 @@ frame_support::construct_runtime!(
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>},
|
||||
}
|
||||
@@ -176,7 +176,7 @@ impl ExtBuilder {
|
||||
}
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
self.set_associated_consts();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: if self.monied {
|
||||
vec![
|
||||
|
||||
Reference in New Issue
Block a user