ccdexplorer-fundamentals


Nameccdexplorer-fundamentals JSON
Version 0.2.37 PyPI version JSON
download
home_pagehttps://github.com/ccdexplorer/ccdexplorer-fundamentals
SummaryShared code for CCDExplorer.io and its Notification Bot.
upload_time2024-11-08 17:39:16
maintainerNone
docs_urlNone
authorSander de Ruiter
requires_pythonNone
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements rich python-dateutil base58 eth-hash pycryptodome pytest leb128 pydantic pymongo motor requests apprise py-graphql-client chardet pytest grpcio aiohttp python-dotenv grpcio-tools jsonschema-markdown pytest-asyncio
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CCD Explorer Fundamentals

This repository hosts the shared code used by many of the other repositories in the CCD Explorer Universe. The only way I knew how to make this work (locally and in Docker containers), is by publishing this repo as a Python package. 

Most important modules in the repo are:
* GRPCClient: this is the partial Python SDK that contains all relevant GRPC types and methods to request information from the GRPC endpoint from a node.
* MongoDB: this module contains the connection to the MongoDB instance (or replicaset). See the [Mongo Type Docs](/docs/mongo_types_docs.md) for more information. 
* Tooter: this module is a light wrapper around [Apprise](https://github.com/caronc/apprise), used to send notifications.
* CIS: this module contains logic to decode CIS-2 events according to the [CIS-2 Specifications](http://proposals.concordium.software/CIS/cis-2.html#cis-2-functions-tokenmetadata). This module is used in token accounting. See the [CIS Type Docs](/docs/cis_types_docs.md) for more information. 


## Modules
### GRPCClient
This module is implemented as a partial Python SDK for the GRPC endpoint for a node. As such, it needs to be updated regularly whenever new types and methods are added to the [GRPC Protocol Documentation](http://developer.concordium.software/concordium-grpc-api/). It relies heavily on [BetterProto](https://github.com/danielgtaylor/python-betterproto), however only version 2.0.0b6 seems to work. Hence, run
```
pip install "betterproto[compiler]"==2.0.0b6
```
to install this version.

BetterProto takes the `.proto` files from the [Concordium GRPC Api Repo](https://github.com/Concordium/concordium-grpc-api/tree/main/v2/concordium) and converts this into the neccesary classes. When an update is performed on the Concordium GRPC Api Repo, copy the new files to the same location and run the following command:

```
python -m grpc_tools.protoc -I. --python_out=. --pyi_out=. --grpc_python_out=. --python_betterproto_out=. service.proto
```

This will generate the new `_pb2.py(i)` files.

#### CCD_Types
When I started with this project, I didn't know the first thing about Protobuf. To be honest, I still don't, but I *have* found a way to manage this by creating my own classes, mirroring the classes as generated by the `types.proto` file . These classes are stored in a submodule called `CCD_Types`. This contains 165 classes and 55 type aliases. See the [GRPC Type Docs](/docs/grpc_types_docs.md) for more information.

#### Queries
The services in the `service.proto` file are mirrored in the `queries` submodule, where all relevant GRPC calls are built. These are the methods that other services call to retrieve specific information from the node. 

For every call to the node, it calls `grpc.channel_ready_future` to check if the service is ready (the node is able to respond to queries). Is this somehow fails, the module tries to connect to a different node (as supplied in the `ENV` variables).


## Getting Started

Almost none of the modules in this repo as useful as a standalone package, with the exception of the GRPC SDK. 

## ENV variables

```
NOTIFIER_API_TOKEN (API token for notifier bot)
API_TOKEN (API token for actual bot)
FASTMAIL_TOKEN (I use Fastmail to send email, leave blank, won't send email)
MONGO_URI (MongoDB URI)
ADMIN_CHAT_ID (Telegram admin chat ID)
MAILTO_LINK (I use Fastmail to send email, leave blank, won't send email)
MAILTO_USER (I use Fastmail to send email, leave blank, won't send email)
GRPC_MAINNET (A list of dicts with GPRC hosts) (Example: [{"host": "localhost", "port": 20000}, {"host": "my.validator.com", "port": 20000}])
GRPC_TESTNET (Same as GPRC_MAINNET)
```

### Tests

The CIS module and GRPC module have associated tests. 
## Authors

* **explorer.ccd** - *Everything* 

## License

This project is licensed under the Apache 2.0 License - see the [LICENSE.md](LICENSE.md) file for details.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ccdexplorer/ccdexplorer-fundamentals",
    "name": "ccdexplorer-fundamentals",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Sander de Ruiter",
    "author_email": "sdr@ccdexplorer.io",
    "download_url": "https://files.pythonhosted.org/packages/3b/49/b06897f72c3d380a9777f4b92dfaa637250d518617d3c78a7d24a650e518/ccdexplorer_fundamentals-0.2.37.tar.gz",
    "platform": null,
    "description": "# CCD Explorer Fundamentals\n\nThis repository hosts the shared code used by many of the other repositories in the CCD Explorer Universe. The only way I knew how to make this work (locally and in Docker containers), is by publishing this repo as a Python package. \n\nMost important modules in the repo are:\n* GRPCClient: this is the partial Python SDK that contains all relevant GRPC types and methods to request information from the GRPC endpoint from a node.\n* MongoDB: this module contains the connection to the MongoDB instance (or replicaset). See the [Mongo Type Docs](/docs/mongo_types_docs.md) for more information. \n* Tooter: this module is a light wrapper around [Apprise](https://github.com/caronc/apprise), used to send notifications.\n* CIS: this module contains logic to decode CIS-2 events according to the [CIS-2 Specifications](http://proposals.concordium.software/CIS/cis-2.html#cis-2-functions-tokenmetadata). This module is used in token accounting. See the [CIS Type Docs](/docs/cis_types_docs.md) for more information. \n\n\n## Modules\n### GRPCClient\nThis module is implemented as a partial Python SDK for the GRPC endpoint for a node. As such, it needs to be updated regularly whenever new types and methods are added to the [GRPC Protocol Documentation](http://developer.concordium.software/concordium-grpc-api/). It relies heavily on [BetterProto](https://github.com/danielgtaylor/python-betterproto), however only version 2.0.0b6 seems to work. Hence, run\n```\npip install \"betterproto[compiler]\"==2.0.0b6\n```\nto install this version.\n\nBetterProto takes the `.proto` files from the [Concordium GRPC Api Repo](https://github.com/Concordium/concordium-grpc-api/tree/main/v2/concordium) and converts this into the neccesary classes. When an update is performed on the Concordium GRPC Api Repo, copy the new files to the same location and run the following command:\n\n```\npython -m grpc_tools.protoc -I. --python_out=. --pyi_out=. --grpc_python_out=. --python_betterproto_out=. service.proto\n```\n\nThis will generate the new `_pb2.py(i)` files.\n\n#### CCD_Types\nWhen I started with this project, I didn't know the first thing about Protobuf. To be honest, I still don't, but I *have* found a way to manage this by creating my own classes, mirroring the classes as generated by the `types.proto` file . These classes are stored in a submodule called `CCD_Types`. This contains 165 classes and 55 type aliases. See the [GRPC Type Docs](/docs/grpc_types_docs.md) for more information.\n\n#### Queries\nThe services in the `service.proto` file are mirrored in the `queries` submodule, where all relevant GRPC calls are built. These are the methods that other services call to retrieve specific information from the node. \n\nFor every call to the node, it calls `grpc.channel_ready_future` to check if the service is ready (the node is able to respond to queries). Is this somehow fails, the module tries to connect to a different node (as supplied in the `ENV` variables).\n\n\n## Getting Started\n\nAlmost none of the modules in this repo as useful as a standalone package, with the exception of the GRPC SDK. \n\n## ENV variables\n\n```\nNOTIFIER_API_TOKEN (API token for notifier bot)\nAPI_TOKEN (API token for actual bot)\nFASTMAIL_TOKEN (I use Fastmail to send email, leave blank, won't send email)\nMONGO_URI (MongoDB URI)\nADMIN_CHAT_ID (Telegram admin chat ID)\nMAILTO_LINK (I use Fastmail to send email, leave blank, won't send email)\nMAILTO_USER (I use Fastmail to send email, leave blank, won't send email)\nGRPC_MAINNET (A list of dicts with GPRC hosts) (Example: [{\"host\": \"localhost\", \"port\": 20000}, {\"host\": \"my.validator.com\", \"port\": 20000}])\nGRPC_TESTNET (Same as GPRC_MAINNET)\n```\n\n### Tests\n\nThe CIS module and GRPC module have associated tests. \n## Authors\n\n* **explorer.ccd** - *Everything* \n\n## License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE.md](LICENSE.md) file for details.\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Shared code for CCDExplorer.io and its Notification Bot.",
    "version": "0.2.37",
    "project_urls": {
        "Homepage": "https://github.com/ccdexplorer/ccdexplorer-fundamentals"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "970a4d986c2f1feffd17b483f0c8c74cb663251df752e4d8dfc07c94854cecc4",
                "md5": "bf4d08c7b72a1039d37d4dc6dc1fa9f5",
                "sha256": "f57038f04639f49019e361f7a212219c888c651b8fd32bc568b7fc12c070bdce"
            },
            "downloads": -1,
            "filename": "ccdexplorer_fundamentals-0.2.37-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf4d08c7b72a1039d37d4dc6dc1fa9f5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 215169,
            "upload_time": "2024-11-08T17:39:12",
            "upload_time_iso_8601": "2024-11-08T17:39:12.689193Z",
            "url": "https://files.pythonhosted.org/packages/97/0a/4d986c2f1feffd17b483f0c8c74cb663251df752e4d8dfc07c94854cecc4/ccdexplorer_fundamentals-0.2.37-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b49b06897f72c3d380a9777f4b92dfaa637250d518617d3c78a7d24a650e518",
                "md5": "08a575a26cf2a9dae702e7dc0937e1df",
                "sha256": "744453bf089d33c5038541a25a4c31a1cdb883a428d0b7da98f234d10a9248ca"
            },
            "downloads": -1,
            "filename": "ccdexplorer_fundamentals-0.2.37.tar.gz",
            "has_sig": false,
            "md5_digest": "08a575a26cf2a9dae702e7dc0937e1df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 176427,
            "upload_time": "2024-11-08T17:39:16",
            "upload_time_iso_8601": "2024-11-08T17:39:16.784037Z",
            "url": "https://files.pythonhosted.org/packages/3b/49/b06897f72c3d380a9777f4b92dfaa637250d518617d3c78a7d24a650e518/ccdexplorer_fundamentals-0.2.37.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-08 17:39:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ccdexplorer",
    "github_project": "ccdexplorer-fundamentals",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "rich",
            "specs": []
        },
        {
            "name": "python-dateutil",
            "specs": []
        },
        {
            "name": "base58",
            "specs": []
        },
        {
            "name": "eth-hash",
            "specs": []
        },
        {
            "name": "pycryptodome",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "leb128",
            "specs": []
        },
        {
            "name": "pydantic",
            "specs": []
        },
        {
            "name": "pymongo",
            "specs": []
        },
        {
            "name": "motor",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "apprise",
            "specs": []
        },
        {
            "name": "py-graphql-client",
            "specs": []
        },
        {
            "name": "chardet",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "grpcio",
            "specs": []
        },
        {
            "name": "aiohttp",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "grpcio-tools",
            "specs": []
        },
        {
            "name": "jsonschema-markdown",
            "specs": []
        },
        {
            "name": "pytest-asyncio",
            "specs": []
        }
    ],
    "lcname": "ccdexplorer-fundamentals"
}
        
Elapsed time: 0.42705s