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§

source

type Context: Context

Execution context.

source

type Config

Configuration for the genesis method.

source

type CallMessage: Debug + BorshSerialize + BorshDeserialize

Module defined argument to the call method.

Provided Methods§

source

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.

source

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.

Implementors§