Skip to content

Commit

Permalink
feat: consider the timeout issue
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcodercrane committed Sep 24, 2023
1 parent a3306ad commit d79e068
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/handlers/payout/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,43 @@ export const handleIssueClosed = async (
return { error: `Permit generation skipped since issue's bounty is higher than ${incentivesCalculation.paymentPermitMaxPrice}` };
}

// ASSIGNEE REWARD HANDLER
if (assigneeReward && assigneeReward.reward && assigneeReward.reward[0].account !== "0x") {
const { txData, payoutUrl } = await generatePermit2Signature(
assigneeReward.reward[0].account,
assigneeReward.reward[0].priceInEth,
incentivesCalculation.issue.node_id,
incentivesCalculation.assignee.node_id
);
const tokenSymbol = await getTokenSymbol(incentivesCalculation.paymentToken, incentivesCalculation.rpc);
const shortenRecipient = shortenEthAddress(assigneeReward.reward[0].account, `[ CLAIM ${priceInEth} ${tokenSymbol.toUpperCase()} ]`.length);
logger.info(`Posting a payout url to the issue, url: ${payoutUrl}`);
assigneeComment =
`#### ${title} Reward \n### [ **[ CLAIM ${priceInEth} ${tokenSymbol.toUpperCase()} ]** ](${payoutUrl})\n` + "```" + shortenRecipient + "```";
const permitComments = incentivesCalculation.comments.filter((content) => {
const permitUrlMatches = content.body.match(incentivesCalculation.claimUrlRegex);
if (!permitUrlMatches || permitUrlMatches.length < 2) return false;
else return true;
});

if (permitComments.length > 0) {
logger.info(`Skip to generate a permit url because it has been already posted.`);
return { error: `Permit generation disabled because it was already posted to this issue.` };
}

if (assigneeReward.reward[0].penaltyAmount.gt(0)) {
await removePenalty(
incentivesCalculation.assignee.login,
incentivesCalculation.payload.repository.full_name,
incentivesCalculation.paymentToken,
incentivesCalculation.networkId.toString(),
assigneeReward.reward[0].penaltyAmount
);
}

await savePermitToDB(incentivesCalculation.assignee.id, txData);
}

// COMMENTERS REWARD HANDLER
if (conversationRewards.reward && conversationRewards.reward.length > 0) {
commentersComment = `#### ${conversationRewards.title} Rewards \n`;
Expand Down Expand Up @@ -408,43 +445,6 @@ export const handleIssueClosed = async (
logger.info(`Skipping to generate a permit url for missing account. fallback: ${creatorReward.fallbackReward}`);
}

// ASSIGNEE REWARD HANDLER
if (assigneeReward && assigneeReward.reward && assigneeReward.reward[0].account !== "0x") {
const { txData, payoutUrl } = await generatePermit2Signature(
assigneeReward.reward[0].account,
assigneeReward.reward[0].priceInEth,
incentivesCalculation.issue.node_id,
incentivesCalculation.assignee.node_id
);
const tokenSymbol = await getTokenSymbol(incentivesCalculation.paymentToken, incentivesCalculation.rpc);
const shortenRecipient = shortenEthAddress(assigneeReward.reward[0].account, `[ CLAIM ${priceInEth} ${tokenSymbol.toUpperCase()} ]`.length);
logger.info(`Posting a payout url to the issue, url: ${payoutUrl}`);
assigneeComment =
`#### ${title} Reward \n### [ **[ CLAIM ${priceInEth} ${tokenSymbol.toUpperCase()} ]** ](${payoutUrl})\n` + "```" + shortenRecipient + "```";
const permitComments = incentivesCalculation.comments.filter((content) => {
const permitUrlMatches = content.body.match(incentivesCalculation.claimUrlRegex);
if (!permitUrlMatches || permitUrlMatches.length < 2) return false;
else return true;
});

if (permitComments.length > 0) {
logger.info(`Skip to generate a permit url because it has been already posted.`);
return { error: `Permit generation disabled because it was already posted to this issue.` };
}

if (assigneeReward.reward[0].penaltyAmount.gt(0)) {
await removePenalty(
incentivesCalculation.assignee.login,
incentivesCalculation.payload.repository.full_name,
incentivesCalculation.paymentToken,
incentivesCalculation.networkId.toString(),
assigneeReward.reward[0].penaltyAmount
);
}

await savePermitToDB(incentivesCalculation.assignee.id, txData);
}

// MERGE ALL REWARDS
const rewards = rewardByUser.reduce((acc, curr) => {
const existing = acc.find((item) => item.userId === curr.userId);
Expand Down

0 comments on commit d79e068

Please sign in to comment.