Skip to content

feat(ibc-union): Add query responses #3508

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

Closed
wants to merge 6 commits into from
Closed
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
471 changes: 369 additions & 102 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ color-eyre = { version = "0.6.2", default-features = false }
cosmwasm-schema = { version = "2.1.4", default-features = false }
cosmwasm-std = { version = "2.1.4", default-features = false, features = ["std"] } # cosmwasm-std has a fake std feature that is requried to be enabled by default
crossbeam-queue = { version = "0.3.8", default-features = false }
cw-orch = { version = "0.27.0", default-features = false }
cw-storage-plus = { version = "2.0.0", default-features = false }
dashmap = { version = "5.5.3", default-features = false }
derive_more = { version = "0.99.17", default-features = false }
Expand Down
4 changes: 3 additions & 1 deletion cosmwasm/ibc-union/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ workspace = true
crate-type = ["cdylib", "rlib"]

[features]
library = []
cw-orch-interface = ["dep:cw-orch", "ibc-union-msg/cw-orch-interface"]
library = []

[dependencies]
alloy = { workspace = true, features = ["sol-types"] }
bincode = { workspace = true, features = ["alloc", "derive"] }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true, features = ["abort", "iterator"] }
cw-orch = { workspace = true, optional = true }
depolama = { workspace = true }
embed-commit = { workspace = true }
ethabi = { workspace = true }
Expand Down
9 changes: 9 additions & 0 deletions cosmwasm/ibc-union/core/msg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ repository = { workspace = true }
[lints]
workspace = true

[features]
cw-orch-interface = ["schemars", "dep:cw-orch", "dep:cosmwasm-std", "dep:cosmwasm-schema"]
schemars = ["dep:schemars", "unionlabs-primitives/schemars", "ibc-union-spec/schemars"]

[dependencies]
ibc-union-spec = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
unionlabs-primitives = { workspace = true, features = ["serde"] }

cosmwasm-schema = { workspace = true, optional = true }
cosmwasm-std = { workspace = true, optional = true }
cw-orch = { workspace = true, optional = true }
schemars = { workspace = true, optional = true }
1 change: 1 addition & 0 deletions cosmwasm/ibc-union/core/msg/src/lightclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ibc_union_spec::ClientId;
use unionlabs_primitives::Bytes;

#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
pub enum Status {
Active,
Expand Down
1 change: 1 addition & 0 deletions cosmwasm/ibc-union/core/msg/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use unionlabs_primitives::Bytes;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum IbcUnionMsg {
OnChannelOpenInit {
caller: String,
Expand Down
3 changes: 2 additions & 1 deletion cosmwasm/ibc-union/core/msg/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ibc_union_spec::{Channel, ChannelId, ClientId, ConnectionId, Packet, Timesta
use serde::{Deserialize, Serialize};
use unionlabs_primitives::Bytes;

#[derive(Default, Serialize, Deserialize)]
#[derive(Default, Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct InitMsg {
pub relayers_admin: Option<String>,
Expand All @@ -18,6 +18,7 @@ pub struct MsgRegisterClient {

#[derive(Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
#[cfg_attr(feature = "cw-orch-interface", derive(cw_orch::ExecuteFns))]
pub enum ExecuteMsg {
AddRelayer(String),
RemoveRelayer(String),
Expand Down
21 changes: 19 additions & 2 deletions cosmwasm/ibc-union/core/msg/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
use ibc_union_spec::{ChannelId, ClientId, ConnectionId};
use unionlabs_primitives::H256;

#[derive(serde::Serialize, serde::Deserialize)]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(
feature = "cw-orch-interface",
derive(cosmwasm_schema::QueryResponses, cw_orch::QueryFns)
)]
pub enum QueryMsg {
#[cfg_attr(feature = "cw-orch-interface", returns(ibc_union_spec::Timestamp))]
GetTimestampAtHeight { client_id: ClientId, height: u64 },
#[cfg_attr(feature = "cw-orch-interface", returns(u64))]
GetLatestHeight { client_id: ClientId },
#[cfg_attr(feature = "cw-orch-interface", returns(unionlabs_primitives::Bytes))]
GetClientState { client_id: ClientId },
#[cfg_attr(feature = "cw-orch-interface", returns(unionlabs_primitives::Bytes))]
GetConsensusState { client_id: ClientId, height: u64 },
#[cfg_attr(feature = "cw-orch-interface", returns(crate::lightclient::Status))]
GetStatus { client_id: ClientId },
#[cfg_attr(feature = "cw-orch-interface", returns(String))]
GetClientType { client_id: ClientId },
#[cfg_attr(feature = "cw-orch-interface", returns(ibc_union_spec::Connection))]
GetConnection { connection_id: ConnectionId },
#[cfg_attr(feature = "cw-orch-interface", returns(ibc_union_spec::Channel))]
GetChannel { channel_id: ChannelId },
#[cfg_attr(feature = "cw-orch-interface", returns(std::collections::BTreeSet<u32>))]
GetChannels { contract: String },
#[cfg_attr(feature = "cw-orch-interface", returns(Option<H256>))]
GetBatchPackets { batch_hash: H256 },
#[cfg_attr(feature = "cw-orch-interface", returns(Option<H256>))]
GetBatchReceipts { batch_hash: H256 },
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Addr))]
GetClientImpl { client_id: ClientId },
#[cfg_attr(feature = "cw-orch-interface", returns(String))]
GetRegisteredClientType { client_type: String },
}
29 changes: 29 additions & 0 deletions cosmwasm/ibc-union/core/src/interface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pub const IBC_UNION: &str = "union:ibc-union";

#[cw_orch::interface(
ibc_union_msg::msg::InitMsg,
ibc_union_msg::msg::ExecuteMsg,
ibc_union_msg::query::QueryMsg,
crate::contract::IbcUnionMigrateMsg,
id = IBC_UNION
)]
pub struct IbcUnion<Chain>;

#[cfg(not(target_arch = "wasm32"))]
use cw_orch::prelude::*;

#[cfg(not(target_arch = "wasm32"))]
impl<Chain: CwEnv> Uploadable for IbcUnion<Chain> {
fn wasm(_chain_info: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("ibc_union")
.unwrap()
}
fn wrapper() -> <Mock as TxHandler>::ContractSource {
Box::new(ContractWrapper::new(
crate::contract::execute,
crate::contract::instantiate,
crate::contract::query,
))
}
}
2 changes: 2 additions & 0 deletions cosmwasm/ibc-union/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![cfg_attr(not(test), warn(clippy::unwrap_used))]

pub mod contract;
#[cfg(feature = "cw-orch-interface")]
pub mod interface;
pub mod state;

#[cfg(test)]
Expand Down