From 4e01724472350429fbfdc5d5e78dac6eb73616af Mon Sep 17 00:00:00 2001 From: 0xKurt Date: Thu, 30 Jan 2025 12:50:08 +0100 Subject: [PATCH] remove debugging things --- src/indexer/allo/roundMetadata.ts | 3 +-- src/indexer/allo/v2/handleEvent.ts | 32 ++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/indexer/allo/roundMetadata.ts b/src/indexer/allo/roundMetadata.ts index 5f0a9cbc..bcd30a43 100644 --- a/src/indexer/allo/roundMetadata.ts +++ b/src/indexer/allo/roundMetadata.ts @@ -7,7 +7,6 @@ export const RoundMetadataSchema = z quadraticFundingConfig: z .object({ matchingFundsAvailable: z.number(), - }) - .optional(), + }), }) .passthrough(); diff --git a/src/indexer/allo/v2/handleEvent.ts b/src/indexer/allo/v2/handleEvent.ts index 2e7266b4..b1cd488e 100644 --- a/src/indexer/allo/v2/handleEvent.ts +++ b/src/indexer/allo/v2/handleEvent.ts @@ -398,8 +398,7 @@ export async function handleEvent( if ( parsedMetadata.success && - token !== null && - parsedMetadata.data.quadraticFundingConfig !== undefined + token !== null ) { matchAmount = parseUnits( parsedMetadata.data.quadraticFundingConfig.matchingFundsAvailable.toString(), @@ -484,6 +483,22 @@ export async function handleEvent( applicationsEndTime = getDateFromTimestamp(registrationEndTimeResolved); donationsStartTime = getDateFromTimestamp(poolStartTimeResolved); donationsEndTime = getDateFromTimestamp(poolEndTimeResolved); + + if (parsedMetadata.success && token !== null) { + matchAmount = parseUnits( + parsedMetadata.data.quadraticFundingConfig.matchingFundsAvailable.toString(), + token.decimals + ); + matchAmountInUsd = ( + await convertToUSD( + priceProvider, + chainId, + matchTokenAddress, + matchAmount, + event.blockNumber + ) + ).amount; + } } const fundedAmount = event.params.amount; @@ -546,6 +561,12 @@ export async function handleEvent( }, ]; + + + // Admin roles for the pool are emitted before the pool is created + // so a pending round role is inserted in the db. + // Now that the PoolCreated event is emitted, we can convert + // pending roles to actual round roles. const pendingAdminRoundRoles = await db.getPendingRoundRolesByRole( chainId, adminRole @@ -571,6 +592,10 @@ export async function handleEvent( }); } + // Manager roles for the pool are emitted before the pool is created + // so a pending round role is inserted in the db. + // Now that the PoolCreated event is emitted, we can convert + // pending roles to actual round roles. const pendingManagerRoundRoles = await db.getPendingRoundRolesByRole( chainId, managerRole @@ -799,8 +824,7 @@ export async function handleEvent( if ( parsedMetadata.success && - token !== null && - parsedMetadata.data.quadraticFundingConfig !== undefined + token !== null ) { matchAmount = parseUnits( parsedMetadata.data.quadraticFundingConfig.matchingFundsAvailable.toString(),