pub trait Module {
type InstantiateMsg: for<'a> Deserialize<'a>;
type ExecuteMsg: for<'a> Deserialize<'a>;
type QueryMsg: for<'a> Deserialize<'a>;
type QueryResp: Serialize;
type Error: Display;
// Required methods
fn instantiate(
&mut self,
deps: &mut DepsMut<'_>,
env: &Env,
info: &MessageInfo,
msg: Self::InstantiateMsg,
) -> Result<Response, Self::Error>;
fn execute(
&mut self,
deps: &mut DepsMut<'_>,
env: Env,
info: MessageInfo,
msg: Self::ExecuteMsg,
) -> Result<Response, Self::Error>;
fn query(
&self,
deps: &Deps<'_>,
env: Env,
msg: Self::QueryMsg,
) -> Result<Self::QueryResp, Self::Error>;
}Expand description
A well typed CosmWasm module
A module must implement instantiate, execute, and query handlers. These handlers may, however, be no-ops.
Programmers looking to implement reusable CosmWasm modules should create structs that implement Module.
Required Associated Types§
Sourcetype InstantiateMsg: for<'a> Deserialize<'a>
type InstantiateMsg: for<'a> Deserialize<'a>
The message sent to the module to instantiate its state.
Sourcetype ExecuteMsg: for<'a> Deserialize<'a>
type ExecuteMsg: for<'a> Deserialize<'a>
The type of transaction messages this module can handle. For modules that support multiple types of transaction, this will often times be a sum type.
Sourcetype QueryMsg: for<'a> Deserialize<'a>
type QueryMsg: for<'a> Deserialize<'a>
The type of query messages this module can handle. For modules that support multiple queries, this will often times be a sum type.
Required Methods§
Sourcefn instantiate(
&mut self,
deps: &mut DepsMut<'_>,
env: &Env,
info: &MessageInfo,
msg: Self::InstantiateMsg,
) -> Result<Response, Self::Error>
fn instantiate( &mut self, deps: &mut DepsMut<'_>, env: &Env, info: &MessageInfo, msg: Self::InstantiateMsg, ) -> Result<Response, Self::Error>
The instantiate handler for the module. When a Manager with this module registered is instantiated, this method may be called.
Sourcefn execute(
&mut self,
deps: &mut DepsMut<'_>,
env: Env,
info: MessageInfo,
msg: Self::ExecuteMsg,
) -> Result<Response, Self::Error>
fn execute( &mut self, deps: &mut DepsMut<'_>, env: Env, info: MessageInfo, msg: Self::ExecuteMsg, ) -> Result<Response, Self::Error>
The transaction handler for this module. Messages to this contract will be dispatched by the Manager.