Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 committed Oct 28, 2024
1 parent baf8c34 commit 5bd2d20
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
9 changes: 3 additions & 6 deletions packages/processors/src/allo/handlers/poolCreated.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import { getAddress, zeroAddress } from "viem";

import type { Changeset, NewRound, PendingRoundRole } from "@grants-stack-indexer/repository";
import type { ChainId, ProtocolEvent, Token } from "@grants-stack-indexer/shared";
import { isAlloNativeToken } from "@grants-stack-indexer/shared";
import { getToken } from "@grants-stack-indexer/shared/dist/src/internal.js";
import { getToken, isAlloNativeToken } from "@grants-stack-indexer/shared";

import type { IEventHandler, ProcessorDependencies, StrategyTimings } from "../../internal.js";
import { getRoundRoles } from "../../helpers/roles.js";
import { calculateAmountInUsd } from "../../helpers/tokenMath.js";
import { TokenPriceNotFoundError } from "../../internal.js";
import { calculateAmountInUsd, getRoundRoles } from "../../helpers/index.js";
import { StrategyHandlerFactory, TokenPriceNotFoundError } from "../../internal.js";
import { RoundMetadataSchema } from "../../schemas/index.js";
import { StrategyHandlerFactory } from "../../strategy/strategyHandler.factory.js";

type Dependencies = Pick<
ProcessorDependencies,
Expand Down
3 changes: 3 additions & 0 deletions packages/processors/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./roles.js";
export * from "./utils.js";
export * from "./tokenMath.js";
5 changes: 1 addition & 4 deletions packages/processors/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ export * from "./exceptions/index.js";
export * from "./allo/index.js";

// Strategy
export * from "./strategy/common/index.js";
export * from "./strategy/strategyHandler.factory.js";
export * from "./strategy/strategy.processor.js";
export { getHandler, existsHandler } from "./strategy/mapping.js";
export * from "./strategy/index.js";
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class BaseDistributedHandler implements IEventHandler<"Strategy", "Distri

if (!round) {
//TODO: add logging that round was not found
console.log("Round not found for strategy address", strategyAddress);
return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {

import type { ProcessorDependencies, StrategyTimings } from "../../internal.js";
import DonationVotingMerkleDistributionDirectTransferStrategy from "../../abis/allo-v2/v1/DonationVotingMerkleDistributionDirectTransferStrategy.js";
import { calculateAmountInUsd } from "../../helpers/tokenMath.js";
import { getDateFromTimestamp } from "../../helpers/utils.js";
import { calculateAmountInUsd, getDateFromTimestamp } from "../../helpers/index.js";
import { TokenPriceNotFoundError, UnsupportedEventException } from "../../internal.js";
import { BaseDistributedHandler, BaseStrategyHandler } from "../common/index.js";
import { DVMDRegisteredHandler } from "./handlers/index.js";
Expand Down Expand Up @@ -108,6 +107,7 @@ export class DVMDDirectTransferStrategyHandler extends BaseStrategyHandler {
},
] as const;

// TODO: refactor when evmProvider implements this natively
if (evmProvider.getMulticall3Address()) {
results = await evmProvider.multicall({
contracts: contractCalls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ProjectNotFound,
RoundNotFound,
} from "../../../internal.js";
import { decodeDVMDApplicationData } from "../helpers/decoder.js";
import { decodeDVMDApplicationData } from "../helpers/index.js";

type Dependencies = Pick<
ProcessorDependencies,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./decoder.js";
6 changes: 6 additions & 0 deletions packages/processors/src/strategy/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { Hex } from "viem";
import type { StrategyHandlerConstructor } from "../internal.js";
import { DVMDDirectTransferStrategyHandler } from "./donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.js";

/**
* This mapping connects strategy IDs to their corresponding handler classes.
* When a new strategy event is received, the system uses this mapping to instantiate the appropriate handler
* based on the strategy ID from the event. Each handler implements specific logic for processing events
* from that strategy type.
*/
const strategyIdToHandler: Readonly<Record<string, StrategyHandlerConstructor>> = {
"0x6f9291df02b2664139cec5703c124e4ebce32879c74b6297faa1468aa5ff9ebf":
DVMDDirectTransferStrategyHandler, // DonationVotingMerkleDistributionDirectTransferStrategyv1.0
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export { BigNumber } from "./internal.js";
export type { BigNumberType } from "./internal.js";

export type { TokenCode, Token } from "./internal.js";
export { TOKENS } from "./tokens/tokens.js";
export { TOKENS, getToken } from "./tokens/tokens.js";

0 comments on commit 5bd2d20

Please sign in to comment.