abstract_polytone_note/
msg.rs

1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::{CosmosMsg, Empty, QueryRequest, Uint64};
3
4use polytone::callbacks::CallbackRequest;
5
6#[cw_serde]
7pub struct InstantiateMsg {
8    /// This contract pairs with the first voice module that a relayer
9    /// connects it with, or the pair specified here. Once it has a
10    /// pair, it will never handshake with a different voice module,
11    /// even after channel closure. This ensures that there will only
12    /// ever be one voice for every note.
13    pub pair: Option<Pair>,
14
15    /// The max gas allowed in a transaction. When returning callbacks
16    /// the module will use this to calculate the amount of gas to
17    /// save for handling a callback error. This protects from
18    /// callbacks that run out of gas preventing ACKs or timeouts from
19    /// being returned.
20    ///
21    /// The contract admin can update with `MigrateMsg::WithUpdate`.
22    pub block_max_gas: Uint64,
23}
24
25#[cw_serde]
26#[derive(cw_orch::ExecuteFns)] // cw-orch automatic
27pub enum ExecuteMsg {
28    /// Performs the requested queries on the voice chain and returns
29    /// a callback of Vec<QuerierResult>, or ACK-FAIL if unmarshalling
30    /// any of the query requests fails.
31    #[cw_orch(fn_name("ibc_query"))]
32    Query {
33        msgs: Vec<QueryRequest<Empty>>,
34        callback: CallbackRequest,
35        timeout_seconds: Uint64,
36    },
37    /// Executes the requested messages on the voice chain on behalf
38    /// of the note chain sender. Message receivers can return data in
39    /// their callbacks by calling `set_data` on their `Response`
40    /// object. Optionally, returns a callback of `Vec<Callback>` where
41    /// index `i` corresponds to the callback for `msgs[i]`.
42    ///
43    /// Accounts are created on the voice chain after the first call
44    /// to execute by the local address. To create an account, but
45    /// perform no additional actions, pass an empty list to
46    /// `msgs`. Accounts are queryable via the `RemoteAddress {
47    /// local_address }` query after they have been created.
48    #[cw_orch(fn_name("ibc_execute"))]
49    Execute {
50        msgs: Vec<CosmosMsg<Empty>>,
51        callback: Option<CallbackRequest>,
52        timeout_seconds: Uint64,
53    },
54}
55
56#[cw_serde]
57#[derive(QueryResponses, cw_orch::QueryFns)] // cw-orch automatic
58pub enum QueryMsg {
59    /// This channel this note is currently connected to, or none if
60    /// no channel is connected.
61    #[returns(Option<String>)]
62    ActiveChannel,
63    /// The contract's corresponding voice on a remote chain.
64    #[returns(Option<Pair>)]
65    Pair,
66    /// Returns the remote address for the provided local address. If
67    /// no account exists, returns `None`. An account can be created
68    /// by calling `ExecuteMsg::Execute` with the sender being
69    /// `local_address`.
70    #[returns(Option<String>)]
71    RemoteAddress { local_address: String },
72    /// Currently set gas limit
73    #[returns(Uint64)]
74    BlockMaxGas,
75}
76
77/// This contract's voice. There is one voice per note, and many notes
78/// per voice.
79#[cw_serde]
80pub struct Pair {
81    pub connection_id: String,
82    pub remote_port: String,
83}
84
85#[cw_serde]
86pub enum MigrateMsg {
87    /// Updates the contract's configuration. To update the config
88    /// without updating the code, migrate to the same code ID.
89    WithUpdate { block_max_gas: Uint64 },
90}