1use crate::{
11 base::{
12 ExecuteMsg as MiddlewareExecMsg, InstantiateMsg as MiddlewareInstantiateMsg,
13 MigrateMsg as MiddlewareMigrateMsg, QueryMsg as MiddlewareQueryMsg,
14 },
15 ibc_client::CallbackInfo,
16 objects::core::OsId,
17};
18use cosmwasm_schema::QueryResponses;
19use cosmwasm_std::{Addr, Binary, CosmosMsg, Empty, QueryRequest};
20
21pub type ExecuteMsg<T, R = Empty> = MiddlewareExecMsg<BaseExecuteMsg, T, R>;
22pub type QueryMsg<T = Empty> = MiddlewareQueryMsg<BaseQueryMsg, T>;
23pub type InstantiateMsg<T = Empty> = MiddlewareInstantiateMsg<BaseInstantiateMsg, T>;
24pub type MigrateMsg<T = Empty> = MiddlewareMigrateMsg<BaseMigrateMsg, T>;
25
26#[cosmwasm_schema::cw_serde]
29pub struct BaseInstantiateMsg {
30 pub ans_host_address: String,
32 pub cw1_code_id: u64,
34}
35
36#[cosmwasm_schema::cw_serde]
37pub struct BaseMigrateMsg {}
38
39#[cosmwasm_schema::cw_serde]
40pub enum InternalAction {
41 Register { os_proxy_address: String },
42 WhoAmI,
43}
44
45#[cosmwasm_schema::cw_serde]
47pub enum HostAction {
48 App {
49 msg: Binary,
50 },
51 Dispatch {
52 msgs: Vec<CosmosMsg<Empty>>,
53 },
54 Query {
55 msgs: Vec<QueryRequest<Empty>>,
56 },
57 SendAllBack {},
58 Balances {},
59 Internal(InternalAction),
61}
62
63impl HostAction {
64 pub fn into_packet(
65 self,
66 os_id: OsId,
67 retries: u8,
68 client_chain: String,
69 callback_info: Option<CallbackInfo>,
70 ) -> PacketMsg {
71 PacketMsg {
72 client_chain,
73 retries,
74 callback_info,
75 os_id,
76 action: self,
77 }
78 }
79}
80#[cosmwasm_schema::cw_serde]
82pub struct PacketMsg {
83 pub client_chain: String,
85 pub retries: u8,
87 pub os_id: OsId,
88 pub callback_info: Option<CallbackInfo>,
90 pub action: HostAction,
92}
93
94#[cosmwasm_schema::cw_serde]
96pub enum BaseExecuteMsg {
97 UpdateAdmin { admin: String },
99 UpdateConfig {
100 ans_host_address: Option<String>,
101 cw1_code_id: Option<u64>,
102 },
103 RecoverAccount {
105 closed_channel: String,
106 os_id: OsId,
107 msgs: Vec<CosmosMsg>,
108 },
109}
110
111#[cosmwasm_schema::cw_serde]
113#[derive(QueryResponses)]
114pub enum BaseQueryMsg {
115 #[returns(HostConfigResponse)]
117 Config {},
118 #[returns(AccountResponse)]
121 Account { client_chain: String, os_id: OsId },
122 #[returns(ListAccountsResponse)]
125 ListAccounts {},
126}
127
128#[cosmwasm_schema::cw_serde]
129pub struct HostConfigResponse {
130 pub ans_host_address: Addr,
131}
132
133#[cosmwasm_schema::cw_serde]
134pub struct AccountResponse {
135 pub account: Option<String>,
136}
137
138#[cosmwasm_schema::cw_serde]
139pub struct ListAccountsResponse {
140 pub accounts: Vec<AccountInfo>,
141}
142
143#[cosmwasm_schema::cw_serde]
144pub struct AccountInfo {
145 pub os_id: OsId,
146 pub account: String,
147 pub channel_id: String,
148}