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 8c25428 commit baf8c34
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
10 changes: 4 additions & 6 deletions packages/processors/src/allo/handlers/poolCreated.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ export class PoolCreatedHandler implements IEventHandler<"Allo", "PoolCreated">
strategyId,
);

// const strategy = extractStrategyFromId(strategyId);

const token = getToken(this.chainId, matchTokenAddress);

let strategyTimings: StrategyTimings = {
Expand All @@ -78,15 +76,15 @@ export class PoolCreatedHandler implements IEventHandler<"Allo", "PoolCreated">
donationsEndTime: null,
};

let matchAmount = {
let matchAmountObj = {
matchAmount: 0n,
matchAmountInUsd: "0",
};

if (strategyHandler) {
strategyTimings = await strategyHandler.fetchStrategyTimings(strategyAddress);
if (parsedRoundMetadata.success && token) {
matchAmount = await strategyHandler.fetchMatchAmount(
matchAmountObj = await strategyHandler.fetchMatchAmount(
Number(parsedRoundMetadata.data.quadraticFundingConfig.matchingFundsAvailable),
token,
this.event.blockTimestamp,
Expand Down Expand Up @@ -117,8 +115,8 @@ export class PoolCreatedHandler implements IEventHandler<"Allo", "PoolCreated">
totalAmountDonatedInUsd: "0",
uniqueDonorsCount: 0,
matchTokenAddress,
matchAmount: matchAmount.matchAmount,
matchAmountInUsd: matchAmount.matchAmountInUsd,
matchAmount: matchAmountObj.matchAmount,
matchAmountInUsd: matchAmountObj.matchAmountInUsd,
fundedAmount,
fundedAmountInUsd,
applicationMetadataCid: metadataPointer,
Expand Down
2 changes: 2 additions & 0 deletions packages/processors/src/strategy/common/base.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export abstract class BaseStrategyHandler implements IStrategyHandler<StrategyEv
this.name = name;
}

/** @inheritdoc */
async fetchStrategyTimings(_strategyAddress: Address): Promise<StrategyTimings> {
return {
applicationsStartTime: null,
Expand All @@ -26,6 +27,7 @@ export abstract class BaseStrategyHandler implements IStrategyHandler<StrategyEv
};
}

/** @inheritdoc */
async fetchMatchAmount(
_matchingFundsAvailable: number,
_token: Token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ export class DVMDDirectTransferStrategyHandler extends BaseStrategyHandler {
};
}

/** @inheritdoc */
/**
* Get the amount in USD for a given token and amount and timestamp
* @param token - The token
* @param amount - The amount
* @param timestamp - The timestamp
* @returns The amount in USD
* @throws TokenPriceNotFoundError if the token price is not found
*/
private async getTokenAmountInUsd(
token: Token,
amount: bigint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,25 @@ type Dependencies = Pick<
"roundRepository" | "projectRepository" | "metadataProvider"
>;

/**
* Handles the Registered event for the Donation Voting Merkle Distribution Direct Transfer strategy.
*
* This handler performs the following core actions when a project registers for a round:
* - Validates that both the project and round exist
* - Decodes the application data from the event
* - Retrieves the application metadata
* - Creates a new application record with PENDING status
* - Links the application to both the project and round
*/

export class DVMDRegisteredHandler implements IEventHandler<"Strategy", "Registered"> {
constructor(
readonly event: ProtocolEvent<"Strategy", "Registered">,
private readonly chainId: ChainId,
private readonly dependencies: Dependencies,
) {}

/** @inheritdoc */
async handle(): Promise<Changeset[]> {
const { projectRepository, roundRepository, metadataProvider } = this.dependencies;
const { data: encodedData, recipientId, sender } = this.event.params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class StrategyHandlerFactory {
const _strategyId = strategyId.toLowerCase() as Hex;
const StrategyHandlerClass = getHandler(_strategyId);

console.log("StrategyHandlerClass", StrategyHandlerClass);
return StrategyHandlerClass ? new StrategyHandlerClass(chainId, dependencies) : undefined;
}
}

0 comments on commit baf8c34

Please sign in to comment.