diff --git a/apps/indexer/pnpm-lock.yaml b/apps/indexer/pnpm-lock.yaml index 4878223..c436a8f 100644 --- a/apps/indexer/pnpm-lock.yaml +++ b/apps/indexer/pnpm-lock.yaml @@ -1530,13 +1530,6 @@ packages: } engines: { node: ">=10" } - minimatch@5.1.6: - resolution: - { - integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==, - } - engines: { node: ">=10" } - minimist@1.2.8: resolution: { @@ -1610,10 +1603,10 @@ packages: } engines: { node: ">=0.10.0" } - npm@10.8.3: + npm@10.9.0: resolution: { - integrity: sha512-0IQlyAYvVtQ7uOhDFYZCGK8kkut2nh8cpAdA9E6FvRSJaTgtZRZgNjlC5ZCct//L73ygrpY93CxXpRJDtNqPVg==, + integrity: sha512-ZanDioFylI9helNhl2LNd+ErmVD+H5I53ry41ixlLyCBgkuYb+58CvbAp99hW+zr5L9W4X7CchSoeqKdngOLSw==, } engines: { node: ^18.17.0 || >=20.5.0 } hasBin: true @@ -2611,7 +2604,7 @@ snapshots: "@envio-dev/hypersync-client@0.6.2": dependencies: - npm: 10.8.3 + npm: 10.9.0 yarn: 1.22.22 optionalDependencies: "@envio-dev/hypersync-client-darwin-arm64": 0.6.2 @@ -3127,7 +3120,7 @@ snapshots: fs.realpath: 1.0.0 inflight: 1.0.6 inherits: 2.0.4 - minimatch: 5.1.6 + minimatch: 5.0.1 once: 1.4.0 gopd@1.0.1: @@ -3334,10 +3327,6 @@ snapshots: dependencies: brace-expansion: 2.0.1 - minimatch@5.1.6: - dependencies: - brace-expansion: 2.0.1 - minimist@1.2.8: {} mkdirp@0.5.6: @@ -3384,7 +3373,7 @@ snapshots: normalize-path@3.0.0: {} - npm@10.8.3: {} + npm@10.9.0: {} object-assign@4.1.1: {} diff --git a/packages/data-flow/test/unit/eventsProcessor.spec.ts b/packages/data-flow/test/unit/eventsProcessor.spec.ts index 6df3753..51c4692 100644 --- a/packages/data-flow/test/unit/eventsProcessor.spec.ts +++ b/packages/data-flow/test/unit/eventsProcessor.spec.ts @@ -80,9 +80,9 @@ describe("EventsProcessor", () => { ]; const mockEvent = { contractName: "Strategy", - eventName: "Distributed", + eventName: "DistributedWithRecipientAddress", args: {}, - } as unknown as ProcessorEvent<"Strategy", "Distributed">; + } as unknown as ProcessorEvent<"Strategy", "DistributedWithRecipientAddress">; vi.spyOn(mockStrategyProcessor, "process").mockResolvedValue(mockChangeset); @@ -105,7 +105,7 @@ describe("EventsProcessor", () => { sender: "0x0", recipientAddress: "0x0", recipientId: "0x0", - amount: 1, + amount: 1n, }, transactionFields: { hash: "0x0", diff --git a/packages/data-flow/test/unit/eventsRegistry.spec.ts b/packages/data-flow/test/unit/eventsRegistry.spec.ts index 077f4d3..33736d5 100644 --- a/packages/data-flow/test/unit/eventsRegistry.spec.ts +++ b/packages/data-flow/test/unit/eventsRegistry.spec.ts @@ -68,9 +68,9 @@ describe("InMemoryEventsRegistry", () => { }, }; - const secondEvent: ProcessorEvent<"Strategy", "Registered"> = { + const secondEvent: ProcessorEvent<"Strategy", "RegisteredWithSender"> = { contractName: "Strategy", - eventName: "Registered", + eventName: "RegisteredWithSender", blockNumber: 1, blockTimestamp: 1234567890, chainId: 1 as ChainId, diff --git a/packages/data-flow/test/unit/orchestrator.spec.ts b/packages/data-flow/test/unit/orchestrator.spec.ts index 112b40b..42e1ce3 100644 --- a/packages/data-flow/test/unit/orchestrator.spec.ts +++ b/packages/data-flow/test/unit/orchestrator.spec.ts @@ -254,10 +254,13 @@ describe("Orchestrator", { sequential: true }, () => { }); const strategyEvents: Record = { - Registered: "", - Distributed: "", + RegisteredWithSender: "", + DistributedWithRecipientAddress: "", TimestampsUpdated: "", AllocatedWithToken: "", + RegisteredWithData: "", + DistributedWithData: "", + DistributedWithFlowRate: "", }; for (const event of Object.keys(strategyEvents) as StrategyEvent[]) { @@ -319,7 +322,7 @@ describe("Orchestrator", { sequential: true }, () => { const strategyAddress = "0x123" as Address; const mockEvent = createMockEvent( "Strategy", - "Registered", + "RegisteredWithSender", 1, undefined, strategyAddress, @@ -363,7 +366,7 @@ describe("Orchestrator", { sequential: true }, () => { }); const registeredEvent = createMockEvent( "Strategy", - "Registered", + "RegisteredWithSender", 2, { recipientId: "0x123", diff --git a/packages/processors/src/strategy/common/baseDistributed.handler.ts b/packages/processors/src/strategy/common/baseDistributed.handler.ts index 816428c..f978be6 100644 --- a/packages/processors/src/strategy/common/baseDistributed.handler.ts +++ b/packages/processors/src/strategy/common/baseDistributed.handler.ts @@ -19,9 +19,11 @@ type Dependencies = Pick; * */ -export class BaseDistributedHandler implements IEventHandler<"Strategy", "Distributed"> { +export class BaseDistributedHandler + implements IEventHandler<"Strategy", "DistributedWithRecipientAddress"> +{ constructor( - readonly event: ProcessorEvent<"Strategy", "Distributed">, + readonly event: ProcessorEvent<"Strategy", "DistributedWithRecipientAddress">, private readonly chainId: ChainId, private readonly dependencies: Dependencies, ) {} @@ -46,7 +48,7 @@ export class BaseDistributedHandler implements IEventHandler<"Strategy", "Distri args: { chainId: this.chainId, roundId: round.id, - amount: BigInt(this.event.params.amount), + amount: this.event.params.amount, }, }, ]; diff --git a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts index d6ded27..7487142 100644 --- a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts +++ b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts @@ -46,15 +46,15 @@ export class DVMDDirectTransferStrategyHandler extends BaseStrategyHandler { /** @inheritdoc */ async handle(event: ProcessorEvent<"Strategy", StrategyEvent>): Promise { switch (event.eventName) { - case "Registered": + case "RegisteredWithSender": return new DVMDRegisteredHandler( - event as ProcessorEvent<"Strategy", "Registered">, + event as ProcessorEvent<"Strategy", "RegisteredWithSender">, this.chainId, this.dependencies, ).handle(); - case "Distributed": + case "DistributedWithRecipientAddress": return new BaseDistributedHandler( - event as ProcessorEvent<"Strategy", "Distributed">, + event as ProcessorEvent<"Strategy", "DistributedWithRecipientAddress">, this.chainId, this.dependencies, ).handle(); diff --git a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts index c377b7a..99cd2a0 100644 --- a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts +++ b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts @@ -27,9 +27,9 @@ type Dependencies = Pick< * - Links the application to both the project and round */ -export class DVMDRegisteredHandler implements IEventHandler<"Strategy", "Registered"> { +export class DVMDRegisteredHandler implements IEventHandler<"Strategy", "RegisteredWithSender"> { constructor( - readonly event: ProcessorEvent<"Strategy", "Registered">, + readonly event: ProcessorEvent<"Strategy", "RegisteredWithSender">, private readonly chainId: ChainId, private readonly dependencies: Dependencies, ) {} diff --git a/packages/processors/test/strategy/common/baseDistributed.handler.spec.ts b/packages/processors/test/strategy/common/baseDistributed.handler.spec.ts index a20abdc..74042c7 100644 --- a/packages/processors/test/strategy/common/baseDistributed.handler.spec.ts +++ b/packages/processors/test/strategy/common/baseDistributed.handler.spec.ts @@ -6,16 +6,16 @@ import { ChainId, ProcessorEvent } from "@grants-stack-indexer/shared"; import { BaseDistributedHandler } from "../../../src/strategy/common/baseDistributed.handler.js"; function createMockEvent( - overrides: Partial> = {}, -): ProcessorEvent<"Strategy", "Distributed"> { - const defaultEvent: ProcessorEvent<"Strategy", "Distributed"> = { + overrides: Partial> = {}, +): ProcessorEvent<"Strategy", "DistributedWithRecipientAddress"> { + const defaultEvent: ProcessorEvent<"Strategy", "DistributedWithRecipientAddress"> = { params: { - amount: 1000, + amount: 1000n, recipientAddress: "0x1234567890123456789012345678901234567890", recipientId: "0x1234567890123456789012345678901234567890", sender: "0x1234567890123456789012345678901234567890", }, - eventName: "Distributed", + eventName: "DistributedWithRecipientAddress", srcAddress: "0x1234567890123456789012345678901234567890", blockNumber: 12345, blockTimestamp: 1000000000, @@ -36,7 +36,7 @@ function createMockEvent( describe("BaseDistributedHandler", () => { let handler: BaseDistributedHandler; let mockRoundRepository: IRoundReadRepository; - let mockEvent: ProcessorEvent<"Strategy", "Distributed">; + let mockEvent: ProcessorEvent<"Strategy", "DistributedWithRecipientAddress">; const chainId = 10 as ChainId; beforeEach(() => { diff --git a/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.spec.ts b/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.spec.ts index 87a7825..6e5eaa6 100644 --- a/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.spec.ts +++ b/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.spec.ts @@ -82,8 +82,8 @@ describe("DVMDDirectTransferHandler", () => { it("calls RegisteredHandler for Registered event", async () => { const mockEvent = { - eventName: "Registered", - } as ProcessorEvent<"Strategy", "Registered">; + eventName: "RegisteredWithSender", + } as ProcessorEvent<"Strategy", "RegisteredWithSender">; vi.spyOn(DVMDRegisteredHandler.prototype, "handle").mockResolvedValue([]); @@ -101,8 +101,8 @@ describe("DVMDDirectTransferHandler", () => { it("calls DistributedHandler for Distributed event", async () => { const mockEvent = { - eventName: "Distributed", - } as ProcessorEvent<"Strategy", "Distributed">; + eventName: "DistributedWithRecipientAddress", + } as ProcessorEvent<"Strategy", "DistributedWithRecipientAddress">; vi.spyOn(BaseDistributedHandler.prototype, "handle").mockResolvedValue([]); diff --git a/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.spec.ts b/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.spec.ts index 1340273..c76b4a1 100644 --- a/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.spec.ts +++ b/packages/processors/test/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.spec.ts @@ -14,15 +14,15 @@ import { ProjectNotFound, RoundNotFound } from "../../../../src/exceptions/index import { DVMDRegisteredHandler } from "../../../../src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/index.js"; function createMockEvent( - overrides: DeepPartial> = {}, -): ProcessorEvent<"Strategy", "Registered"> { - const defaultEvent: ProcessorEvent<"Strategy", "Registered"> = { + overrides: DeepPartial> = {}, +): ProcessorEvent<"Strategy", "RegisteredWithSender"> { + const defaultEvent: ProcessorEvent<"Strategy", "RegisteredWithSender"> = { params: { recipientId: "0x1234567890123456789012345678901234567890", sender: "0x0987654321098765432109876543210987654321", data: "0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001000000000000000000000000002c7296a5ec0539f0a018c7176c97c92a9c44e2b4000000000000000000000000e7eb5d2b5b188777df902e89c54570e7ef4f59ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003b6261666b72656967796334336366696e786c6e6168713561617773676869626574763675737273376b6b78663776786d7a626a79726f37366977790000000000", }, - eventName: "Registered", + eventName: "RegisteredWithSender", srcAddress: "0x1234567890123456789012345678901234567890", blockNumber: 12345, blockTimestamp: 1000000000, @@ -37,7 +37,7 @@ function createMockEvent( strategyId: "0x9fa6890423649187b1f0e8bf4265f0305ce99523c3d11aa36b35a54617bb0ec0", }; - return mergeDeep(defaultEvent, overrides) as ProcessorEvent<"Strategy", "Registered">; + return mergeDeep(defaultEvent, overrides) as ProcessorEvent<"Strategy", "RegisteredWithSender">; } describe("DVMDRegisteredHandler", () => { @@ -45,7 +45,7 @@ describe("DVMDRegisteredHandler", () => { let mockRoundRepository: IRoundReadRepository; let mockProjectRepository: IProjectReadRepository; let mockMetadataProvider: IMetadataProvider; - let mockEvent: ProcessorEvent<"Strategy", "Registered">; + let mockEvent: ProcessorEvent<"Strategy", "RegisteredWithSender">; const chainId = 10 as ChainId; beforeEach(() => { diff --git a/packages/shared/src/types/events/strategy.ts b/packages/shared/src/types/events/strategy.ts index fbff8db..73a87a4 100644 --- a/packages/shared/src/types/events/strategy.ts +++ b/packages/shared/src/types/events/strategy.ts @@ -6,8 +6,11 @@ import { Address, AnyEvent, ContractName, ProcessorEvent } from "../../internal. * This array is used to represent all Strategy events. */ const StrategyEventArray = [ - "Registered", - "Distributed", + "RegisteredWithSender", + "RegisteredWithData", + "DistributedWithRecipientAddress", + "DistributedWithData", + "DistributedWithFlowRate", "TimestampsUpdated", "AllocatedWithToken", ] as const; @@ -20,37 +23,64 @@ export type StrategyEvent = (typeof StrategyEventArray)[number]; /** * This type maps Strategy events to their respective parameters. */ -export type StrategyEventParams = T extends "Registered" - ? RegisteredParams - : T extends "Distributed" - ? DistributedParams - : T extends "TimestampsUpdated" - ? TimestampsUpdatedParams - : T extends "AllocatedWithToken" - ? AllocatedWithTokenParams - : never; +export type StrategyEventParams = T extends "RegisteredWithSender" + ? RegisteredWithSenderParams + : T extends "RegisteredWithData" + ? RegisteredWithDataParams + : T extends "DistributedWithRecipientAddress" + ? DistributedWithRecipientAddressParams + : T extends "DistributedWithData" + ? DistributedWithDataParams + : T extends "DistributedWithFlowRate" + ? DistributedWithFlowRateParams + : T extends "TimestampsUpdated" + ? TimestampsUpdatedParams + : T extends "AllocatedWithToken" + ? AllocatedWithTokenParams + : never; // ============================================================================= // =============================== Event Parameters ============================ // ============================================================================= -export type RegisteredParams = { + +// ======================= Registered ======================= +export type RegisteredWithSenderParams = { recipientId: Address; data: Hex; sender: Address; }; -export type DistributedParams = { +export type RegisteredWithDataParams = { + recipient: Address; + data: Hex; +}; + +// ======================= Distributed ======================= +export type DistributedWithRecipientAddressParams = { recipientAddress: Address; recipientId: Address; sender: Address; - amount: number; + amount: bigint; }; +export type DistributedWithDataParams = { + data: Hex; + sender: Address; +}; + +export type DistributedWithFlowRateParams = { + flowRate: bigint; + sender: Address; +}; + +// ======================= TimestampsUpdated ======================= + export type TimestampsUpdatedParams = { contractAddress: Address; timestamp: number; }; +// ======================= Allocated ======================= export type AllocatedWithTokenParams = { contractAddress: Address; tokenAddress: Address;