Skip to content

Commit

Permalink
Remove polytone dep (#501)
Browse files Browse the repository at this point in the history
* remove polytone dep

* format
  • Loading branch information
Buckram123 authored Sep 30, 2024
1 parent e590ce8 commit a58d5af
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/interchain/interchain-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cw-orch-daemon = { workspace = true, optional = true }
futures = "0.3.30"
ibc-relayer-types = { workspace = true }
log = { workspace = true }
polytone = "1.0.0"
# TODO: polytone = "2.0.0"
prost = "0.13.1"
serde_json = { workspace = true }
thiserror = { workspace = true }
Expand Down
58 changes: 57 additions & 1 deletion packages/interchain/interchain-core/src/ack_parser.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{from_json, Binary};
use cw_orch_core::environment::CwEnv;
use polytone::ack::Callback;
use prost::Message;
// TODO: when polytone updates to cosmwasm v2 use polytone::ack::Callback;
use polytone_callback::Callback;

use crate::{
env::decode_ack_error,
Expand Down Expand Up @@ -147,3 +148,58 @@ pub mod acknowledgement {
}
}
}

mod polytone_callback {
use super::*;

use cosmwasm_std::{SubMsgResponse, Uint64};

#[cw_serde]
pub struct ExecutionResponse {
/// The address on the remote chain that executed the messages.
pub executed_by: String,
/// Index `i` corresponds to the result of executing the `i`th
/// message.
pub result: Vec<SubMsgResponse>,
}

#[cw_serde]
pub struct ErrorResponse {
/// The index of the first message who's execution failed.
pub message_index: Uint64,
/// The error that occured executing the message.
pub error: String,
}

/// Copy of the [polytone::ack::Callback](https://docs.rs/polytone/1.0.0/polytone/ack/index.html#reexport.Callback)
/// But without cosmwasm v1 dependencies
#[cw_serde]
pub enum Callback {
/// Result of executing the requested query, or an error.
///
/// result[i] corresponds to the i'th query and contains the
/// base64 encoded query response.
Query(Result<Vec<Binary>, ErrorResponse>),

/// Result of executing the requested messages, or an error.
///
/// 14/04/23: if a submessage errors the reply handler can see
/// `codespace: wasm, code: 5`, but not the actual error. as a
/// result, we can't return good errors for Execution and this
/// error string will only tell you the error's codespace. for
/// example, an out-of-gas error is code 11 and looks like
/// `codespace: sdk, code: 11`.
Execute(Result<ExecutionResponse, String>),

/// An error occured that could not be recovered from. The only
/// known way that this can occur is message handling running out
/// of gas, in which case the error will be `codespace: sdk, code:
/// 11`.
///
/// This error is not named becuase it could also occur due to a
/// panic or unhandled error during message processing. We don't
/// expect this to happen and have carefully written the code to
/// avoid it.
FatalError(String),
}
}

0 comments on commit a58d5af

Please sign in to comment.