Trait sov_modules_api::Module
source · pub trait Module: Default {
type Context: Context;
type Config;
type CallMessage: Debug + BorshSerialize + BorshDeserialize;
// Provided methods
fn genesis(
&self,
_config: &Self::Config,
_working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>
) -> Result<(), Error> { ... }
fn call(
&self,
_message: Self::CallMessage,
_context: &Self::Context,
_working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>
) -> Result<CallResponse, Error> { ... }
}
Expand description
All the methods have a default implementation that can’t be invoked (because they take NonInstantiable
parameter).
This allows developers to override only some of the methods in their implementation and safely ignore the others.
Required Associated Types§
sourcetype CallMessage: Debug + BorshSerialize + BorshDeserialize
type CallMessage: Debug + BorshSerialize + BorshDeserialize
Module defined argument to the call method.
Provided Methods§
sourcefn genesis(
&self,
_config: &Self::Config,
_working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>
) -> Result<(), Error>
fn genesis( &self, _config: &Self::Config, _working_set: &mut WorkingSet<<Self::Context as Spec>::Storage> ) -> Result<(), Error>
Genesis is called when a rollup is deployed and can be used to set initial state values in the module.
sourcefn call(
&self,
_message: Self::CallMessage,
_context: &Self::Context,
_working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>
) -> Result<CallResponse, Error>
fn call( &self, _message: Self::CallMessage, _context: &Self::Context, _working_set: &mut WorkingSet<<Self::Context as Spec>::Storage> ) -> Result<CallResponse, Error>
Call allows interaction with the module and invokes state changes. It takes a module defined type and a context as parameters.