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: direct grants lite strategy #34

Merged
merged 7 commits into from
Nov 19, 2024
Merged

Conversation

0xnigir1
Copy link
Collaborator

@0xnigir1 0xnigir1 commented Nov 15, 2024

🤖 Linear

Closes GIT-162 GIT-164 GIT-165 GIT-158 GIT-168 GIT-143 GIT-141

Description

  • add ApplicationPayout model, repository and Changesets
  • add DirectGrantsLiteStrategy handler and events handlers:
    • Registered
    • UpdatedRegistration
    • TimestampsUpdated
    • Allocated
    • RecipientStatusUpdated

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.

@0xnigir1 0xnigir1 self-assigned this Nov 15, 2024
Copy link

linear bot commented Nov 15, 2024

GIT-158 Allocated

StrategyTimings,
UnsupportedEventException,
} from "../../../internal.js";
import { BaseStrategyHandler } from "../common/base.strategy.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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

const { srcAddress } = this.event;
const { recipientId: _recipientId, amount: strAmount, token: _token } = this.event.params;

const amount = BigInt(strAmount);
Copy link
Collaborator

Choose a reason for hiding this comment

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

if amount is zero maybe we should return early to avoid unnecessary calls that'll just return 0

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 wouldn't return early but very nice catch, i will improve code to avoid querying prices wen amount is 0 🤝

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

* @returns The changeset with an UpdateRound operation.
* @throws RoundNotFound if the round is not found.
*/
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.

I noticed in some of the handlers you do inherit docs for handle() and in others you write it out--not sure if it's intentional or you want to pick one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


if (!isValidApplicationStatus(status)) {
logger.warn(
`[DGLiteUpdatedRegistrationHandler] Invalid status: ${this.event.params.status}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm surprised there isn't an actual exception thrown for this but if that's intentional then it's ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

from Contracts side there are more defined statuses but Gitcoin's team said that some are un-implemented flows. i've decided to skip status that are un-implemented but could throw too 🤔
cc @0xkenj1 opinions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is something to tackle once we are focusing on error handling, for now it is okay, as nigiri said, there are some un-implemented flows, and for simplicity i think skipping is a good choice for now.

@@ -50,3 +74,19 @@ export const decodeDVMDExtendedApplicationData = (
recipientsCounter: values[1].toString(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this isn't part of this PR but I noticed the "encodededDVMD" typo lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

const result = await handler.handle();

// parsed data:
// {
Copy link
Collaborator

Choose a reason for hiding this comment

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

commented out code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


import { DGLiteTimestampsUpdatedHandler } from "../../../../src/processors/strategy/directGrantsLite/handlers/timestampsUpdated.handler.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.

consider moving the createXEvent functions for the handlers into one file because it will be easier to find if you make changes to multiple 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.

ah you're 100% right, didn't realize that. will do ser 🫡

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@0xkenj1 0xkenj1 left a comment

Choose a reason for hiding this comment

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

LGTM after addressing beebs comments :)

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.

👌

@0xnigir1 0xnigir1 merged commit 0623cda into dev Nov 19, 2024
6 checks passed
@0xnigir1 0xnigir1 deleted the feat/direct-grants-lite-strategy branch November 19, 2024 17:55
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