1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use abstract_core::{
    ibc_client::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg},
    IBC_CLIENT,
};

use cw_orch::{
    contract::Contract,
    interface,
    prelude::{
        artifacts_dir_from_workspace, ArtifactsDir, ContractWrapper, CwEnv, Mock, TxHandler,
        Uploadable, WasmPath,
    },
};

use crate::RegisteredModule;

#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg)]
pub struct IbcClient<Chain>;

impl<Chain: CwEnv> Uploadable for IbcClient<Chain> {
    #[cfg(feature = "integration")]
    fn wrapper(&self) -> <Mock as TxHandler>::ContractSource {
        Box::new(
            ContractWrapper::new_with_empty(
                ::ibc_client::contract::execute,
                ::ibc_client::contract::instantiate,
                ::ibc_client::contract::query,
            )
            .with_migrate(::ibc_client::contract::migrate),
        )
    }
    fn wasm(&self) -> WasmPath {
        artifacts_dir_from_workspace!()
            .find_wasm_path("ibc_client")
            .unwrap()
    }
}

impl<Chain: CwEnv> RegisteredModule for IbcClient<Chain> {
    type InitMsg = InstantiateMsg;

    fn module_id<'a>() -> &'a str {
        IBC_CLIENT
    }
    fn module_version<'a>() -> &'a str {
        ibc_client::contract::CONTRACT_VERSION
    }
}

impl<Chain: CwEnv> From<Contract<Chain>> for IbcClient<Chain> {
    fn from(value: Contract<Chain>) -> Self {
        IbcClient(value)
    }
}