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

feat: all event handlers for allo contract #39

Merged
merged 3 commits into from
Dec 10, 2024
Merged

Conversation

0xkenj1
Copy link
Collaborator

@0xkenj1 0xkenj1 commented Nov 28, 2024

🤖 Linear

Closes GIT-137 GIT-149 GIT-150 GIT-151 GIT-152

Description

Added all the remaining handlers for Allo contract events.

Checklist before requesting a review

  • I have conducted a self-review of my code.
  • I have conducted a QA.
  • If it is a core feature, I have included comprehensive tests.

Copy link
Collaborator

@0xnigir1 0xnigir1 left a comment

Choose a reason for hiding this comment

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

nice ser 🙌 , some smol comments but great job

Comment on lines 23 to 24

async handle(): Promise<Changeset[]> {
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
async handle(): Promise<Changeset[]> {
/* @inheritdoc */
async handle(): Promise<Changeset[]> {

Comment on lines 31 to 33
if (!round) {
return [];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

i guess this was the original implementation but isn't it better to throw here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right

) {}

async handle(): Promise<Changeset[]> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch

Comment on lines 45 to 48
if (!round) {
logger.error(`Round not found for roundId: ${this.event.params.poolId.toString()}`);
return [];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same doubt here

Comment on lines 29 to 30

async handle(): Promise<Changeset[]> {
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
async handle(): Promise<Changeset[]> {
/* @inheritdoc */
async handle(): Promise<Changeset[]> {

import { getToken } from "@grants-stack-indexer/shared";

import type { IEventHandler, ProcessorDependencies } from "../../../internal.js";
import { getTokenAmountInUsd } from "../../../helpers/pricing.js";
Copy link
Collaborator

Choose a reason for hiding this comment

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

import from index.js

Comment on lines 24 to 25

async handle(): Promise<Changeset[]> {
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
async handle(): Promise<Changeset[]> {
/* @inheritdoc */
async handle(): Promise<Changeset[]> {

Comment on lines 23 to 24

async handle(): Promise<Changeset[]> {
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
async handle(): Promise<Changeset[]> {
/* @inheritdoc */
async handle(): Promise<Changeset[]> {

Comment on lines +11 to +34
function createMockEvent(
overrides: Partial<ProcessorEvent<"Allo", "PoolFunded">> = {},
): ProcessorEvent<"Allo", "PoolFunded"> {
return {
blockNumber: 116385567,
blockTimestamp: 1708369911,
chainId: 10 as ChainId,
contractName: "Allo",
eventName: "PoolFunded",
logIndex: 123,
srcAddress: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1",
params: {
poolId: "1",
amount: "100",
fee: "10",
},
transactionFields: {
hash: "0xtransactionhash",
transactionIndex: 5,
from: "0xsenderaddress",
},
...overrides,
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's a shared createMock function in event.mock.ts file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will skip this, since is not that straight forward to implement it for Allo events, will add it as a low priority tech debt

Copy link
Collaborator

@jahabeebs jahabeebs left a comment

Choose a reason for hiding this comment

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

Mostly same comments as nigiri ^

];
}

logger.warn(`No round found for role ${role} on chain ${this.chainId}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed this file has a logger warn but the others don't--maybe want to add loggers to the others?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yea, thats part of the issues to address from your feedback of the internal review

import { TokenPriceNotFoundError } from "../../../src/internal.js";
import { PoolMetadataUpdatedHandler } from "../../../src/processors/allo/handlers/index.js";

function createMockEvent(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can extract these out into a common file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same answer as for nigiri

Copy link
Collaborator

@0xnigir1 0xnigir1 left a comment

Choose a reason for hiding this comment

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

lgtm (what a way to get back from retreat ser xd)

@0xkenj1 0xkenj1 merged commit 1d83d5d into dev Dec 10, 2024
6 checks passed
@0xkenj1 0xkenj1 deleted the feat/allo-event-handlers branch December 10, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants