Skip to main content

Cosmos Protobuf

This repository compains the whole cosmos protobuf files compiled for python and ready to use with grpc. Please use the according .proto file as documentation for each python file.

Installation

You can install this package directly from the repository by using:

python -m pip install sentinel-protobuf

Usage

The following code snippet will query the balances for the address osmo15hzhcvgs2ljfng6unghvr5l32prwqdyq4aguxn. The according query.proto file in the bank subdirectory contains the Request and the Response for this request. The details for the response are defined in QueryAllBalancesResponse. It contains the balances and pagination attribute which can be accessed as shown in the example below.

import grpc
import cosmospy_protobuf.cosmos.bank.v1beta1.query_pb2_grpc as query_pb2_grpc
import cosmospy_protobuf.cosmos.bank.v1beta1.query_pb2 as query_pb2

host = "osmosis.strange.love"
port = "9090"

c = grpc.insecure_channel(f'{host}:{port}')
stub = query_pb2_grpc.QueryStub(c)

r = stub.AllBalances(query_pb2.QueryAllBalancesRequest(address="osmo15hzhcvgs2ljfng6unghvr5l32prwqdyq4aguxn"))
print(r.balances)

Build yourself

There are two scripts helping you to fork this repository to work with any cosmos based coin.

Addititional Requirements:

  1. grpcio-tools
  2. GitPython
  3. protoletariat

Steps:

  1. Create a config in configs and take a existing one as example
  2. Run the aggregate.py file with your filename without .json (Example python aggregate.py cosmos)
  3. Run the compile.py to compile all your files to protobuf
  4. Build your package. You're done!

Protobuf compilation

The files are compiled using the grpc_tools.protoc command from the grpcio-tools library. To compile a .proto file manually use following command:

python -m grpc_tools.protoc -I <absolute path to project root> --python_out=. --grpc_python_out=. <absolute path to .proto file>

After compiling all the files with protoc you need to fix the imports by using protoletariat

Note:

  • The --grpc_python_out=. is only needed when compiling a query.proto file as these define the actual grpc query
  • To compile the whole project it is favorable to match all proto files by using *.proto instead of each individual file. You can also match the whole folders to compile multiple folders at the same time. Not that the folders might contain sub-folders.

Other Cosmos based coins

Currently following coins are maintained by me:

  • Cosmos (this branch)
  • Evmos (branch: chain/evmos, package name: evmos-protobuf)
  • Osmosis (branch: chain/osmosis, package name: osmosis-protobuf)
  • Stargaze (branch: chain/stargaze, package name: stargaze-protobuf)
  • Sentinel (branch: chain/sentinel, package name sentinel-protobuf)

Metadata

Release files for sentinel-protobuf 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sentinel-protobuf 0.2.1
File Size Uploaded Provenance Actions
sentinel_protobuf-0.2.1.tar.gz 240.6 kB Without provenance Details for sentinel_protobuf-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sentinel-protobuf 0.2.1
File Interpreter ABI Platform Actions
sentinel_protobuf-0.2.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for sentinel_protobuf-0.2.1-py2.py3-none-any.whl

Total release size: 735.0 kB

Release files / sentinel_protobuf-0.2.1.tar.gz

Download URL sentinel_protobuf-0.2.1.tar.gz
Size 240.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e731a8de07a0e650959f062ed3596609966345732daa1062888a7dcdaf4391e8
BLAKE2b-256 checksum
How to use checksums
398f867c65bbe43a4e3c5e6075a8780b07660006189cea441fd1e14a4bb06307
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.10

Release files / sentinel_protobuf-0.2.1-py2.py3-none-any.whl

Download URL sentinel_protobuf-0.2.1-py2.py3-none-any.whl
Size 494.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
de741712a8b6a45f46e01615d898d2726da3d026b647d1fc4ea25c71124f3623
BLAKE2b-256 checksum
How to use checksums
7540a865feebb8a1dd450a36ee93e73536f9628506285e001e1b25fff66c70d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.10

Security for sentinel-protobuf 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page