abstract_app/msgs.rs
1#[macro_export]
2/// Generates boilerplate code and entrypoint message types.
3///
4/// ### Usage
5///
6/// Requires three arguments:
7/// 1. The App type.
8/// 2. The App's custom execute message type.
9/// 3. The App's custom query message type.
10///
11/// ```rust,ignore
12/// abstract_app::app_msg_types!(MyApp, MyAppExecuteMsg, MyAppQueryMsg);
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/// <MyApp as sdk::base::InstantiateEndpoint>::InstantiateMsg;
20/// pub type ExecuteMsg = <MyApp as sdk::base::ExecuteEndpoint>::ExecuteMsg;
21/// pub type QueryMsg = <MyApp as sdk::base::QueryEndpoint>::QueryMsg;
22/// pub type MigrateMsg = <MyApp as sdk::base::MigrateEndpoint>::MigrateMsg;
23///
24/// // Implements the trait-bounds for the abstract app messages, which allows them to be used in the App type.
25/// // Also implements `Into<ExecuteMsg> for MyAppExecuteMsg` and `Into<QueryMsg> for MyAppQueryMsg`.
26/// // This enables the use of the `impl_into` macro of cw-orchestrator.
27/// impl abstract_std::app::AppExecuteMsg for MyAppExecuteMsg {}
28/// impl abstract_std::app::AppQueryMsg for MyAppQueryMsg {}
29/// ```
30macro_rules! app_msg_types {
31 ($app_type:ty, $app_execute_msg: ty, $app_query_msg: ty) => {
32 /// Top-level Abstract App instantiate message. This is the message that is passed to the `instantiate` entrypoint of the smart-contract.
33 pub type InstantiateMsg =
34 <$app_type as $crate::sdk::base::InstantiateEndpoint>::InstantiateMsg;
35 /// Top-level Abstract App execute message. This is the message that is passed to the `execute` entrypoint of the smart-contract.
36 pub type ExecuteMsg = <$app_type as $crate::sdk::base::ExecuteEndpoint>::ExecuteMsg;
37 /// Top-level Abstract App query message. This is the message that is passed to the `query` entrypoint of the smart-contract.
38 pub type QueryMsg = <$app_type as $crate::sdk::base::QueryEndpoint>::QueryMsg;
39 /// Top-level Abstract App migrate message. This is the message that is passed to the `migrate` entrypoint of the smart-contract.
40 pub type MigrateMsg = <$app_type as $crate::sdk::base::MigrateEndpoint>::MigrateMsg;
41
42 impl $crate::std::app::AppExecuteMsg for $app_execute_msg {}
43 impl $crate::std::app::AppQueryMsg for $app_query_msg {}
44 };
45}