Skip to content

Commit

Permalink
feat: migrate core module under the ibc crate into ibc-core
Browse files Browse the repository at this point in the history
feat: migrate `core` module under the `ibc` crate into `ibc-core`

feat: migrate `applications` module under the `ibc` crate into `ibc-apps` (#967)

* feat: restructure and split off applications codebase into ibc-apps dir

* imp: rename transfer dir to ics20_transfer

* feat: add ibc-apps crate

* fix: remove redundant dep + fix cargo doc

* docs: add README and descriptions

* docs: update main README page

* nit: docstrings

* nit: docstrings

* imp: rename folder to ics20-transfer

* chore: move serializers into ics20-transfer/types

* fix: apply reviewer comments

* imp: add docstring for cosmos_adr028_escrow_address

* fix: add missing features + use workspace deps for ibc crates

* imp: place re-exports under mod

* nit: apply suggestions from code review

Co-authored-by: Sean Chen <seanchen11235@gmail.com>
Signed-off-by: Farhad Shabani <Farhad.Shabani@gmail.com>

* fix: cargo fmt

---------

Signed-off-by: Farhad Shabani <Farhad.Shabani@gmail.com>
Co-authored-by: Sean Chen <seanchen11235@gmail.com>

feat: restructure and split off applications codebase into ibc-apps dir

refactor: nits from nightly clippy (#962)

* use enum tuple variants directly

* use first() over get(0)

* use infallible conversion

* rm redundant export

* cargo fmt

ci: spell check on GitHub workflows (#964)

* typos github action

* cutom config for typos

* fix spelling to counterparty

* fix spelling to transfer

imp: rename transfer dir to ics20_transfer

feat: add ibc-apps crate

fix: remove redundant dep + fix cargo doc

docs: add README and descriptions

docs: update main README page

nit: docstrings

nit: docstrings

imp: rename folder to ics20-transfer

chore: move serializers into ics20-transfer/types

fix: apply reviewer comments

imp: add docstring for cosmos_adr028_escrow_address

fix: add missing features + use workspace deps for ibc crates

imp: place re-exports under mod

feat: ibc core codebase overhaul (part-1)

feat: ibc core codebase overhaul (part-2)

chore: comment out ibc-query & ibc-testkit

fix: add missing features

nit
  • Loading branch information
Farhad-Shabani committed Nov 17, 2023
1 parent 68b4ca6 commit 10c316d
Show file tree
Hide file tree
Showing 261 changed files with 4,469 additions and 3,007 deletions.
50 changes: 43 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
resolver = "2"
members = [
"crates/ibc",
"crates/ibc-data-types",
"crates/ibc-primitives",
"crates/ibc-core",
"crates/ibc-core/ics02-client",
"crates/ibc-core/ics02-client/types",
"crates/ibc-core/ics03-connection",
"crates/ibc-core/ics03-connection/types",
"crates/ibc-core/ics04-channel",
"crates/ibc-core/ics04-channel/types",
"crates/ibc-core/ics23-commitment/types",
"crates/ibc-core/ics24-host/types",
"crates/ibc-core/context",
"crates/ibc-core/extra",
"crates/ibc-core/context/types",
"crates/ibc-core/ics26-routing",
"crates/ibc-core/ics26-routing/types",
"crates/ibc-apps",
"crates/ibc-apps/ics20-transfer",
"crates/ibc-apps/ics20-transfer/types",
Expand Down Expand Up @@ -35,7 +51,7 @@ parking_lot = { version = "0.12.1", default-features = false }
primitive-types = { version = "0.12.2", default-features = false, features = ["serde_no_std"] }
prost = { version = "0.12", default-features = false }
rstest = "0.18.2"
schemars = { version = "0.8.15"}
schemars = { version = "0.8.15" }
sha2 = { version = "0.10.8", default-features = false }
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", default-features = false }
Expand All @@ -45,14 +61,34 @@ test-log = { version = "0.2.13", features = ["trace"] }
time = { version = ">=0.3.0, <0.3.31", default-features = false }
tracing = { version = "0.1.40", default-features = false }
tracing-subscriber = { version = "0.3.17", features = ["fmt", "env-filter", "json"] }
typed-builder = { version = "0.18.0"}
typed-builder = { version = "0.18.0" }

# ibc dependencies
ibc = { version = "0.47.0", path = "./crates/ibc", default-features = false }
ibc-testkit = { version = "0.47.0", path = "./crates/ibc-testkit", default-features = false}
ibc-app-transfer = { version = "0.47.0", path = "./crates/ibc-apps/ics20-transfer", default-features = false }
ibc-app-transfer-types = { version = "0.47.0", path = "./crates/ibc-apps/ics20-transfer/types", default-features = false }
ibc-derive = { version = "0.3.0", path = "./crates/ibc-derive" }
ibc = { version = "0.47.0", path = "./crates/ibc", default-features = false }
ibc-apps = { version = "0.47.0", path = "./crates/ibc-apps", default-features = false }
ibc-core = { version = "0.47.0", path = "./crates//ibc-core", default-features = false }
ibc-primitives = { version = "0.47.0", path = "./crates/ibc-primitives", default-features = false }
ibc-testkit = { version = "0.47.0", path = "./crates/ibc-testkit" }
ibc-derive = { version = "0.3.0", path = "./crates/ibc-derive" }

ibc-core-client = { version = "0.47.0", path = "./crates/ibc-core/ics02-client", default-features = false }
ibc-core-connection = { version = "0.47.0", path = "./crates/ibc-core/ics03-connection", default-features = false }
ibc-core-channel = { version = "0.47.0", path = "./crates/ibc-core/ics04-channel", default-features = false }
ibc-core-router = { version = "0.47.0", path = "./crates/ibc-core/ics26-routing", default-features = false }
ibc-core-context = { version = "0.47.0", path = "./crates/ibc-core/context", default-features = false }
ibc-core-extra = { version = "0.47.0", path = "./crates/ibc-core/extra", default-features = false }
ibc-app-transfer = { version = "0.47.0", path = "./crates/ibc-apps/ics20-transfer", default-features = false }

ibc-core-client-context = { version = "0.47.0", path = "./crates/ibc-core/ics02-client/context", default-features = false }
ibc-core-client-types = { version = "0.47.0", path = "./crates/ibc-core/ics02-client/types", default-features = false }
ibc-core-channel-types = { version = "0.47.0", path = "./crates/ibc-core/ics04-channel/types", default-features = false }
ibc-core-connection-types = { version = "0.47.0", path = "./crates/ibc-core/ics03-connection/types" }
ibc-core-commitment-types = { version = "0.47.0", path = "./crates/ibc-core/ics23-commitment/types", default-features = false }
ibc-core-host-types = { version = "0.47.0", path = "./crates/ibc-core/ics24-host/types", default-features = false }
ibc-core-router-types = { version = "0.47.0", path = "./crates/ibc-core/ics26-routing/types", default-features = false }
ibc-core-context-types = { version = "0.47.0", path = "./crates/ibc-core/context/types", default-features = false }
ibc-app-transfer-types = { version = "0.47.0", path = "./crates/ibc-apps/ics20-transfer/types", default-features = false }

ibc-proto = { version = "0.38.0", default-features = false }
ics23 = { version = "0.11", default-features = false }

Expand Down
12 changes: 6 additions & 6 deletions crates/ibc-apps/ics20-transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde_json = { workspace = true, optional = true }
sha2 = { workspace = true }

# ibc dependencies
ibc = { workspace = true }
ibc-core = { workspace = true }
ibc-app-transfer-types = { workspace = true }

[dev-dependencies]
Expand All @@ -32,26 +32,26 @@ subtle-encoding = { workspace = true }
default = ["std"]
std = [
"ibc-app-transfer-types/std",
"ibc/std",
"ibc-core/std",
"serde_json/std",
"sha2/std",
]
serde = [
"ibc-app-transfer-types/serde",
"ibc/serde",
"ibc-core/serde",
"serde_json"
]
schema = [
"ibc-app-transfer-types/schema",
"ibc/schema",
"ibc-core/schema",
"serde",
"std",
]
borsh = [
"ibc-app-transfer-types/borsh",
"ibc/borsh",
"ibc-core/borsh",
]
parity-scale-codec = [
"ibc-app-transfer-types/parity-scale-codec",
"ibc/parity-scale-codec",
"ibc-core/parity-scale-codec",
]
6 changes: 3 additions & 3 deletions crates/ibc-apps/ics20-transfer/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Defines the main context traits and IBC module callbacks

use ibc::core::ics24_host::identifier::{ChannelId, PortId};
use ibc::prelude::*;
use ibc::Signer;
use ibc_app_transfer_types::error::TokenTransferError;
use ibc_app_transfer_types::{PrefixedCoin, PrefixedDenom, VERSION};
use ibc_core::host::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
use ibc_core::primitives::Signer;
use sha2::{Digest, Sha256};

/// Methods required in token transfer validation, to be implemented by the host
Expand Down
3 changes: 1 addition & 2 deletions crates/ibc-apps/ics20-transfer/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
pub mod on_recv_packet;
pub mod send_transfer;

use ibc::core::ics04_channel::packet::Packet;
use ibc::prelude::*;
use ibc_app_transfer_types::error::TokenTransferError;
use ibc_app_transfer_types::is_sender_chain_source;
use ibc_app_transfer_types::packet::PacketData;
use ibc_core::channel::types::packet::Packet;

use crate::context::{TokenTransferExecutionContext, TokenTransferValidationContext};

Expand Down
6 changes: 3 additions & 3 deletions crates/ibc-apps/ics20-transfer/src/handler/on_recv_packet.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use ibc::core::ics04_channel::packet::Packet;
use ibc::core::router::ModuleExtras;
use ibc::prelude::*;
use ibc_app_transfer_types::error::TokenTransferError;
use ibc_app_transfer_types::events::DenomTraceEvent;
use ibc_app_transfer_types::packet::PacketData;
use ibc_app_transfer_types::{is_receiver_chain_source, TracePrefix};
use ibc_core::channel::types::packet::Packet;
use ibc_core::primitives::prelude::*;
use ibc_core::router::types::module::ModuleExtras;

use crate::context::TokenTransferExecutionContext;

Expand Down
13 changes: 7 additions & 6 deletions crates/ibc-apps/ics20-transfer/src/handler/send_transfer.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use ibc::core::events::{MessageEvent, ModuleEvent};
use ibc::core::ics04_channel::context::{SendPacketExecutionContext, SendPacketValidationContext};
use ibc::core::ics04_channel::handler::send_packet::{send_packet_execute, send_packet_validate};
use ibc::core::ics04_channel::packet::Packet;
use ibc::core::ics24_host::path::{ChannelEndPath, SeqSendPath};
use ibc::prelude::*;
use ibc_app_transfer_types::error::TokenTransferError;
use ibc_app_transfer_types::events::TransferEvent;
use ibc_app_transfer_types::msgs::transfer::MsgTransfer;
use ibc_app_transfer_types::{is_sender_chain_source, MODULE_ID_STR};
use ibc_core::channel::context::{SendPacketExecutionContext, SendPacketValidationContext};
use ibc_core::channel::handler::{send_packet_execute, send_packet_validate};
use ibc_core::channel::types::packet::Packet;
use ibc_core::context::types::events::MessageEvent;
use ibc_core::host::path::{ChannelEndPath, SeqSendPath};
use ibc_core::primitives::prelude::*;
use ibc_core::router::types::event::ModuleEvent;

use crate::context::{TokenTransferExecutionContext, TokenTransferValidationContext};

Expand Down
18 changes: 9 additions & 9 deletions crates/ibc-apps/ics20-transfer/src/module.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use ibc::core::ics04_channel::acknowledgement::{Acknowledgement, AcknowledgementStatus};
use ibc::core::ics04_channel::channel::{Counterparty, Order};
use ibc::core::ics04_channel::packet::Packet;
use ibc::core::ics04_channel::Version;
use ibc::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId};
use ibc::core::router::ModuleExtras;
use ibc::core::ContextError;
use ibc::prelude::*;
use ibc::Signer;
use ibc_app_transfer_types::error::TokenTransferError;
use ibc_app_transfer_types::events::{AckEvent, AckStatusEvent, RecvEvent, TimeoutEvent};
use ibc_app_transfer_types::packet::PacketData;
use ibc_app_transfer_types::{ack_success_b64, VERSION};
use ibc_core::channel::types::acknowledgement::{Acknowledgement, AcknowledgementStatus};
use ibc_core::channel::types::channel::{Counterparty, Order};
use ibc_core::channel::types::packet::Packet;
use ibc_core::channel::types::Version;
use ibc_core::context::types::error::ContextError;
use ibc_core::host::identifiers::{ChannelId, ConnectionId, PortId};
use ibc_core::primitives::prelude::*;
use ibc_core::primitives::Signer;
use ibc_core::router::types::module::ModuleExtras;

use crate::context::{TokenTransferExecutionContext, TokenTransferValidationContext};
use crate::handler::on_recv_packet::process_recv_packet_execute;
Expand Down
10 changes: 5 additions & 5 deletions crates/ibc-apps/ics20-transfer/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ serde_json = { workspace = true, optional = true}
uint = { version = "0.9", default-features = false }

# ibc dependencies
ibc = { workspace = true }
ibc-core = { workspace = true }
ibc-proto = { workspace = true }

## parity dependencies
Expand All @@ -49,7 +49,7 @@ std = [
"uint/std",
"primitive-types/std",
]
borsh = ["dep:borsh", "ibc/borsh", "ibc-proto/borsh"]
serde = ["dep:serde", "serde_json", "ibc/serde", "ibc-proto/serde"]
schema = ["dep:schemars", "ibc/schema", "ibc-proto/json-schema", "serde", "std"]
parity-scale-codec = ["dep:parity-scale-codec", "dep:scale-info", "ibc/parity-scale-codec", "ibc-proto/parity-scale-codec"]
borsh = ["dep:borsh", "ibc-core/borsh", "ibc-proto/borsh"]
serde = ["dep:serde", "serde_json", "ibc-core/serde", "ibc-proto/serde"]
schema = ["dep:schemars", "ibc-core/schema", "ibc-proto/json-schema", "serde", "std"]
parity-scale-codec = ["dep:parity-scale-codec", "dep:scale-info", "ibc-core/parity-scale-codec", "ibc-proto/parity-scale-codec"]
2 changes: 1 addition & 1 deletion crates/ibc-apps/ics20-transfer/types/src/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::ops::Deref;
use core::str::FromStr;

use derive_more::{Display, From, Into};
use ibc::prelude::*;
use ibc_core::primitives::prelude::*;
use primitive_types::U256;

use super::error::TokenTransferError;
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc-apps/ics20-transfer/types/src/coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use core::fmt::{Display, Error as FmtError, Formatter};
use core::str::FromStr;

use ibc::prelude::*;
use ibc_core::primitives::prelude::*;
use ibc_proto::cosmos::base::v1beta1::Coin as ProtoCoin;

use super::amount::Amount;
Expand Down
4 changes: 2 additions & 2 deletions crates/ibc-apps/ics20-transfer/types/src/denom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use core::fmt::{Display, Error as FmtError, Formatter};
use core::str::FromStr;

use derive_more::{Display, From};
use ibc::core::ics24_host::identifier::{ChannelId, PortId};
use ibc::prelude::*;
use ibc_core::host::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
use ibc_proto::ibc::applications::transfer::v1::DenomTrace as RawDenomTrace;

use super::error::TokenTransferError;
Expand Down
11 changes: 6 additions & 5 deletions crates/ibc-apps/ics20-transfer/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use core::convert::Infallible;
use core::str::Utf8Error;

use displaydoc::Display;
use ibc::core::ics04_channel::acknowledgement::StatusValue;
use ibc::core::ics04_channel::channel::Order;
use ibc::core::ics24_host::identifier::{ChannelId, IdentifierError, PortId};
use ibc::core::ContextError;
use ibc::prelude::*;
use ibc_core::channel::types::acknowledgement::StatusValue;
use ibc_core::channel::types::channel::Order;
use ibc_core::context::types::error::ContextError;
use ibc_core::host::error::IdentifierError;
use ibc_core::host::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
use uint::FromDecStrErr;

#[derive(Display, Debug)]
Expand Down
18 changes: 9 additions & 9 deletions crates/ibc-apps/ics20-transfer/types/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Defines all token transfer event types
use ibc::core::events::ModuleEvent;
use ibc::core::ics04_channel::acknowledgement::AcknowledgementStatus;
use ibc::prelude::*;
use ibc::Signer;
use ibc_core::channel::types::acknowledgement::AcknowledgementStatus;
use ibc_core::primitives::prelude::*;
use ibc_core::primitives::Signer;
use ibc_core::router::types::event::ModuleEvent;

use super::Memo;
use crate::{Amount, PrefixedDenom, MODULE_ID_STR};
Expand All @@ -22,7 +22,7 @@ pub enum Event {
Transfer(TransferEvent),
}

/// Event emitted in the `onRecvPacket` module callback to indicate that the
/// Event emitted by the `onRecvPacket` module callback to indicate the that the
/// `RecvPacket` message was processed
pub struct RecvEvent {
pub sender: Signer,
Expand Down Expand Up @@ -58,7 +58,7 @@ impl From<RecvEvent> for ModuleEvent {
}
}

/// Event emitted by the `onAcknowledgePacket` module callback
/// Event emitted in the `onAcknowledgePacket` module callback
pub struct AckEvent {
pub sender: Signer,
pub receiver: Signer,
Expand Down Expand Up @@ -93,7 +93,7 @@ impl From<AckEvent> for ModuleEvent {
}
}

/// Event emitted by the `onAcknowledgePacket` module callback to indicate
/// Event emitted in the `onAcknowledgePacket` module callback to indicate
/// whether the acknowledgement is a success or a failure
pub struct AckStatusEvent {
pub acknowledgement: AcknowledgementStatus,
Expand All @@ -114,7 +114,7 @@ impl From<AckStatusEvent> for ModuleEvent {
}
}

/// Event emitted by the `onTimeoutPacket` module callback
/// Event emitted in the `onTimeoutPacket` module callback
pub struct TimeoutEvent {
pub refund_receiver: Signer,
pub refund_denom: PrefixedDenom,
Expand Down Expand Up @@ -143,7 +143,7 @@ impl From<TimeoutEvent> for ModuleEvent {
}
}

/// Event emitted by the `onRecvPacket` module callback when new tokens are minted
/// Event emitted in the `onRecvPacket` module callback when new tokens are minted
pub struct DenomTraceEvent {
pub trace_hash: Option<String>,
pub denom: PrefixedDenom,
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc-apps/ics20-transfer/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub const VERSION: &str = "ics20-1";
/// equivalent to `base64::encode(0x01)`.
pub const ACK_SUCCESS_B64: &str = "AQ==";

use ibc::core::ics04_channel::acknowledgement::StatusValue;
use ibc_core::channel::types::acknowledgement::StatusValue;

/// Returns a successful acknowledgement status for the token transfer application.
pub fn ack_success_b64() -> StatusValue {
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc-apps/ics20-transfer/types/src/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::fmt::{
};
use core::str::FromStr;

use ibc::prelude::*;
use ibc_core::primitives::prelude::*;

/// Represents the token transfer memo
#[cfg_attr(
Expand Down
13 changes: 7 additions & 6 deletions crates/ibc-apps/ics20-transfer/types/src/msgs/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//! Defines the token transfer message type
use ibc::core::ics04_channel::error::PacketError;
use ibc::core::ics04_channel::timeout::TimeoutHeight;
use ibc::core::ics24_host::identifier::{ChannelId, PortId};
use ibc::core::timestamp::Timestamp;
use ibc::core::{ContextError, Msg};
use ibc::prelude::*;

use ibc_core::channel::types::error::PacketError;
use ibc_core::channel::types::timeout::TimeoutHeight;
use ibc_core::context::types::error::ContextError;
use ibc_core::host::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
use ibc_core::primitives::{Msg, Timestamp};
use ibc_proto::google::protobuf::Any;
use ibc_proto::ibc::applications::transfer::v1::MsgTransfer as RawMsgTransfer;
use ibc_proto::Protobuf;
Expand Down
4 changes: 2 additions & 2 deletions crates/ibc-apps/ics20-transfer/types/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use core::convert::TryFrom;
use core::str::FromStr;

use ibc::prelude::*;
use ibc::Signer;
use ibc_core::primitives::prelude::*;
use ibc_core::primitives::Signer;
use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketData as RawPacketData;

use super::error::TokenTransferError;
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc-apps/ics20-transfer/types/src/serializers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::fmt::Display;
use core::str::FromStr;

use ibc::prelude::*;
use ibc_core::primitives::prelude::*;
use serde::{de, Deserialize, Deserializer, Serializer};

// Note: This method serializes to a String instead of a str
Expand Down
Loading

0 comments on commit 10c316d

Please sign in to comment.