Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: packages and apps #28

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,33 @@ Grants Stack Indexer v2 is a tool designed to index blockchain events generated

## 📖 Overview

This repository is a monorepo that contains 1 package and 2 applications:
This repository is a monorepo that contains 8 packages and 3 applications:

- @ts-turborepo-boilerplate/sample-lib: A sample library for querying account balances.
- @ts-turborepo-boilerplate/sample-app: A demo application demonstrating the use of sample-lib.
- @grants-stack-indexer/indexer: An [`envio`](https://docs.envio.dev/) indexer, that collects all the relevant events from Allo contracts.
### Applications

- **@grants-stack-indexer/indexer**: An Envio indexer service that collects relevant events from Allo contracts. It is designed to run on the Envio hosted platform and includes a Dockerfile for deployment.

- **@grants-stack-indexer/processing**: This service runs the core processing pipeline, coordinating components from various packages to process blockchain events. It manages an Orchestrator per chain.

- **@grants-stack-indexer/scripts**: Contains scripts for managing the database schema and migrations. It includes scripts for running migrations and resetting the database schema.

### Packages/libs

- **@grants-stack-indexer/chain-providers**: Provides wrappers of the Viem library to interact with EVM-based blockchains. It includes utilities for reading contracts and making batch requests.

- **@grants-stack-indexer/data-flow**: Manages the flow of data between different components of the indexer. It includes core components for the processing pipeline.

- **@grants-stack-indexer/indexer-client**: A client library for interacting with blockchain event indexing services. It provides methods to fetch events by block number and log index.

- **@grants-stack-indexer/metadata**: Handles metadata related to the indexed events. It provides a metadata provider to retrieve metadata from IPFS.

- **@grants-stack-indexer/pricing**: Manages pricing data and calculations. It includes providers to get the price of a token at a specific timestamp using chainId and token address.

- **@grants-stack-indexer/processors**: Contains various data processors used in the indexing pipeline. It includes processors for handling Allo, Strategy, and Registry events.

- **@grants-stack-indexer/repository**: Manages the storage and retrieval of indexed data. It implements the Repository pattern to abstract database operations.

- **@grants-stack-indexer/shared**: Provides shared utilities, types, constants, and logger. It is designed to be used across the packages of the monorepo to ensure consistency and reusability.

## 🚀 Local Deployment (Development)

Expand Down
28 changes: 27 additions & 1 deletion packages/data-flow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Available scripts that can be run using `pnpm`:
You can import the package in your TypeScript or JavaScript files as follows:

```typescript
import { EventsFetcher } from "@grants-stack-indexer/data-flow";
import { EventsFetcher, Orchestrator, EventsRegistry, EventsFetcher, EventsProcessor } from "@grants-stack-indexer/data-flow";
```

### Example
Expand All @@ -43,3 +43,29 @@ const result = await eventsFetcher.fetcEventsByBlockNumberAndLogIndex(
logIndex,
);
```

## API

### [Orchestrator](./src/orchestrator.ts)

The `Orchestrator` class is responsible for orchestrating the processing pipeline for the gitcoin grants-stack-indexer.

### [EventsRegistry](./src/eventsRegistry.ts)

The `EventsRegistry` class is responsible for registering processed events in the processing pipeline.

### [EventsProcessor](./src/eventsProcessor.ts)

The `EventsProcessor` class is responsible for processing events in the processing pipeline.

### [EventsFetcher](./src/eventsFetcher.ts)

The `EventsFetcher` class is responsible for fetching events from the blockchain.

### [StrategyRegistry](./src/strategyRegistry.ts)

The `StrategyRegistry` stores strategy IDs in memory to populate strategy events with them.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `StrategyRegistry` stores strategy IDs in memory to populate strategy events with them.
The `StrategyRegistry` stores strategy IDs to populate strategy events with them given the Strategy address.


### [DataLoader](./src/data-loader/dataLoader.ts)

The `DataLoader` is responsible for applying changesets to the database..
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `DataLoader` is responsible for applying changesets to the database..
The `DataLoader` is responsible for applying changesets to the database.

42 changes: 41 additions & 1 deletion packages/indexer-client/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @grants-stack-indexer/indexer-client

Is library for interacting with blockchain event indexing services.
This is a library for interacting with blockchain event indexing services.

## Available Scripts

Expand All @@ -18,6 +18,34 @@ Available scripts that can be run using `pnpm`:
| `test` | Run tests using vitest |
| `test:cov` | Run tests with coverage report |

## 📋 Prerequisites

- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed.

## Installation

```bash
$ pnpm install
```

## Building

To build the monorepo packages, run:

```bash
$ pnpm build
```

## Test

```bash
# unit tests
$ pnpm run test

# test coverage
$ pnpm run test:cov
```

## Usage

### Importing the Package
Expand All @@ -34,3 +62,15 @@ import { EnvioIndexerClient } from "@grants-stack-indexer/indexer-client";
const envioIndexerClient = new EnvioIndexerClient("http://example.com/graphql", "secret");
await envioIndexerClient.getEventsByBlockNumberAndLogIndex(1, 12345, 0);
```

## API

### [IIndexerClient](./src/interfaces/indexerClient.interface.ts)

Available methods

- `getEventsAfterBlockNumberAndLogIndex(chainId: ChainId, fromBlock: number, logIndex: number, limit?: number): Promise<AnyIndexerFetchedEvent[]>`

## References

- [Envio](https://docs.envio.dev/docs/HyperIndex/overview)
28 changes: 28 additions & 0 deletions packages/metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ Available scripts that can be run using `pnpm`:
| `test` | Run tests using vitest |
| `test:cov` | Run tests with coverage report |

## 📋 Prerequisites

- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed.

## Installation

```bash
$ pnpm install
```

## Building

To build the monorepo packages, run:

```bash
$ pnpm build
```

## Test

```bash
# unit tests
$ pnpm run test

# test coverage
$ pnpm run test:cov
```

## Usage

### Importing the Package
Expand Down
28 changes: 28 additions & 0 deletions packages/pricing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ Available scripts that can be run using `pnpm`:
| `test` | Run tests using vitest |
| `test:cov` | Run tests with coverage report |

## 📋 Prerequisites

- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed.

## Installation

```bash
$ pnpm install
```

## Building

To build the monorepo packages, run:

```bash
$ pnpm build
```

## Test

```bash
# unit tests
$ pnpm run test

# test coverage
$ pnpm run test:cov
```

## Usage

### Importing the Package
Expand Down
51 changes: 46 additions & 5 deletions packages/processors/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# grants-stack-indexer: processors package
# Grants stack indexer v2 `processors` package

Description of your package goes here.
The `processors` package provides a set of utilities for processing and transforming data within the grants stack indexer project. It includes processors for handling Allo, Strategy, and Registry events.

## Setup

Expand All @@ -22,14 +22,55 @@ Available scripts that can be run using `pnpm`:
| `test` | Run tests using vitest |
| `test:cov` | Run tests with coverage report |

## 📋 Prerequisites

- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed.

## Installation

```bash
$ pnpm install
```

## Building

To build the monorepo packages, run:

```bash
$ pnpm build
```

## Test

```bash
# unit tests
$ pnpm run test

# test coverage
$ pnpm run test:cov
```

## Usage

Describe how to use your package here.
```typescript
import { AlloProcessor } from "@grants-stack-indexer/processors";

const alloProcessor = new AlloProcessor(chainId, dependencies);
const changeset = await this.alloProcessor.process(event);
```

## API

Describe your package's API here.
### Processors

This package provides the following repositories:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This package provides the following repositories:
This package provides the following events' processors:


1. **AlloProcessor**: Handles the processing of Allo V2 events from the Allo contract by delegating them to the appropriate handler

2. **RegistryProcessor**: Handles the processing of Allo V2 events from the Registry contract by delegating them to the appropriate handler

3. **StrategyProcessor**: Handles the processing of Allo V2 events from the Strategy contract by delegating them to the appropriate handler

## References

Add any relevant references here.
- [Allo Protocol](https://github.com/allo-protocol/allo-v2)
3 changes: 3 additions & 0 deletions packages/processors/src/allo/allo.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import type { IProcessor, ProcessorDependencies } from "../internal.js";
import { UnsupportedEventException } from "../internal.js";
import { PoolCreatedHandler } from "./handlers/index.js";

/**
* AlloProcessor handles the processing of Allo V2 events by delegating them to the appropriate handler
*/
export class AlloProcessor implements IProcessor<"Allo", AlloEvent> {
constructor(
private readonly chainId: ChainId,
Expand Down
30 changes: 30 additions & 0 deletions packages/repository/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ Available scripts that can be run using `pnpm`:
| `test` | Run tests using Vitest |
| `test:cov` | Run tests with coverage report |

## 📋 Prerequisites

- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed.

## Installation

```bash
$ pnpm install
```

## Building

To build the monorepo packages, run:

```bash
$ pnpm build
```

## Test

```bash
# unit tests
$ pnpm run test

# test coverage
$ pnpm run test:cov
```

## Usage

This package provides repository interfaces and implementations for projects and rounds. It uses Kysely as the query builder library.
Expand Down Expand Up @@ -53,6 +81,8 @@ This package provides the following repositories:

2. **IRoundRepository**: Manages round-related database operations, including round roles and pending roles.

3. **IApplicationRepository**: Manages application-related database operations.

## References

- [Kysely](https://kysely.dev/)
Expand Down
Loading