Skip to content

Commit

Permalink
Refactoring to mint on c chain (#21)
Browse files Browse the repository at this point in the history
MintRequest - implementation of mint() and buy(); refactoring; changes to README.md
---------

Co-authored-by: evlekht <[email protected]>
Co-authored-by: Ekrem Seren <[email protected]>
Co-authored-by: Mohamed Elmoslemany <[email protected]>
  • Loading branch information
4 people authored Jun 25, 2024
1 parent a22d8ee commit bd1cbcf
Show file tree
Hide file tree
Showing 20 changed files with 1,713 additions and 626 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ build
.vscode
.idea
*.iml

camino-messenger-bot-supplier.yaml
camino-messenger-bot-distributor.yaml

distributor-matrix.db
supplier-matrix.db

coverage.out
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ RUN apk add --no-cache olm-dev
WORKDIR /

COPY --from=build-stage /camino-messenger-bot/bot /camino-messenger-bot
COPY abi /abi

ENTRYPOINT ["./camino-messenger-bot"]
ENTRYPOINT ["./camino-messenger-bot"]
95 changes: 66 additions & 29 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,42 @@ Camino-Messenger-Bot is designed to facilitate communication through various mes
## Components

1. **Messenger**
- The Messenger component declares a decoupled messenger interface with the functionalities that include sending and receiving messages asynchronously.

- The Messenger component declares a decoupled messenger interface with the functionalities that include sending and receiving messages asynchronously.

Currently, the only concrete implementation is the `matrix-messenger`, which utilizes the [Mautrix Golang SDK](https://github.com/mautrix/go) for the Matrix client. Note that the `mautrix` dependency requires the `olm` C library during both build time and runtime.

2. **Message Processor**
- The Message Processor utilizes the Messenger to receive and process messages.

- The Message Processor utilizes the Messenger to receive and process messages.

3. **gRPC Server**
- This component acts as a Message Request gateway, accepting protobuf messages. These requests are then forwarded to the Message Processor.

- This component acts as a Message Request gateway, accepting protobuf messages. These requests are then forwarded to the Message Processor.

4. **gRPC Client**
- The gRPC Client communicates with a middleware or "partner-plugin" via gRPC, exchanging protobuf messages. The middleware handles necessary conversions and interacts with the external system of the partner. It's important to note that the middleware is not part of this application.
- The gRPC Client communicates with a middleware or "partner-plugin" via gRPC, exchanging protobuf messages. The middleware handles necessary conversions and interacts with the external system of the partner. It's important to note that the middleware is not part of this application.

## Camino Messenger Protocol (CMP)

## Dependencies
This application depends on the [camino-messenger-protocol](https://github.com/chain4travel/camino-messenger-protocol), which is a separate repository. The protocol defines the protobuf messages and services used for communication between the gRPC server and client.

Version used: [release-2](https://github.com/chain4travel/camino-messenger-protocol/releases/tag/release-2)
Currently [release-6](https://github.com/chain4travel/camino-messenger-protocol/releases/tag/release-6) of Camino Messenger Protocol is used.

## Examples and Docker Support

The repository includes examples demonstrating the setup of gRPC servers and clients under the `examples` folder. Additionally, Dockerfiles and a docker-compose.yml file are provided to simplify the deployment of a provider, distributor bot, and a partner plugin application that mocks responses.

## Getting Started

### Install required olm library
### Install required `olm` library

Certainly! The installation of the `olm` library may vary depending on the operating system. Here are instructions for Linux (Debian and Ubuntu) and Windows:
Below are instructions for installing the `olm` library for Linux (Debian and Ubuntu) and macOS:

#### Linux (Debian/Ubuntu)

1. **Update Package Lists:**

```bash
sudo apt update
```
Expand All @@ -47,52 +52,84 @@ Certainly! The installation of the `olm` library may vary depending on the opera

#### macOS

1. **Install Homebrew:**
If you don't have Homebrew installed, you can install it by following the instructions on [https://brew.sh/](https://brew.sh/).
1. **Update Homebrew:**

2. **Update Homebrew:**
```bash
brew update
```

3. **Install libolm:**
> [!TIP]
> If you don't have Homebrew installed, you can install it by following
> the instructions on [https://brew.sh/](https://brew.sh/).
2. **Install libolm:**
```bash
brew install libolm
```
#### Verify Installation
## Build
After installing `olm`, you can verify its installation by checking the library version:
Use the provided build script to build the application. This will create a binary in the `./build` directory.
```bash
olm --version
./scripts/build.sh
```
This command should print the installed `olm` version.
## Run
Note: The provided instructions assume a certain level of system familiarity. Adjustments might be necessary based on your specific setup or if you encounter any issues during the installation process.
### Configuration
### Build
Use the provided example configuration files for suppliers
(`camino-messenger-bot-supplier.yaml.example`) and distributors
(`camino-messenger-bot-distributor.yaml.example`).
```bash
go build -o bot cmd/camino-messenger-bot/main.go
```
### Create Configuration
Copy them accordingly and edit fields, mainly the private keys. Most of the default
values should be fine for testing.
Create a configuration YAML file based on the provided example "camino-messenger-bot.yaml.example".
> [!IMPORTANT]
> Keep in mind that the addresses of `evm_private_key` in the config file needs to
> have funds on C-Chain to pay for the transaction fees. (If you are using **MintRequest**)
### Start the Application
Start the bot using the related config file depending on your need.
**Supplier Bot:**
```bash
./bot --config camino-messenger-bot.yaml
./build/bot --config camino-messenger-bot-supplier.yaml
```
**Distributor Bot:**
```bash
./build/bot --config camino-messenger-bot-distributor.yaml
```
> [!TIP]
> For testing and development, you can also start two bots, one supplier and one distributor.
Feel free to explore and customize the application based on your specific requirements. If you encounter any issues or have questions, please refer to the documentation or open an issue in the repository.
### Running partner plugin example
Run the partner plugin, setting the `PORT` env as defined in your supplier bot
configuration file's `partner_plugin_port` field, e.g.:

```bash
PORT=50051 go run examples/rpc/partner-plugin/server.go
```

## Tracing
The application supports tracing by providing an otel (OpenTelemetry) sdk implementation adding traces to all requests and responses.

The application supports tracing by providing an otel (OpenTelemetry) sdk
implementation adding traces to all requests and responses.

Traces cross the boundaries of the application by using traceIDs and context propagation.
The tracing configuration can be set in the configuration file.
By default, tracing is disabled. For the moment the application uses a Jaeger exporter to send the traces to a Jaeger instance.
A future improvement could include an otel collector as the middle stop for traces and feed to them different tracing systems.

The tracing configuration can be set in the configuration file. By default, tracing
is disabled.

For the moment the application uses a Jaeger exporter to send the traces to a Jaeger
instance. A future improvement could include an otel collector as the middle stop
for traces and feed to them different tracing systems.
Loading

0 comments on commit bd1cbcf

Please sign in to comment.