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: registry handlers #31

Merged
merged 7 commits into from
Nov 13, 2024
Merged

feat: registry handlers #31

merged 7 commits into from
Nov 13, 2024

Conversation

0xkenj1
Copy link
Collaborator

@0xkenj1 0xkenj1 commented Nov 12, 2024

🤖 Linear

Closes GIT-138 GIT-145 GIT-146 GIT-147 GIT-148

Description

All Registry contract event handlers.

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.

💯 really smol comments but nice ser

Comment on lines 21 to 22
) {}
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[]> {

or a more specific description

Comment on lines 11 to 13
/**
* Handles the ProfileMetadataUpdated event for the Registry contract from Allo protocol.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

i like adding here a general overview of the main actions performed by the handler

for example for PoolCreatedHandler

/**
 * Handles the PoolCreated event for the Allo protocol.
 *
 * This handler performs the following core actions when a new pool is created:
 * - Retrieves the metadata associated with the pool
 * - Determines the correct token address, handling native tokens appropriately.
 * - Extracts the correct strategy information from the provided strategy ID.
 * - Calculates the funded amount in USD based on the token's pricing.
 * - Creates a new round object
 */

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is great, i saw it on your prs 💯

Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto for description and inheritdoc

Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto for description and inheritdoc

Comment on lines 27 to 29
if (!project) {
return [];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we throw here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto for description and inheritdoc

Comment on lines 29 to 37
if (!parsedMetadata.success) {
// logger.warn({
// msg: `ProfileMetadataUpdated: Failed to parse metadata`,
// event,
// metadataCid,
// metadata,
// });
return [];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we throw or return empty?

Copy link
Collaborator

Choose a reason for hiding this comment

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

missing test cases for the newly created handlers

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 ser

@0xkenj1 0xkenj1 requested a review from 0xnigir1 November 12, 2024 22:32
0xnigir1
0xnigir1 previously approved these changes Nov 13, 2024
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.

great pr ⏭️ , just one comment but maybe i've mixed up things in my head

@@ -1,6 +1,6 @@
import { Address, ChainId } from "@grants-stack-indexer/shared";

export type ProjectType = "canonical" | "linked";
export type ProjectType = "canonical" | "linked" | "unknown";
Copy link
Collaborator

Choose a reason for hiding this comment

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

i thought we wouldn't use "unknown" as value

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

readonly chainId: ChainId,
private dependencies: Dependencies,
) {}
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.

/* @inheritdoc */ ?

@@ -5,3 +5,9 @@ export class ProjectNotFound extends Error {
super(`Project not found for chainId: ${chainId} and anchorAddress: ${anchorAddress}`);
}
}

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 the above exception should be called ProjectByAnchorNotFound since there are multiple of these but just a suggestion

metadata: [0, mockCid],
profileId: "mockProfileId",
},
// Add other necessary event properties here
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete or TODO?

@@ -9,7 +9,7 @@ import {
} from "@grants-stack-indexer/shared";

import { ProcessorDependencies } from "../../../src/internal.js";
import { RoleGrantedHandler } from "../../../src/registry/handlers/index.js"; // Adjust path if needed
import { RoleGrantedHandler } from "../../../src/processors/registry/handlers/index.js"; // Adjust path if needed
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment intentional?


const handler = new RoleRevokedHandler(mockEvent, mockChainId, mockDependencies);

await expect(handler.handle()).rejects.toThrow(error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we could specifically check that the new custom error is thrown here

@0xkenj1 0xkenj1 merged commit 81254f2 into dev Nov 13, 2024
6 checks passed
@0xkenj1 0xkenj1 deleted the feat/registry-handlers branch November 13, 2024 20:33
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