Skip to content

Latest commit

 

History

History
82 lines (62 loc) · 2.91 KB

README.md

File metadata and controls

82 lines (62 loc) · 2.91 KB

rebus-grpc-client

This is a GRPC client package of rebuschain/rebus.core for Rust.

Depended libraries

proto files


% find src/proto/cosmos -type f -follow -print | awk '{print "\""$0"\","}'
% find src/proto/ibc -type f -follow -print | awk '{print "\""$0"\","}'
% find src/proto/rebus -type f -follow -print | awk '{print "\""$0"\","}'
% find src/proto/ethermint -type f -follow -print | awk '{print "\""$0"\","}'

Installation

Dependencies

Importing

Cargo.toml

[dependencies]
rebus-grpc-client = { version = "0.2.3", git = "https://github.com/kumanote/rebus-grpc-client-rs", branch = "main" }

rust files

use rebus_grpc_client::{cosmos, tonic};

Usage

Here's a basic example:

use rebus_grpc_client::{cosmos, tonic};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let addr = "http://localhost:9090";
    let mut client =
        cosmos::base::tendermint::v1beta1::service_client::ServiceClient::connect(addr).await?;
    let request = tonic::Request::new(cosmos::base::tendermint::v1beta1::GetLatestBlockRequest {});
    let response = client.get_latest_block(request).await?;
    let latest_height = response.into_inner().block.unwrap().header.unwrap().height;
    let request = tonic::Request::new(cosmos::base::tendermint::v1beta1::GetBlockByHeightRequest {
        height: latest_height,
    });
    let response = client.get_block_by_height(request).await?;
    assert_eq!(
        latest_height,
        response.into_inner().block.unwrap().header.unwrap().height
    );
    Ok(())
}