mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 22:41:06 +00:00
Make use of assimilate_storage for GenesisConfig (#1982)
* Make use of `assimilate_storage` for `GenesisConfig` Fixes incorrect initialization of the staking gensis storage. * Add some documentation
This commit is contained in:
@@ -270,6 +270,7 @@ decl_storage! {
|
||||
build(|storage: &mut primitives::StorageOverlay, _: &mut primitives::ChildrenStorageOverlay, config: &GenesisConfig<T>| {
|
||||
with_storage(storage, || {
|
||||
for &(ref stash, ref controller, balance) in &config.stakers {
|
||||
assert!(T::Currency::free_balance(&stash) >= balance);
|
||||
let _ = <Module<T>>::bond(T::Origin::from(Some(stash.clone()).into()), T::Lookup::unlookup(controller.clone()), balance, RewardDestination::Staked);
|
||||
let _ = <Module<T>>::validate(T::Origin::from(Some(controller.clone()).into()), Default::default());
|
||||
}
|
||||
|
||||
@@ -137,7 +137,16 @@ impl ExtBuilder {
|
||||
let _ = balances::GenesisConfig::<Test>{
|
||||
balances: if self.monied {
|
||||
if self.reward > 0 {
|
||||
vec![(1, 10 * balance_factor), (2, 20 * balance_factor), (3, 300 * balance_factor), (4, 400 * balance_factor), (10, balance_factor), (11, balance_factor * 1000), (20, balance_factor), (21, balance_factor * 2000)]
|
||||
vec![
|
||||
(1, 10 * balance_factor),
|
||||
(2, 20 * balance_factor),
|
||||
(3, 300 * balance_factor),
|
||||
(4, 400 * balance_factor),
|
||||
(10, balance_factor),
|
||||
(11, balance_factor * 1000),
|
||||
(20, balance_factor),
|
||||
(21, balance_factor * 2000)
|
||||
]
|
||||
} else {
|
||||
vec![(1, 10 * balance_factor), (2, 20 * balance_factor), (3, 300 * balance_factor), (4, 400 * balance_factor)]
|
||||
}
|
||||
|
||||
@@ -389,21 +389,6 @@ fn decl_store_extra_genesis(
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl#fparam #scrate::runtime_primitives::BuildStorage for GenesisConfig#sparam {
|
||||
|
||||
fn build_storage(self) -> ::std::result::Result<(#scrate::runtime_primitives::StorageOverlay, #scrate::runtime_primitives::ChildrenStorageOverlay), String> {
|
||||
let mut r: #scrate::runtime_primitives::StorageOverlay = Default::default();
|
||||
let mut c: #scrate::runtime_primitives::ChildrenStorageOverlay = Default::default();
|
||||
|
||||
{
|
||||
use #scrate::rstd::{cell::RefCell, marker::PhantomData};
|
||||
let storage = (RefCell::new(&mut r), PhantomData::<Self>::default());
|
||||
#builders
|
||||
}
|
||||
|
||||
#scall(&mut r, &mut c, &self);
|
||||
|
||||
Ok((r, c))
|
||||
}
|
||||
fn assimilate_storage(self, r: &mut #scrate::runtime_primitives::StorageOverlay, c: &mut #scrate::runtime_primitives::ChildrenStorageOverlay) -> ::std::result::Result<(), String> {
|
||||
use #scrate::rstd::{cell::RefCell, marker::PhantomData};
|
||||
let storage = (RefCell::new(r), PhantomData::<Self>::default());
|
||||
|
||||
@@ -62,6 +62,11 @@
|
||||
/// - `Inherent $( (CALL) )*` - If the module provides/can check inherents. The optional parameter
|
||||
/// is for modules that use a `Call` from a different module as
|
||||
/// inherent.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The population of the genesis storage depends on the order of modules. So, if one of your
|
||||
/// modules depends on another module. The dependent module need to come before the module depending on it.
|
||||
#[macro_export]
|
||||
macro_rules! construct_runtime {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user