Skip to content

Commit

Permalink
Add query responses to ibc-union
Browse files Browse the repository at this point in the history
  • Loading branch information
adairrr committed Jan 14, 2025
1 parent 4580146 commit 2b8f4ba
Show file tree
Hide file tree
Showing 8 changed files with 415 additions and 100 deletions.
463 changes: 364 additions & 99 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions cosmwasm/ibc-union/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ serde_json = { workspace = true }
strum = { version = "0.26.3", features = ["derive"] }
thiserror = { workspace = true }
unionlabs = { workspace = true, features = ["ethabi"] }
cw-orch = "0.27.0"
cosmwasm-schema = { workspace = true }
3 changes: 3 additions & 0 deletions cosmwasm/ibc-union/core/msg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ workspace = true
ibc-solidity = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
unionlabs-primitives = { workspace = true, features = ["serde"] }
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-orch = "0.27.0"
2 changes: 1 addition & 1 deletion cosmwasm/ibc-union/core/msg/src/lightclient.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use unionlabs_primitives::Bytes;

#[derive(serde::Serialize, serde::Deserialize)]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
#[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/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct MsgRegisterClient {

#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
#[derive(cw_orch::ExecuteFns)] // cw-orch automatic
pub enum ExecuteMsg {
RegisterClient(MsgRegisterClient),
CreateClient(MsgCreateClient),
Expand Down
12 changes: 12 additions & 0 deletions cosmwasm/ibc-union/core/msg/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@ use unionlabs_primitives::H256;

#[derive(serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
#[derive(cosmwasm_schema::QueryResponses, cw_orch::QueryFns)]
pub enum QueryMsg {
#[returns(u64)]
GetTimestampAtHeight { client_id: u32, height: u64 },
#[returns(u64)]
GetLatestHeight { client_id: u32 },
#[returns(cosmwasm_std::Binary)]
GetClientState { client_id: u32 },
#[returns(cosmwasm_std::Binary)]
GetConsensusState { client_id: u32, height: u64 },
#[returns(crate::lightclient::Status)]
GetStatus { client_id: u32 },
#[returns(u64)]
GetClientType { client_id: u32 },
#[returns(ibc_solidity::Connection)]
GetConnection { connection_id: u32 },
#[returns(ibc_solidity::Channel)]
GetChannel { channel_id: u32 },
#[returns(BTreeSet<u32>)]
GetChannels { contract: String },
#[returns(Option<H256>)]
GetBatchPackets { channel_id: u32, batch_hash: H256 },
#[returns(Option<H256>)]
GetBatchReceipts { channel_id: u32, batch_hash: H256 },
}
31 changes: 31 additions & 0 deletions cosmwasm/ibc-union/core/src/interface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
pub const UNION_IBC: &str = "union:union-ibc";

#[cw_orch::interface(
crate::msg::InstantiateMsg,
crate::msg::ExecuteMsg,
crate::msg::QueryMsg,
crate::msg::MigrateMsg,
id = EVM_NOTE
)]
pub struct UnionIbc<Chain>;

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

#[cfg(not(target_arch = "wasm32"))]
impl<Chain: CwEnv> Uploadable for UnionIbc<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,
)
)
}
}
1 change: 1 addition & 0 deletions cosmwasm/ibc-union/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pub mod contract;
pub mod state;
pub mod interface;

use cosmwasm_std::{Addr, StdError};
use ibc_solidity::{ChannelState, ConnectionState};
Expand Down

0 comments on commit 2b8f4ba

Please sign in to comment.