abstract_sdk/base/endpoints/execute.rs
1use cosmwasm_std::{DepsMut, Env, MessageInfo, Response};
2use schemars::JsonSchema;
3use serde::Serialize;
4
5use crate::base::handler::Handler;
6
7/// Trait for a contract's Execute entry point.
8pub trait ExecuteEndpoint: Handler {
9 /// The message type for the Execute entry point.
10 type ExecuteMsg: Serialize + JsonSchema;
11
12 /// Handler for the Execute endpoint.
13 fn execute(
14 self,
15 deps: DepsMut,
16 env: Env,
17 info: MessageInfo,
18 msg: Self::ExecuteMsg,
19 ) -> Result<Response, Self::Error>;
20}
21
22/// Trait for a custom contract Execute entry point
23///
24/// To use it:
25/// - create a custom execute enum, with your custom methods
26/// - copy all desired endpoints of App [`abstract_std::app::ExecuteMsg`] or Adapter [`abstract_std::adapter::ExecuteMsg`]
27/// - Add your custom type to the end of export_endpoints!() and cw_orch_interface!() macros
28pub trait CustomExecuteHandler<Module: Handler>: Sized {
29 /// Module execute message (`crate::msg::ExecuteMsg` of your module)
30 type ExecuteMsg;
31
32 // Can't use try_into because of conflicting impls, in core
33 /// Convert custom execute message to your module execute message, or if not possible return custom
34 fn try_into_base(self) -> Result<Self::ExecuteMsg, Self>;
35
36 /// Handle of custom execute methods of the module.
37 ///
38 /// This method is used if [`CustomExecuteHandler::into_execute_msg`] returned Error
39 fn custom_execute(
40 self,
41 deps: DepsMut,
42 env: Env,
43 info: MessageInfo,
44 module: Module,
45 ) -> Result<Response, Module::Error>;
46}