Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove polytone dep #501

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
}
}

mod polytone_callback {
use super::*;

use cosmwasm_std::{SubMsgResponse, Uint64};

#[cw_serde]

Check warning on line 157 in packages/interchain/interchain-core/src/ack_parser.rs

View check run for this annotation

Codecov / codecov/patch

packages/interchain/interchain-core/src/ack_parser.rs#L157

Added line #L157 was not covered by tests
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]

Check warning on line 166 in packages/interchain/interchain-core/src/ack_parser.rs

View check run for this annotation

Codecov / codecov/patch

packages/interchain/interchain-core/src/ack_parser.rs#L166

Added line #L166 was not covered by tests
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),
}
}
Loading