Execution
Execution
pub struct ExecuteContext<'a> {
pub deps: DepsMut<'a>,
pub info: MessageInfo,
pub env: Env,
pub amp_ctx: Option<AMPPkt>,
}use andromeda_std::{ExecuteContext, ContractError};
// ..
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, ContractError> {
let ctx = ExecuteContext::new(deps, info, env);
if let ExecuteMsg::AMPReceive(pkt) = msg {
ADOContract::default().execute_amp_receive(ctx, pkt, handle_execute)
} else {
handle_execute(ctx, msg)
}
}
pub fn handle_execute(ctx: ExecuteContext, msg: ExecuteMsg) -> Result<Response, ContractError> {
match msg {
// .. Your execute message handlers,
ExecuteMsg::MyMsg { some_param } => my_handler(ctx, some_param),
_ => ADOContract::default().execute(ctx, msg),
}
}
pub fn my_handler(ctx: ExecuteContext, some_param: SomeVariableType) -> Result<Response, ContractError> {
let ExecuteContext { amp_ctx, deps, info, env } = ctx;
// .. Your code
}Was this helpful?