abstract_std/native/ibc/
polytone_callbacks.rs

1//! Copy of [polytone::callbacks](https://docs.rs/polytone/1.0.0/polytone/callbacks/index.html) types used inside abstract
2
3use super::*;
4
5use cosmwasm_std::{Addr, SubMsgResponse, Uint64};
6
7#[cw_serde]
8pub enum Callback {
9    /// Result of executing the requested query, or an error.
10    ///
11    /// result[i] corresponds to the i'th query and contains the
12    /// base64 encoded query response.
13    Query(Result<Vec<Binary>, ErrorResponse>),
14
15    /// Result of executing the requested messages, or an error.
16    ///
17    /// 14/04/23: if a submessage errors the reply handler can see
18    /// `codespace: wasm, code: 5`, but not the actual error. as a
19    /// result, we can't return good errors for Execution and this
20    /// error string will only tell you the error's codespace. for
21    /// example, an out-of-gas error is code 11 and looks like
22    /// `codespace: sdk, code: 11`.
23    Execute(Result<ExecutionResponse, String>),
24
25    /// An error occured that could not be recovered from. The only
26    /// known way that this can occur is message handling running out
27    /// of gas, in which case the error will be `codespace: sdk, code:
28    /// 11`.
29    ///
30    /// This error is not named becuase it could also occur due to a
31    /// panic or unhandled error during message processing. We don't
32    /// expect this to happen and have carefully written the code to
33    /// avoid it.
34    FatalError(String),
35}
36
37#[cw_serde]
38pub struct ErrorResponse {
39    /// The index of the first message who's execution failed.
40    pub message_index: Uint64,
41    /// The error that occured executing the message.
42    pub error: String,
43}
44
45#[cw_serde]
46pub struct ExecutionResponse {
47    /// The address on the remote chain that executed the messages.
48    pub executed_by: String,
49    /// Index `i` corresponds to the result of executing the `i`th
50    /// message.
51    pub result: Vec<SubMsgResponse>,
52}
53
54/// A request for a callback.
55#[cw_serde]
56pub struct CallbackRequest {
57    pub receiver: String,
58    pub msg: Binary,
59}
60
61/// Executed on the callback receiver upon message completion. When
62/// being executed, the message will be tagged with "callback":
63///
64/// ```json
65/// {"callback": {
66///       "initiator": ...,
67///       "initiator_msg": ...,
68///       "result": ...,
69/// }}
70/// ```
71#[cw_serde]
72pub struct CallbackMessage {
73    /// Initaitor on the note chain.
74    pub initiator: Addr,
75    /// Message sent by the initaitor. This _must_ be base64 encoded
76    /// or execution will fail.
77    pub initiator_msg: Binary,
78    /// Data from the host chain.
79    pub result: Callback,
80}