Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Sep 13, 2023
1 parent 4f6d59c commit 0217951
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 29 deletions.
1 change: 0 additions & 1 deletion crates/relayer-cli/src/cli_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use ibc_relayer::{
config::Config,
spawn,
};
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId};

use crate::error::Error;
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/create/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use ibc_relayer::chain::requests::{
use ibc_relayer::channel::Channel;
use ibc_relayer::connection::Connection;
use ibc_relayer::foreign_client::ForeignClient;
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics03_connection::connection::IdentifiedConnectionEnd;
use ibc_relayer_types::core::ics04_channel::channel::Ordering;
use ibc_relayer_types::core::ics04_channel::version::Version;
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/create/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use ibc_relayer::chain::handle::ChainHandle;
use ibc_relayer::chain::requests::{IncludeProof, QueryClientStateRequest, QueryHeight};
use ibc_relayer::connection::Connection;
use ibc_relayer::foreign_client::ForeignClient;
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};

use crate::cli_utils::{spawn_chain_runtime, ChainHandlePair};
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/query/channel_ends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use ibc_relayer::chain::requests::{
};
use ibc_relayer::client_state::AnyClientState;
use ibc_relayer::registry::Registry;
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd;
use ibc_relayer_types::core::ics04_channel::channel::{ChannelEnd, State};
use ibc_relayer_types::core::ics24_host::identifier::ChainId;
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/query/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use ibc_relayer::chain::requests::{
QueryConnectionRequest, QueryHeight,
};
use ibc_relayer::registry::Registry;
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics04_channel::channel::{ChannelEnd, State};
use ibc_relayer_types::core::ics24_host::identifier::{
ChainId, ChannelId, ConnectionId, PortChannelId, PortId,
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/query/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use ibc_relayer::chain::handle::ChainHandle;
use serde::Serialize;

use ibc_relayer::chain::requests::{PageRequest, QueryClientStatesRequest};
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};

use crate::cli_utils::spawn_chain_runtime;
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/query/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use ibc_relayer::chain::handle::ChainHandle;
use ibc_relayer::chain::requests::{
IncludeProof, PageRequest, QueryClientStateRequest, QueryConnectionsRequest, QueryHeight,
};
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ConnectionId};

use crate::cli_utils::spawn_chain_runtime;
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/tx/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use ibc_relayer::config::Config;
use ibc_relayer::event::IbcEventWithHeight;
use ibc_relayer::foreign_client::{CreateOptions, ForeignClient};
use ibc_relayer::{chain::handle::ChainHandle, config::GenesisRestart};
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};
use ibc_relayer_types::events::IbcEvent;
use ibc_relayer_types::Height;
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/chain/counterparty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::collections::HashSet;

use ibc_relayer_types::{
core::{
ics02_client::client_state::ClientState,
ics03_connection::connection::{
ConnectionEnd, IdentifiedConnectionEnd, State as ConnectionState,
},
Expand Down
29 changes: 13 additions & 16 deletions crates/relayer/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ impl AnyClientState {
AnyClientState::Mock(mock_state) => mock_state.refresh_time(),
}
}

pub fn expired(&self, elapsed_since_latest: Duration) -> bool {
match self {
AnyClientState::Tendermint(tm_state) => tm_state.expired(elapsed_since_latest),
AnyClientState::LocalhostV1(local_state) => local_state.expired(elapsed_since_latest),
AnyClientState::LocalhostV2(local_state) => local_state.expired(elapsed_since_latest),

#[cfg(test)]
AnyClientState::Mock(mock_state) => mock_state.expired(elapsed_since_latest),
}
}
}

impl Protobuf<Any> for AnyClientState {}
Expand Down Expand Up @@ -187,14 +198,7 @@ impl From<AnyClientState> for Any {

impl ClientState for AnyClientState {
fn chain_id(&self) -> ChainId {
match self {
AnyClientState::Tendermint(state) => state.chain_id(),
AnyClientState::LocalhostV1(state) => state.chain_id(),
AnyClientState::LocalhostV2(state) => state.chain_id(),

#[cfg(test)]
AnyClientState::Mock(state) => state.chain_id(),
}
self.chain_id()
}

fn client_type(&self) -> ClientType {
Expand All @@ -210,14 +214,7 @@ impl ClientState for AnyClientState {
}

fn expired(&self, elapsed_since_latest: Duration) -> bool {
match self {
AnyClientState::Tendermint(tm_state) => tm_state.expired(elapsed_since_latest),
AnyClientState::LocalhostV1(local_state) => local_state.expired(elapsed_since_latest),
AnyClientState::LocalhostV2(local_state) => local_state.expired(elapsed_since_latest),

#[cfg(test)]
AnyClientState::Mock(mock_state) => mock_state.expired(elapsed_since_latest),
}
self.expired(elapsed_since_latest)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};

use ibc_relayer_types::applications::ics29_fee::events::IncentivizedPacket;
use ibc_relayer_types::core::{
ics02_client::{client_state::ClientState, events::UpdateClient},
ics02_client::events::UpdateClient,
ics03_connection::events::Attributes as ConnectionAttributes,
ics04_channel::events::{
Attributes, CloseInit, SendPacket, TimeoutPacket, WriteAcknowledgement,
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/supervisor/client_state_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use flex_error::define_error;
use ibc_relayer_types::core::ics02_client::trust_threshold::TrustThreshold;
use tracing::{debug, trace};

use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd;
use ibc_relayer_types::core::ics04_channel::error::Error as ChannelError;
use ibc_relayer_types::core::ics24_host::identifier::{
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/supervisor/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use itertools::Itertools;
use tracing::{debug, error, error_span, info, warn};

use ibc_relayer_types::core::{
ics02_client::client_state::ClientState,
ics03_connection::connection::{IdentifiedConnectionEnd, State as ConnectionState},
ics04_channel::{
channel::{IdentifiedChannelEnd, State as ChannelState},
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/supervisor/spawn.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use tracing::{error, info};

use ibc_relayer_types::core::{
ics02_client::client_state::ClientState, ics03_connection::connection::IdentifiedConnectionEnd,
ics03_connection::connection::IdentifiedConnectionEnd,
ics04_channel::channel::State as ChannelState,
};

Expand Down

0 comments on commit 0217951

Please sign in to comment.