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]
26pub enum ExecuteMsg {
27 /// Performs the requested queries on the voice chain and returns
28 /// a callback of Vec<QuerierResult>, or ACK-FAIL if unmarshalling
29 /// any of the query requests fails.
30 Query {
31 msgs: Vec<QueryRequest<Empty>>,
32 callback: CallbackRequest,
33 timeout_seconds: Uint64,
34 },
35 /// Executes the requested messages on the voice chain on behalf
36 /// of the note chain sender. Message receivers can return data in
37 /// their callbacks by calling `set_data` on their `Response`
38 /// object. Optionally, returns a callback of `Vec<Callback>` where
39 /// index `i` corresponds to the callback for `msgs[i]`.
40 ///
41 /// Accounts are created on the voice chain after the first call
42 /// to execute by the local address. To create an account, but
43 /// perform no additional actions, pass an empty list to
44 /// `msgs`. Accounts are queryable via the `RemoteAddress {
45 /// local_address }` query after they have been created.
46 Execute {
47 msgs: Vec<CosmosMsg<Empty>>,
48 callback: Option<CallbackRequest>,
49 timeout_seconds: Uint64,
50 },
51}
52
53#[cw_serde]
54#[derive(QueryResponses)]
55pub enum QueryMsg {
56 /// This channel this note is currently connected to, or none if
57 /// no channel is connected.
58 #[returns(Option<String>)]
59 ActiveChannel,
60 /// The contract's corresponding voice on a remote chain.
61 #[returns(Option<Pair>)]
62 Pair,
63 /// Returns the remote address for the provided local address. If
64 /// no account exists, returns `None`. An account can be created
65 /// by calling `ExecuteMsg::Execute` with the sender being
66 /// `local_address`.
67 #[returns(Option<String>)]
68 RemoteAddress { local_address: String },
69 /// Currently set gas limit
70 #[returns(Uint64)]
71 BlockMaxGas,
72}
73
74/// This contract's voice. There is one voice per note, and many notes
75/// per voice.
76#[cw_serde]
77pub struct Pair {
78 pub connection_id: String,
79 pub remote_port: String,
80}
81
82#[cw_serde]
83pub enum MigrateMsg {
84 /// Updates the contract's configuration. To update the config
85 /// without updating the code, migrate to the same code ID.
86 WithUpdate { block_max_gas: Uint64 },
87}