From 5daaf48eb30cae4246f57fa0e84daa31feec9325 Mon Sep 17 00:00:00 2001 From: Guilherme Allen Date: Wed, 15 Jan 2025 10:42:19 +0000 Subject: [PATCH] Add category and chains flags to verify (#32) --- src/commands/verify.ts | 24 +++++++++++++++++++++++- src/services/plugin.ts | 28 +++++++++++++++------------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/commands/verify.ts b/src/commands/verify.ts index 7708b52..f979b34 100644 --- a/src/commands/verify.ts +++ b/src/commands/verify.ts @@ -18,9 +18,29 @@ export const verifyCommand = new Command() "To verify a plugin we need the url for a public repository containing the plugin's code", ) .option( - "-v, --version ", + "-v, --version [versionNumber]", "Specify the version of the plugin in case of an update", ) + .option( + "-c, --categories [categories]", + "List some categories that describe the type of plugin you're verifying. Example: -c DeFi,Investing", + (categories) => + categories && typeof categories === "string" && categories.length > 0 + ? categories.split(",") + : null, + ) + .option( + "-x, --chains [chainIds]", + "If your plugin works on specific evm chains, you can specify them so your plugin is easier to find. If your plugin does not work on evm you can ignore this flag. Example: -x 1,8453", + (str) => { + // convert comma separated numbers on a string to an int array + if (!str || typeof str !== "string" || str.length === 0) { + return null; + } + const strArray = str.split(","); + return strArray.map((num) => parseInt(num)); + }, + ) .action(async (options) => { const url = options.url || deployedUrl; @@ -49,5 +69,7 @@ export const verifyCommand = new Command() email: options.email, repo: options.repo, version: options.version, + categories: options.categories, + chains: options.chains, }); }); diff --git a/src/services/plugin.ts b/src/services/plugin.ts index f88e510..55e2b64 100644 --- a/src/services/plugin.ts +++ b/src/services/plugin.ts @@ -97,12 +97,16 @@ export class PluginService { repo, version, accountId, + categories, + chains, }: { pluginId: string; email: string; repo: string; version?: string; accountId?: string; + categories?: string[]; + chains?: number[]; }): Promise { const message = await this.auth.getAuthentication(accountId); if (!message) { @@ -111,19 +115,17 @@ export class PluginService { } try { - //const res = await fetch(`${this.bitteUrls.BASE_URL}/verify/${pluginId}`, { - const res = await fetch( - `http://localhost:3001/api/ai-plugins/verify/${pluginId}`, - { - method: "POST", - headers: { "bitte-api-key": message }, - body: JSON.stringify({ - repo: repo, - email: email, - version: version, - }), - }, - ); + const res = await fetch(`${this.bitteUrls.BASE_URL}/verify/${pluginId}`, { + method: "POST", + headers: { "bitte-api-key": message }, + body: JSON.stringify({ + repo: repo, + email: email, + version: version, + categories: categories, + chains: chains, + }), + }); if (res.ok) { console.log(