From da7bbe7802531565a3d40eae38ec0db3c19a9f19 Mon Sep 17 00:00:00 2001 From: 0xkenj1 Date: Thu, 28 Nov 2024 13:18:26 -0300 Subject: [PATCH] fix: build types --- packages/data-flow/test/unit/eventsRegistry.spec.ts | 12 ++++++------ packages/data-flow/test/unit/orchestrator.spec.ts | 12 ++++++------ .../processors/allo/handlers/poolCreated.handler.ts | 5 +++-- .../processors/allo/handlers/poolFunded.handler.ts | 2 +- .../test/allo/handlers/poolCreated.handler.spec.ts | 12 ++++++------ .../test/allo/handlers/poolFunded.handler.spec.ts | 10 +++++----- .../handlers/poolMetadataUpdated.handler.spec.ts | 4 ++-- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/packages/data-flow/test/unit/eventsRegistry.spec.ts b/packages/data-flow/test/unit/eventsRegistry.spec.ts index 59920e4..7a20e6f 100644 --- a/packages/data-flow/test/unit/eventsRegistry.spec.ts +++ b/packages/data-flow/test/unit/eventsRegistry.spec.ts @@ -29,12 +29,12 @@ describe("InMemoryEventsRegistry", () => { srcAddress: "0x123", strategyId: "0xstrategy", params: { - poolId: 1n, + poolId: "1", profileId: "0x456", strategy: "0x789", token: "0xtoken", - amount: 0n, - metadata: [1n, "0xmetadata"], + amount: "0", + metadata: ["1", "0xmetadata"], }, transactionFields: { hash: "0xabc", @@ -61,12 +61,12 @@ describe("InMemoryEventsRegistry", () => { srcAddress: "0x123", strategyId: "0xstrategy", params: { - poolId: 1n, + poolId: "1", profileId: "0x456", strategy: "0x789", token: "0xtoken", - amount: 0n, - metadata: [1n, "0xmetadata"], + amount: "0", + metadata: ["1", "0xmetadata"], }, transactionFields: { hash: "0xabc", diff --git a/packages/data-flow/test/unit/orchestrator.spec.ts b/packages/data-flow/test/unit/orchestrator.spec.ts index 0ad1bb3..a27d72d 100644 --- a/packages/data-flow/test/unit/orchestrator.spec.ts +++ b/packages/data-flow/test/unit/orchestrator.spec.ts @@ -200,11 +200,11 @@ describe("Orchestrator", { sequential: true }, () => { "0x6f9291df02b2664139cec5703c124e4ebce32879c74b6297faa1468aa5ff9ebf" as Hex; const mockEvent = createMockEvent("Allo", "PoolCreated", 1, { strategy: strategyAddress, - poolId: 1n, + poolId: "1", profileId: "0x123", token: "0x123", - amount: 100n, - metadata: [1n, "1"], + amount: "100", + metadata: ["1", "1"], }); const eventsProcessorSpy = vi.spyOn(orchestrator["eventsProcessor"], "processEvent"); @@ -384,11 +384,11 @@ describe("Orchestrator", { sequential: true }, () => { "0x6f9291df02b2664139cec5703c124e4ebce32879c74b6297faa1468aa5ff9ebf" as Hex; const poolCreatedEvent = createMockEvent("Allo", "PoolCreated", 1, { strategy: strategyAddress, - poolId: 1n, + poolId: "1", profileId: "0x123", token: "0x123", - amount: 100n, - metadata: [1n, "1"], + amount: "100", + metadata: ["1", "1"], }); const registeredEvent = createMockEvent( "Strategy", diff --git a/packages/processors/src/processors/allo/handlers/poolCreated.handler.ts b/packages/processors/src/processors/allo/handlers/poolCreated.handler.ts index 9979c72..8db23a6 100644 --- a/packages/processors/src/processors/allo/handlers/poolCreated.handler.ts +++ b/packages/processors/src/processors/allo/handlers/poolCreated.handler.ts @@ -39,8 +39,9 @@ export class PoolCreatedHandler implements IEventHandler<"Allo", "PoolCreated"> poolId, token: tokenAddress, strategy: strategyAddress, - amount: fundedAmount, + amount, } = this.event.params; + const fundedAmount = BigInt(amount); const { hash: txHash, from: txFrom } = this.event.transactionFields; const strategyId = this.event.strategyId; @@ -99,7 +100,7 @@ export class PoolCreatedHandler implements IEventHandler<"Allo", "PoolCreated"> // transaction sender const createdBy = txFrom ?? (await evmProvider.getTransaction(txHash)).from; - const roundRoles = getRoundRoles(poolId); + const roundRoles = getRoundRoles(BigInt(poolId)); const newRound: NewRound = { chainId: this.chainId, diff --git a/packages/processors/src/processors/allo/handlers/poolFunded.handler.ts b/packages/processors/src/processors/allo/handlers/poolFunded.handler.ts index 6e4c92e..a24ad6e 100644 --- a/packages/processors/src/processors/allo/handlers/poolFunded.handler.ts +++ b/packages/processors/src/processors/allo/handlers/poolFunded.handler.ts @@ -23,7 +23,7 @@ export class PoolFundedHandler implements IEventHandler<"Allo", "PoolFunded"> { async handle(): Promise { const poolId = this.event.params.poolId.toString(); - const fundedAmount = this.event.params.amount; + const fundedAmount = BigInt(this.event.params.amount); const { roundRepository, pricingProvider } = this.dependencies; const round = await roundRepository.getRoundById(this.chainId, poolId); diff --git a/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts b/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts index 6109242..67c23e0 100644 --- a/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts +++ b/packages/processors/test/allo/handlers/poolCreated.handler.spec.ts @@ -24,11 +24,11 @@ function createMockEvent( srcAddress: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1", params: { strategy: "0xD545fbA3f43EcA447CC7FBF41D4A8F0f575F2491", - poolId: 10n, + poolId: "10", profileId: "0xcc3509068dfb6604965939f100e57dde21e9d764d8ce4b34284bbe9364b1f5ed", - amount: 0n, + amount: "0", token: "0x4200000000000000000000000000000000000042", - metadata: [1n, "bafkreihrjyu5tney6wia2hmkertc74nzfpsgxw2epvnxm72bxj6ifnd4ku"], + metadata: ["1", "bafkreihrjyu5tney6wia2hmkertc74nzfpsgxw2epvnxm72bxj6ifnd4ku"], }, transactionFields: { hash: "0xd2352acdcd59e312370831ea927d51a1917654697a72434cd905a60897a5bb8b", @@ -72,7 +72,7 @@ describe("PoolCreatedHandler", () => { it("process an event with initial funds", async () => { const fundedAmount = parseUnits("10", 18); const mockEvent = createMockEvent({ - params: { amount: fundedAmount }, + params: { amount: fundedAmount.toString() }, strategyId: "0xunknown", }); @@ -308,7 +308,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: "1" }, strategyId: "0xunknown" }); vi.spyOn(mockMetadataProvider, "getMetadata").mockResolvedValue(undefined); @@ -469,7 +469,7 @@ describe("PoolCreatedHandler", () => { const fundedAmount = parseUnits("10", 18); const mockEvent = createMockEvent({ params: { - amount: fundedAmount, + amount: fundedAmount.toString(), token: "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE", }, strategyId: "0xunknown", diff --git a/packages/processors/test/allo/handlers/poolFunded.handler.spec.ts b/packages/processors/test/allo/handlers/poolFunded.handler.spec.ts index 8e7caab..59a9502 100644 --- a/packages/processors/test/allo/handlers/poolFunded.handler.spec.ts +++ b/packages/processors/test/allo/handlers/poolFunded.handler.spec.ts @@ -20,9 +20,9 @@ function createMockEvent( logIndex: 123, srcAddress: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1", params: { - poolId: 1n, - amount: 100n, - fee: 10n, + poolId: "1", + amount: "100", + fee: "10", }, transactionFields: { hash: "0xtransactionhash", @@ -101,9 +101,9 @@ describe("PoolFundedHandler", () => { args: { chainId: 10, roundId: "1", - fundedAmount: mockEvent.params.amount, + fundedAmount: BigInt(mockEvent.params.amount), fundedAmountInUsd: calculateAmountInUsd( - mockEvent.params.amount, + BigInt(mockEvent.params.amount), mockPrice.priceUsd, mockToken?.decimals as number, ), diff --git a/packages/processors/test/allo/handlers/poolMetadataUpdated.handler.spec.ts b/packages/processors/test/allo/handlers/poolMetadataUpdated.handler.spec.ts index d3d9752..47305c0 100644 --- a/packages/processors/test/allo/handlers/poolMetadataUpdated.handler.spec.ts +++ b/packages/processors/test/allo/handlers/poolMetadataUpdated.handler.spec.ts @@ -23,8 +23,8 @@ function createMockEvent( logIndex: 456, srcAddress: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1", params: { - poolId: 1n, - metadata: [1n, "bafkreihrjyu5tney6wia2hmkertc74nzfpsgxw2epvnxm72bxj6ifnd4ku"], + poolId: "1", + metadata: ["1", "bafkreihrjyu5tney6wia2hmkertc74nzfpsgxw2epvnxm72bxj6ifnd4ku"], }, transactionFields: { hash: "0xtransactionhash",