Skip to content

Commit

Permalink
Merge branch 'refactor/bounties-to-tasks' into refactor/general
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Sep 25, 2023
2 parents 7062a04 + 840620d commit 03466d6
Show file tree
Hide file tree
Showing 29 changed files with 142 additions and 142 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: "Bounty Proposal"
name: "Task Proposal"
description: Have a suggestion for how to improve UbiquiBot? Let us know!
title: "Bounty Proposal: "
title: "Task Proposal: "

body:
- type: markdown
attributes:
value: |
## Feature Request Form
Thank you for taking the time to file a feature request.
If you register your wallet address, you will be eligible for compensation if this is accepted!
Thank you for taking the time to file a feature request.
If you register your wallet address, you will be eligible for compensation if this is accepted!
Please let us know how we can improve the bot.
- type: textarea
Expand All @@ -17,14 +17,14 @@ body:
description: Please let us know what inspired you to write this proposal. Backlinking to specific comments on GitHub, and leaving a remark about how the bot should have interacted with it is usually sufficient context.
validations:
required: false

- type: textarea
attributes:
label: Describe the solution
description: A clear description of what you want to happen. Add any considered drawbacks.
validations:
required: true

- type: textarea
attributes:
label: Remarks
Expand Down
2 changes: 1 addition & 1 deletion .github/ubiquibot-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
priceMultiplier: 1.5
# newContributorGreeting:
# enabled: true
# header: "Thank you for contributing to UbiquiBot! Please be sure to set your wallet address before completing your first bounty so that the automatic payout upon task completion will work for you."
# header: "Thank you for contributing to UbiquiBot! Please be sure to set your wallet address before completing your first task so that the automatic payout upon task completion will work for you."
# helpMenu: true
# footer: "###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!"
6 changes: 3 additions & 3 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Calculate Bounty Based on Events
name: Calculate Task Price Based on Events
on:
push:
issues:
Expand All @@ -14,12 +14,12 @@ on:
- edited

