Skip to content

kumanote/osmosis-grpc-client-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osmosis-grpc-client

This is a GRPC client package of osmosis-labs/osmosis 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/osmosis -type f -regex ".*\.proto" -follow -print | awk '{print "\""$0"\","}'

Installation

Dependencies

Importing

Cargo.toml

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

rust files

use osmosis_grpc_client::{cosmos, tonic};

Usage

Here's a basic example:

use osmosis_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(())
}

About

Rust implementation of cosmos osmosisd GRPC client.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages