evm_note/msg.rs
1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::Uint64;
3
4pub use polytone_evm::{callbacks::CallbackRequest, erc20::Erc20Token, evm::EvmMsg};
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 // #[cfg_attr(feature = "interface", 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<EvmMsg<String>>,
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 // TODO: remove for prod
76 /// Returns the stored ack info for debugging purposes.
77 #[returns(AckInfosResponse)]
78 AckInfos {
79 start_after: Option<u64>,
80 limit: Option<u8>,
81 },
82}
83
84/// This contract's voice. There is one voice per note, and many notes
85/// per voice.
86#[cw_serde]
87pub struct Pair {
88 pub connection_id: String,
89 pub remote_port: String,
90}
91
92#[cw_serde]
93pub enum MigrateMsg {
94 /// Updates the contract's configuration. To update the config
95 /// without updating the code, migrate to the same code ID.
96 WithUpdate {
97 block_max_gas: Uint64,
98 },
99 None,
100}
101
102#[cw_serde]
103pub struct AckInfosResponse {
104 pub acks: Vec<(u64, crate::ibc::temp_test::AckInfo)>,
105}