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 combined 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 a json representation of the default RuntimeGenesisConfig
provided by the
runtime
.
Calls GenesisBuilder::get_preset
in the
runtime
with None
argument.
sourcepub fn get_named_preset(&self, id: Option<&String>) -> Result<Value, String>
pub fn get_named_preset(&self, id: Option<&String>) -> Result<Value, String>
Returns a JSON blob representation of the builtin GenesisConfig
identified by id
.
Calls GenesisBuilder::get_preset
provided by 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>
Calls sp_genesis_builder::GenesisBuilder::build_state
provided by 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 RuntimeGenesisConfig
.
This function generates the RuntimeGenesisConfig
for the runtime by applying a provided
JSON patch. The patch modifies the default RuntimeGenesisConfig
allowing customization of
the specific keys. The resulting RuntimeGenesisConfig
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 RuntimeGenesisConfig
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
RuntimeGenesisConfig
. - Keys in the default configuration that have null values in the patch will be removed from
the resulting
RuntimeGenesisConfig
. This is helpful for changing enum variant value.
Please note that the patch may contain full RuntimeGenesisConfig
.
pub fn get_storage_for_named_preset( &self, name: Option<&String>, ) -> Result<Storage, String>
pub fn preset_names(&self) -> Result<Vec<PresetId>, String>
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> Freeze for GenesisConfigBuilderRuntimeCaller<'a, EHF>
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§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
.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.