abstract_adapter/msgs.rs
1#[macro_export]
2/// Generates boilerplate code and entrypoint message types.
3///
4/// ### Usage
5///
6/// Requires three arguments:
7/// 1. The Adapter type.
8/// 2. The Adapter's custom execute message type.
9/// 3. The Adapter's custom query message type.
10///
11/// ```rust,ignore
12/// abstract_adapter::adapter_msg_types!(MyAdapter, MyAdapterExecuteMsg, MyAdapterQueryMsg);
13/// ```
14///
15/// Generates:
16/// ```ignore
17/// // These are the entry point messages expected by the smart-contract. Our custom messages get wrapped by the abstract base message.
18/// pub type InstantiateMsg =
19/// <MyAdapter as abstract_sdk::base::InstantiateEndpoint>::InstantiateMsg;
20/// pub type ExecuteMsg = <MyAdapter as abstract_sdk::base::ExecuteEndpoint>::ExecuteMsg;
21/// pub type QueryMsg = <MyAdapter as abstract_sdk::base::QueryEndpoint>::QueryMsg;
22///
23/// // Implements the trait-bounds for the abstract adapter messages, which allows them to be used in the Adapter type.
24/// // Also implements `Into<ExecuteMsg> for MyAdapterExecuteMsg` and `Into<QueryMsg> for MyAdapterQueryMsg`.
25/// // This enables the use of the `impl_into` macro of cw-orchestrator.
26/// impl abstract_std::adapter::AdapterExecuteMsg for MyAdapterExecuteMsg {}
27/// impl abstract_std::adapter::AdapterQueryMsg for MyAdapterQueryMsg {}
28/// ```
29macro_rules! adapter_msg_types {
30 ($adapter_type:ty, $adapter_execute_msg: ty, $adapter_query_msg: ty) => {
31 /// Top-level Abstract Adapter instantiate message. This is the message that is passed to the `instantiate` entrypoint of the smart-contract.
32 pub type InstantiateMsg =
33 <$adapter_type as $crate::sdk::base::InstantiateEndpoint>::InstantiateMsg;
34 /// Top-level Abstract Adapter execute message. This is the message that is passed to the `execute` entrypoint of the smart-contract.
35 pub type ExecuteMsg = <$adapter_type as $crate::sdk::base::ExecuteEndpoint>::ExecuteMsg;
36 /// Top-level Abstract Adapter query message. This is the message that is passed to the `query` entrypoint of the smart-contract.
37 pub type QueryMsg = <$adapter_type as $crate::sdk::base::QueryEndpoint>::QueryMsg;
38
39 impl $crate::std::adapter::AdapterExecuteMsg for $adapter_execute_msg {}
40 impl $crate::std::adapter::AdapterQueryMsg for $adapter_query_msg {}
41 };
42}