Skip to content

Commit 4abb9e3

Browse files
committed
feat(ibc-union): implement QueryResponses and cw-orch function generation
1 parent d5c4aeb commit 4abb9e3

File tree

10 files changed

+2054
-1260
lines changed

10 files changed

+2054
-1260
lines changed

Cargo.lock

+1,981-1,254
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ tracing = { version = "0.1.40", default-features = false }
366366
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "ansi"] }
367367
typenum = { version = "1.17.0", default-features = false }
368368

369+
cw-orch = "0.27.0"
370+
369371
[patch."crates-io"]
370372
arbitrary = { git = "https://github.com/unionlabs/arbitrary" }
371373
# parity-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }

cosmwasm/ibc-union/core/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ workspace = true
1515
crate-type = ["cdylib", "rlib"]
1616

1717
[features]
18-
library = []
18+
cw-orch-interface = ["dep:cw-orch", "ibc-union-msg/cw-orch-interface"]
19+
library = []
1920

2021
[dependencies]
2122
alloy = { workspace = true, features = ["sol-types"] }
@@ -32,3 +33,4 @@ strum = { version = "0.26.3", features = ["derive"] }
3233
thiserror = { workspace = true }
3334
unionlabs = { workspace = true, features = ["ethabi"] }
3435
unionlabs-cosmwasm-upgradable = { workspace = true }
36+
cw-orch = { workspace = true, optional = true }

cosmwasm/ibc-union/core/msg/Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ repository = { workspace = true }
1111
[lints]
1212
workspace = true
1313

14+
[features]
15+
cw-orch-interface = ["schemars", "dep:cw-orch", "dep:cosmwasm-std", "dep:cosmwasm-schema"]
16+
schemars = ["dep:schemars", "unionlabs-primitives/schemars", "ibc-union-spec/schemars"]
17+
1418
[dependencies]
1519
ibc-union-spec = { workspace = true, features = ["serde"] }
1620
serde = { workspace = true, features = ["derive"] }
1721
unionlabs-primitives = { workspace = true, features = ["serde"] }
22+
23+
cosmwasm-schema = { workspace = true, optional = true }
24+
cosmwasm-std = { workspace = true, optional = true }
25+
cw-orch = { workspace = true, optional = true }
26+
schemars = { workspace = true, optional = true }

cosmwasm/ibc-union/core/msg/src/lightclient.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use unionlabs_primitives::Bytes;
22

