Skip to content

Commit

Permalink
remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed Jan 30, 2025
1 parent d8e8540 commit bd236da
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 71 deletions.
8 changes: 5 additions & 3 deletions src/indexer/allo/roundMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ export const RoundMetadataSchema = z
.object({
name: z.string(),
roundType: z.union([z.literal("private"), z.literal("public")]),
quadraticFundingConfig: z.object({
matchingFundsAvailable: z.number(),
}).optional(),
quadraticFundingConfig: z
.object({
matchingFundsAvailable: z.number(),
})
.optional(),
})
.passthrough();
68 changes: 4 additions & 64 deletions src/indexer/allo/v2/handleEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,59 +275,38 @@ export async function handleEvent(

case "PoolCreated": {
const { pointer: metadataPointer } = event.params.metadata;
console.log("===> 1: Extracted metadataPointer:", metadataPointer);

const { roundMetadata, applicationMetadata } = await fetchPoolMetadata(
ipfsGet,
metadataPointer
);
console.log(
"===> 2: Fetched pool metadata",
roundMetadata,
applicationMetadata
);

const parsedMetadata = RoundMetadataSchema.safeParse(roundMetadata);
console.log("===> 3: Parsed round metadata");

const poolId = event.params.poolId;
console.log("===> 4: Got poolId:", poolId.toString());

const { managerRole, adminRole } = generateRoundRoles(poolId);
console.log(
"===> 5: Generated roles - manager:",
managerRole,
"admin:",
adminRole
);

const strategyAddress = event.params.strategy;
console.log("===> 6: Got strategyAddress:", strategyAddress);

const strategyId = await readContract({
contract: "AlloV2/IStrategy/V1",
address: strategyAddress,
functionName: "getStrategyId",
});
console.log("===> 7: Read strategyId:", strategyId);

const strategy = extractStrategyFromId(strategyId);
console.log("===> 8: Extracted strategy:", strategy?.name);

let matchAmount = 0n;
let matchAmountInUsd = 0;
console.log("===> 9: Initialized match amounts");

let matchTokenAddress = parseAddress(event.params.token);
console.log("===> 10: Parsed token address:", matchTokenAddress);

if (matchTokenAddress === ALLO_NATIVE_TOKEN) {
matchTokenAddress = parseAddress(zeroAddress);
console.log("===> 11: Updated matchTokenAddress to zero address");
}

const token = getTokenForChain(chainId, matchTokenAddress);
console.log("===> 12: Got token for chain:", token);

switch (strategy?.name) {
case "allov2.DonationVotingMerkleDistributionDirectTransferStrategy":
Expand All @@ -336,7 +315,6 @@ export async function handleEvent(
"AlloV2/DonationVotingMerkleDistributionDirectTransferStrategy/V1",
address: strategyAddress,
});
console.log("===> 13: Subscribed to DVMD strategy");
break;
case "allov2.DirectGrantsSimpleStrategy":
subscribeToContract({
Expand Down Expand Up @@ -382,7 +360,6 @@ export async function handleEvent(
) {
const contract =
"AlloV2/DonationVotingMerkleDistributionDirectTransferStrategy/V1";
console.log("===> 15: Using DVMD strategy contract");

const [
registrationStartTimeResolved,
Expand Down Expand Up @@ -411,15 +388,13 @@ export async function handleEvent(
functionName: "allocationEndTime",
}),
]);
console.log("===> 16: Retrieved all timestamps from contract");

applicationsStartTime = getDateFromTimestamp(
registrationStartTimeResolved
);
applicationsEndTime = getDateFromTimestamp(registrationEndTimeResolved);
donationsStartTime = getDateFromTimestamp(allocationStartTimeResolved);
donationsEndTime = getDateFromTimestamp(allocationEndTimeResolved);
console.log("===> 17: Converted timestamps to dates");

if (
parsedMetadata.success &&
Expand All @@ -430,7 +405,6 @@ export async function handleEvent(
parsedMetadata.data.quadraticFundingConfig.matchingFundsAvailable.toString(),
token.decimals
);
console.log("===> 18: Parsed match amount:", matchAmount.toString());

matchAmountInUsd = (
await convertToUSD(
Expand All @@ -441,10 +415,6 @@ export async function handleEvent(
event.blockNumber
)
).amount;
console.log(
"===> 19: Converted match amount to USD:",
matchAmountInUsd
);
}
} else if (
strategy !== null &&
Expand All @@ -455,10 +425,6 @@ export async function handleEvent(
strategy.name === "allov2.DirectGrantsSimpleStrategy"
? "AlloV2/DirectGrantsSimpleStrategy/V1"
: "AlloV2/DirectGrantsLiteStrategy/V1";
console.log(
"===> 20: Using Direct Grants strategy contract:",
contract
);

const [registrationStartTimeResolved, registrationEndTimeResolved] =
await Promise.all([
Expand All @@ -473,19 +439,16 @@ export async function handleEvent(
functionName: "registrationEndTime",
}),
]);
console.log("===> 21: Retrieved registration timestamps");

applicationsStartTime = getDateFromTimestamp(
registrationStartTimeResolved
);
applicationsEndTime = getDateFromTimestamp(registrationEndTimeResolved);
console.log("===> 22: Converted registration timestamps to dates");
} else if (
strategy !== null &&
strategy.name === "allov2.EasyRetroFundingStrategy"
) {
const contract = "AlloV2/EasyRetroFundingStrategy/V1";
console.log("===> 23: Using Easy Retro Funding strategy contract");

const [
registrationStartTimeResolved,
Expand Down Expand Up @@ -514,20 +477,17 @@ export async function handleEvent(
functionName: "poolEndTime",
}),
]);
console.log("===> 24: Retrieved all Easy Retro timestamps");

applicationsStartTime = getDateFromTimestamp(
registrationStartTimeResolved
);
applicationsEndTime = getDateFromTimestamp(registrationEndTimeResolved);
donationsStartTime = getDateFromTimestamp(poolStartTimeResolved);
donationsEndTime = getDateFromTimestamp(poolEndTimeResolved);
console.log("===> 25: Converted all Easy Retro timestamps to dates");
}

const fundedAmount = event.params.amount;
let fundedAmountInUsd = 0;
console.log("===> 26: Got funded amount:", fundedAmount.toString());

if (token !== null && fundedAmount > 0n) {
fundedAmountInUsd = (
Expand All @@ -539,19 +499,13 @@ export async function handleEvent(
event.blockNumber
)
).price;
console.log(
"===> 27: Converted funded amount to USD:",
fundedAmountInUsd
);
}

const tx = await rpcClient.getTransaction({
hash: event.transactionHash,
});
console.log("===> 28: Retrieved transaction");

const createdBy = tx.from;
console.log("===> 29: Got creator address:", createdBy);

const newRound: NewRound = {
chainId,
Expand Down Expand Up @@ -584,22 +538,18 @@ export async function handleEvent(
projectId: event.params.profileId,
totalDistributed: 0n,
};
console.log("===> 30: Created new round object");
console.log(newRound);

const changes: Changeset[] = [
{
type: "InsertRound",
round: newRound,
},
];
console.log("===> 31: Initialized changes array with InsertRound");

const pendingAdminRoundRoles = await db.getPendingRoundRolesByRole(
chainId,
adminRole
);
console.log("===> 32: Retrieved pending admin round roles");

if (pendingAdminRoundRoles.length > 0) {
for (const pr of pendingAdminRoundRoles) {
Expand All @@ -614,22 +564,17 @@ export async function handleEvent(
},
});
}
console.log("===> 33: Added admin round roles to changes");

changes.push({
type: "DeletePendingRoundRoles",
ids: pendingAdminRoundRoles.map((r) => r.id!),
});
console.log(
"===> 34: Added deletion of pending admin roles to changes"
);
}

