Skip to content

Commit

Permalink
fix: make client response fields public + remove reduntant QueryConne…
Browse files Browse the repository at this point in the history
…ctionChannelsRequest (#1139)
  • Loading branch information
Farhad-Shabani authored Mar 25, 2024
1 parent 6f4c52c commit aa9c9a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 44 deletions.
26 changes: 13 additions & 13 deletions ibc-query/src/core/client/types/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ impl From<IdentifiedClientState> for RawIdentifiedClientState {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryConsensusStateResponse {
consensus_state: Any,
proof: Proof,
proof_height: Height,
pub consensus_state: Any,
pub proof: Proof,
pub proof_height: Height,
}

impl QueryConsensusStateResponse {
Expand Down Expand Up @@ -213,8 +213,8 @@ impl From<QueryConsensusStateResponse> for RawQueryConsensusStateResponse {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ConsensusStateWithHeight {
height: Height,
consensus_state: Any,
pub height: Height,
pub consensus_state: Any,
}

impl ConsensusStateWithHeight {
Expand Down Expand Up @@ -257,8 +257,8 @@ impl From<ConsensusStateWithHeight> for RawConsensusStateWithHeight {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryConsensusStatesResponse {
consensus_states: Vec<ConsensusStateWithHeight>,
pagination: Option<PageResponse>,
pub consensus_states: Vec<ConsensusStateWithHeight>,
pub pagination: Option<PageResponse>,
}

impl QueryConsensusStatesResponse {
Expand Down Expand Up @@ -308,8 +308,8 @@ impl From<QueryConsensusStatesResponse> for RawQueryConsensusStatesResponse {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryConsensusStateHeightsResponse {
consensus_state_heights: Vec<Height>,
pagination: Option<PageResponse>,
pub consensus_state_heights: Vec<Height>,
pub pagination: Option<PageResponse>,
}

impl QueryConsensusStateHeightsResponse {
Expand Down Expand Up @@ -356,7 +356,7 @@ impl From<QueryConsensusStateHeightsResponse> for RawQueryConsensusStateHeightsR
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryClientStatusResponse {
status: Status,
pub status: Status,
}

impl QueryClientStatusResponse {
Expand Down Expand Up @@ -390,7 +390,7 @@ impl From<QueryClientStatusResponse> for RawQueryClientStatusResponse {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryClientParamsResponse {
allowed_clients: Vec<ClientId>,
pub allowed_clients: Vec<ClientId>,
}

impl QueryClientParamsResponse {
Expand Down Expand Up @@ -436,7 +436,7 @@ impl From<QueryClientParamsResponse> for RawQueryClientParamsResponse {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryUpgradedClientStateResponse {
upgraded_client_state: Any,
pub upgraded_client_state: Any,
}

impl QueryUpgradedClientStateResponse {
Expand Down Expand Up @@ -474,7 +474,7 @@ impl From<QueryUpgradedClientStateResponse> for RawQueryUpgradedClientStateRespo
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryUpgradedConsensusStateResponse {
upgraded_consensus_state: Any,
pub upgraded_consensus_state: Any,
}

impl QueryUpgradedConsensusStateResponse {
Expand Down
31 changes: 0 additions & 31 deletions ibc-query/src/core/connection/types/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use ibc::core::client::types::Height;
use ibc::core::host::types::identifiers::{ClientId, ConnectionId};
use ibc::primitives::prelude::*;
use ibc_proto::ibc::core::channel::v1::QueryConnectionChannelsRequest as RawQueryConnectionChannelsRequest;
use ibc_proto::ibc::core::connection::v1::{
QueryClientConnectionsRequest as RawQueryClientConnectionsRequest,
QueryConnectionClientStateRequest as RawQueryConnectionClientStateRequest,
Expand Down Expand Up @@ -129,33 +128,3 @@ impl From<RawQueryConnectionParamsRequest> for QueryConnectionParamsRequest {
Self { query_height: None }
}
}

/// Defines the RPC method request type for querying the channels associated
/// with a connection.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QueryConnectionChannelsRequest {
pub connection_id: ConnectionId,
pub pagination: Option<PageRequest>,
}

impl TryFrom<RawQueryConnectionChannelsRequest> for QueryConnectionChannelsRequest {
type Error = QueryError;

fn try_from(request: RawQueryConnectionChannelsRequest) -> Result<Self, Self::Error> {
Ok(Self {
connection_id: request.connection.parse()?,
pagination: request.pagination.map(Into::into),
})
}
}

impl From<QueryConnectionChannelsRequest> for RawQueryConnectionChannelsRequest {
fn from(request: QueryConnectionChannelsRequest) -> Self {
Self {
connection: request.connection_id.to_string(),
pagination: request.pagination.map(Into::into),
}
}
}

0 comments on commit aa9c9a8

Please sign in to comment.