Code Monkey home page Code Monkey logo

Comments (1)

rnbguy avatar rnbguy commented on July 17, 2024 1

Cosmos GRPC supports reflections. One can leverage it to load proto files from live GRPC endpoints without access to source protobufs.

The following examples uses grpculrl on CLI. We need to find a library to do the same programmatically during Atomkraft runtime.

Describing a query

$ grpcurl -plaintext <GRPC_IP:PORT> describe cosmos.staking.v1beta1.Query.Validator
cosmos.staking.v1beta1.Query.Validator is a method:
rpc Validator ( .cosmos.staking.v1beta1.QueryValidatorRequest ) returns ( .cosmos.staking.v1beta1.QueryValidatorResponse ) {
  option (.google.api.http) = { get:"/cosmos/staking/v1beta1/validators/{validator_addr}"  };
}

Performing the query

$ grpcurl -plaintext -d '{"validator_addr": "cosmosvaloper16k579jk6yt2cwmqx9dz5xvq9fug2tekvlu9qdv"}' <GRPC_IP:PORT> cosmos.staking.v1beta1.Query.Validator
{
  "validator": {
    "operatorAddress": "cosmosvaloper16k579jk6yt2cwmqx9dz5xvq9fug2tekvlu9qdv",
    "consensusPubkey": {"@type":"/cosmos.crypto.ed25519.PubKey","key":"pTcg/QVBC+LzpR0BuynDpMkNh4tajyeKCOtmWMfkvFU="},
    "status": "BOND_STATUS_BONDED",
    "tokens": "3217496887306",
    "delegatorShares": "3217818666723387338143077808531",
    "description": {
      "moniker": "Informal Systems",
...

The type_urls and proto files for Msg types can be retrieved from cosmos.base.reflection.v1beta1.ReflectionService and cosmos.base.reflection.v2alpha1.ReflectionService.

Listing all tx msg types

$ grpcurl -plaintext <GRPC_IP:PORT> cosmos.base.reflection.v2alpha1.ReflectionService.GetTxDescriptor
{
  "tx": {
    "fullname": "cosmos.tx.v1beta1.Tx",
    "msgs": [
      {
        "msgTypeUrl": "/ibc.core.channel.v1.MsgChannelOpenInit"
      },
      {
        "msgTypeUrl": "/ibc.core.channel.v1.MsgChannelCloseConfirm"
...

Describing a tx msg type

$ grpcurl -plaintext <GRPC_IP:PORT> describe ibc.core.channel.v1.MsgChannelOpenInit
ibc.core.channel.v1.MsgChannelOpenInit is a message:
message MsgChannelOpenInit {
  option (.gogoproto.equal) = false;
  option (.gogoproto.goproto_getters) = false;
  string port_id = 1 [(.gogoproto.moretags) = "yaml:\port_id\"];
  .ibc.core.channel.v1.Channel channel = 2 [(.gogoproto.nullable) = false];
  string signer = 3;
}

from atomkraft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.