use ibc::core::primitives::prelude::*;
use ibc_proto::cosmos::base::query::v1beta1::{
PageRequest as RawPageRequest, PageResponse as RawPageResponse,
};
pub type Proof = Vec<u8>;
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PageRequest {
pub key: Vec<u8>,
pub offset: u64,
pub limit: u64,
pub count_total: bool,
pub reverse: bool,
}
impl PageRequest {
pub fn all() -> Self {
Self {
limit: u64::MAX,
..Default::default()
}
}
}
impl From<PageRequest> for RawPageRequest {
fn from(request: PageRequest) -> Self {
Self {
key: request.key,
offset: request.offset,
limit: request.limit,
count_total: request.count_total,
reverse: request.reverse,
}
}
}
impl From<RawPageRequest> for PageRequest {
fn from(request: RawPageRequest) -> Self {
Self {
key: request.key,
offset: request.offset,
limit: request.limit,
count_total: request.count_total,
reverse: request.reverse,
}
}
}
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PageResponse {
pub next_key: Vec<u8>,
pub total: u64,
}
impl From<PageResponse> for RawPageResponse {
fn from(response: PageResponse) -> Self {
Self {
next_key: response.next_key,
total: response.total,
}
}
}
impl From<RawPageResponse> for PageResponse {
fn from(response: RawPageResponse) -> Self {
Self {
next_key: response.next_key,
total: response.total,
}
}
}