Package: sentinel-protobuf
Cosmos ProtobufThis 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.InstallationYou can install this package directly from the repository by using:python -m pip install sentinel-protobufUsageThe following code snippet will query the balances for the addressosmo15hzhcvgs2ljfng6unghvr5l32prwqdyq4aguxn. 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 inQueryAllBalancesResponse. It contains the balances and pagination attribute which can be accessed as shown in the example below.importgrpcimportcosmospy_protobuf.cosmos.bank.v1beta1.query_pb2_grpcasquery_pb2_grpcimportcosmospy_protobuf.cosmos.bank.v1beta1.query_pb2asquery_pb2host="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 exampleThe following code snippet will query all the subscription for sentnode123importgrpcfromsentinel_protobuf.sentinel.subscription.v2.subscription_pb2importNodeSubscriptionfromsentinel_protobuf.sentinel.subscription.v2.querier_pb2importQuerySubscriptionsForNodeRequestfromsentinel_protobuf.sentinel.subscription.v2.querier_pb2_grpcimportQueryServiceStub# 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"))forsubscriptioninresponse.subscriptions:print(NodeSubscription.FromString(subscription.value))Build yourselfThere are two scripts helping you to fork this repository to work with any cosmos based coin.Addititional Requirements:grpcio-toolsGitPythonprotoletariatSteps:Create a config inconfigsand take a existing one as exampleRun theaggregate.pyfile with your filename without.json(Examplepython aggregate.py cosmos)Run thecompile.pyto compile all your files to protobufBuild your package. You're done!Protobuf compilationThe files are compiled using thegrpc_tools.protoccommand from thegrpcio-toolslibrary.
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 usingprotoletariatNote:The --grpc_python_out=. is only needed when compiling a query.proto file as these define the actual grpc queryTo 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 coinsCurrently 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)