diff --git a/packages/processors/src/allo/handlers/poolCreated.handler.ts b/packages/processors/src/allo/handlers/poolCreated.handler.ts index d10b575..e46f915 100644 --- a/packages/processors/src/allo/handlers/poolCreated.handler.ts +++ b/packages/processors/src/allo/handlers/poolCreated.handler.ts @@ -40,15 +40,15 @@ export class PoolCreatedHandler implements IEventHandler<"Allo", "PoolCreated"> async handle(): Promise { const { metadataProvider, evmProvider } = this.dependencies; - const [metadataPointer] = this.event.params.metadata; + const metadataPointer = this.event.params.metadata[1]; const { poolId, - strategyId, token: tokenAddress, - contractAddress: strategyAddress, + strategy: strategyAddress, amount: fundedAmount, } = this.event.params; const { hash: txHash, from: txFrom } = this.event.transactionFields; + const strategyId = this.event.strategyId; const metadata = await metadataProvider.getMetadata<{ round?: unknown; diff --git a/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts b/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts index 26acf4c..89a8061 100644 --- a/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts +++ b/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts @@ -26,19 +26,19 @@ function createMockEvent( logIndex: 221, srcAddress: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1", params: { - contractAddress: "0xD545fbA3f43EcA447CC7FBF41D4A8F0f575F2491", + strategy: "0xD545fbA3f43EcA447CC7FBF41D4A8F0f575F2491", poolId: 10n, profileId: "0xcc3509068dfb6604965939f100e57dde21e9d764d8ce4b34284bbe9364b1f5ed", - strategyId: "0x9fa6890423649187b1f0e8bf4265f0305ce99523c3d11aa36b35a54617bb0ec0", amount: 0n, token: "0x4200000000000000000000000000000000000042", - metadata: ["bafkreihrjyu5tney6wia2hmkertc74nzfpsgxw2epvnxm72bxj6ifnd4ku", 1n], + metadata: [1n, "bafkreihrjyu5tney6wia2hmkertc74nzfpsgxw2epvnxm72bxj6ifnd4ku"], }, transactionFields: { hash: "0xd2352acdcd59e312370831ea927d51a1917654697a72434cd905a60897a5bb8b", transactionIndex: 6, from: "0xcBf407C33d68a55CB594Ffc8f4fD1416Bba39DA5", }, + strategyId: "0x9fa6890423649187b1f0e8bf4265f0305ce99523c3d11aa36b35a54617bb0ec0", }; return mergeDeep(defaultEvent, overrides) as ProtocolEvent<"Allo", "PoolCreated">; @@ -75,7 +75,8 @@ describe("PoolCreatedHandler", () => { it("process an event with initial funds", async () => { const fundedAmount = parseUnits("10", 18); const mockEvent = createMockEvent({ - params: { amount: fundedAmount, strategyId: "0xunknown" }, + params: { amount: fundedAmount }, + strategyId: "0xunknown", }); vi.spyOn(mockPricingProvider, "getTokenPrice").mockResolvedValue({ @@ -105,7 +106,7 @@ describe("PoolCreatedHandler", () => { it("process an unknown strategyId", async () => { const mockEvent = createMockEvent({ - params: { strategyId: "0xunknown" }, + strategyId: "0xunknown", }); vi.spyOn(mockMetadataProvider, "getMetadata").mockResolvedValue(undefined); @@ -126,7 +127,7 @@ describe("PoolCreatedHandler", () => { chainId: 10, id: "10", tags: ["allo-v2"], - strategyAddress: mockEvent.params.contractAddress, + strategyAddress: mockEvent.params.strategy, strategyId: "0xunknown", strategyName: "", createdByAddress: mockEvent.transactionFields.from, @@ -214,7 +215,7 @@ describe("PoolCreatedHandler", () => { applicationsEndTime: new Date("2021-01-01T00:00:00.000Z"), donationsStartTime: new Date("2021-01-01T00:00:00.000Z"), donationsEndTime: new Date("2021-01-01T00:00:00.000Z"), - strategyAddress: mockEvent.params.contractAddress, + strategyAddress: mockEvent.params.strategy, strategyId: "0x9fa6890423649187b1f0e8bf4265f0305ce99523c3d11aa36b35a54617bb0ec0", strategyName: "allov2.DonationVotingMerkleDistributionDirectTransferStrategy", createdByAddress: mockEvent.transactionFields.from, @@ -232,7 +233,7 @@ describe("PoolCreatedHandler", () => { it("fetches transaction sender if not present in event", async () => { const mockEvent = createMockEvent({ - params: { strategyId: "0xunknown" }, + strategyId: "0xunknown", transactionFields: { hash: "0xd2352acdcd59e312370831ea927d51a1917654697a72434cd905a60897a5bb8b", from: undefined, @@ -310,7 +311,7 @@ describe("PoolCreatedHandler", () => { }); it("throws an error if token price fetch fails", async () => { - const mockEvent = createMockEvent({ params: { amount: 1n, strategyId: "0xunknown" } }); + const mockEvent = createMockEvent({ params: { amount: 1n }, strategyId: "0xunknown" }); vi.spyOn(mockMetadataProvider, "getMetadata").mockResolvedValue(undefined); @@ -474,8 +475,8 @@ describe("PoolCreatedHandler", () => { params: { amount: fundedAmount, token: "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE", - strategyId: "0xunknown", }, + strategyId: "0xunknown", }); vi.spyOn(mockRoundRepository, "getPendingRoundRoles").mockResolvedValue([]); diff --git a/packages/shared/src/types/events/allo.ts b/packages/shared/src/types/events/allo.ts index 32f5c44..d4b8e57 100644 --- a/packages/shared/src/types/events/allo.ts +++ b/packages/shared/src/types/events/allo.ts @@ -16,11 +16,10 @@ export type AlloEventParams = T extends "PoolCreated" // =============================== Event Parameters ============================ // ============================================================================= export type PoolCreatedParams = { - contractAddress: Address; + strategy: Address; poolId: bigint; profileId: Address; - strategyId: Address; token: Address; amount: bigint; - metadata: [pointer: string, protocol: bigint]; + metadata: [protocol: bigint, pointer: string]; }; diff --git a/packages/shared/src/types/events/common.ts b/packages/shared/src/types/events/common.ts index 3a492d3..1dcc640 100644 --- a/packages/shared/src/types/events/common.ts +++ b/packages/shared/src/types/events/common.ts @@ -61,6 +61,21 @@ export type ProtocolEvent; srcAddress: Address; transactionFields: TransactionFields; -}; +} & (T extends "Strategy" // strategyId should be defined for Strategy events or PoolCreated events in Allo + ? { strategyId: Address } + : T extends "Allo" + ? E extends "PoolCreated" + ? { strategyId: Address } + : Record + : Record); -export type AnyProtocolEvent = ProtocolEvent>; +/** + * TODO: This type is currently only used in the EventsFetcher and IndexerClient. + * In the future, we should evaluate if a more decoupled or generic type is needed + * to improve flexibility and reduce dependencies across different parts of the system. + * Consider creating separate event types for different contexts if necessary. + */ +export type AnyProtocolEvent = Omit< + ProtocolEvent>, + "strategyId" +>; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 36e40e1..8cac965 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,8 +65,8 @@ importers: specifier: 4.3.10 version: 4.3.10 envio: - specifier: 2.4.1 - version: 2.4.1 + specifier: 2.5.2 + version: 2.5.2 ethers: specifier: 6.8.0 version: 6.8.0 @@ -2005,42 +2005,42 @@ packages: } engines: { node: ">=6" } - envio-darwin-arm64@2.4.1: + envio-darwin-arm64@2.5.2: resolution: { - integrity: sha512-uwwKhThFH9dZhQKd6kmleeTyl//GlJGvhFXuhuJ7xn93oGbOOy3hsoYfJZSbVmb0SSSJkgWdAKN82mYHNfdVwQ==, + integrity: sha512-O/+sgImwhQJXlaypMgESWRUzVlkA3dH+2JpdI1LcIVuCpRN/OvBUbRxDHOU79uxeGXvUeeCn1zSGukod6hxG7g==, } cpu: [arm64] os: [darwin] - envio-darwin-x64@2.4.1: + envio-darwin-x64@2.5.2: resolution: { - integrity: sha512-SKqI2hQmjmqlDYCwFaEK6TDJMLL/UE/wWlUIzsAY5drJQTwAL0mBXzUfQM8JbMgDoxeWyKNegUV1vCuTmCDREw==, + integrity: sha512-/K1XCoIXnjTG4LWUqUUPpSdIBFC1tsryQLp1c040YNnsqVmE9EJufclUL0dc2Rf8SNqC/XgNPGWlndcBDSJWFw==, } cpu: [x64] os: [darwin] - envio-linux-arm64@2.4.1: + envio-linux-arm64@2.5.2: resolution: { - integrity: sha512-ujUUifyKM4kHkHfcudeH8iIf5xPiW9t+IzMCgY4gug2fs3Z3biyhmeaylYNpvNiIoQ58vZqJ23fBKaUn7CPPog==, + integrity: sha512-OqrxwwdfN0mcipnq8TQYQL9yZHoHgr7QB8tILjkjtRhz9LOhyjjqlwmNKiDjbpQ8nR2odORKvTlJGEvHb2AO5A==, } cpu: [arm64] os: [linux] - envio-linux-x64@2.4.1: + envio-linux-x64@2.5.2: resolution: { - integrity: sha512-aeVQ9I4zum6X+kBeJrFev/bTDePZRSlt6HytcnqJd7+iWagQggUejhcrSccp2eRSeQ95sGp+F+lQOFfWJHyEJQ==, + integrity: sha512-qpJDjNeY8b8o1v47ulQgu0RGiN8T3BTg2veCRQHeHgpBqh1f7otPEqX2apADo5K+wYlUsH9HXJfbf25SLEQBdw==, } cpu: [x64] os: [linux] - envio@2.4.1: + envio@2.5.2: resolution: { - integrity: sha512-GsHv4S/mAzr//XCyTHFBnfd1CZFlfaG+wcWJkpeguzhnttNSOMJXCR4UPG0PxV2cZYiA3eVrOSPn58fTzk2G5g==, + integrity: sha512-fWHmggBijehdtOkSErHgASUiEhPwDi4ouxOdgHsi0B/DkabgwTYwa8Z+pBhf324exHhGRhAVxZwBtoKI98MUGA==, } hasBin: true @@ -5631,24 +5631,24 @@ snapshots: env-paths@2.2.1: {} - envio-darwin-arm64@2.4.1: + envio-darwin-arm64@2.5.2: optional: true - envio-darwin-x64@2.4.1: + envio-darwin-x64@2.5.2: optional: true - envio-linux-arm64@2.4.1: + envio-linux-arm64@2.5.2: optional: true - envio-linux-x64@2.4.1: + envio-linux-x64@2.5.2: optional: true - envio@2.4.1: + envio@2.5.2: optionalDependencies: - envio-darwin-arm64: 2.4.1 - envio-darwin-x64: 2.4.1 - envio-linux-arm64: 2.4.1 - envio-linux-x64: 2.4.1 + envio-darwin-arm64: 2.5.2 + envio-darwin-x64: 2.5.2 + envio-linux-arm64: 2.5.2 + envio-linux-x64: 2.5.2 environment@1.1.0: {}