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)
Sentinel example
The following code snippet will query all the subscription for sentnode123
import grpc
from sentinel_protobuf.sentinel.subscription.v2.subscription_pb2 import NodeSubscription
from sentinel_protobuf.sentinel.subscription.v2.querier_pb2 import QuerySubscriptionsForNodeRequest
from sentinel_protobuf.sentinel.subscription.v2.querier_pb2_grpc import QueryServiceStub
# channel = grpc.secure_channel("host:port", grpc.ssl_channel_credentials())
channel = grpc.insecure_channel("grpc.sentinel.co:9090")
stub = QueryServiceStub(channel)
response = stub.QuerySubscriptionsForNode(QuerySubscriptionsForNodeRequest(address="sentnode123"))
for subscription in response.subscriptions:
print(NodeSubscription.FromString(subscription.value))
Build yourself
There are two scripts helping you to fork this repository to work with any cosmos based coin.
Addititional Requirements:
grpcio-toolsGitPythonprotoletariat
Steps:
- Create a config in
configsand take a existing one as example - Run the
aggregate.pyfile with your filename without.json(Examplepython aggregate.py cosmos) - Run the
compile.pyto compile all your files to protobuf - 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
*.protoinstead 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 namesentinel-protobuf)
Metadata
Release files for sentinel-protobuf 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sentinel_protobuf-0.5.1.tar.gz | 1.5 MB | Without provenance | Details for sentinel_protobuf-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sentinel_protobuf-0.5.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for sentinel_protobuf-0.5.1-py2.py3-none-any.whl |
Total release size: 3.0 MB
Release files / sentinel_protobuf-0.5.1.tar.gz
| Download URL | sentinel_protobuf-0.5.1.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a89d7e588d4cdd802ab00bf769677975989a3bbbe7804d6f19d704594f637d8c
|
|
BLAKE2b-256 checksum How to use checksums |
36d8eb059b04ed87214a34bd12fdef9e7b59c7e3e0ff40411bfbd5313f728ed5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.18
|
Release files / sentinel_protobuf-0.5.1-py2.py3-none-any.whl
| Download URL | sentinel_protobuf-0.5.1-py2.py3-none-any.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
00d3e33414342f60c4c999ffc4596a8721a75f717f4aee20868ef9e515a1a21f
|
|
BLAKE2b-256 checksum How to use checksums |
4b7f8d0d334636f393588b4d3fb9841be007cd33e725722dc7890af8e0610fe8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.18
|
Security for sentinel-protobuf 0.5.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.