ctrl-Felix / cosmospy-protobuf

Cosmos Protobuf library
16 stars 14 forks source link

Cannot convert response message to JSON #18

Open tdiesler opened 11 months ago

tdiesler commented 11 months ago
import grpc
import osmosis_protobuf.osmosis.gamm.v1beta1.query_pb2_grpc as query_grpc
import osmosis_protobuf.osmosis.gamm.v1beta1.query_pb2 as query
from google.protobuf.json_format import MessageToJson

    c = grpc.insecure_channel('grpc.osmosis.zone:9090')
    stub = query_grpc.QueryStub(c)
    res: query.QueryPoolResponse = stub.Pool(query.QueryPoolRequest(pool_id=708))
    res = MessageToJson(res)

gives ...

      except KeyError as e:
>       raise TypeError(
            'Can not find message descriptor by type_url: {0}'.format(type_url)
          ) from e
E       TypeError: Can not find message descriptor by type_url: /osmosis.gamm.v1beta1.Pool

MessageToDict fails in the same way.

How would I read the nested content of QueryPoolResponse? cheers

I can do ...

grpcurl -plaintext -d '{"pool_id": 704}' grpc.osmosis.zone:9090 osmosis.gamm.v1beta1.Query.Pool | jq
tdiesler commented 11 months ago

I'm using osmosis-protobuf-0.3.1