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

Update CGP crates to use new delegate_components! and define_components! proc macros #379

Merged
merged 6 commits into from
Jul 2, 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
44 changes: 35 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ tendermint-testgen = { version = "0.37" }
basecoin = { version = "0.1.0" }
cgp-core = { version = "0.1.0" }
cgp-error-eyre = { version = "0.1.0" }
cgp-component-macro = { version = "0.1.0" }
clap = { version = "4.5.3" }
oneline-eyre = { version = "0.1.0" }
prost = { version = "0.12.3" }
Expand Down Expand Up @@ -152,15 +153,16 @@ ibc-derive = { git = "https://github.com/cosmos/ibc-rs.git", re
basecoin = { git = "https://github.com/informalsystems/basecoin-rs.git", rev = "65c00d3" }
tower-abci = { git = "https://github.com/informalsystems/tower-abci", rev = "37d952e" }

cgp-core = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-component = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-component-macro = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-error = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-error-eyre = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-async = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-async-macro = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-run = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-inner = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-core = { git = "https://github.com/informalsystems/cgp.git" }
cgp-component = { git = "https://github.com/informalsystems/cgp.git" }
cgp-component-macro = { git = "https://github.com/informalsystems/cgp.git" }
cgp-component-macro-lib = { git = "https://github.com/informalsystems/cgp.git" }
cgp-error = { git = "https://github.com/informalsystems/cgp.git" }
cgp-error-eyre = { git = "https://github.com/informalsystems/cgp.git" }
cgp-async = { git = "https://github.com/informalsystems/cgp.git" }
cgp-async-macro = { git = "https://github.com/informalsystems/cgp.git" }
cgp-run = { git = "https://github.com/informalsystems/cgp.git" }
cgp-inner = { git = "https://github.com/informalsystems/cgp.git" }

ibc-relayer = { git = "https://github.com/informalsystems/hermes.git", rev = "ddc0dd8" }
ibc-telemetry = { git = "https://github.com/informalsystems/hermes.git", rev = "ddc0dd8" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use std::sync::OnceLock;

use cgp_core::prelude::*;
use cgp_core::{delegate_all, ErrorRaiserComponent, ErrorTypeComponent};
use cgp_core::{ErrorRaiserComponent, ErrorTypeComponent};
use cgp_error_eyre::{ProvideEyreError, RaiseDebugError};
use eyre::Error;
use hermes_celestia_test_components::bootstrap::components::CelestiaBootstrapComponents as BaseCelestiaBootstrapComponents;
Expand All @@ -28,10 +28,7 @@ use hermes_cosmos_integration_tests::traits::bootstrap::cosmos_builder::CosmosBu
use hermes_cosmos_integration_tests::traits::bootstrap::gas_denom::GasDenomGetter;
use hermes_cosmos_integration_tests::traits::bootstrap::relayer_chain_config::RelayerChainConfigBuilderComponent;
use hermes_cosmos_relayer::contexts::builder::CosmosBuilder;
use hermes_cosmos_test_components::bootstrap::components::cosmos_sdk_legacy::{
CanUseLegacyCosmosSdkChainBootstrapper, IsLegacyCosmosSdkBootstrapComponent,
LegacyCosmosSdkBootstrapComponents,
};
use hermes_cosmos_test_components::bootstrap::components::cosmos_sdk_legacy::*;
use hermes_cosmos_test_components::bootstrap::traits::chain::build_chain_driver::ChainDriverBuilderComponent;
use hermes_cosmos_test_components::bootstrap::traits::fields::account_prefix::AccountPrefixGetter;
use hermes_cosmos_test_components::bootstrap::traits::fields::chain_command_path::ChainCommandPathGetter;
Expand Down Expand Up @@ -68,11 +65,13 @@ impl HasComponents for CelestiaBootstrap {
type Components = CelestiaBootstrapComponents;
}

delegate_all!(
IsLegacyCosmosSdkBootstrapComponent,
LegacyCosmosSdkBootstrapComponents,
CelestiaBootstrapComponents,
);
with_legacy_cosmos_sdk_bootstrap_components! {
delegate_components! {
CelestiaBootstrapComponents {
@LegacyCosmosSdkBootstrapComponents: LegacyCosmosSdkBootstrapComponents,
}
}
}

delegate_components! {
CelestiaBootstrapComponents {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ use crate::bootstrap::traits::init_bridge_data::BridgeDataInitializerComponent;
use crate::bootstrap::traits::start_bridge::BridgeStarterComponent;
use crate::bootstrap::traits::types::bridge_config::BridgeConfigTypeComponent;

pub struct CelestiaBootstrapComponents;

delegate_components! {
#[mark_component(IsCelestiaBootstrapComponent)]
define_components! {
CelestiaBootstrapComponents {
BridgeDataInitializerComponent:
InitCelestiaBridgeData,
Expand Down
2 changes: 0 additions & 2 deletions crates/cli/cli-framework/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![recursion_limit = "256"]

use hermes_cosmos_relayer::types::error::Error;

pub mod application;
Expand Down
2 changes: 0 additions & 2 deletions crates/cli/cli/bin/hermes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![recursion_limit = "256"]

use hermes_cli::application::HermesCli;
use hermes_cli_framework::application::boot;

Expand Down
1 change: 1 addition & 0 deletions crates/cosmos/cosmos-chain-components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description = """

[dependencies]
cgp-core = { workspace = true }
cgp-component-macro = { workspace = true }
hermes-runtime = { workspace = true }
hermes-relayer-components = { workspace = true }
hermes-relayer-components-extra = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cgp_core::prelude::delegate_components;
use cgp_core::prelude::*;
use hermes_relayer_components::chain::impls::delegate::message_builders::channel_handshake::DelegateBuildChannelHandshakeMessage;
use hermes_relayer_components::chain::impls::delegate::message_builders::connection_handshake::DelegateBuildConnectionHandshakeMessage;
use hermes_relayer_components::chain::impls::delegate::message_builders::create_client::DelegateBuildCreateClientMessage;
Expand Down Expand Up @@ -176,10 +176,7 @@ use crate::impls::types::create_client_options::ProvideCosmosCreateClientSetting
use crate::impls::types::payload::ProvideCosmosPayloadTypes;
use crate::traits::abci_query::AbciQuerierComponent;

pub struct CosmosClientComponents;

delegate_components! {
#[mark_component(IsCosmosClientComponents)]
define_components! {
CosmosClientComponents {
[
HeightTypeComponent,
Expand Down
54 changes: 21 additions & 33 deletions crates/cosmos/cosmos-chain-components/src/components/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
use cgp_core::prelude::*;
use hermes_relayer_components::chain::traits::send_message::MessageSenderComponent;
use hermes_relayer_components::chain::traits::types::chain_id::ChainIdTypeComponent;
use hermes_relayer_components::chain::traits::types::event::EventTypeComponent;
use hermes_relayer_components::chain::traits::types::message::MessageTypeComponent;
use hermes_relayer_components::components::default::transaction::DefaultTxComponents;
use hermes_relayer_components::transaction::impls::poll_tx_response::PollTimeoutGetterComponent;
use hermes_relayer_components::transaction::traits::encode_tx::TxEncoderComponent;
use hermes_relayer_components::transaction::traits::estimate_tx_fee::TxFeeEstimatorComponent;
use hermes_relayer_components::transaction::traits::nonce::allocate_nonce::NonceAllocatorComponent;
use hermes_relayer_components::transaction::traits::nonce::nonce_guard::NonceGuardComponent;
use hermes_relayer_components::transaction::traits::nonce::query_nonce::NonceQuerierComponent;
use hermes_relayer_components::transaction::traits::parse_events::TxResponseAsEventsParserComponent;
use hermes_relayer_components::transaction::traits::poll_tx_response::TxResponsePollerComponent;
use hermes_relayer_components::transaction::traits::query_tx_response::TxResponseQuerierComponent;
use hermes_relayer_components::transaction::traits::send_messages_with_signer::MessagesWithSignerSenderComponent;
use hermes_relayer_components::transaction::traits::send_messages_with_signer_and_nonce::MessagesWithSignerAndNonceSenderComponent;
use hermes_relayer_components::transaction::traits::submit_tx::TxSubmitterComponent;
use hermes_relayer_components::transaction::traits::types::fee::FeeTypeComponent;
use hermes_relayer_components::transaction::traits::types::nonce::NonceTypeComponent;
use hermes_relayer_components::transaction::traits::types::signer::SignerTypeComponent;
use hermes_relayer_components::transaction::traits::types::transaction::TransactionTypeComponent;
use hermes_relayer_components::transaction::traits::types::tx_hash::TransactionHashTypeComponent;
use hermes_relayer_components::transaction::traits::types::tx_response::TxResponseTypeComponent;
pub use hermes_relayer_components::chain::traits::send_message::MessageSenderComponent;
pub use hermes_relayer_components::components::default::transaction::DefaultTxComponents;
pub use hermes_relayer_components::transaction::impls::poll_tx_response::PollTimeoutGetterComponent;
pub use hermes_relayer_components::transaction::traits::encode_tx::TxEncoderComponent;
pub use hermes_relayer_components::transaction::traits::estimate_tx_fee::TxFeeEstimatorComponent;
pub use hermes_relayer_components::transaction::traits::nonce::allocate_nonce::NonceAllocatorComponent;
pub use hermes_relayer_components::transaction::traits::nonce::nonce_guard::NonceGuardComponent;
pub use hermes_relayer_components::transaction::traits::nonce::query_nonce::NonceQuerierComponent;
pub use hermes_relayer_components::transaction::traits::parse_events::TxResponseAsEventsParserComponent;
pub use hermes_relayer_components::transaction::traits::poll_tx_response::TxResponsePollerComponent;
pub use hermes_relayer_components::transaction::traits::query_tx_response::TxResponseQuerierComponent;
pub use hermes_relayer_components::transaction::traits::send_messages_with_signer::MessagesWithSignerSenderComponent;
pub use hermes_relayer_components::transaction::traits::send_messages_with_signer_and_nonce::MessagesWithSignerAndNonceSenderComponent;
pub use hermes_relayer_components::transaction::traits::submit_tx::TxSubmitterComponent;
pub use hermes_relayer_components::transaction::traits::types::fee::FeeTypeComponent;
pub use hermes_relayer_components::transaction::traits::types::nonce::NonceTypeComponent;
pub use hermes_relayer_components::transaction::traits::types::signer::SignerTypeComponent;
pub use hermes_relayer_components::transaction::traits::types::transaction::TransactionTypeComponent;
pub use hermes_relayer_components::transaction::traits::types::tx_hash::TransactionHashTypeComponent;
pub use hermes_relayer_components::transaction::traits::types::tx_response::TxResponseTypeComponent;

use crate::impls::transaction::encode_tx::EncodeCosmosTx;
use crate::impls::transaction::estimate_fee::EstimateCosmosTxFee;
Expand All @@ -30,19 +27,10 @@ use crate::impls::transaction::poll_timeout::DefaultPollTimeout;
use crate::impls::transaction::query_nonce::QueryCosmosAccount;
use crate::impls::transaction::query_tx_response::QueryCosmosTxResponse;
use crate::impls::transaction::submit_tx::BroadcastCosmosTx;
use crate::impls::types::chain::ProvideCosmosChainTypes;
use crate::impls::types::transaction::ProvideCosmosTransactionTypes;

pub struct CosmosTxComponents;

delegate_components! {
define_components! {
CosmosTxComponents {
[
ChainIdTypeComponent,
MessageTypeComponent,
EventTypeComponent,
]:
ProvideCosmosChainTypes,
[
SignerTypeComponent,
NonceTypeComponent,
Expand Down
15 changes: 6 additions & 9 deletions crates/cosmos/cosmos-chain-components/src/encoding/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ use cgp_core::prelude::*;
use hermes_encoding_components::impls::delegate::DelegateEncoding;
use hermes_encoding_components::impls::encoded::ProvideEncodedBytes;
use hermes_encoding_components::impls::schema::ProvideStringSchema;
use hermes_encoding_components::traits::convert::ConverterComponent;
use hermes_encoding_components::traits::decoder::DecoderComponent;
use hermes_encoding_components::traits::encoded::EncodedTypeComponent;
use hermes_encoding_components::traits::encoder::EncoderComponent;
use hermes_encoding_components::traits::schema::{SchemaGetterComponent, SchemaTypeComponent};
pub use hermes_encoding_components::traits::convert::ConverterComponent;
pub use hermes_encoding_components::traits::decoder::DecoderComponent;
pub use hermes_encoding_components::traits::encoded::EncodedTypeComponent;
pub use hermes_encoding_components::traits::encoder::EncoderComponent;
pub use hermes_encoding_components::traits::schema::{SchemaGetterComponent, SchemaTypeComponent};

use crate::encoding::convert::CosmosConverterComponents;
use crate::encoding::encode::CosmosEncoderComponents;
use crate::encoding::type_url::CosmosTypeUrlSchemas;

pub struct CosmosEncodingComponents;

delegate_components! {
#[mark_component(IsCosmosEncodingComponent)]
define_components! {
CosmosEncodingComponents {
EncodedTypeComponent:
ProvideEncodedBytes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use alloc::sync::Arc;
use cgp_core::CanRaiseError;
use core::time::Duration;

use cgp_core::{delegate_components, Async, CanRaiseError, HasErrorType};
use cgp_core::prelude::*;
use hermes_relayer_components::chain::impls::types::ack::ProvideBytesAcknowlegement;
use hermes_relayer_components::chain::impls::types::commitment::ProvideBytesPacketCommitment;
use hermes_relayer_components::chain::impls::types::commitment_prefix::ProvideCommitmentPrefixBytes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cgp_core::{delegate_components, Async};
use cgp_core::prelude::*;
use hermes_relayer_components::chain::impls::types::payloads::channel::ProvideChannelPayloadTypes;
use hermes_relayer_components::chain::impls::types::payloads::connection::ProvideConnectionPayloadTypes;
use hermes_relayer_components::chain::impls::types::payloads::packet::ProvidePacketPayloadTypes;
Expand Down
1 change: 0 additions & 1 deletion crates/cosmos/cosmos-chain-components/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(refining_impl_trait)]
#![allow(clippy::type_complexity)]
#![allow(clippy::infallible_destructuring_match)]
#![recursion_limit = "256"]

extern crate alloc;

Expand Down
Loading
Loading