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

Commit

Permalink
refactor: config Name Format (#761)
Browse files Browse the repository at this point in the history
* feat(camelCase): changing config file case from
kebab case to camel case

* refactor(config): reverting file name to
ubiquibot-config.yml

* feat(camelCase):
- changing ubiquibot-config-default.json to cameCase

* feat(private):
- changing to camelCase in private

* feat(config.ts):
- updating WideConfigSchema and MergedConfigSchema

* feat(update-base):
- updating price-multiplier to camelCase counterpart priceMultiplier

* fix(config):
- removing quotes

* fix(quotes):
- removing left out quotes

* fix(ts-errors):
- fixing ts errors

* fix: build

---------

Co-authored-by: 0xCodercrane <[email protected]>
  • Loading branch information
Sadaf-A and 0xcodercrane authored Sep 22, 2023
1 parent c40efc5 commit b417336
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/ubiquibot-config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
price-multiplier: 1.5
priceMultiplier: 1.5
2 changes: 1 addition & 1 deletion src/bindings/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
},
ask: {
apiKey: openAIKey,
tokenLimit: openAITokenLimit,
tokenLimit: openAITokenLimit || 0,
},
accessControl: enableAccessControl,
};
Expand Down
57 changes: 28 additions & 29 deletions src/configs/ubiquibot-config-default.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { MergedConfig } from "../types";

