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

Clean code #3383

Merged
merged 7 commits into from
Jun 5, 2023
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 crates/chain-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description = """

[dependencies]
ibc-proto = { version = "0.31.0-alpha.2" }
ibc-relayer-types = { version = "0.24.0", path = "../relayer-types", features = ["std"] }
ibc-relayer-types = { version = "0.24.0", path = "../relayer-types" }
tendermint-rpc = { version = "0.32.0", features = ["http-client", "websocket-client"] }

async-trait = "0.1.67"
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ telemetry = ["ibc-relayer/telemetry", "ibc-telemetry"]
rest-server = ["ibc-relayer-rest"]

[dependencies]
ibc-relayer-types = { version = "0.24.0", path = "../relayer-types", features = ["std", "clock"] }
ibc-relayer-types = { version = "0.24.0", path = "../relayer-types" }
ibc-relayer = { version = "0.24.0", path = "../relayer" }
ibc-telemetry = { version = "0.24.0", path = "../telemetry", optional = true }
ibc-relayer-rest = { version = "0.24.0", path = "../relayer-rest", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/commands/config/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Runnable for AutoCmd {
.iter_mut()
.zip(names_and_keys.iter().map(|n| &n.1).cloned());

for (mut chain_config, key_option) in configs_and_keys {
for (chain_config, key_option) in configs_and_keys {
// If a key is provided, use it
if let Some(key_name) = key_option {
info!("{}: uses key \"{}\"", &chain_config.id, &key_name);
Expand Down
10 changes: 4 additions & 6 deletions crates/relayer-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ description = """
all-features = true

[features]
default = ["std"]
std = ["flex-error/std", "flex-error/eyre_tracer", "ibc-proto/std", "clock"]
clock = ["tendermint/clock", "time/std"]

clock = []
# This feature grants access to development-time mocking libraries, such as `MockContext` or `MockHeader`.
# Depends on the `testgen` suite for generating Tendermint light blocks.
mocks = ["tendermint-testgen", "clock", "std"]
mocks = ["tendermint-testgen", "clock"]

[dependencies]
# Proto definitions for all IBC-related interfaces, e.g., connections or channels.
ibc-proto = { version = "0.31.0-alpha.2", features = ["std"] }
ibc-proto = { version = "0.31.0-alpha.2" }
ics23 = { version = "0.10.1", features = ["std", "host-functions"] }
time = { version = ">=0.3.0, <0.3.21" }
serde_derive = { version = "1.0.104" }
Expand All @@ -48,6 +45,7 @@ num-rational = "0.4.1"

[dependencies.tendermint]
version = "0.32.0"
features = ["clock"]

[dependencies.tendermint-proto]
version = "0.32.0"
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-types/src/applications/ics29_fee/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use prost::EncodeError;
use crate::applications::transfer::error::Error as TransferError;
use crate::core::ics04_channel::error::Error as ChannelError;
use crate::core::ics24_host::error::ValidationError;
use crate::prelude::*;
use crate::signer::SignerError;

