Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

fix: stale bounty #670

Merged
merged 12 commits into from
Sep 7, 2023
4 changes: 2 additions & 2 deletions src/bindings/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ms from "ms";

import { BotConfig, BotConfigSchema } from "../types";
import { DEFAULT_BOT_DELAY, DEFAULT_DISQUALIFY_TIME, DEFAULT_FOLLOWUP_TIME, DEFAULT_PERMIT_BASE_URL } from "../configs";
import { DEFAULT_BOT_DELAY, DEFAULT_DISQUALIFY_TIME, DEFAULT_FOLLOWUP_TIME, DEFAULT_PERMIT_BASE_URL, STALE_BOUNTY_TIME } from "../configs";
import { getPayoutConfigByNetworkId } from "../helpers";
import { ajv } from "../utils";
import { Context } from "probot";
Expand Down Expand Up @@ -76,7 +76,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
command: commandSettings,
assign: {
bountyHunterMax: bountyHunterMax,
staleBountyTime: ms(process.env.STALE_BOUNTY_TIME || "30d"),
staleBountyTime: ms(STALE_BOUNTY_TIME),
},
sodium: {
privateKey: process.env.X25519_PRIVATE_KEY ?? "",
Expand Down
1 change: 1 addition & 0 deletions src/configs/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const ASSIGN_COMMAND_ENABLED = true;
*/
export const DEFAULT_FOLLOWUP_TIME = "4 days"; // 4 days
export const DEFAULT_DISQUALIFY_TIME = "7 days"; // 7 days
export const STALE_BOUNTY_TIME = "30d"; // 2 minutes
Keyrxng marked this conversation as resolved.
Show resolved Hide resolved

export const DEFAULT_NETWORK_ID = 1; // ethereum
export const DEFAULT_RPC_ENDPOINT = "https://rpc-bot.ubq.fi/v1/mainnet";
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { tableComment } from "./table";
import { bountyInfo } from "../../wildcard";
import { ASSIGN_COMMAND_ENABLED, GLOBAL_STRINGS } from "../../../configs";
import { isParentIssue } from "../../pricing";
import ms from "ms";

export const assign = async (body: string) => {
const { payload: _payload } = getBotContext();
Expand Down Expand Up @@ -113,6 +114,7 @@ export const assign = async (body: string) => {
}

const isBountyStale = new Date().getTime() - new Date(issue.created_at).getTime() > staleBounty;
const days = Math.floor((new Date().getTime() - new Date(issue.created_at).getTime()) / (1000 * 60 * 60 * 24));

// double check whether the assign message has been already posted or not
logger.info(`Creating an issue comment: ${comment.commit}`);
Expand All @@ -121,7 +123,7 @@ export const assign = async (body: string) => {
const latestComment = comments.length > 0 ? comments[0].body : undefined;
if (latestComment && comment.commit != latestComment) {
const { multiplier, reason, bounty } = await getMultiplierInfoToDisplay(payload.sender.login, id?.toString(), issue);
return tableComment({ ...comment, multiplier, reason, bounty, isBountyStale }) + comment.tips;
return tableComment({ ...comment, multiplier, reason, bounty, isBountyStale, days }) + comment.tips;
}
return;
};
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ export const tableComment = ({
reason,
bounty,
isBountyStale,
days,
}: {
deadline: string;
wallet: string;
multiplier?: string;
reason?: string;
bounty?: string;
isBountyStale?: boolean;
days?: number;
}) => {
return `
<code>
<table>
<tr>
<td>Ready to begin?</td>
${!isBountyStale ? `<td>You can start right away!</td>` : `<td>Please wait for confirmation first.</td>`}
${!isBountyStale ? `<td>You can start right away!</td>` : `<td>This task was created over ${days} days ago. Please verify that it is still current.</td>`}
</tr>
<tr>
<td>Deadline</td>
Expand Down
1 change: 1 addition & 0 deletions src/utils/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "./helpers";

import DEFAULT_CONFIG_JSON from "../../ubiquibot-config-default.json";
import ms from "ms";

const CONFIG_REPO = "ubiquibot-config";
const CONFIG_PATH = ".github/ubiquibot-config.yml";
Expand Down
21 changes: 13 additions & 8 deletions ubiquibot-config-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,40 @@
"command-settings": [
{
"name": "start",
"enabled": false
"enabled": true
},
{
"name": "stop",
"enabled": false
"enabled": true
},
{
"name": "wallet",
"enabled": false
"enabled": true
},
{
"name": "payout",
"enabled": false
"enabled": true
},
{
"name": "multiplier",
"enabled": false
"enabled": true
},
{
"name": "query",
"enabled": false
"enabled": true
},
{
"name": "allow",
"enabled": false
"enabled": true
},
{
"name": "autopay",
"enabled": false
"enabled": true
},
{
"name": "assign",
"enabled": true,
"staleBountyTime": 120000
Keyrxng marked this conversation as resolved.
Show resolved Hide resolved
}
],
"incentives": {
Expand Down