stargaze-protobuf


Namestargaze-protobuf JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryThis package contains a compiled python version of all cosmos protobuf files with their dependencies
upload_time2023-03-24 10:08:17
maintainer
docs_urlNone
author
requires_python
licenseBSD 3-Clause License
keywords proto protobuf stargaze stargaze-protobuf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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 cosmospy-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.  

```python
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.
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!
5. 
## Protobuf compilation 

The files are compiled using the ``grpc_tools.protoc`` command from the [grpcio-tools](https://pypi.org/project/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](https://github.com/cpcloud/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`)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "stargaze-protobuf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "proto,protobuf,stargaze,stargaze-protobuf",
    "author": "",
    "author_email": "ctrl-felix <dev@ctrl-felix.de>",
    "download_url": "https://files.pythonhosted.org/packages/74/c2/17b5dd50e41290ce69aac7751b1177328bdea3b1556cd0fd67b3136f317b/stargaze_protobuf-0.1.0.tar.gz",
    "platform": null,
    "description": "# Cosmos Protobuf\nThis 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.\n\n## Installation\n\nYou can install this package directly from the repository by using:\n```\npython -m pip install cosmospy-protobuf\n```\n\n## Usage\n\nThe 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.  \n\n```python\nimport grpc\nimport cosmospy_protobuf.cosmos.bank.v1beta1.query_pb2_grpc as query_pb2_grpc\nimport cosmospy_protobuf.cosmos.bank.v1beta1.query_pb2 as query_pb2\n\nhost = \"osmosis.strange.love\"\nport = \"9090\"\n\nc = grpc.insecure_channel(f'{host}:{port}')\nstub = query_pb2_grpc.QueryStub(c)\n\nr = stub.AllBalances(query_pb2.QueryAllBalancesRequest(address=\"osmo15hzhcvgs2ljfng6unghvr5l32prwqdyq4aguxn\"))\nprint(r.balances)\n\n```\n\n## Build yourself\nThere are two scripts helping you to fork this repository to work with any cosmos based coin.\n1. Create a config in ``configs`` and take a existing one as example\n2. Run the ``aggregate.py`` file with your filename without ``.json`` (Example ``python aggregate.py cosmos``)\n3. Run the ``compile.py`` to compile all your files to protobuf\n4. Build your package. You're done!\n5. \n## Protobuf compilation \n\nThe files are compiled using the ``grpc_tools.protoc`` command from the [grpcio-tools](https://pypi.org/project/grpcio-tools/) library.\nTo compile a .proto file manually use following command:\n```\npython -m grpc_tools.protoc -I <absolute path to project root> --python_out=. --grpc_python_out=. <absolute path to .proto file>\n```\n\nAfter compiling all the files with protoc you need to fix the imports by using [protoletariat](https://github.com/cpcloud/protoletariat)\n\nNote:\n* The --grpc_python_out=. is only needed when compiling a query.proto file as these define the actual grpc query\n* 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.\n\n## Other Cosmos based coins\nCurrently following coins are maintained by me:\n* Cosmos (this branch)\n* Evmos (branch: ``chain/evmos``, package name: ``evmos-protobuf``)\n* Osmosis (branch: ``chain/osmosis``, package name: `osmosis-protobuf`)\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License",
    "summary": "This package contains a compiled python version of all cosmos protobuf files with their dependencies",
    "version": "0.1.0",
    "split_keywords": [
        "proto",
        "protobuf",
        "stargaze",
        "stargaze-protobuf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "41633edc001355470afb1c6d93d60806b9dc73f4bd3f6b1def9b67ede5880afd",
                "md5": "ad7b3c2aa076a727ff3b683bc1b2db8a",
                "sha256": "ec57579e0adcb1099a26509c94bf4297138e1e15b1cb0a00e1b6f7b24878f7c6"
            },
            "downloads": -1,
            "filename": "stargaze_protobuf-0.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ad7b3c2aa076a727ff3b683bc1b2db8a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 598127,
            "upload_time": "2023-03-24T10:07:39",
            "upload_time_iso_8601": "2023-03-24T10:07:39.226338Z",
            "url": "https://files.pythonhosted.org/packages/41/63/3edc001355470afb1c6d93d60806b9dc73f4bd3f6b1def9b67ede5880afd/stargaze_protobuf-0.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74c217b5dd50e41290ce69aac7751b1177328bdea3b1556cd0fd67b3136f317b",
                "md5": "2e87820505b8c70cba3c1f57dd87e091",
                "sha256": "1e8b5ebd381cfe47e44231faf3d37386a5c3c43a1e46bf5b21477302115d581e"
            },
            "downloads": -1,
            "filename": "stargaze_protobuf-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2e87820505b8c70cba3c1f57dd87e091",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25912148,
            "upload_time": "2023-03-24T10:08:17",
            "upload_time_iso_8601": "2023-03-24T10:08:17.549816Z",
            "url": "https://files.pythonhosted.org/packages/74/c2/17b5dd50e41290ce69aac7751b1177328bdea3b1556cd0fd67b3136f317b/stargaze_protobuf-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-24 10:08:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "stargaze-protobuf"
}
        
Elapsed time: 0.05051s