pub mod state {
use std::collections::HashSet;
pub use crate::objects::core::ACCOUNT_ID;
use crate::objects::{gov_type::GovernanceDetails, module::ModuleId};
use cosmwasm_std::{Addr, Api};
use cw_address_like::AddressLike;
use cw_controllers::Admin;
use cw_storage_plus::{Item, Map};
pub type SuspensionStatus = bool;
#[cosmwasm_schema::cw_serde]
pub struct Config {
pub version_control_address: Addr,
pub module_factory_address: Addr,
}
#[cosmwasm_schema::cw_serde]
pub struct AccountInfo<T: AddressLike = Addr> {
pub name: String,
pub governance_details: GovernanceDetails<T>,
pub chain_id: String,
pub description: Option<String>,
pub link: Option<String>,
}
impl AccountInfo<String> {
pub fn verify(self, api: &dyn Api) -> Result<AccountInfo<Addr>, crate::AbstractError> {
let governance_details = self.governance_details.verify(api)?;
Ok(AccountInfo {
name: self.name,
governance_details,
chain_id: self.chain_id,
description: self.description,
link: self.link,
})
}
}
impl From<AccountInfo<Addr>> for AccountInfo<String> {
fn from(value: AccountInfo<Addr>) -> Self {
AccountInfo {
name: value.name,
governance_details: value.governance_details.into(),
chain_id: value.chain_id,
description: value.description,
link: value.link,
}
}
}
pub const SUSPENSION_STATUS: Item<SuspensionStatus> = Item::new("\u{0}{12}is_suspended");
pub const CONFIG: Item<Config> = Item::new("\u{0}{6}config");
pub const INFO: Item<AccountInfo<Addr>> = Item::new("\u{0}{4}info");
pub const ACCOUNT_FACTORY: Admin = Admin::new("\u{0}{7}factory");
pub const OWNER: Admin = Admin::new("owner");
pub const ACCOUNT_MODULES: Map<ModuleId, Addr> = Map::new("modules");
pub const DEPENDENTS: Map<ModuleId, HashSet<String>> = Map::new("dependents");
}
use self::state::AccountInfo;
use crate::manager::state::SuspensionStatus;
use crate::objects::{
core::AccountId,
gov_type::GovernanceDetails,
module::{Module, ModuleInfo},
};
use cosmwasm_schema::QueryResponses;
use cosmwasm_std::{Binary, Uint64};
use cw2::ContractVersion;
#[cosmwasm_schema::cw_serde]
pub struct MigrateMsg {}
#[cosmwasm_schema::cw_serde]
pub struct InstantiateMsg {
pub account_id: AccountId,
pub owner: GovernanceDetails<String>,
pub version_control_address: String,
pub module_factory_address: String,
pub name: String,
pub description: Option<String>,
pub link: Option<String>,
}
#[cosmwasm_schema::cw_serde]
pub struct CallbackMsg {}
#[cosmwasm_schema::cw_serde]
#[cfg_attr(feature = "boot", derive(boot_core::ExecuteFns))]
pub enum ExecuteMsg {
ExecOnModule { module_id: String, exec_msg: Binary },
UpdateModuleAddresses {
to_add: Option<Vec<(String, String)>>,
to_remove: Option<Vec<String>>,
},
InstallModule {
module: ModuleInfo,
init_msg: Option<Binary>,
},
RegisterModule { module_addr: String, module: Module },
UninstallModule { module_id: String },
Upgrade {
modules: Vec<(ModuleInfo, Option<Binary>)>,
},
UpdateInfo {
name: Option<String>,
description: Option<String>,
link: Option<String>,
},
SetOwner { owner: GovernanceDetails<String> },
UpdateStatus { is_suspended: Option<bool> },
UpdateSettings { ibc_enabled: Option<bool> },
Callback(CallbackMsg),
}
#[cosmwasm_schema::cw_serde]
#[derive(QueryResponses)]
#[cfg_attr(feature = "boot", derive(boot_core::QueryFns))]
pub enum QueryMsg {
#[returns(ModuleVersionsResponse)]
ModuleVersions { ids: Vec<String> },
#[returns(ModuleAddressesResponse)]
ModuleAddresses { ids: Vec<String> },
#[returns(ModuleInfosResponse)]
ModuleInfos {
start_after: Option<String>,
limit: Option<u8>,
},
#[returns(ConfigResponse)]
Config {},
#[returns(InfoResponse)]
Info {},
}
#[cosmwasm_schema::cw_serde]
pub struct ModuleVersionsResponse {
pub versions: Vec<ContractVersion>,
}
#[cosmwasm_schema::cw_serde]
pub struct ModuleAddressesResponse {
pub modules: Vec<(String, String)>,
}
#[cosmwasm_schema::cw_serde]
pub struct ConfigResponse {
pub account_id: Uint64,
pub owner: String,
pub is_suspended: SuspensionStatus,
pub version_control_address: String,
pub module_factory_address: String,
}
#[cosmwasm_schema::cw_serde]
pub struct InfoResponse {
pub info: AccountInfo<String>,
}
#[cosmwasm_schema::cw_serde]
pub struct ManagerModuleInfo {
pub id: String,
pub version: ContractVersion,
pub address: String,
}
#[cosmwasm_schema::cw_serde]
pub struct ModuleInfosResponse {
pub module_infos: Vec<ManagerModuleInfo>,
}