andromeda_std/os/
kernel.rs

1use crate::ado_base::ownership::OwnershipMessage;
2use crate::amp::messages::AMPMsg;
3use crate::amp::messages::AMPPkt;
4use crate::amp::AndrAddr;
5use cosmwasm_schema::{cw_serde, QueryResponses};
6use cosmwasm_std::Addr;
7use cosmwasm_std::Binary;
8
9#[cw_serde]
10pub struct ChannelInfo {
11    pub kernel_address: String,
12    pub ics20_channel_id: Option<String>,
13    pub direct_channel_id: Option<String>,
14    pub supported_modules: Vec<String>,
15}
16
17impl Default for ChannelInfo {
18    fn default() -> Self {
19        ChannelInfo {
20            kernel_address: "".to_string(),
21            ics20_channel_id: None,
22            direct_channel_id: None,
23            supported_modules: vec![],
24        }
25    }
26}
27
28#[cw_serde]
29pub struct InstantiateMsg {
30    pub owner: Option<String>,
31    pub chain_name: String,
32}
33
34#[cw_serde]
35pub enum ExecuteMsg {
36    /// Receives an AMP Packet for relaying
37    #[serde(rename = "amp_receive")]
38    AMPReceive(AMPPkt),
39    /// Constructs an AMPPkt with a given AMPMsg and sends it to the recipient
40    Send {
41        message: AMPMsg,
42    },
43    /// Upserts a key address to the kernel, restricted to the owner of the kernel
44    UpsertKeyAddress {
45        key: String,
46        value: String,
47    },
48    /// Creates an ADO with the given type and message
49    Create {
50        ado_type: String,
51        msg: Binary,
52        owner: Option<AndrAddr>,
53        chain: Option<String>,
54    },
55    /// Assigns a given channel to the given chain
56    AssignChannels {
57        ics20_channel_id: Option<String>,
58        direct_channel_id: Option<String>,
59        chain: String,
60        kernel_address: String,
61    },
62    /// Recovers funds from failed IBC messages
63    Recover {},
64    /// Update Current Chain
65    UpdateChainName {
66        chain_name: String,
67    },
68    // Only accessible to key contracts
69    Internal(InternalMsg),
70    // Base message
71    Ownership(OwnershipMessage),
72}
73
74#[cw_serde]
75pub enum InternalMsg {
76    // Restricted to VFS
77    RegisterUserCrossChain {
78        username: String,
79        address: String,
80        chain: String,
81    },
82}
83
84#[cw_serde]
85pub struct ChannelInfoResponse {
86    pub ics20: Option<String>,
87    pub direct: Option<String>,
88    pub kernel_address: String,
89    pub supported_modules: Vec<String>,
90}
91
92#[cw_serde]
93pub struct ChainNameResponse {
94    pub chain_name: String,
95}
96
97#[cw_serde]
98#[derive(QueryResponses)]
99pub enum QueryMsg {
100    #[returns(cosmwasm_std::Addr)]
101    KeyAddress { key: String },
102    #[returns(bool)]
103    VerifyAddress { address: String },
104    #[returns(Option<ChannelInfoResponse>)]
105    ChannelInfo { chain: String },
106    #[returns(Vec<::cosmwasm_std::Coin>)]
107    Recoveries { addr: Addr },
108    #[returns(ChainNameResponse)]
109    ChainName {},
110    // Base queries
111    #[returns(crate::ado_base::version::VersionResponse)]
112    Version {},
113    #[returns(crate::ado_base::ado_type::TypeResponse)]
114    Type {},
115    #[returns(crate::ado_base::ownership::ContractOwnerResponse)]
116    Owner {},
117}
118
119#[cw_serde]
120pub enum IbcExecuteMsg {
121    SendMessage {
122        recipient: AndrAddr,
123        message: Binary,
124    },
125    CreateADO {
126        instantiation_msg: Binary,
127        owner: AndrAddr,
128        ado_type: String,
129    },
130    RegisterUsername {
131        username: String,
132        address: String,
133    },
134}