ibc_query/
lib.rs

1//! Contains a set of utility traits and implementations for querying the state
2//! of an `ibc-rs` enabled chain, including implementation of essential IBC
3//! query methods and gRPC query services defined in `ibc-proto` crate.
4//! Therefore, some ready-to-use Query structs for each layer of the client,
5//! connection, and channel have been implemented and exposed by this crate.
6//!
7//! The provided structs include blanket implementation of their corresponding
8//! gRPC service traits, if the host implements the following _context_ traits:
9//! - [`ValidationContext`](ibc::core::host::ValidationContext)
10//! - [`ProvableContext`](crate::core::context::ProvableContext)
11//! - [`QueryContext`](crate::core::context::QueryContext)
12//! - [`UpgradeValidationContext`](ibc::cosmos_host::upgrade_proposal::UpgradeValidationContext)
13//!   - Only for
14//!     [`ClientQuery::upgraded_client_state`](ibc_proto::ibc::core::client::v1::query_server::Query::upgraded_client_state)
15//!     and
16//!     [`ClientQuery::upgraded_client_state`](ibc_proto::ibc::core::client::v1::query_server::Query::upgraded_consensus_state)
17//!
18//! Example
19//! ```rust,ignore
20//! use ibc_proto::ibc::core::{
21//!     channel::v1::query_server::QueryServer as ChannelQueryServer
22//!     client::v1::query_server::QueryServer as ClientQueryServer,
23//!     connection::v1::query_server::QueryServer as ConnectionQueryServer,
24//! }
25//! use ibc::core::ValidationContext;
26//! use ibc::hosts::tendermint::upgrade_proposal::UpgradeValidationContext;
27//! use ibc::services::core::{ProvableContext, QueryContext};
28//! use ibc::services::{ChannelQueryService, ClientQueryService, ConnectionQueryService};
29//!
30//! struct Ibc;
31//! impl ValidationContext for Ibc { }
32//! impl ProvableContext for Ibc { }
33//! impl QueryContext for Ibc { }
34//!
35//! struct Upgrade;
36//! impl UpgradeValidationContext for Upgrade { }
37//!
38//! let ibc = Ibc::new();
39//! let upgrade = Upgrade::new();
40//!
41//! // `ibc` and `upgrade` must be thread-safe
42//!
43//! let client_service = ClientQueryServer::new(ClientQueryService::new(ibc.clone(), upgrade))
44//! let connection_service = ConnectionQueryServer::new(ConnectionQueryService::new(ibc.clone()))
45//! let channel_service = ChannelQueryServer::new(ChannelQueryService::new(ibc))
46//!
47//! let grpc_server = tonic::transport::Server::builder()
48//!       .add_service(client_service)
49//!       .add_service(connection_service)
50//!       .add_service(channel_service)
51//!       .serve(addr);
52//! ```
53//!
54
55#![cfg_attr(not(test), deny(clippy::unwrap_used))]
56#![no_std]
57#![deny(
58    warnings,
59    trivial_casts,
60    trivial_numeric_casts,
61    unused_import_braces,
62    unused_qualifications,
63    rust_2018_idioms
64)]
65#![forbid(unsafe_code)]
66
67extern crate alloc;
68
69#[cfg(feature = "std")]
70extern crate std;
71
72pub mod core;
73pub mod error;
74pub mod types;
75pub mod utils;