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

Rename DaemonInterchainEnv to DaemonInterchain #475

Merged
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Breaking

- Rename `DaemonInterchainEnv` to `DaemonInterchain` for consistency.

## 0.24.1

- Added async query functions generations with cw_orch::QueryFns
Expand Down
8 changes: 4 additions & 4 deletions cw-orch-interchain/examples/doc_daemon.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use cw_orch::prelude::networks::{LOCAL_JUNO, LOCAL_MIGALOO, LOCAL_OSMO};
use cw_orch::prelude::*;
use cw_orch_interchain::{
ChannelCreationValidator, ChannelCreator, DaemonInterchainEnv, InterchainEnv, Starship,
ChannelCreationValidator, ChannelCreator, DaemonInterchain, InterchainEnv, Starship,
};
/// Others

fn create_daemon_env() -> cw_orch::anyhow::Result<DaemonInterchainEnv> {
let mut interchain = DaemonInterchainEnv::new(
fn create_daemon_env() -> cw_orch::anyhow::Result<DaemonInterchain> {
let mut interchain = DaemonInterchain::new(
vec![(LOCAL_JUNO, None), (LOCAL_OSMO, None)],
&ChannelCreationValidator,
)?;
Expand All @@ -22,7 +22,7 @@ fn create_daemon_env() -> cw_orch::anyhow::Result<DaemonInterchainEnv> {
Ok(interchain)
}

fn create_starship_env() -> cw_orch::anyhow::Result<DaemonInterchainEnv<Starship>> {
fn create_starship_env() -> cw_orch::anyhow::Result<DaemonInterchain<Starship>> {
let starship = Starship::new(None)?;
let interchain = starship.interchain_env();

Expand Down
4 changes: 2 additions & 2 deletions cw-orch-interchain/examples/follow_packets_txhash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cw_orch::{
environment::{ChainInfo, NetworkInfo},
prelude::networks::osmosis::OSMOSIS_1,
};
use cw_orch_interchain_daemon::{ChannelCreationValidator, DaemonInterchainEnv};
use cw_orch_interchain_daemon::{ChannelCreationValidator, DaemonInterchain};

pub const NOBLE: NetworkInfo = NetworkInfo {
chain_name: "noble",
Expand All @@ -27,7 +27,7 @@ fn follow_by_tx_hash() -> cw_orch::anyhow::Result<()> {
let dst_chain = ARCHWAY_1;
let src_chain = OSMOSIS_1;

let interchain = DaemonInterchainEnv::new(
let interchain = DaemonInterchain::new(
vec![(src_chain.clone(), None), (dst_chain, None)],
&ChannelCreationValidator,
)?;
Expand Down
2 changes: 1 addition & 1 deletion cw-orch-interchain/examples/manual_ica_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {

let starship = Starship::new(None).unwrap();

let interchain = DaemonInterchainEnv::from_daemons(
let interchain = DaemonInterchain::from_daemons(
starship.daemons.values().cloned().collect(),
&ChannelCreationValidator,
);
Expand Down
2 changes: 1 addition & 1 deletion cw-orch-interchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod prelude {

#[cfg(feature = "daemon")]
pub use cw_orch_interchain_daemon::{
ChannelCreationValidator, ChannelCreator, DaemonInterchainEnv,
ChannelCreationValidator, ChannelCreator, DaemonInterchain,
};
#[cfg(feature = "daemon")]
pub use cw_orch_starship::Starship;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/interchain/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ Visit the dedicated [Starship](./integrations/daemon.md#for-testing) page for mo

### [Cosmos SDK Node Scripting](./integrations/daemon.md#for-scripting)

The `DaemonInterchainEnvironment` object allows developers to script, deploy and manage their application on running chains with attention to IBC functionalities. This enhances the developer experience with more tooling, more useful logging. This is the all-in-one toolbox cor the cosmwasm IBC developer.
The `DaemonInterchain` object allows developers to script, deploy and manage their application on running chains with attention to IBC functionalities. This enhances the developer experience with more tooling, more useful logging. This is the all-in-one toolbox cor the cosmwasm IBC developer.

Visit the dedicated [Daemon Interchain](./integrations/daemon.md#for-scripting) page for more details and code snippets.
6 changes: 3 additions & 3 deletions docs/src/interchain/integrations/daemon.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use cw_orch::prelude::*;
use cw_orch_interchain::prelude::*;
use cw_orch::prelude::networks::{LOCAL_JUNO, LOCAL_OSMO};
fn main(){
let mut interchain = DaemonInterchainEnv::new(vec![
let mut interchain = DaemonInterchain::new(vec![
(LOCAL_JUNO, None),
(LOCAL_OSMO, None)
], &ChannelCreationValidator)?;
Expand Down Expand Up @@ -121,7 +121,7 @@ Finally the `await_and_check_packets` function allows to follow all packet execu
## Analysis Usage

The `await_single_packet` and `await_packets` function were coded for scripting usage in mind. They allow to await and repeatedly query Cosmos SDK Nodes until the cycle is complete. However, it is also possible to inspect past transactions using those tools.
Using the `DaemonInterchainEnv::await_packets_for_txhash` function, one can inspect the history of packets linked to a transaction from a transaction hash only. This enables all kinds of analysis usage, here are some:
Using the `DaemonInterchain::await_packets_for_txhash` function, one can inspect the history of packets linked to a transaction from a transaction hash only. This enables all kinds of analysis usage, here are some:

- Relayer activity
- Analysis of past transactions for fund recovery
Expand All @@ -132,7 +132,7 @@ Using the `DaemonInterchainEnv::await_packets_for_txhash` function, one can insp

cw-orchestrator doesn't provide[^documentation_date] relayer capabilities. We only provide tools to analyze IBC activity based on packet relaying mechanism that only relayers can provide. However, when testing your implementation with Starship, you might want to automatically create channels on your test setup.

This is what the second argument of the `DaemonInterchainEnv::new` function is used for. You provide an object which will be responsible for creating an IBC channel between two ports. We provide 2 such structures, you can obviously create your own if your needs differ:
This is what the second argument of the `DaemonInterchain::new` function is used for. You provide an object which will be responsible for creating an IBC channel between two ports. We provide 2 such structures, you can obviously create your own if your needs differ:

1. `cw_orch_interchain::interchain::ChannelCreationValidator`
This is used when you want to have full control over the channel creation. When `interchain.create_channel` is called, the script will stop and prompt you to create a channel with external tools. Once the channel creation process is done on your side, you simply have to input the connection-id on which you created the channel to be able to resume execution. This solution is not ideal at all but allows you to script on actual nodes without having to separate your scripts into multiple parts or change the syntax you coded for your tests.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/interchain/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ let osmosis = Daemon::builder(cw_orch::daemon::networks::OSMO_5)
.unwrap();

// This will allow us to follow packets execution between juno and osmosis
let interchain = DaemonInterchainEnv::from_daemons(
let interchain = DaemonInterchain::from_daemons(
vec![juno, osmosis],
&ChannelCreationValidator,
);
Expand Down
12 changes: 6 additions & 6 deletions packages/interchain/interchain-daemon/src/channel_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use dialoguer::Input;
use ibc_relayer_types::core::ics24_host::identifier::PortId;

use crate::{interchain_env::DaemonInterchainEnv, InterchainDaemonError};
use crate::{interchain_env::DaemonInterchain, InterchainDaemonError};

/// Used for allowing multiple interaction types with the Daemon interchain environment
pub trait ChannelCreator: Clone {
Expand All @@ -21,7 +21,7 @@
) -> Result<String, InterchainDaemonError>;

/// Returns an interchain environment from the channel creator object
fn interchain_env(&self) -> DaemonInterchainEnv<Self>;
fn interchain_env(&self) -> DaemonInterchain<Self>;
}

/// This is a struct for use with actual RPCs where you want to create you channel manually
Expand All @@ -47,8 +47,8 @@
Ok(connection_id)
}

fn interchain_env(&self) -> DaemonInterchainEnv<Self> {
panic!("To create an RPC based interchain environement, use DaemonInterchainEnv::new(). Use the Starship::interchain_env() method for interacting with Starship")
fn interchain_env(&self) -> DaemonInterchain<Self> {
panic!("To create an RPC based interchain environement, use DaemonInterchain::new(). Use the Starship::interchain_env() method for interacting with Starship")

Check warning on line 51 in packages/interchain/interchain-daemon/src/channel_creator.rs

View check run for this annotation

Codecov / codecov/patch

packages/interchain/interchain-daemon/src/channel_creator.rs#L50-L51

Added lines #L50 - L51 were not covered by tests
}
}

Expand Down Expand Up @@ -76,7 +76,7 @@
Ok(connection_id)
}

fn interchain_env(&self) -> DaemonInterchainEnv<Self> {
DaemonInterchainEnv::from_daemons(self.daemons.values().cloned().collect(), self)
fn interchain_env(&self) -> DaemonInterchain<Self> {
DaemonInterchain::from_daemons(self.daemons.values().cloned().collect(), self)

Check warning on line 80 in packages/interchain/interchain-daemon/src/channel_creator.rs

View check run for this annotation

Codecov / codecov/patch

packages/interchain/interchain-daemon/src/channel_creator.rs#L79-L80

Added lines #L79 - L80 were not covered by tests
}
}
14 changes: 7 additions & 7 deletions packages/interchain/interchain-daemon/src/interchain_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use tokio::runtime::Handle;

/// Represents a set of locally running blockchain nodes and a Hermes relayer.
#[derive(Clone)]
pub struct DaemonInterchainEnv<C: ChannelCreator = ChannelCreationValidator> {
pub struct DaemonInterchain<C: ChannelCreator = ChannelCreationValidator> {
/// Daemons indexable by network id, i.e. "juno-1", "osmosis-2", ...
daemons: HashMap<NetworkId, Daemon>,

Expand All @@ -43,8 +43,8 @@ pub struct DaemonInterchainEnv<C: ChannelCreator = ChannelCreationValidator> {

type Mnemonic = String;

impl<C: ChannelCreator> DaemonInterchainEnv<C> {
/// Builds a new [`DaemonInterchainEnv`] instance.
impl<C: ChannelCreator> DaemonInterchain<C> {
/// Builds a new [`DaemonInterchain`] instance.
/// For use with starship, we advise to use [`cw_orch_starship::Starship::interchain_env`] instead
/// channel_creator allows you to specify an object that is able to create channels
/// Use [`crate::ChannelCreationValidator`] for manual channel creations.
Expand All @@ -55,7 +55,7 @@ impl<C: ChannelCreator> DaemonInterchainEnv<C> {
Self::new_with_runtime(chains, channel_creator, RUNTIME.handle())
}

/// Builds a new [`DaemonInterchainEnv`] instance.
/// Builds a new [`DaemonInterchain`] instance.
/// For use with starship, we advise to use [`cw_orch_starship::Starship::interchain_env`] instead
/// channel_creator allows you to specify an object that is able to create channels
/// Use [`crate::ChannelCreationValidator`] for manual channel creations.
Expand Down Expand Up @@ -157,7 +157,7 @@ impl<C: ChannelCreator> DaemonInterchainEnv<C> {
}
}

impl<C: ChannelCreator> InterchainEnv<Daemon> for DaemonInterchainEnv<C> {
impl<C: ChannelCreator> InterchainEnv<Daemon> for DaemonInterchain<C> {
type ChannelCreationResult = ();

type Error = InterchainDaemonError;
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<C: ChannelCreator> InterchainEnv<Daemon> for DaemonInterchainEnv<C> {
}
}

impl<C: ChannelCreator> DaemonInterchainEnv<C> {
impl<C: ChannelCreator> DaemonInterchain<C> {
/// This function follows every IBC packet sent out in a tx result
/// This allows only providing the transaction hash when you don't have access to the whole response object
///
Expand All @@ -303,7 +303,7 @@ impl<C: ChannelCreator> DaemonInterchainEnv<C> {
/// let dst_chain = ARCHWAY_1;
/// let src_chain = OSMOSIS_1;
///
/// let interchain = DaemonInterchainEnv::new(
/// let interchain = DaemonInterchain::new(
/// vec![(src_chain.clone(), None), (dst_chain, None)],
/// &ChannelCreationValidator,
/// ).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion packages/interchain/interchain-daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ pub type IcDaemonResult<R> = Result<R, InterchainDaemonError>;
/// We want to export some major elements
pub use channel_creator::{ChannelCreationValidator, ChannelCreator};

pub use interchain_env::DaemonInterchainEnv;
pub use interchain_env::DaemonInterchain;
Loading