diff --git a/packages/processors/src/allo/handlers/poolCreated.handler.ts b/packages/processors/src/allo/handlers/poolCreated.handler.ts index eec68e4..1a38ac4 100644 --- a/packages/processors/src/allo/handlers/poolCreated.handler.ts +++ b/packages/processors/src/allo/handlers/poolCreated.handler.ts @@ -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, diff --git a/packages/processors/src/helpers/index.ts b/packages/processors/src/helpers/index.ts new file mode 100644 index 0000000..0160fc0 --- /dev/null +++ b/packages/processors/src/helpers/index.ts @@ -0,0 +1,3 @@ +export * from "./roles.js"; +export * from "./utils.js"; +export * from "./tokenMath.js"; diff --git a/packages/processors/src/internal.ts b/packages/processors/src/internal.ts index fa8511a..b71289f 100644 --- a/packages/processors/src/internal.ts +++ b/packages/processors/src/internal.ts @@ -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"; diff --git a/packages/processors/src/strategy/common/baseDistributed.handler.ts b/packages/processors/src/strategy/common/baseDistributed.handler.ts index 60a6dda..138e918 100644 --- a/packages/processors/src/strategy/common/baseDistributed.handler.ts +++ b/packages/processors/src/strategy/common/baseDistributed.handler.ts @@ -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 []; } diff --git a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts index 561028d..fb1ee1e 100644 --- a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts +++ b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/dvmdDirectTransfer.handler.ts @@ -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"; @@ -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, diff --git a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts index eb170ac..8fd10c8 100644 --- a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts +++ b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/handlers/registered.handler.ts @@ -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, diff --git a/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/helpers/index.ts b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/helpers/index.ts new file mode 100644 index 0000000..1616d7f --- /dev/null +++ b/packages/processors/src/strategy/donationVotingMerkleDistributionDirectTransfer/helpers/index.ts @@ -0,0 +1 @@ +export * from "./decoder.js"; diff --git a/packages/processors/src/strategy/mapping.ts b/packages/processors/src/strategy/mapping.ts index 20c1c67..9913bf2 100644 --- a/packages/processors/src/strategy/mapping.ts +++ b/packages/processors/src/strategy/mapping.ts @@ -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> = { "0x6f9291df02b2664139cec5703c124e4ebce32879c74b6297faa1468aa5ff9ebf": DVMDDirectTransferStrategyHandler, // DonationVotingMerkleDistributionDirectTransferStrategyv1.0 diff --git a/packages/shared/src/external.ts b/packages/shared/src/external.ts index 2843728..0216b8e 100644 --- a/packages/shared/src/external.ts +++ b/packages/shared/src/external.ts @@ -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";