Skip to content

Commit

Permalink
rm TimeoutOnClose
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Oct 28, 2024
1 parent 7c9b0ef commit 51f4c22
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 137 deletions.
2 changes: 0 additions & 2 deletions ibc-eureka-core/ics04-channel/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ mod acknowledgement;
mod recv_packet;
mod send_packet;
mod timeout;
mod timeout_on_close;

pub use acknowledgement::*;
pub use recv_packet::*;
pub use send_packet::*;
pub use timeout::*;
pub use timeout_on_close::*;
30 changes: 7 additions & 23 deletions ibc-eureka-core/ics04-channel/src/handler/timeout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ibc_eureka_core_channel_types::commitment::compute_packet_commitment;
use ibc_eureka_core_channel_types::error::ChannelError;
use ibc_eureka_core_channel_types::events::TimeoutPacket;
use ibc_eureka_core_channel_types::msgs::{MsgTimeout, MsgTimeoutOnClose};
use ibc_eureka_core_channel_types::msgs::MsgTimeout;
use ibc_eureka_core_client::context::prelude::*;
use ibc_eureka_core_handler_types::events::{IbcEvent, MessageEvent};
use ibc_eureka_core_host::types::path::{
Expand All @@ -11,46 +11,30 @@ use ibc_eureka_core_host::{ExecutionContext, ValidationContext};
use ibc_eureka_core_router::module::Module;
use ibc_primitives::prelude::*;

use super::timeout_on_close;

pub enum TimeoutMsgType {
Timeout(MsgTimeout),
TimeoutOnClose(MsgTimeoutOnClose),
}

pub fn timeout_packet_validate<ValCtx>(
ctx_a: &ValCtx,
module: &dyn Module,
timeout_msg_type: TimeoutMsgType,
msg: MsgTimeout,
) -> Result<(), ChannelError>
where
ValCtx: ValidationContext,
{
match &timeout_msg_type {
TimeoutMsgType::Timeout(msg) => validate(ctx_a, msg),
TimeoutMsgType::TimeoutOnClose(msg) => timeout_on_close::validate(ctx_a, msg),
}?;

let (packet, signer) = match timeout_msg_type {
TimeoutMsgType::Timeout(msg) => (msg.packet, msg.signer),
TimeoutMsgType::TimeoutOnClose(msg) => (msg.packet, msg.signer),
};
validate(ctx_a, &msg)?;

Check warning on line 22 in ibc-eureka-core/ics04-channel/src/handler/timeout.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/timeout.rs#L14-L22

Added lines #L14 - L22 were not covered by tests

let (packet, signer) = (msg.packet, msg.signer);

module.on_timeout_packet_validate(&packet, &signer)
}

Check warning on line 27 in ibc-eureka-core/ics04-channel/src/handler/timeout.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/src/handler/timeout.rs#L24-L27

Added lines #L24 - L27 were not covered by tests

pub fn timeout_packet_execute<ExecCtx>(
ctx_a: &mut ExecCtx,
module: &mut dyn Module,
timeout_msg_type: TimeoutMsgType,
msg: MsgTimeout,
) -> Result<(), ChannelError>
where
ExecCtx: ExecutionContext,
{
let (packet, signer) = match timeout_msg_type {
TimeoutMsgType::Timeout(msg) => (msg.packet, msg.signer),
TimeoutMsgType::TimeoutOnClose(msg) => (msg.packet, msg.signer),
};
let (packet, signer) = (msg.packet, msg.signer);

let payload = &packet.payloads[0];

Expand Down
90 changes: 0 additions & 90 deletions ibc-eureka-core/ics04-channel/src/handler/timeout_on_close.rs

This file was deleted.

2 changes: 0 additions & 2 deletions ibc-eureka-core/ics04-channel/types/src/msgs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ pub enum PacketMsg {
Recv(MsgRecvPacket),
Ack(MsgAcknowledgement),
Timeout(MsgTimeout),
TimeoutOnClose(MsgTimeoutOnClose),
}

pub fn packet_msg_to_port_id(msg: &PacketMsg) -> &PortId {
match msg {
PacketMsg::Recv(msg) => &msg.packet.payloads[0].header.target_port.1,
PacketMsg::Ack(msg) => &msg.packet.payloads[0].header.source_port.1,
PacketMsg::Timeout(msg) => &msg.packet.payloads[0].header.source_port.1,

Check warning on line 35 in ibc-eureka-core/ics04-channel/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/types/src/msgs/mod.rs#L31-L35

Added lines #L31 - L35 were not covered by tests
PacketMsg::TimeoutOnClose(msg) => &msg.packet.payloads[0].header.source_port.1,
}
}

Check warning on line 37 in ibc-eureka-core/ics04-channel/types/src/msgs/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics04-channel/types/src/msgs/mod.rs#L37

Added line #L37 was not covered by tests
16 changes: 3 additions & 13 deletions ibc-eureka-core/ics25-handler/src/entrypoint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ibc_eureka_core_channel::handler::{
acknowledgement_packet_execute, acknowledgement_packet_validate, recv_packet_execute,
recv_packet_validate, timeout_packet_execute, timeout_packet_validate, TimeoutMsgType,
recv_packet_validate, timeout_packet_execute, timeout_packet_validate,
};
use ibc_eureka_core_channel::types::msgs::{packet_msg_to_port_id, PacketMsg};
use ibc_eureka_core_client::context::{ClientExecutionContext, ClientValidationContext};
Expand Down Expand Up @@ -73,12 +73,7 @@ where
match msg {
PacketMsg::Recv(msg) => recv_packet_validate(ctx, msg)?,
PacketMsg::Ack(msg) => acknowledgement_packet_validate(ctx, module, msg)?,
PacketMsg::Timeout(msg) => {
timeout_packet_validate(ctx, module, TimeoutMsgType::Timeout(msg))?
}
PacketMsg::TimeoutOnClose(msg) => {
timeout_packet_validate(ctx, module, TimeoutMsgType::TimeoutOnClose(msg))?
}
PacketMsg::Timeout(msg) => timeout_packet_validate(ctx, module, msg)?,

Check warning on line 76 in ibc-eureka-core/ics25-handler/src/entrypoint.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics25-handler/src/entrypoint.rs#L73-L76

Added lines #L73 - L76 were not covered by tests
}
}
};
Expand Down Expand Up @@ -123,12 +118,7 @@ where
match msg {
PacketMsg::Recv(msg) => recv_packet_execute(ctx, module, msg)?,
PacketMsg::Ack(msg) => acknowledgement_packet_execute(ctx, module, msg)?,
PacketMsg::Timeout(msg) => {
timeout_packet_execute(ctx, module, TimeoutMsgType::Timeout(msg))?
}
PacketMsg::TimeoutOnClose(msg) => {
timeout_packet_execute(ctx, module, TimeoutMsgType::TimeoutOnClose(msg))?
}
PacketMsg::Timeout(msg) => timeout_packet_execute(ctx, module, msg)?,

Check warning on line 121 in ibc-eureka-core/ics25-handler/src/entrypoint.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics25-handler/src/entrypoint.rs#L118-L121

Added lines #L118 - L121 were not covered by tests
}
}
}
Expand Down
9 changes: 2 additions & 7 deletions ibc-eureka-core/ics25-handler/types/src/msgs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ibc_eureka_core_channel_types::msgs::{
MsgAcknowledgement, MsgRecvPacket, MsgTimeout, MsgTimeoutOnClose, PacketMsg,
ACKNOWLEDGEMENT_TYPE_URL, RECV_PACKET_TYPE_URL, TIMEOUT_ON_CLOSE_TYPE_URL, TIMEOUT_TYPE_URL,
MsgAcknowledgement, MsgRecvPacket, MsgTimeout, PacketMsg, ACKNOWLEDGEMENT_TYPE_URL,
RECV_PACKET_TYPE_URL, TIMEOUT_TYPE_URL,
};
#[allow(deprecated)]
use ibc_eureka_core_client_types::msgs::{
Expand Down Expand Up @@ -64,11 +64,6 @@ impl TryFrom<Any> for MsgEnvelope {
let domain_msg = MsgTimeout::decode_vec(&any_msg.value)?;
Ok(MsgEnvelope::Packet(PacketMsg::Timeout(domain_msg)))

Check warning on line 65 in ibc-eureka-core/ics25-handler/types/src/msgs.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics25-handler/types/src/msgs.rs#L63-L65

Added lines #L63 - L65 were not covered by tests
}
TIMEOUT_ON_CLOSE_TYPE_URL => {
let domain_msg = MsgTimeoutOnClose::decode_vec(&any_msg.value)?;
Ok(MsgEnvelope::Packet(PacketMsg::TimeoutOnClose(domain_msg)))
}

_ => Err(DecodingError::UnknownTypeUrl(any_msg.type_url))?,

Check warning on line 67 in ibc-eureka-core/ics25-handler/types/src/msgs.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics25-handler/types/src/msgs.rs#L67

Added line #L67 was not covered by tests
}
}

Check warning on line 69 in ibc-eureka-core/ics25-handler/types/src/msgs.rs

View check run for this annotation

Codecov / codecov/patch

ibc-eureka-core/ics25-handler/types/src/msgs.rs#L69

Added line #L69 was not covered by tests
Expand Down

0 comments on commit 51f4c22

Please sign in to comment.