define_error! {
Expand Down
6 changes: 3 additions & 3 deletions crates/relayer-types/src/applications/ics29_fee/events.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use core::fmt::Display;
use core::str::FromStr;
use itertools::Itertools;
use serde_derive::{Deserialize, Serialize};
use std::fmt::Display;
use std::str::FromStr;
use tendermint::abci;

use super::error::Error;
use crate::applications::transfer::coin::RawCoin;
use crate::core::ics04_channel::packet::Sequence;
use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::events::IbcEventType;
use crate::prelude::*;

use crate::signer::Signer;

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ibc_proto::ibc::applications::fee::v1::{Fee as ProtoFee, MsgPayPacketFee};
use crate::applications::ics29_fee::error::Error;
use crate::applications::transfer::coin::RawCoin;
use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::prelude::*;

use crate::signer::Signer;
use crate::tx_msg::encode_message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::applications::ics29_fee::error::Error;
use crate::applications::transfer::coin::RawCoin;
use crate::core::ics04_channel::packet::Sequence;
use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::prelude::*;

use crate::signer::Signer;
use crate::tx_msg::encode_message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ibc_proto::ibc::applications::fee::v1::{MsgRegisterCounterpartyPayee, MsgReg

use crate::applications::ics29_fee::error::Error;
use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::prelude::*;

use crate::signer::Signer;
use crate::tx_msg::encode_message;

Expand Down
4 changes: 2 additions & 2 deletions crates/relayer-types/src/applications/ics29_fee/packet_fee.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use core::str::FromStr;
use ibc_proto::cosmos::base::v1beta1::Coin as ProtoCoin;
use ibc_proto::ibc::applications::fee::v1::{
Fee as ProtoFee, IdentifiedPacketFees as ProtoIdentifiedPacketFees, PacketFee as ProtoPacketFee,
};
use std::str::FromStr;

use super::error::Error;
use crate::applications::transfer::amount::Amount;
use crate::applications::transfer::coin::RawCoin;
use crate::core::ics04_channel::packet_id::PacketId;
use crate::prelude::*;

use crate::signer::Signer;

/// The core type that encodes the different fees that are redeemable by relayers for relaying
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-types/src/applications/ics31_icq/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::core::ics24_host::error::ValidationError as Ics24ValidationError;
use tendermint::error::Error as TendermintError;

use crate::prelude::*;
use flex_error::define_error;

define_error! {
Expand Down
5 changes: 2 additions & 3 deletions crates/relayer-types/src/applications/ics31_icq/events.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use alloc::collections::BTreeMap;
use core::str::FromStr;
use std::collections::BTreeMap;
use std::str::FromStr;

use serde::{Deserialize, Serialize};
use tendermint::{abci, block::Height};

use crate::core::ics24_host::identifier::{ChainId, ConnectionId};
use crate::events::IbcEvent;
use crate::prelude::*;

use super::error::Error;

Expand Down
4 changes: 0 additions & 4 deletions crates/relayer-types/src/applications/ics31_icq/response.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use alloc::string::{String, ToString};
use alloc::vec;
use alloc::vec::Vec;

use ibc_proto::google::protobuf::Any;
use ibc_proto::stride::interchainquery::v1::MsgSubmitQueryResponse;
use prost::Message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use core::fmt::{Display, Error as FmtError, Formatter};
use std::fmt::{Display, Error as FmtError, Formatter};

use serde::{Deserialize, Serialize};

use crate::prelude::*;

use super::error::Error;

/// A string constant included in error acknowledgements.
Expand Down
7 changes: 3 additions & 4 deletions crates/relayer-types/src/applications/transfer/amount.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use core::iter::Sum;
use core::ops::Add;
use core::str::FromStr;
use derive_more::{Display, From, Into};
use serde::{Deserialize, Serialize};
use std::iter::Sum;
use std::ops::Add;
use std::str::FromStr;

use super::error::Error;
use crate::bigint::U256;
use crate::prelude::*;

/// A type for representing token transfer amounts.
#[derive(
Expand Down
5 changes: 2 additions & 3 deletions crates/relayer-types/src/applications/transfer/coin.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use core::fmt::{Display, Error as FmtError, Formatter};
use core::str::{from_utf8, FromStr};
use ibc_proto::cosmos::base::v1beta1::Coin as ProtoCoin;
use safe_regex::regex;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Error as FmtError, Formatter};
use std::str::{from_utf8, FromStr};

use super::amount::Amount;
use super::denom::{BaseDenom, PrefixedDenom};
use super::error::Error;
use crate::prelude::*;
use crate::serializers::serde_string;

/// A `Coin` type with fully qualified `PrefixedDenom`.
Expand Down
5 changes: 2 additions & 3 deletions crates/relayer-types/src/applications/transfer/denom.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use core::fmt::{Display, Error as FmtError, Formatter};
use core::str::FromStr;
use std::fmt::{Display, Error as FmtError, Formatter};
use std::str::FromStr;

use derive_more::{Display, From};
use ibc_proto::ibc::applications::transfer::v1::DenomTrace as RawDenomTrace;
use serde::{Deserialize, Serialize};

use super::error::Error;
use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::prelude::*;
use crate::serializers::serde_string;

/// Base denomination type
Expand Down
7 changes: 3 additions & 4 deletions crates/relayer-types/src/applications/transfer/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use alloc::string::FromUtf8Error;
use core::convert::Infallible;
use core::str::Utf8Error;
use flex_error::{define_error, DisplayOnly, TraceError};
use ibc_proto::protobuf::Error as TendermintProtoError;
use std::convert::Infallible;
use std::str::Utf8Error;
use std::string::FromUtf8Error;
use subtle_encoding::Error as EncodingError;
use uint::FromDecStrErr;

Expand All @@ -11,7 +11,6 @@ use crate::core::ics04_channel::error as channel_error;
use crate::core::ics04_channel::version::Version;
use crate::core::ics24_host::error::ValidationError;
use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::prelude::*;
use crate::signer::SignerError;

define_error! {
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-types/src/applications/transfer/events.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::applications::transfer::acknowledgement::Acknowledgement;
use crate::applications::transfer::{Amount, PrefixedDenom, MODULE_ID_STR};
use crate::events::ModuleEvent;
use crate::prelude::*;

use crate::signer::Signer;

const EVENT_TYPE_PACKET: &str = "fungible_token_packet";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! This is the definition of a transfer messages that an application submits to a chain.

use crate::prelude::*;

use ibc_proto::cosmos::base::v1beta1::Coin;
use ibc_proto::google::protobuf::Any;
use ibc_proto::ibc::applications::transfer::v1::MsgTransfer as RawMsgTransfer;
Expand Down
6 changes: 3 additions & 3 deletions crates/relayer-types/src/applications/transfer/packet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use alloc::string::{String, ToString};
use core::convert::TryFrom;
use core::str::FromStr;
use std::convert::TryFrom;
use std::str::FromStr;
use std::string::{String, ToString};

use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketData as RawPacketData;
use serde::{Deserialize, Serialize};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::convert::{TryFrom, TryInto};
use core::time::Duration;
use std::convert::{TryFrom, TryInto};
use std::time::Duration;

use prost::Message;
use serde::{Deserialize, Serialize};
Expand All @@ -21,7 +21,6 @@ use crate::core::ics02_client::error::Error as Ics02Error;
use crate::core::ics02_client::trust_threshold::TrustThreshold;
use crate::core::ics23_commitment::specs::ProofSpecs;
use crate::core::ics24_host::identifier::ChainId;
use crate::prelude::*;
use crate::timestamp::{Timestamp, ZERO_DURATION};
use crate::Height;

Expand Down Expand Up @@ -368,7 +367,7 @@ impl From<ClientState> for Any {

#[cfg(test)]
mod tests {
use crate::prelude::*;

use crate::Height;
use core::time::Duration;
use test_log::test;
Expand Down Expand Up @@ -673,7 +672,6 @@ mod tests {

#[cfg(any(test, feature = "mocks"))]
pub mod test_util {
use crate::prelude::*;
use core::time::Duration;

use tendermint::block::Header;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::prelude::*;

use ibc_proto::google::protobuf::Any;
use ibc_proto::ibc::lightclients::tendermint::v1::ConsensusState as RawConsensusState;
use ibc_proto::protobuf::Protobuf;
Expand Down
2 changes: 0 additions & 2 deletions crates/relayer-types/src/clients/ics07_tendermint/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::prelude::*;

use flex_error::{define_error, TraceError};

use crate::core::ics02_client::error::Error as Ics02Error;
Expand Down
4 changes: 1 addition & 3 deletions crates/relayer-types/src/clients/ics07_tendermint/header.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use alloc::string::ToString;
use core::fmt::{Display, Error as FmtError, Formatter};
use std::fmt::{Display, Error as FmtError, Formatter};

use bytes::Buf;
use ibc_proto::google::protobuf::Any;
Expand Down Expand Up @@ -150,7 +149,6 @@ impl From<Header> for RawHeader {

#[cfg(any(test, feature = "mocks"))]
pub mod test_util {
use alloc::vec;

use subtle_encoding::hex;
use tendermint::block::signed_header::SignedHeader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::prelude::*;

use ibc_proto::ibc::lightclients::tendermint::v1::Misbehaviour as RawMisbehaviour;
use ibc_proto::protobuf::Protobuf;
use serde::{Deserialize, Serialize};
Expand Down
6 changes: 3 additions & 3 deletions crates/relayer-types/src/core/ics02_client/client_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::marker::{Send, Sync};
use core::time::Duration;
use std::marker::{Send, Sync};
use std::time::Duration;

use dyn_clone::DynClone;
use erased_serde::Serialize as ErasedSerialize;
Expand All @@ -10,7 +10,7 @@ use crate::core::ics02_client::client_type::ClientType;
use crate::core::ics02_client::error::Error;
use crate::core::ics24_host::identifier::ChainId;
use crate::dynamic_typing::AsAny;
use crate::prelude::*;

use crate::Height;

use super::consensus_state::ConsensusState;
Expand Down
3 changes: 1 addition & 2 deletions crates/relayer-types/src/core/ics02_client/client_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;
use core::fmt::{Display, Error as FmtError, Formatter};
use serde_derive::{Deserialize, Serialize};
use std::fmt::{Display, Error as FmtError, Formatter};

use super::error::Error;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::prelude::*;

use core::marker::{Send, Sync};
use std::marker::{Send, Sync};

use dyn_clone::DynClone;
use erased_serde::Serialize as ErasedSerialize;
Expand Down
2 changes: 0 additions & 2 deletions crates/relayer-types/src/core/ics02_client/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::prelude::*;

use flex_error::{define_error, TraceError};
use ibc_proto::protobuf::Error as TendermintProtoError;

Expand Down
3 changes: 1 addition & 2 deletions crates/relayer-types/src/core/ics02_client/events.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//! Types for the IBC events emitted from Tendermint Websocket by the client module.

use core::fmt::{Display, Error as FmtError, Formatter};
use serde_derive::{Deserialize, Serialize};
use std::fmt::{Display, Error as FmtError, Formatter};
use tendermint::abci;

use super::header::Header;
use crate::core::ics02_client::client_type::ClientType;
use crate::core::ics02_client::height::Height;
use crate::core::ics24_host::identifier::ClientId;
use crate::events::{IbcEvent, IbcEventType};
use crate::prelude::*;

/// The content of the `key` field for the attribute containing the client identifier.
pub const CLIENT_ID_ATTRIBUTE_KEY: &str = "client_id";
Expand Down
2 changes: 0 additions & 2 deletions crates/relayer-types/src/core/ics02_client/header.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::prelude::*;

use dyn_clone::DynClone;
use erased_serde::Serialize as ErasedSerialize;
use ibc_proto::google::protobuf::Any;
Expand Down
Loading