abstract_core/
app.rs

1//! # Abstract App
2//!
3//! `abstract_core::app` implements shared functionality that's useful for creating new Abstract apps.
4//!
5//! ## Description
6//! An app is a contract that is allowed to perform actions on a [proxy](crate::proxy) contract while also being migratable.
7use crate::{
8    base::{
9        ExecuteMsg as EndpointExecMsg, InstantiateMsg as EndpointInstantiateMsg,
10        MigrateMsg as EndpointMigrateMsg, QueryMsg as EndpointQueryMsg,
11    },
12    objects::{module_version::ModuleDataResponse, nested_admin::TopLevelOwnerResponse},
13    version_control::AccountBase,
14};
15
16pub type ExecuteMsg<ModuleMsg = Empty, ReceiveMsg = Empty> =
17    EndpointExecMsg<BaseExecuteMsg, ModuleMsg, ReceiveMsg>;
18pub type QueryMsg<ModuleMsg = Empty> = EndpointQueryMsg<BaseQueryMsg, ModuleMsg>;
19pub type InstantiateMsg<ModuleMsg = Empty> = EndpointInstantiateMsg<BaseInstantiateMsg, ModuleMsg>;
20pub type MigrateMsg<ModuleMsg = Empty> = EndpointMigrateMsg<BaseMigrateMsg, ModuleMsg>;
21
22use cosmwasm_schema::QueryResponses;
23use cosmwasm_std::{Addr, Empty};
24#[allow(unused_imports)]
25use cw_controllers::AdminResponse;
26use serde::Serialize;
27
28/// Trait indicates that the type is used as an app message
29/// in the [`ExecuteMsg`] enum.
30/// Enables [`Into<ExecuteMsg>`] for BOOT fn-generation support.
31pub trait AppExecuteMsg: Serialize {}
32impl<T: AppExecuteMsg, R: Serialize> From<T> for ExecuteMsg<T, R> {
33    fn from(app: T) -> Self {
34        Self::Module(app)
35    }
36}
37
38impl AppExecuteMsg for Empty {}
39
40/// Trait indicates that the type is used as an app message
41/// in the [`QueryMsg`] enum.
42/// Enables [`Into<QueryMsg>`] for BOOT fn-generation support.
43pub trait AppQueryMsg: Serialize {}
44impl<T: AppQueryMsg> From<T> for QueryMsg<T> {
45    fn from(app: T) -> Self {
46        Self::Module(app)
47    }
48}
49impl AppQueryMsg for Empty {}
50
51/// Used by Module Factory to instantiate App
52#[cosmwasm_schema::cw_serde]
53pub struct BaseInstantiateMsg {
54    pub ans_host_address: String,
55    pub version_control_address: String,
56    pub account_base: AccountBase,
57}
58
59#[cosmwasm_schema::cw_serde]
60#[cfg_attr(feature = "interface", derive(cw_orch::ExecuteFns))]
61#[cfg_attr(feature = "interface", impl_into(ExecuteMsg<T>))]
62pub enum BaseExecuteMsg {
63    /// Updates the base config
64    UpdateConfig {
65        ans_host_address: Option<String>,
66        version_control_address: Option<String>,
67    },
68}
69
70impl<T> From<BaseExecuteMsg> for ExecuteMsg<T> {
71    fn from(base: BaseExecuteMsg) -> Self {
72        Self::Base(base)
73    }
74}
75
76#[cosmwasm_schema::cw_serde]
77#[derive(QueryResponses)]
78#[cfg_attr(feature = "interface", derive(cw_orch::QueryFns))]
79#[cfg_attr(feature = "interface", impl_into(QueryMsg<ModuleMsg>))]
80pub enum BaseQueryMsg {
81    /// Returns [`AppConfigResponse`]
82    #[returns(AppConfigResponse)]
83    BaseConfig {},
84    /// Returns the admin.
85    /// Returns [`AdminResponse`]
86    #[returns(AdminResponse)]
87    BaseAdmin {},
88    /// Returns module data
89    /// Returns [`ModuleDataResponse`]
90    #[returns(ModuleDataResponse)]
91    ModuleData {},
92    /// Returns top level owner
93    /// Returns [`TopLevelOwnerResponse`]
94    #[returns(TopLevelOwnerResponse)]
95    TopLevelOwner {},
96}
97
98impl<T> From<BaseQueryMsg> for QueryMsg<T> {
99    fn from(base: BaseQueryMsg) -> Self {
100        Self::Base(base)
101    }
102}
103
104#[cosmwasm_schema::cw_serde]
105pub struct AppConfigResponse {
106    pub proxy_address: Addr,
107    pub ans_host_address: Addr,
108    pub manager_address: Addr,
109}
110
111#[cosmwasm_schema::cw_serde]
112pub struct BaseMigrateMsg {}