pub struct GenesisConfigBuilderRuntimeCaller<'a, EHF = ()>where
EHF: HostFunctions,{ /* private fields */ }Expand description
A utility that facilitates calling the GenesisBuilder API from the runtime wasm code blob.
EHF type allows to specify the extended host function required for building runtime’s genesis
config. The type will be compbined with default sp_io::SubstrateHostFunctions.
Implementations§
source§impl<'a, EHF> GenesisConfigBuilderRuntimeCaller<'a, EHF>where
EHF: HostFunctions,
impl<'a, EHF> GenesisConfigBuilderRuntimeCaller<'a, EHF>where
EHF: HostFunctions,
sourcepub fn new(code: &'a [u8]) -> Self
pub fn new(code: &'a [u8]) -> Self
Creates new instance using the provided code blob.
This code is later referred to as runtime.
sourcepub fn get_default_config(&self) -> Result<Value, String>
pub fn get_default_config(&self) -> Result<Value, String>
Returns the default GenesisConfig provided by the runtime.
Calls GenesisBuilder::create_default_config in the runtime.
sourcepub fn get_storage_for_config(&self, config: Value) -> Result<Storage, String>
pub fn get_storage_for_config(&self, config: Value) -> Result<Storage, String>
Build the given GenesisConfig and returns the genesis state.
Calls GenesisBuilder::build_config
provided by the runtime.
sourcepub fn get_storage_for_patch(&self, patch: Value) -> Result<Storage, String>
pub fn get_storage_for_patch(&self, patch: Value) -> Result<Storage, String>
Creates the genesis state by patching the default GenesisConfig and applying it.
This function generates the GenesisConfig for the runtime by applying a provided JSON
patch. The patch modifies the default GenesisConfig allowing customization of the specific
keys. The resulting GenesisConfig is then deserialized from the patched JSON
representation and stored in the storage.
If the provided JSON patch is incorrect or the deserialization fails the error will be returned.
The patching process modifies the default GenesisConfig according to the following rules:
- Existing keys in the default configuration will be overridden by the corresponding values in the patch.
- If a key exists in the patch but not in the default configuration, it will be added to
the resulting
GenesisConfig. - Keys in the default configuration that have null values in the patch will be removed from
the resulting
GenesisConfig. This is helpful for changing enum variant value.
Please note that the patch may contain full GenesisConfig.
Trait Implementations§
source§impl<'a, EHF> FetchRuntimeCode for GenesisConfigBuilderRuntimeCaller<'a, EHF>where
EHF: HostFunctions,
impl<'a, EHF> FetchRuntimeCode for GenesisConfigBuilderRuntimeCaller<'a, EHF>where
EHF: HostFunctions,
Auto Trait Implementations§
impl<'a, EHF = ()> !RefUnwindSafe for GenesisConfigBuilderRuntimeCaller<'a, EHF>
impl<'a, EHF> Send for GenesisConfigBuilderRuntimeCaller<'a, EHF>
impl<'a, EHF> Sync for GenesisConfigBuilderRuntimeCaller<'a, EHF>
impl<'a, EHF> Unpin for GenesisConfigBuilderRuntimeCaller<'a, EHF>where
EHF: Unpin,
impl<'a, EHF = ()> !UnwindSafe for GenesisConfigBuilderRuntimeCaller<'a, EHF>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.