const pendingManagerRoundRoles = await db.getPendingRoundRolesByRole(
chainId,
managerRole
);
console.log("===> 35: Retrieved pending manager round roles");

if (pendingManagerRoundRoles.length > 0) {
for (const pr of pendingManagerRoundRoles) {
Expand All @@ -644,18 +589,12 @@ export async function handleEvent(
},
});
}
console.log("===> 36: Added manager round roles to changes");

changes.push({
type: "DeletePendingRoundRoles",
ids: pendingManagerRoundRoles.map((r) => r.id!),
});
console.log(
"===> 37: Added deletion of pending manager roles to changes"
);
}

console.log("===> 38: Returning all changes");
return changes;
}

Expand Down Expand Up @@ -1145,9 +1084,10 @@ export async function handleEvent(
)) as Record<string, unknown>;

const blockNumber = Number(event.blockNumber);
const blockTimestamp = getDateFromTimestamp(
BigInt((await blockTimestampInMs(chainId, event.blockNumber)) / 1000)
) || undefined;
const blockTimestamp =
getDateFromTimestamp(
BigInt((await blockTimestampInMs(chainId, event.blockNumber)) / 1000)
) || undefined;
let distribution;
switch (round.strategyName) {
case "allov2.EasyRetroFundingStrategy": {
Expand Down
4 changes: 0 additions & 4 deletions src/indexer/allo/v2/poolMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ export async function fetchPoolMetadata(ipfsGet: IpfsGetFn, cid: string) {
let applicationMetadata: Metadata["application"] | null;
const metadata = await ipfsGet<Metadata | undefined>(cid);

console.log("===> 1: Fetched metadata", metadata);

if (metadata !== undefined && metadata.round !== undefined) {
console.log("===> 2: Found round metadata");
roundMetadata = metadata.round;
}

if (metadata !== undefined && metadata.application !== undefined) {
console.log("===> 3: Found application metadata");
applicationMetadata = metadata.application;
}

Expand Down

0 comments on commit bd236da

Please sign in to comment.