cosmospy-protobuf


Namecosmospy-protobuf JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummaryThis package contains a compiled python version of all cosmos protobuf files with their dependencies
upload_time2023-11-27 18:33:33
maintainer
docs_urlNone
author
requires_python
licenseBSD 3-Clause License
keywords cosmos cosmos-protobuf cosmospy cosmospy-protobuf proto protobuf
VCS
bugtrack_url
requirements grpcio-tools
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 # using grpcio
import cosmospy_protobuf.cosmos.bank.v1beta1.query_pb2_grpc as query_pb2_grpc # for gprcio
#import cosmospy_protobuf.cosmos.bank.v1beta1.query_grpc as query_grpc # for gprclib
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. `grpclib`
3. `GitPython`
4. `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](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=. --grpclib_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=. and --grpclib_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`)

Maintained by external contributors:

- Sentinel (branch: `chain/sentinel`, package name: `sentinel-protobuf`)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cosmospy-protobuf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "cosmos,cosmos-protobuf,cosmospy,cosmospy-protobuf,proto,protobuf",
    "author": "",
    "author_email": "ctrl-felix <dev@ctrl-felix.de>",
    "download_url": "https://files.pythonhosted.org/packages/ee/ff/52e0ca3d2990e55fa9f28bc95005a040480bd3e2ac8519712532ca0672db/cosmospy_protobuf-0.4.0.tar.gz",
    "platform": null,
    "description": "# Cosmos Protobuf\n\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\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 # using grpcio\nimport cosmospy_protobuf.cosmos.bank.v1beta1.query_pb2_grpc as query_pb2_grpc # for gprcio\n#import cosmospy_protobuf.cosmos.bank.v1beta1.query_grpc as query_grpc # for gprclib\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\n\nThere are two scripts helping you to fork this repository to work with any cosmos based coin.\n\nAddititional Requirements:\n\n1. `grpcio-tools`\n2. `grpclib`\n3. `GitPython`\n4. `protoletariat`\n\nSteps:\n\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!\n\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\n```\npython -m grpc_tools.protoc -I <absolute path to project root> --python_out=. --grpc_python_out=. --grpclib_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\n- The --grpc_python_out=. and --grpclib_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\n\nCurrently following coins are maintained by me:\n\n- Cosmos (this branch)\n- Evmos (branch: `chain/evmos`, package name: `evmos-protobuf`)\n- Osmosis (branch: `chain/osmosis`, package name: `osmosis-protobuf`)\n- Stargaze (branch: `chain/stargaze`, package name: `stargaze-protobuf`)\n\nMaintained by external contributors:\n\n- Sentinel (branch: `chain/sentinel`, package name: `sentinel-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.4.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/ctrl-Felix/cosmospy-protobuf/issues",
        "Homepage": "https://github.com/ctrl-Felix/cosmospy-protobuf/"
    },
    "split_keywords": [
        "cosmos",
        "cosmos-protobuf",
        "cosmospy",
        "cosmospy-protobuf",
        "proto",
        "protobuf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "95667fffcc56f3cc220fb69fc220176f0eca6b5aea6881f244906e575f045de8",
                "md5": "4edb434eeac13fbaef9308c4f1ec4859",
                "sha256": "4f08f6461604cf858f2eefc9592b3d911e8db3c11115015615cada99c8f78066"
            },
            "downloads": -1,
            "filename": "cosmospy_protobuf-0.4.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4edb434eeac13fbaef9308c4f1ec4859",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 608872,
            "upload_time": "2023-11-27T18:33:08",
            "upload_time_iso_8601": "2023-11-27T18:33:08.270231Z",
            "url": "https://files.pythonhosted.org/packages/95/66/7fffcc56f3cc220fb69fc220176f0eca6b5aea6881f244906e575f045de8/cosmospy_protobuf-0.4.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eeff52e0ca3d2990e55fa9f28bc95005a040480bd3e2ac8519712532ca0672db",
                "md5": "e1f085cf1871d301950ef4f30abda6ae",
                "sha256": "06a3fabb4983c34b083f7f141f7bf7434ede0fa726fafecb1921f3dec31233e7"
            },
            "downloads": -1,
            "filename": "cosmospy_protobuf-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e1f085cf1871d301950ef4f30abda6ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 21422797,
            "upload_time": "2023-11-27T18:33:33",
            "upload_time_iso_8601": "2023-11-27T18:33:33.015921Z",
            "url": "https://files.pythonhosted.org/packages/ee/ff/52e0ca3d2990e55fa9f28bc95005a040480bd3e2ac8519712532ca0672db/cosmospy_protobuf-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-27 18:33:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ctrl-Felix",
    "github_project": "cosmospy-protobuf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "grpcio-tools",
            "specs": [
                [
                    ">=",
                    "1.46.3"
                ]
            ]
        }
    ],
    "lcname": "cosmospy-protobuf"
}
        
Elapsed time: 0.38865s