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

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3,235 changes: 1,981 additions & 1,254 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
@@ -327,6 +327,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 }
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 }
4 changes: 3 additions & 1 deletion cosmwasm/ibc-union/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -15,12 +15,14 @@ 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"] }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true, features = ["abort"] }
cw-orch = { workspace = true, optional = true }
cw-storage-plus = { workspace = true }
ethabi = { workspace = true }
hex = { workspace = true }
9 changes: 9 additions & 0 deletions cosmwasm/ibc-union/core/msg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
3 changes: 2 additions & 1 deletion cosmwasm/ibc-union/core/msg/src/lightclient.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use unionlabs_primitives::Bytes;

#[derive(serde::Serialize, serde::Deserialize)]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
pub enum Status {
Active,
3 changes: 2 additions & 1 deletion cosmwasm/ibc-union/core/msg/src/module.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use ibc_union_spec::types::Packet;
use unionlabs_primitives::Bytes;

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

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct InitMsg {}

@@ -15,6 +15,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 {
RegisterClient(MsgRegisterClient),
CreateClient(MsgCreateClient),
24 changes: 22 additions & 2 deletions cosmwasm/ibc-union/core/msg/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
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(u64))]
GetTimestampAtHeight { client_id: u32, height: u64 },
#[cfg_attr(feature = "cw-orch-interface", returns(u64))]
GetLatestHeight { client_id: u32 },
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Binary))]
GetClientState { client_id: u32 },
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Binary))]
GetConsensusState { client_id: u32, height: u64 },
#[cfg_attr(feature = "cw-orch-interface", returns(crate::lightclient::Status))]
GetStatus { client_id: u32 },
#[cfg_attr(feature = "cw-orch-interface", returns(u64))]
GetClientType { client_id: u32 },
#[cfg_attr(
feature = "cw-orch-interface",
returns(ibc_union_spec::types::Connection)
)]
GetConnection { connection_id: u32 },
#[cfg_attr(feature = "cw-orch-interface", returns(ibc_union_spec::types::Channel))]
GetChannel { channel_id: u32 },
#[cfg_attr(feature = "cw-orch-interface", returns(std::collections::BTreeSet<u32>))]
GetChannels { contract: String },
#[cfg_attr(feature = "cw-orch-interface", returns(Option<Vec<u8>>))]
GetBatchPackets { channel_id: u32, batch_hash: H256 },
#[cfg_attr(feature = "cw-orch-interface", returns(Option<Vec<u8>>))]
GetBatchReceipts { channel_id: u32, batch_hash: H256 },
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Addr))]
GetClientImpl { client_id: u32 },
#[cfg_attr(feature = "cw-orch-interface", returns(cosmwasm_std::Addr))]
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)]