ccdefundamentals


Nameccdefundamentals JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/ccdexplorer/ccdefundamentals
SummaryShared code for CCDExplorer.io and its Notification Bot.
upload_time2024-03-17 14:58:57
maintainer
docs_urlNone
authorSander de Ruiter
requires_python
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
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).
* 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.


## 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.

#### 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/ccdefundamentals",
    "name": "ccdefundamentals",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Sander de Ruiter",
    "author_email": "sdr@ccdexplorer.io",
    "download_url": "https://files.pythonhosted.org/packages/79/75/4d996c3670ce89780add1d845ea490edca2da35f313fed2fa626052a68a2/ccdefundamentals-0.1.6.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).\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.\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.\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.1.6",
    "project_urls": {
        "Homepage": "https://github.com/ccdexplorer/ccdefundamentals"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b2f9c8a5f0ec5efc531c8b831e39e94001a0c3d0e433ee4430f5f1eb301904a",
                "md5": "8c4ce0ceaad5cee1b48754315fd5cce8",
                "sha256": "af1ba9ef5211ab2a670fda0fef5534632f032ec12d9f4f30593c7dbe60c2c1b5"
            },
            "downloads": -1,
            "filename": "ccdefundamentals-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c4ce0ceaad5cee1b48754315fd5cce8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 201878,
            "upload_time": "2024-03-17T14:58:55",
            "upload_time_iso_8601": "2024-03-17T14:58:55.916390Z",
            "url": "https://files.pythonhosted.org/packages/7b/2f/9c8a5f0ec5efc531c8b831e39e94001a0c3d0e433ee4430f5f1eb301904a/ccdefundamentals-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "79754d996c3670ce89780add1d845ea490edca2da35f313fed2fa626052a68a2",
                "md5": "5161b397c6ec45cfdc3ffd2d11270c61",
                "sha256": "9e715e876f9ad737d1fdabcef51229d7b27a81924ee313b52c3e91abb79a58db"
            },
            "downloads": -1,
            "filename": "ccdefundamentals-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "5161b397c6ec45cfdc3ffd2d11270c61",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 166120,
            "upload_time": "2024-03-17T14:58:57",
            "upload_time_iso_8601": "2024-03-17T14:58:57.479548Z",
            "url": "https://files.pythonhosted.org/packages/79/75/4d996c3670ce89780add1d845ea490edca2da35f313fed2fa626052a68a2/ccdefundamentals-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-17 14:58:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ccdexplorer",
    "github_project": "ccdefundamentals",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ccdefundamentals"
}
        
Elapsed time: 0.23299s