sharingiscaring 0.4.40
Shared code for Concordium Explorer (Bot)
License: MIT

# Sharing is Caring

This repository hosts the shared code used by many of the other repositories in the Concordium 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

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

### Prerequisites

What things you need to install the software and how to install them

```
Give examples
```

### Installing

A step by step series of examples that tell you how to get a development env running

Say what the step will be

```
Give the example
```

And repeat

```
until finished
```

End with an example of getting some data out of the system or using it for a little demo

## Running the tests

Explain how to run the automated tests for this system

### Break down into end to end tests

Explain what these tests test and why

```
Give an example
```

### And coding style tests

Explain what these tests test and why

```
Give an example
```

## Deployment

Add additional notes about how to deploy this on a live system

## Built With

* [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
* [Maven](https://maven.apache.org/) - Dependency Management
* [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds

## Contributing

Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). 

## Authors

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

## License

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