export const DefaultConfig: MergedConfig = {
"evm-network-id": 100,
"price-multiplier": 1,
"issue-creator-multiplier": 2,
"payment-permit-max-price": 9007199254740991,
"max-concurrent-assigns": 9007199254740991,
"assistive-pricing": false,
"disable-analytics": false,
"comment-incentives": false,
"register-wallet-with-verification": false,
"openai-api-key": null,
"openai-token-limit": 8000,
"stale-bounty-time": "0d",
"promotion-comment":
"\n<h6>If you enjoy the DevPool experience, please follow <a href='https://github.com/ubiquity'>Ubiquity on GitHub</a> and star <a href='https://github.com/ubiquity/devpool-directory'>this repo</a> to show your support. It helps a lot!</h6>",
"default-labels": [],
"time-labels": [
export const DefaultConfig : MergedConfig = {
evmNetworkId: 100,
priceMultiplier: 1,
issueCreatorMultiplier: 2,
paymentPermitMaxPrice: 9007199254740991,
maxConcurrentAssigns: 9007199254740991,
assistivePricing: false,
disableAnalytics: false,
commentIncentives: false,
registerWalletWithVerification: false,
promotionComment: "\n<h6>If you enjoy the DevPool experience, please follow <a href='https://github.com/ubiquity'>Ubiquity on GitHub</a> and star <a href='https://github.com/ubiquity/devpool-directory'>this repo</a> to show your support. It helps a lot!</h6>",
defaultLabels: [],
timeLabels: [

{
name: "Time: <1 Hour",
},
Expand All @@ -33,7 +30,7 @@ export const DefaultConfig: MergedConfig = {
name: "Time: <1 Month",
},
],
"priority-labels": [
priorityLabels: [
{
name: "Priority: 1 (Normal)",
},
Expand All @@ -50,7 +47,7 @@ export const DefaultConfig: MergedConfig = {
name: "Priority: 5 (Emergency)",
},
],
"command-settings": [
commandSettings: [
{
name: "start",
enabled: false,
Expand Down Expand Up @@ -89,15 +86,17 @@ export const DefaultConfig: MergedConfig = {
},
],
incentives: {
comment: {
elements: {},
totals: {
word: 0,
},
},

"comment": {
"elements": {},
"totals": {
"word": 0
}
}
},
"enable-access-control": {
label: false,
organization: true,
enableAccessControl: {
"label": false,
"organization": true
},
};
staleBountyTime:"0d"
}
4 changes: 2 additions & 2 deletions src/handlers/push/update-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export const updateBaseRate = async (context: Context, payload: PushPayload, fil
const previousContent = Buffer.from(preFileContent, "base64").toString();
const previousConfig = await parseYAML(previousContent);

if (!previousConfig || !previousConfig["price-multiplier"]) {
if (!previousConfig || !previousConfig["priceMultiplier"]) {
logger.debug("No multiplier found in file object");
return;
}

const previousBaseRate = previousConfig["price-multiplier"];
const previousBaseRate = previousConfig["priceMultiplier"];

// fetch all labels
const repoLabels = await listLabelsForRepo();
Expand Down
78 changes: 39 additions & 39 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const CommentsSchema = Type.Object({
});

export const AskSchema = Type.Object({
apiKey: Type.Union([Type.String(), Type.Null()]),
apiKey: Type.Optional(Type.String()),
tokenLimit: Type.Number(),
});

Expand Down Expand Up @@ -163,26 +163,26 @@ export type GPTResponse = Static<typeof GPTResponseSchema>;

export const WideConfigSchema = Type.Object(
{
"evm-network-id": Type.Optional(Type.Number()),
"price-multiplier": Type.Optional(Type.Number()),
"issue-creator-multiplier": Type.Optional(Type.Number()),
"time-labels": Type.Optional(Type.Array(LabelItemSchema)),
"priority-labels": Type.Optional(Type.Array(LabelItemSchema)),
"payment-permit-max-price": Type.Optional(Type.Number()),
"command-settings": Type.Optional(Type.Array(CommandItemSchema)),
"promotion-comment": Type.Optional(Type.String()),
"disable-analytics": Type.Optional(Type.Boolean()),
"comment-incentives": Type.Optional(Type.Boolean()),
"assistive-pricing": Type.Optional(Type.Boolean()),
"max-concurrent-assigns": Type.Optional(Type.Number()),
evmNetworkId: Type.Optional(Type.Number()),
priceMultiplier: Type.Optional(Type.Number()),
issueCreatorMultiplier: Type.Optional(Type.Number()),
timeLabels: Type.Optional(Type.Array(LabelItemSchema)),
priorityLabels: Type.Optional(Type.Array(LabelItemSchema)),
paymentPermitMaxPrice: Type.Optional(Type.Number()),
commandSettings: Type.Optional(Type.Array(CommandItemSchema)),
promotionComment: Type.Optional(Type.String()),
disableAnalytics: Type.Optional(Type.Boolean()),
commentIncentives: Type.Optional(Type.Boolean()),
assistivePricing: Type.Optional(Type.Boolean()),
maxConcurrentAssigns: Type.Optional(Type.Number()),
incentives: Type.Optional(IncentivesSchema),
"default-labels": Type.Optional(Type.Array(Type.String())),
"register-wallet-with-verification": Type.Optional(Type.Boolean()),
"enable-access-control": Type.Optional(AccessControlSchema),
"stale-bounty-time": Type.Optional(Type.String()),
"openai-api-key": AskSchema.apiKey,
"openai-token-limit": Type.Optional(Type.Number()),
"private-key-encrypted": Type.Optional(Type.String()),
defaultLabels: Type.Optional(Type.Array(Type.String())),
registerWalletWithVerification: Type.Optional(Type.Boolean()),
enableAccessControl: Type.Optional(AccessControlSchema),
openAIKey: Type.Optional(Type.String()),
openAITokenLimit: Type.Optional(Type.Number()),
staleBountyTime: Type.Optional(Type.String()),
privateKeyEncrypted: Type.Optional(Type.String()),
},
{
additionalProperties: false,
Expand All @@ -194,26 +194,26 @@ export type WideConfig = Static<typeof WideConfigSchema>;
export type WideRepoConfig = WideConfig;

export const MergedConfigSchema = Type.Object({
"evm-network-id": Type.Number(),
"price-multiplier": Type.Number(),
"private-key-encrypted": Type.Optional(Type.String()),
"issue-creator-multiplier": Type.Number(),
"time-labels": Type.Array(LabelItemSchema),
"priority-labels": Type.Array(LabelItemSchema),
"payment-permit-max-price": Type.Number(),
"command-settings": Type.Array(CommandItemSchema),
"promotion-comment": Type.String(),
"disable-analytics": Type.Boolean(),
"comment-incentives": Type.Boolean(),
"assistive-pricing": Type.Boolean(),
"max-concurrent-assigns": Type.Number(),
evmNetworkId: Type.Number(),
priceMultiplier: Type.Number(),
privateKeyEncrypted: Type.Optional(Type.String()),
issueCreatorMultiplier: Type.Number(),
timeLabels: Type.Array(LabelItemSchema),
priorityLabels: Type.Array(LabelItemSchema),
paymentPermitMaxPrice: Type.Number(),
commandSettings: Type.Array(CommandItemSchema),
promotionComment: Type.String(),
disableAnalytics: Type.Boolean(),
commentIncentives: Type.Boolean(),
assistivePricing: Type.Boolean(),
maxConcurrentAssigns: Type.Number(),
incentives: IncentivesSchema,
"default-labels": Type.Array(Type.String()),
"register-wallet-with-verification": Type.Boolean(),
"enable-access-control": AccessControlSchema,
"openai-api-key": AskSchema.apiKey,
"openai-token-limit": Type.Number(),
"stale-bounty-time": Type.String(),
defaultLabels: Type.Array(Type.String()),
registerWalletWithVerification: Type.Boolean(),
enableAccessControl: AccessControlSchema,
openAIKey: Type.Optional(Type.String()),
openAITokenLimit: Type.Optional(Type.Number()),
staleBountyTime: Type.String(),
});

export type MergedConfig = Static<typeof MergedConfigSchema>;
41 changes: 21 additions & 20 deletions src/utils/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { WideConfig, WideRepoConfig, WideConfigSchema } from "../types";

const CONFIG_REPO = "ubiquibot-config";
const CONFIG_PATH = ".github/ubiquibot-config.yml";
const KEY_NAME = "private-key-encrypted";
const KEY_NAME = "privateKeyEncrypted";
const KEY_PREFIX = "HSK_";

export const getConfigSuperset = async (context: Context, type: "org" | "repo", filePath: string): Promise<string | undefined> => {
Expand Down Expand Up @@ -141,26 +141,27 @@ export const getWideConfig = async (context: Context) => {
const mergedConfigData: MergedConfig = mergeConfigs(configs);

const configData = {
networkId: mergedConfigData["evm-network-id"],
networkId: mergedConfigData.evmNetworkId,
privateKey: privateKeyDecrypted ?? "",
assistivePricing: mergedConfigData["assistive-pricing"],
commandSettings: mergedConfigData["command-settings"],
baseMultiplier: mergedConfigData["price-multiplier"],
issueCreatorMultiplier: mergedConfigData["issue-creator-multiplier"],
timeLabels: mergedConfigData["time-labels"],
priorityLabels: mergedConfigData["priority-labels"],
paymentPermitMaxPrice: mergedConfigData["payment-permit-max-price"],
disableAnalytics: mergedConfigData["disable-analytics"],
bountyHunterMax: mergedConfigData["max-concurrent-assigns"],
incentiveMode: mergedConfigData["comment-incentives"],
incentives: mergedConfigData["incentives"],
defaultLabels: mergedConfigData["default-labels"],
promotionComment: mergedConfigData["promotion-comment"],
registerWalletWithVerification: mergedConfigData["register-wallet-with-verification"],
enableAccessControl: mergedConfigData["enable-access-control"],
openAIKey: mergedConfigData["openai-api-key"],
openAITokenLimit: mergedConfigData["openai-token-limit"],
staleBountyTime: mergedConfigData["stale-bounty-time"],
assistivePricing: mergedConfigData.assistivePricing,
commandSettings: mergedConfigData.commandSettings,
baseMultiplier: mergedConfigData.priceMultiplier,
issueCreatorMultiplier: mergedConfigData.issueCreatorMultiplier,
timeLabels: mergedConfigData.timeLabels,
priorityLabels: mergedConfigData.priorityLabels,
paymentPermitMaxPrice: mergedConfigData.paymentPermitMaxPrice,
disableAnalytics: mergedConfigData.disableAnalytics,
bountyHunterMax: mergedConfigData.maxConcurrentAssigns,
incentiveMode: mergedConfigData.commentIncentives,
incentives: mergedConfigData.incentives,
defaultLabels: mergedConfigData.defaultLabels,
promotionComment: mergedConfigData.promotionComment,
registerWalletWithVerification: mergedConfigData.registerWalletWithVerification,
enableAccessControl: mergedConfigData.enableAccessControl,
openAIKey: mergedConfigData.openAIKey,
openAITokenLimit: mergedConfigData.openAITokenLimit,
staleBountyTime: mergedConfigData.staleBountyTime,

};

return configData;
Expand Down

0 comments on commit b417336

Please sign in to comment.