3-
#[derive(serde::Serialize, serde::Deserialize)]
3+
#[derive(serde::Serialize, serde::Deserialize, Debug)]
4+
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
45
#[serde(deny_unknown_fields, rename_all = "snake_case")]
56
pub enum Status {
67
Active,

cosmwasm/ibc-union/core/msg/src/module.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use ibc_union_spec::types::Packet;
22
use unionlabs_primitives::Bytes;
33

4-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
4+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq)]
55
#[serde(deny_unknown_fields, rename_all = "snake_case")]
6+
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
67
pub enum IbcUnionMsg {
78
OnChannelOpenInit {
89
connection_id: u32,

cosmwasm/ibc-union/core/msg/src/msg.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ibc_union_spec::types::{Channel, Packet};
22
use serde::{Deserialize, Serialize};
33
use unionlabs_primitives::Bytes;
44

5-
#[derive(Serialize, Deserialize)]
5+
#[derive(Serialize, Deserialize, Debug)]
66
#[serde(deny_unknown_fields)]
77
pub struct InitMsg {}
88

@@ -15,6 +15,7 @@ pub struct MsgRegisterClient {
1515

1616
#[derive(Debug, Serialize, Deserialize)]
1717
#[serde(deny_unknown_fields, rename_all = "snake_case")]
18+
#[cfg_attr(feature = "cw-orch-interface", derive(cw_orch::ExecuteFns))]
1819
pub enum ExecuteMsg {
1920
RegisterClient(MsgRegisterClient),
2021
CreateClient(MsgCreateClient),
+22-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
use unionlabs_primitives::H256;
2-
3-
#[derive(serde::Serialize, serde::Deserialize)]
2+
#[derive(serde::Serialize, serde::Deserialize, Debug)]
43
#[serde(deny_unknown_fields, rename_all = "snake_case")]
4+
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
5+
#[cfg_attr(
6+
feature = "cw-orch-interface",
7+
derive(cosmwasm_schema::QueryResponses, cw_orch::QueryFns)
8+
)]
59
pub enum QueryMsg {
10+
#[cfg_attr(feature = "cw-orch-interface", returns(u64))]
611
GetTimestampAtHeight { client_id: u32, height: u64 },
12+
#[cfg_attr(feature = "cw-orch-interface", returns(u64))]
713
GetLatestHeight { client_id: u32 },
14+
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Binary))]
815
GetClientState { client_id: u32 },
16+
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Binary))]
917
GetConsensusState { client_id: u32, height: u64 },
18+
#[cfg_attr(feature = "cw-orch-interface", returns(crate::lightclient::Status))]
1019
GetStatus { client_id: u32 },
20+
#[cfg_attr(feature = "cw-orch-interface", returns(u64))]
1121
GetClientType { client_id: u32 },
22+
#[cfg_attr(
23+
feature = "cw-orch-interface",
24+
returns(ibc_union_spec::types::Connection)
25+
)]
1226
GetConnection { connection_id: u32 },
27+
#[cfg_attr(feature = "cw-orch-interface", returns(ibc_union_spec::types::Channel))]
1328
GetChannel { channel_id: u32 },
29+
#[cfg_attr(feature = "cw-orch-interface", returns(std::collections::BTreeSet<u32>))]
1430
GetChannels { contract: String },
31+
#[cfg_attr(feature = "cw-orch-interface", returns(Option<Vec<u8>>))]
1532
GetBatchPackets { channel_id: u32, batch_hash: H256 },
33+
#[cfg_attr(feature = "cw-orch-interface", returns(Option<Vec<u8>>))]
1634
GetBatchReceipts { channel_id: u32, batch_hash: H256 },
35+
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Addr))]
1736
GetClientImpl { client_id: u32 },
37+
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Addr))]
1838
GetRegisteredClientType { client_type: String },
1939
}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
pub const IBC_UNION: &str = "union:ibc-union";
2+
3+
#[cw_orch::interface(
4+
ibc_union_msg::msg::InitMsg,
5+
ibc_union_msg::msg::ExecuteMsg,
6+
ibc_union_msg::query::QueryMsg,
7+
crate::contract::IbcUnionMigrateMsg,
8+
id = IBC_UNION
9+
)]
10+
pub struct IbcUnion<Chain>;
11+
12+
#[cfg(not(target_arch = "wasm32"))]
13+
use cw_orch::prelude::*;
14+
15+
#[cfg(not(target_arch = "wasm32"))]
16+
impl<Chain: CwEnv> Uploadable for IbcUnion<Chain> {
17+
fn wasm(_chain_info: &ChainInfoOwned) -> WasmPath {
18+
artifacts_dir_from_workspace!()
19+
.find_wasm_path("ibc_union")
20+
.unwrap()
21+
}
22+
fn wrapper() -> <Mock as TxHandler>::ContractSource {
23+
Box::new(ContractWrapper::new(
24+
crate::contract::execute,
25+
crate::contract::instantiate,
26+
crate::contract::query,
27+
))
28+
}
29+
}

cosmwasm/ibc-union/core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![cfg_attr(not(test), warn(clippy::unwrap_used))]
22

33
pub mod contract;
4+
#[cfg(feature = "cw-orch-interface")]
5+
pub mod interface;
46
pub mod state;
57

68
#[cfg(test)]

0 commit comments

Comments
 (0)