-
Notifications
You must be signed in to change notification settings - Fork 0
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 remaining event handlers for DVMD strategy #30
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a smoll comments. Huge work here, sir! 👏💎
if (!rawDistribution) { | ||
logger.warn(`No matching distribution found for pointer: ${pointer}`); | ||
|
||
throw new MetadataNotFound(`No matching distribution found for pointer: ${pointer}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should MetadataProvider be responsible for throwing a "not found" error instead of having the handler doing it?
private readonly chainId: ChainId, | ||
private readonly dependencies: Dependencies, | ||
) { | ||
this.bitmap = new StatusesBitmap(256n, 4n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
values to build StatusesBitmap
are always the same ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i followed original implementation. are constants values
/** | ||
* Checks if an application status index is valid (between 1 and 3) | ||
* @see ApplicationStatus | ||
*/ | ||
export function isValidApplicationStatus(status: number): boolean { | ||
return status >= 1 && status <= 3; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like this hardcoding that much. But it is something that probably won't change.
What about using Object.keys(ApplicationStatus).length
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't follow exactly your idea, you mean to use the length as the upper bound limit?
// it("correctly convert timestamps to Date objects", async () => { | ||
// const timestamps = { | ||
// registrationStartTime: 1704067200n, // 2024-01-01 00:00:00 | ||
// registrationEndTime: 1704153600n, // 2024-01-02 00:00:00 | ||
// allocationStartTime: 1704240000n, // 2024-01-03 00:00:00 | ||
// allocationEndTime: 1704326400n, // 2024-01-04 00:00:00 | ||
// }; | ||
|
||
// mockEvent = createMockEvent({ | ||
// params: timestamps, | ||
// }); | ||
// const mockRound = { id: "round1" } as Round; | ||
|
||
// vi.spyOn(mockRoundRepository, "getRoundByStrategyAddress").mockResolvedValue(mockRound); | ||
|
||
// handler = new DVMDTimestampsUpdatedHandler(mockEvent, chainId, { | ||
// roundRepository: mockRoundRepository, | ||
// }); | ||
|
||
// const result = await handler.handle(); | ||
|
||
// expect(result.length).toBe(1); | ||
// const changeset = result[0] as { | ||
// type: "UpdateRound"; | ||
// args: { chainId: ChainId; roundId: string; round: PartialRound }; | ||
// }; | ||
|
||
// expect(changeset.type).toBe("UpdateRound"); | ||
// expect(changeset.args.chainId).toBe(chainId); | ||
// expect(changeset.args.roundId).toBe("round1"); | ||
// expect(changeset.args.round).toBeDefined(); | ||
|
||
// const partialRound = changeset.args.round; | ||
|
||
// expect(partialRound.applicationsStartTime).toEqual(new Date("2024-01-01T00:00:00.000Z")); | ||
// expect(partialRound.applicationsEndTime).toEqual(new Date("2024-01-02T00:00:00.000Z")); | ||
// expect(partialRound.donationsStartTime).toEqual(new Date("2024-01-03T00:00:00.000Z")); | ||
// expect(partialRound.donationsEndTime).toEqual(new Date("2024-01-04T00:00:00.000Z")); | ||
// }); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad
const timestamps = { | ||
registrationStartTime: 1704067200n, // 2024-01-01 00:00:00 | ||
registrationEndTime: 1704153600n, // 2024-01-02 00:00:00 | ||
allocationStartTime: 1704240000n, // 2024-01-03 00:00:00 | ||
allocationEndTime: 1704326400n, // 2024-01-04 00:00:00 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may we check if envio is actually returning this params of the event as string or number ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right here, it's string. should we treat as string or have the indexer-client parse it and coerce to bigint?
|
||
export type MatchingDistribution = z.infer<typeof MatchingDistributionSchema>; | ||
|
||
// handle ethers bigint serialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean viem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just copy-pasted the comment, will delete it
projectPayoutAddress: z.string(), | ||
projectId: z.string(), | ||
projectName: z.string(), | ||
matchPoolPercentage: z.coerce.number(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will coerce empty strings to 0 rather than fail validation--just checking if you're ok with this. If you'd prefer to fail validation you can check out this: colinhacks/zod#2461 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting 👀 , have to say that '' being 0 is kinda unexpected
private readonly dependencies: Dependencies, | ||
) {} | ||
|
||
async handle(): Promise<Changeset[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inheritdoc?
|
||
type ApplicationUpdate = { | ||
application: Application; | ||
status: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the status can only be a number between 1-3 maybe we should validate it rather than just typing it as number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's kinda a weird thing because the original implementation expected more statutes but currently only 3 of the status flow are in production. however the status on Index 0 is not one of them so I rather keep this as it is for now
private readonly dependencies: Dependencies, | ||
) {} | ||
|
||
async handle(): Promise<Changeset[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inherit doc?
); | ||
}); | ||
|
||
it("should handle empty matching distribution array", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should
@@ -40,7 +40,7 @@ export type Round = { | |||
strategyId: string; | |||
strategyName: string; | |||
readyForPayoutTransaction: string | null; | |||
matchingDistribution: MatchingDistribution | null; | |||
matchingDistribution: MatchingDistribution[] | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe should be called matchingDistributions if it's an array now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was always an array, i forgot the [ ]
, however i'll keep the field name so we don't break the current DB schema and we have the same name across all the app
🤖 Linear
Closes GIT-170 GIT-155 GIT-156 GIT-160 GIT-167
Description
TimestampsUpdated
DistributionUpdated
(common to all strategies)FundsDistributed
(common to all strategies)RecipientStatusUpdated
(common to all strategies)UpdatedRegistration
Checklist before requesting a review