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 (also applies to
nullvalues). - If a key exists in the patch but not in the default configuration, it will be added to
the resulting
RuntimeGenesisConfig.
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<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<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§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.