abstract_os/
app.rs

1//! # Abstract App
2//!
3//! `abstract_os::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::base::{
8    ExecuteMsg as EndpointExecMsg, InstantiateMsg as EndpointInstantiateMsg,
9    MigrateMsg as EndpointMigrateMsg, QueryMsg as EndpointQueryMsg,
10};
11
12pub type ExecuteMsg<AppMsg = Empty, ReceiveMsg = Empty> =
13    EndpointExecMsg<BaseExecuteMsg, AppMsg, ReceiveMsg>;
14pub type QueryMsg<AppMsg = Empty> = EndpointQueryMsg<BaseQueryMsg, AppMsg>;
15pub type InstantiateMsg<AppMsg = Empty> = EndpointInstantiateMsg<BaseInstantiateMsg, AppMsg>;
16pub type MigrateMsg<AppMsg = Empty> = EndpointMigrateMsg<BaseMigrateMsg, AppMsg>;
17
18use cosmwasm_schema::QueryResponses;
19use cosmwasm_std::{Addr, Empty};
20use cw_controllers::AdminResponse;
21use serde::Serialize;
22
23/// Trait indicates that the type is used as an app message
24/// in the [`ExecuteMsg`] enum.
25/// Enables [`Into<ExecuteMsg>`] for BOOT fn-generation support.
26pub trait AppExecuteMsg: Serialize {}
27impl<T: AppExecuteMsg, R: Serialize> From<T> for ExecuteMsg<T, R> {
28    fn from(app: T) -> Self {
29        Self::App(app)
30    }
31}
32
33impl AppExecuteMsg for Empty {}
34
35/// Trait indicates that the type is used as an app message
36/// in the [`QueryMsg`] enum.
37/// Enables [`Into<QueryMsg>`] for BOOT fn-generation support.
38pub trait AppQueryMsg: Serialize {}
39impl<T: AppQueryMsg> From<T> for QueryMsg<T> {
40    fn from(app: T) -> Self {
41        Self::App(app)
42    }
43}
44impl AppQueryMsg for Empty {}
45
46/// Used by Module Factory to instantiate App
47#[cosmwasm_schema::cw_serde]
48pub struct BaseInstantiateMsg {
49    pub ans_host_address: String,
50}
51
52#[cosmwasm_schema::cw_serde]
53#[cfg_attr(feature = "boot", derive(boot_core::ExecuteFns))]
54#[cfg_attr(feature = "boot", impl_into(ExecuteMsg<T>))]
55pub enum BaseExecuteMsg {
56    /// Updates the base config
57    UpdateConfig { ans_host_address: Option<String> },
58}
59
60impl<T> From<BaseExecuteMsg> for ExecuteMsg<T> {
61    fn from(base: BaseExecuteMsg) -> Self {
62        Self::Base(base)
63    }
64}
65
66#[cosmwasm_schema::cw_serde]
67#[derive(QueryResponses)]
68#[cfg_attr(feature = "boot", derive(boot_core::QueryFns))]
69#[cfg_attr(feature = "boot", impl_into(QueryMsg<AppMsg>))]
70pub enum BaseQueryMsg {
71    /// Returns [`AppConfigResponse`]
72    #[returns(AppConfigResponse)]
73    Config {},
74    /// Returns the admin.
75    #[returns(AdminResponse)]
76    Admin {},
77}
78
79impl<T> From<BaseQueryMsg> for QueryMsg<T> {
80    fn from(base: BaseQueryMsg) -> Self {
81        Self::Base(base)
82    }
83}
84
85#[cosmwasm_schema::cw_serde]
86pub struct AppConfigResponse {
87    pub proxy_address: Addr,
88    pub ans_host_address: Addr,
89    pub manager_address: Addr,
90}
91
92#[cosmwasm_schema::cw_serde]
93pub struct BaseMigrateMsg {}