jobs:
calculate_bounty_job:
calculate_task_job:
# ignore events invoked by bots
if: >-
github.event.pull_request.payload.sender.type != 'Bot' && github.repository != 'ubiquity/ubiquibot'
runs-on: ubuntu-latest
name: Calculate Bounty with UbiquiBot
name: Calculate Task Price with UbiquiBot
steps:
# To use this repository's private action,
# you must check out the repository
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ yarn start:watch
- `DISQUALIFY_TIME`: (optional) Set a custom disqualify time (default: 7 days).
- `OPENAI_API_HOST`: (optional) Set OpenAI host url (default: https://api.openai.com).
- `OPENAI_API_KEY`: Set OpenAI key.
- `CHATGPT_USER_PROMPT_FOR_IMPORTANT_WORDS`: (optional) Set a custom user prompt for finding important words
- `CHATGPT_USER_PROMPT_FOR_IMPORTANT_WORDS`: (optional) Set a custom user prompt for finding important words
(default: "I need your help to find important words (e.g. unique adjectives) from github issue below and I want to parse them easily so please separate them using #(No other contexts needed). Please separate the words by # so I can parse them easily. Please answer simply as I only need the important words. Here is the issue content.\n").
- `CHATGPT_USER_PROMPT_FOR_MEASURE_SIMILARITY`: (optional) Set a custom user prompt for measuring similarity
- `CHATGPT_USER_PROMPT_FOR_MEASURE_SIMILARITY`: (optional) Set a custom user prompt for measuring similarity
(default: 'I have two github issues and I need to measure the possibility of the 2 issues are the same content (No other contents needed and give me only the number in %).\n Give me in number format and add % after the number.\nDo not tell other things since I only need the number (e.g. 85%). Here are two issues:\n 1. "%first%"\n2. "%second%"').
- `SIMILARITY_THRESHOLD`: (optional) Set similarity threshold (default: 80).
- `MEASURE_SIMILARITY_AI_TEMPERATURE`: (optional) Set ChatGPT temperature for measuring similarity (default: 0).
Expand All @@ -48,7 +48,7 @@ Instead, it is recommended to make a copy of the `.env.example` file and replace

1. Go to the [UbiquiBot App Marketplace](https://github.com/marketplace/ubiquibot)
2. Choose a plan and install UbiquiBot on your repository
3. Congratulations! You can now use the UbiquiBot to manage your bounties.
3. Congratulations! You can now use the UbiquiBot to manage your tasks.

To test the bot, you can:

Expand All @@ -61,14 +61,14 @@ To test the bot, you can:

`evm-network-id` is ID of the EVM-compatible network that will be used for payouts.

`price-multiplier` is a base number that will be used to calculate bounty price based on the following formula: `price = price-multiplier * time-label-weight * priority-label-weight * 100`
`price-multiplier` is a base number that will be used to calculate task price based on the following formula: `price = price-multiplier * time-label-weight * priority-label-weight * 100`

`time-labels` are labels for marking the time limit of the bounty:
`time-labels` are labels for marking the time limit of the task:

- `name` is a human-readable name
- `value` is number of seconds that corresponds to the time limit of the bounty
- `value` is number of seconds that corresponds to the time limit of the task

`priority-labels` are labels for marking the priority of the bounty:
`priority-labels` are labels for marking the priority of the task:

- `name` is a human-readable name

Expand All @@ -83,7 +83,7 @@ To test the bot, you can:

`disable-analytics` can be `true` or `false` that disables or enables weekly analytics collection by Ubiquity.

`payment-permit-max-price` sets the max amount for automatic payout of bounties when the issue is closed.
`payment-permit-max-price` sets the max amount for automatic payout of tasks when the issue is closed.

`comment-incentives` can be `true` or `false` that enable or disable comment incentives. These are payments generated for comments in the issue by contributors, excluding the assignee.

Expand All @@ -98,7 +98,7 @@ To test the bot, you can:
- `totals`:
- `word` defines reward for each word in the comment

`max-concurrent-assigns` is the maximum number of bounties that can be assigned to a bounty hunter at once. This excludes bounties with delayed or approved pull request reviews.
`max-concurrent-assigns` is the maximum number of tasks that can be assigned to an assignee at once. This excludes tasks with delayed or approved pull request reviews.

`register-wallet-with-verification` can be `true` or `false`. If enabled, it requires a signed message to set wallet address. This prevents users from setting wallet address from centralized exchanges, which would make payments impossible to claim.

Expand Down Expand Up @@ -139,7 +139,7 @@ DISQUALIFY_TIME="7 days" // 7 days
6. Open `localhost:3000` and follow instructions to add the bot to one of your repositories.

At this point the `.env` files auto-fill the empty fields (`PRIVATE_KEY` and `APP_ID`) if it is not previously filled.
Now you can make changes to the repository on GitHub (e.g. add a bounty) and the bot should react.
Now you can make changes to the repository on GitHub (e.g. add a task) and the bot should react.

You can, for example:

Expand All @@ -150,13 +150,13 @@ You can, for example:

## How it works

Bounty bot is built using the [probot](https://probot.github.io/) framework so initially the bot is a github app. But thanks to the [probot/adapter-github-actions](https://github.com/probot/adapter-github-actions) you can also use the bot as a github action.
Task bot is built using the [probot](https://probot.github.io/) framework so initially the bot is a github app. But thanks to the [probot/adapter-github-actions](https://github.com/probot/adapter-github-actions) you can also use the bot as a github action.

You can use the bounty bot as a [github app](https://github.com/marketplace/ubiquibot).
You can use the task bot as a [github app](https://github.com/marketplace/ubiquibot).

When using as a github app the flow is the following:

1. Bounty bot is added to a repository as a github app
1. Task bot is added to a repository as a github app
2. You run the bot "backend" (for example on your local machine)
3. Some event happens in a repository and the bot should react somehow (for example: on adding a time label to an issue the bot should add a price label)
4. Event details are sent to your deployed bot instance (to a webhook URL that was set in github app's settings)
Expand Down Expand Up @@ -197,7 +197,7 @@ Make sure you have your local instance of ubiquibot running.

## Architecture Overview

Bounty bot is built using the [probot](https://probot.github.io/) framework so initially the bot is a github app
Task bot is built using the [probot](https://probot.github.io/) framework so initially the bot is a github app

<pre>
&lt;root&gt;
Expand Down
8 changes: 4 additions & 4 deletions src/adapters/supabase/helpers/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ const getDbDataFromPermit = (permit: InsertPermit): Record<string, unknown> => {
repository_id: permit.repositoryId,
issue_id: permit.issueId,
network_id: permit.evmNetworkId,
bounty_hunter_id: permit.bountyHunterId,
task_hunter_id: permit.taskHunterId,
token_address: permit.tokenAddress,
payout_amount: permit.payoutAmount,
bounty_hunter_address: permit.bountyHunterAddress,
task_hunter_address: permit.taskHunterAddress,
nonce: permit.nonce,
deadline: permit.deadline,
signature: permit.signature,
Expand All @@ -492,10 +492,10 @@ const getPermitFromDbData = (data: Record<string, unknown>): Permit => {
repositoryId: data.repository_i,
issueId: data.issue_id,
evmNetworkId: data.network_id,
bountyHunterId: data.bounty_hunter_id,
taskHunterId: data.task_hunter_id,
tokenAddress: data.token_address,
payoutAmount: data.payout_amount,
bountyHunterAddress: data.bounty_hunter_address,
taskHunterAddress: data.task_hunter_address,
nonce: data.nonce,
deadline: data.deadline,
signature: data.signature,
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
commandSettings,
assistivePricing,
registerWalletWithVerification,
staleBountyTime,
staleTaskTime,
publicAccessControl,
openAIKey,
openAITokenLimit,
Expand Down Expand Up @@ -93,7 +93,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
command: commandSettings,
assign: {
maxConcurrentTasks: maxConcurrentTasks,
staleBountyTime: ms(staleBountyTime),
staleTaskTime: ms(staleTaskTime),
},
sodium: {
privateKey: process.env.X25519_PRIVATE_KEY ?? "",
Expand Down
2 changes: 1 addition & 1 deletion src/configs/strings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const GLOBAL_STRINGS = {
unassignComment: "Releasing the bounty back to dev pool because the allocated duration already ended!",
unassignComment: "Releasing the task due to lack of updates.",
askUpdate: "Do you have any updates",
assignCommandDisabledComment: "The `/assign` command is disabled for this repository.",
skipPriceLabelGenerationComment: "Pricing is disabled on parent issues.",
Expand Down
4 changes: 2 additions & 2 deletions src/configs/ubiquibot-config-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ export const DefaultConfig: MergedConfig = {
setLabel: true,
fundExternalClosedIssue: true,
},
staleBountyTime: "0d",
staleTaskTime: "0d",
newContributorGreeting: {
enabled: false,
header:
"Thank you for contributing! Please be sure to set your wallet address before completing your first bounty so that the automatic payout upon task completion will work for you.",
"Thank you for contributing! Please be sure to set your wallet address before completing your first task so that the automatic payout upon task completion will work for you.",
helpMenu: true,
footer:
"###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!",
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/comment/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export enum IssueCommentCommands {
STOP = "/stop", // unassign to default
WALLET = "/wallet", // register wallet address
PAYOUT = "/payout", // request permit payout
MULTIPLIER = "/multiplier", // set bounty multiplier (for treasury)
MULTIPLIER = "/multiplier", // set task multiplier (for contributor)
QUERY = "/query",
ASK = "/ask", // ask GPT a question
// Access Controls
Expand Down
30 changes: 15 additions & 15 deletions src/handlers/comment/handlers/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Payload, LabelItem, Comment, IssueType, Issue } from "../../../types";
import { deadLinePrefix } from "../../shared";
import { getWalletAddress, getWalletMultiplier } from "../../../adapters/supabase";
import { tableComment } from "./table";
import { bountyInfo } from "../../wildcard";
import { taskInfo } from "../../wildcard";
import { ASSIGN_COMMAND_ENABLED, GLOBAL_STRINGS } from "../../../configs";
import { isParentIssue } from "../../pricing";

Expand All @@ -18,7 +18,7 @@ export const assign = async (body: string) => {

const id = organization?.id || repository?.id; // repository?.id as fallback

const staleBounty = config.assign.staleBountyTime;
const staleTask = config.assign.staleTaskTime;

logger.info(`Received '/start' command from user: ${payload.sender.login}, body: ${body}`);
const issue = (_payload as Payload).issue;
Expand Down Expand Up @@ -103,7 +103,7 @@ export const assign = async (body: string) => {
<ul>
<li>Use <code>/wallet 0x0000...0000</code> if you want to update your registered payment wallet address @${payload.sender.login}.</li>
<li>Be sure to open a draft pull request as soon as possible to communicate updates on your progress.</li>
<li>Be sure to provide timely updates to us when requested, or you will be automatically unassigned from the bounty.</li>
<li>Be sure to provide timely updates to us when requested, or you will be automatically unassigned from the task.</li>
<ul>`,
};

Expand All @@ -114,12 +114,12 @@ export const assign = async (body: string) => {

let days: number | undefined;
let staleToDays: number | undefined;
let isBountyStale = false;
let isTaskStale = false;

if (staleBounty !== 0) {
if (staleTask !== 0) {
days = Math.floor((new Date().getTime() - new Date(issue.created_at).getTime()) / (1000 * 60 * 60 * 24));
staleToDays = Math.floor(staleBounty / (1000 * 60 * 60 * 24));
isBountyStale = days >= staleToDays;
staleToDays = Math.floor(staleTask / (1000 * 60 * 60 * 24));
isTaskStale = days >= staleToDays;
}

// double check whether the assign message has been already posted or not
Expand All @@ -128,8 +128,8 @@ export const assign = async (body: string) => {
const comments = issueComments.sort((a: Comment, b: Comment) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
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, days }) + comment.tips;
const { multiplier, reason, task } = await getMultiplierInfoToDisplay(payload.sender.login, id?.toString(), issue);
return tableComment({ ...comment, multiplier, reason, task, isTaskStale, days }) + comment.tips;
}
return;
};
Expand All @@ -139,24 +139,24 @@ const getMultiplierInfoToDisplay = async (senderLogin: string, org_id: string, i

const multiplier = value?.toFixed(2) || "1.00";

let _multiplierToDisplay, _reasonToDisplay, _bountyToDisplay;
let _multiplierToDisplay, _reasonToDisplay, _taskToDisplay;

if (value == 1) {
if (reason) {
_multiplierToDisplay = multiplier;
_reasonToDisplay = reason;
} else {
// default mode: normal bounty hunter with default multiplier 1 and no reason
// default mode: normal contributor with default multiplier 1 and no reason
// nothing to show about multiplier
}
} else {
_multiplierToDisplay = multiplier;
_reasonToDisplay = reason;
_bountyToDisplay = `Permit generation disabled because price label is not set.`;
const issueDetailed = bountyInfo(issue);
_taskToDisplay = `Permit generation disabled because price label is not set.`;
const issueDetailed = taskInfo(issue);
if (issueDetailed.priceLabel) {
_bountyToDisplay = (+issueDetailed.priceLabel.substring(7, issueDetailed.priceLabel.length - 4) * value).toString() + " USD";
_taskToDisplay = (+issueDetailed.priceLabel.substring(7, issueDetailed.priceLabel.length - 4) * value).toString() + " USD";
}
}
return { multiplier: _multiplierToDisplay, reason: _reasonToDisplay, bounty: _bountyToDisplay };
return { multiplier: _multiplierToDisplay, reason: _reasonToDisplay, task: _taskToDisplay };
};
4 changes: 2 additions & 2 deletions src/handlers/comment/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const issueReopenedCallback = async (): Promise<void> => {
}

await addCommentToIssue(
`@${assignee} please be sure to review this conversation and implement any necessary fixes. Unless this is closed as completed, its payment of **${formattedAmount} ${tokenSymbol}** will be deducted from your next bounty.`,
`@${assignee} please be sure to review this conversation and implement any necessary fixes. Unless this is closed as completed, its payment of **${formattedAmount} ${tokenSymbol}** will be deducted from your next task.`,
issue.number
);
} else {
Expand Down Expand Up @@ -292,7 +292,7 @@ export const userCommands = (): UserCommands[] => {
},
{
id: IssueCommentCommands.MULTIPLIER,
description: `Set the bounty payout multiplier for a specific contributor, and provide a reason for why.\n\te.g. '/wallet @user 0.5 "Multiplier reason"'`,
description: `Set the task payout multiplier for a specific contributor, and provide a reason for why.\n\te.g. '/wallet @user 0.5 "Multiplier reason"'`,
handler: multiplier,
callback: commandCallback,
},
Expand Down
Loading

0 comments on commit 03466d6

Please sign in to comment.