diff --git a/.cspell.json b/.cspell.json index 213394b..631d106 100644 --- a/.cspell.json +++ b/.cspell.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", "version": "0.2", - "ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "./src/adapters/supabase/**/**.ts"], + "ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/*.http", "**/*.toml", "src/types/database.ts"], "useGitignore": true, "language": "en", "words": ["Nektos", "dataurl", "devpool", "outdir", "servedir", "Supabase", "SUPABASE", "typebox", "ubiquibot", "Smee"], diff --git a/.dev.vars.example b/.dev.vars.example index e49d79a..f21929f 100644 --- a/.dev.vars.example +++ b/.dev.vars.example @@ -1 +1,2 @@ -MY_SECRET="MY_SECRET" +SUPABASE_URL= +SUPABASE_KEY= diff --git a/.env.example b/.env.example deleted file mode 100644 index e49d79a..0000000 --- a/.env.example +++ /dev/null @@ -1 +0,0 @@ -MY_SECRET="MY_SECRET" diff --git a/.github/knip.ts b/.github/knip.ts index 17857ad..ee2b695 100644 --- a/.github/knip.ts +++ b/.github/knip.ts @@ -3,7 +3,7 @@ import type { KnipConfig } from "knip"; const config: KnipConfig = { entry: ["build/index.ts"], project: ["src/**/*.ts"], - ignore: ["src/types/config.ts", "**/__mocks__/**", "**/__fixtures__/**"], + ignore: ["**/__mocks__/**", "**/__fixtures__/**", "src/types/database.ts"], ignoreExportsUsedInFile: true, // eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@mswjs/data"], diff --git a/.github/workflows/compute.yml b/.github/workflows/compute.yml index 3d204b1..b793400 100644 --- a/.github/workflows/compute.yml +++ b/.github/workflows/compute.yml @@ -1,4 +1,4 @@ -name: "the name of the plugin" +name: "command-wallet" on: workflow_dispatch: @@ -18,7 +18,7 @@ on: jobs: compute: - name: "plugin name" + name: "command-wallet" runs-on: ubuntu-latest permissions: write-all env: @@ -38,7 +38,7 @@ jobs: - name: execute directive run: npx tsx ./src/main.ts - id: plugin-name + id: command-wallet env: SUPABASE_URL: ${{ secrets.SUPABASE_URL }} SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index 6b3066e..8d17568 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -8,5 +8,5 @@ jobs: name: Conventional Commits runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ubiquity/action-conventional-commits@master diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml new file mode 100644 index 0000000..412923c --- /dev/null +++ b/.github/workflows/database.yml @@ -0,0 +1,44 @@ +name: Database + +on: + push: + branches: + - main + +env: + SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }} + SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }} + SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }} + +jobs: + generate_types: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.10.0" + + - name: Generate Supabase Types + run: | + yarn install + yarn run "supabase:generate:remote" + + - name: Commit and Push generated types + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add src/types/database.ts + if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then + git commit -m "chore: updated generated Supabase types" || echo "Lint-staged check failed" + git push origin main + else + echo "No changes to commit" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..4d57466 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,28 @@ +name: Deploy to Cloudflare Pages + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + deploy-to-cloudflare: + name: Automatic Cloudflare Deploy + runs-on: ubuntu-22.04 + steps: + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20.10.0" + - uses: actions/checkout@v4 + - uses: cloudflare/wrangler-action@v3 + with: + wranglerVersion: '3.61.0' + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + secrets: | + SUPABASE_URL + SUPABASE_KEY + env: + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} + SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml index 7f8747e..dab2af6 100644 --- a/.github/workflows/jest-testing.yml +++ b/.github/workflows/jest-testing.yml @@ -5,6 +5,8 @@ on: env: NODE_ENV: "test" + SUPABASE_URL: "http://127.0.0.1:3000" + SUPABASE_KEY: "supabase-key" jobs: testing: diff --git a/.github/workflows/knip-reporter.yml b/.github/workflows/knip-reporter.yml index f6e66ed..a396735 100644 --- a/.github/workflows/knip-reporter.yml +++ b/.github/workflows/knip-reporter.yml @@ -11,6 +11,7 @@ permissions: write-all jobs: knip-reporter: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion != 'success' }} steps: - uses: actions/download-artifact@v4 with: @@ -26,7 +27,6 @@ jobs: trim: true - name: Report knip results to pull request - if: ${{ github.event.workflow_run.conclusion != 'success' }} uses: gitcoindev/knip-reporter@main with: verbose: true diff --git a/.gitignore b/.gitignore index a033be6..0ed9687 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ coverage junit.xml cypress/screenshots script.ts -.wrangler \ No newline at end of file +.wrangler +http-client.private.env.json +test-dashboard.md diff --git a/README.md b/README.md index 4dcb9f1..4493990 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# `@ubiquibot/plugin-template` +# `@ubiquibot/command-wallet` + +Allows users to register their wallets to collect rewards. ## Prerequisites @@ -7,38 +9,23 @@ ## Getting Started -1. Create a new repository using this template. -2. Clone the repository to your local machine. -3. Install the dependencies preferably using `yarn` or `bun`. - -## Creating a new plugin - -- If your plugin is to be used as a slash command which should have faster response times as opposed to longer running GitHub action tasks, you should use the `worker` type. - -1. Ensure you understand and have setup the [kernel](https://github.com/ubiquity/ubiquibot-kernel). -2. Update [compute.yml](./.github/workflows/compute.yml) with your plugin's name and update the `id`. -3. Update [context.ts](./src/types/context.ts) with the events that your plugin will fire on. -4. Update [plugin-inputs.ts](./src/types/plugin-inputs.ts) to match the `with:` settings in your org or repo level configuration. +1. Install the dependencies preferably using `yarn` or `bun`. +2. Copy `.dev.vars.example` to `.dev.vars` and fill the variables +3. Generate Supabase types by running + ```shell + yarn prebuild + ``` +4. Run the project with `yarn wrangler` -- Your plugin config should look similar to this: +## Example configuration ```yml -- plugin: /:compute.yml@development - name: plugin-name - id: plugin-name-command - description: "Plugin description" # small description of what the plugin does - command: "" # if you are creating a plugin with a slash command - example: "" # how to invoke the slash command - with: # these are the example settings, the kernel passes these to the plugin. - disabledCommands: [] - timers: - reviewDelayTolerance: 86000 - taskStaleTimeoutDuration: 2580000 - miscellaneous: - maxConcurrentTasks: 3 - labels: - time: [] - priority: [] +- plugin: ubiquibot/command-wallet + name: command-wallet + id: command-wallet + description: "Allows users to register their wallets to collect rewards." + command: "/wallet" + example: "/wallet ubiquibot.eth" ``` ###### At this stage, your plugin will fire on your defined events with the required settings passed in from the kernel. You can now start writing your plugin's logic. diff --git a/eslint.config.mjs b/eslint.config.mjs index e53d263..f43237a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -9,7 +9,7 @@ export default tsEslint.config({ "@typescript-eslint": tsEslint.plugin, "check-file": checkFile, }, - ignores: [".github/knip.ts"], + ignores: [".github/knip.ts", "src/types/database.ts"], extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended], languageOptions: { parser: tsEslint.parser, diff --git a/jest.config.json b/jest.config.json index 21e90b8..2796b3f 100644 --- a/jest.config.json +++ b/jest.config.json @@ -6,5 +6,6 @@ "collectCoverage": true, "coverageReporters": ["json", "lcov", "text", "clover", "json-summary"], "reporters": ["default", "jest-junit", "jest-md-dashboard"], - "coverageDirectory": "coverage" + "coverageDirectory": "coverage", + "setupFiles": ["dotenv/config"] } diff --git a/package.json b/package.json index cbe5fb0..c6d9822 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "plugin-template", + "name": "command-wallet", "version": "1.0.0", - "description": "Ubiquibot plugin template repository with TypeScript support.", + "description": "Allows users to register their wallets to collect rewards.", "author": "Ubiquity DAO", "license": "MIT", "main": "src/worker.ts", @@ -9,6 +9,7 @@ "node": ">=20.10.0" }, "scripts": { + "prebuild": "dotenv -- cross-env yarn supabase:generate:remote", "format": "run-p format:*", "format:lint": "eslint --fix .", "format:prettier": "prettier --write .", @@ -16,8 +17,10 @@ "knip": "knip --config .github/knip.ts", "knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts", "prepare": "husky install", - "test": "jest --setupFiles dotenv/config --coverage", - "worker": "wrangler dev --env dev --port 4000" + "test": "DOTENV_CONFIG_PATH=.dev.vars jest --setupFiles dotenv/config --coverage", + "worker": "wrangler dev --env dev --port 4000", + "supabase:generate:local": "supabase gen types typescript --local > src/types/database.ts", + "supabase:generate:remote": "cross-env-shell \"supabase gen types typescript --project-id $SUPABASE_PROJECT_ID --schema public > src/types/database.ts\"" }, "keywords": [ "typescript", @@ -33,7 +36,9 @@ "@octokit/webhooks": "13.2.7", "@sinclair/typebox": "0.32.33", "@supabase/supabase-js": "2.43.5", + "commander": "12.1.0", "dotenv": "16.4.5", + "ethers": "6.13.1", "typebox-validators": "0.3.5" }, "devDependencies": { @@ -46,7 +51,9 @@ "@jest/globals": "29.7.0", "@mswjs/data": "0.16.1", "@types/node": "20.14.5", + "cross-env": "7.0.3", "cspell": "8.9.0", + "dotenv-cli": "7.4.2", "eslint": "9.5.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-check-file": "2.8.0", @@ -60,11 +67,12 @@ "lint-staged": "15.2.7", "npm-run-all": "4.1.5", "prettier": "3.3.2", + "supabase": "1.178.2", "ts-jest": "29.1.5", "tsx": "4.15.6", "typescript": "5.4.5", "typescript-eslint": "7.13.1", - "wrangler": "3.60.3" + "wrangler": "3.61.0" }, "lint-staged": { "*.ts": [ diff --git a/src/adapters/index.ts b/src/adapters/index.ts index 23fb4b3..588bcb2 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -1,17 +1,11 @@ import { SupabaseClient } from "@supabase/supabase-js"; -import { Context } from "../types/context"; -import { Access } from "./supabase/helpers/access"; -import { User } from "./supabase/helpers/user"; -import { Label } from "./supabase/helpers/label"; -import { Super } from "./supabase/helpers/supabase"; +import { Context } from "../types"; +import { Wallet } from "./supabase/helpers/wallet"; export function createAdapters(supabaseClient: SupabaseClient, context: Context) { return { supabase: { - access: new Access(supabaseClient, context), - user: new User(supabaseClient, context), - label: new Label(supabaseClient, context), - super: new Super(supabaseClient, context), + wallet: new Wallet(supabaseClient, context), }, }; } diff --git a/src/adapters/supabase/helpers/access.ts b/src/adapters/supabase/helpers/access.ts deleted file mode 100644 index dc32281..0000000 --- a/src/adapters/supabase/helpers/access.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { SupabaseClient } from "@supabase/supabase-js"; -import { Super } from "./supabase"; -import { Context } from "../../../types/context"; - -export class Access extends Super { - constructor(supabase: SupabaseClient, context: Context) { - super(supabase, context); - } - - public async getAccess(userId: number, repositoryId: number) { - const { data, error } = await this.supabase - .from("access") - .select("*") - .filter("user_id", "eq", userId) - .filter("repository_id", "eq", repositoryId) - .limit(1) - .maybeSingle(); - - if (error) { - this.context.logger.fatal(error.message, error); - throw new Error(error.message); - } - return data; - } - - public async setAccess(userId: number, repositoryId: number, labels: string[]) { - if (!labels.length) { - return this.clearAccess(userId, repositoryId); - } - const { data, error } = await this.supabase - .from("access") - .upsert({ - user_id: userId, - repository_id: repositoryId, - labels: labels, - }) - .select() - .maybeSingle(); - - if (error) throw new Error(error.message); - return data; - } - - public async clearAccess(userId: number, repositoryId: number): Promise { - const { data, error } = await this.supabase.from("access").delete().filter("user_id", "eq", userId).filter("repository_id", "eq", repositoryId); - if (error) throw new Error(error.message); - return data; - } -} diff --git a/src/adapters/supabase/helpers/label.ts b/src/adapters/supabase/helpers/label.ts deleted file mode 100644 index 77e0288..0000000 --- a/src/adapters/supabase/helpers/label.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { SupabaseClient } from "@supabase/supabase-js"; -import { Super } from "./supabase"; -import { Context } from "../../../types/context"; - -export class Label extends Super { - constructor(supabase: SupabaseClient, context: Context) { - super(supabase, context); - } - - async saveLabelChange({ - previousLabel, - currentLabel, - authorized, - userId, - repositoryId, - }: { - previousLabel: string; - currentLabel: string; - authorized: boolean; - userId: number; - repositoryId: number; - }) { - const { data, error } = await this.supabase - .from("labels") - .insert({ - label_from: previousLabel, - label_to: currentLabel, - authorized: authorized, - user_id: userId, - repository_id: repositoryId, - }) - .select() - .single(); - - if (error) throw new Error(error.message); - return data; - } - - async getLabelChanges(repositoryNodeId: string) { - const { data, error } = await this.supabase.from("labels").select("*").eq("repository_id", repositoryNodeId).eq("authorized", false); - - if (error) throw new Error(error.message); - return data; - } - - async approveLabelChange(id: number): Promise { - const { data, error } = await this.supabase.from("labels").update({ authorized: true }).eq("id", id); - - if (error) throw new Error(error.message); - return data; - } -} diff --git a/src/adapters/supabase/helpers/supabase.ts b/src/adapters/supabase/helpers/supabase.ts index 7a13b85..e338218 100644 --- a/src/adapters/supabase/helpers/supabase.ts +++ b/src/adapters/supabase/helpers/supabase.ts @@ -1,11 +1,12 @@ import { SupabaseClient } from "@supabase/supabase-js"; -import { Context } from "../../../types/context"; +import { Context } from "../../../types"; +import { Database } from "../../../types/database"; export class Super { - protected supabase: SupabaseClient; + protected supabase: SupabaseClient; protected context: Context; - constructor(supabase: SupabaseClient, context: Context) { + constructor(supabase: SupabaseClient, context: Context) { this.supabase = supabase; this.context = context; } diff --git a/src/adapters/supabase/helpers/user.ts b/src/adapters/supabase/helpers/user.ts deleted file mode 100644 index fa8b687..0000000 --- a/src/adapters/supabase/helpers/user.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { SupabaseClient } from "@supabase/supabase-js"; -import { Super } from "./supabase"; -import { Context } from "../../../types/context"; - -type Wallet = { - address: string; -}; - -export class User extends Super { - user_id: string | undefined; - comment_id: string | undefined; - issue_id: string | undefined; - repository_id: string | undefined; - node_id: string | undefined; - node_type: string | undefined; - - constructor(supabase: SupabaseClient, context: Context) { - super(supabase, context); - } - - async getUserById(userId: number, issueNumber: number) { - const { data, error } = await this.supabase.from("users").select("*").eq("id", userId).single(); - if (error) { - console.error(FAILED_TO_GET_USER, { userId, error, issueNumber }); - return null; - } - - console.info(SUCCESSFULLY_FETCHED_USER, { userId, issueNumber, ...data }); - return data; - } - - async getWalletByUserId(userId: number, issueNumber: number) { - const { data, error }: { data: { wallets: Wallet } | null; error: unknown } = await this.supabase - .from("users") - .select("wallets(*)") - .eq("id", userId) - .single(); - if ((error && !data) || !data?.wallets?.address) { - console.error("No wallet address found", { userId, issueNumber }, true); - throw new Error("No wallet address found"); - } - - console.info("Successfully fetched wallet", { userId, address: data.wallets?.address }); - return data.wallets?.address; - } - - public async getMultiplier(userId: number, repositoryId: number) { - const locationData = await this.getLocationsFromRepo(repositoryId); - if (locationData && locationData.length > 0) { - const accessData = await this._getAccessData(locationData, userId); - if (accessData) { - return { - value: accessData.multiplier || null, - reason: accessData.multiplier_reason || null, - }; - } - } - return null; - } - - private async _getAccessData(locationData: { id: number }[], userId: number) { - const locationIdsInCurrentRepository = locationData.map((location) => location.id); - - const { data: accessData, error: accessError } = await this.supabase - .from("access") - .select("multiplier, multiplier_reason") - .in("location_id", locationIdsInCurrentRepository) - .eq("user_id", userId) - .order("id", { ascending: false }) // get the latest one - .maybeSingle(); - if (accessError) throw console.error("Error getting access data", accessError); - return accessData; - } - - public async getLocationsFromRepo(repositoryId: number) { - const { data: locationData, error } = await this.supabase.from("locations").select("id").eq("repository_id", repositoryId); - - if (error) throw console.error("Error getting location data", new Error(error.message)); - return locationData; - } -} - -const FAILED_TO_GET_USER = "Failed to get user"; -const SUCCESSFULLY_FETCHED_USER = "Successfully fetched user"; diff --git a/src/adapters/supabase/helpers/wallet.ts b/src/adapters/supabase/helpers/wallet.ts new file mode 100644 index 0000000..161b0ea --- /dev/null +++ b/src/adapters/supabase/helpers/wallet.ts @@ -0,0 +1,193 @@ +import { SupabaseClient } from "@supabase/supabase-js"; +import { Context } from "../../../types"; +import { Database } from "../../../types/database"; +import { Super } from "./supabase"; + +type WalletRow = Database["public"]["Tables"]["wallets"]["Row"]; +type WalletInsert = Database["public"]["Tables"]["wallets"]["Insert"]; +type UserRow = Database["public"]["Tables"]["users"]["Row"]; +type UserWithWallet = (UserRow & { wallets: WalletRow | null })[]; + +export class Wallet extends Super { + constructor(supabase: SupabaseClient, context: Context) { + super(supabase, context); + } + + public async getAddress(id: number) { + const userWithWallet = await this._getUserWithWallet(id); + return this._validateAndGetWalletAddress(userWithWallet); + } + + public async upsertWalletAddress(context: Context, address: string) { + const payload = context.payload; + + const userData = await this._getUserData(payload); + const registeredWalletData = await this._getRegisteredWalletData(userData); + + const locationMetaData = this._getLocationMetaData(payload); + + if (!registeredWalletData) { + await this._registerNewWallet(context, { + address, + locationMetaData, + payload, + }); + } else { + await this._updateExistingWallet(context, { + address, + locationMetaData, + payload, + walletData: registeredWalletData, + }); + } + } + + private async _getUserWithWallet(id: number) { + const { data, error } = await this.supabase.from("users").select("*, wallets(*)").filter("id", "eq", id); + if (error) throw error; + return data; + } + + private _validateAndGetWalletAddress(userWithWallet: UserWithWallet): string { + if (userWithWallet[0]?.wallets?.address === undefined) throw new Error("Wallet address is undefined"); + if (userWithWallet[0]?.wallets?.address === null) throw new Error("Wallet address is null"); + return userWithWallet[0]?.wallets?.address; + } + + private async _checkIfUserExists(userId: number) { + const { data, error } = await this.supabase.from("users").select("*").eq("id", userId).maybeSingle(); + if (error) throw error; + return data as UserRow; + } + + private async _getUserData(payload: Context["payload"]) { + let userData = await this._checkIfUserExists(payload.sender.id); + if (!userData) { + const user = payload.sender; + userData = await this._registerNewUser(user, this._getLocationMetaData(payload)); + } + return userData; + } + + private async _registerNewUser(user: Context["payload"]["sender"], locationMetaData: LocationMetaData) { + // Insert the location metadata into the locations table + const { data: locationData, error: locationError } = await this.supabase.from("locations").insert(locationMetaData).select().single(); + + if (locationError) { + throw new Error(locationError.message); + } + + // Get the ID of the inserted location + const locationId = locationData.id; + + // Register the new user with the location ID + const { data: userData, error: userError } = await this.supabase + .from("users") + .insert([{ id: user.id, location_id: locationId }]) + .select() + .single(); + + if (userError) { + throw new Error(userError.message); + } + + return userData as UserRow; + } + + private async _checkIfWalletExists(userData: UserRow) { + if (userData.wallet_id === null) { + return { data: null, error: null }; + } + const { data, error } = await this.supabase.from("wallets").select("*").eq("id", userData.wallet_id).maybeSingle(); + + return { data, error }; + } + + private async _updateWalletId(walletId: number, userId: number) { + const { error } = await this.supabase.from("users").update({ wallet_id: walletId }).eq("id", userId); + + if (error) { + throw error; + } + } + + private async _getRegisteredWalletData(userData: UserRow) { + const walletResponse = await this._checkIfWalletExists(userData); + const walletData = walletResponse.data; + const walletError = walletResponse.error; + + if (walletError) throw walletError; + return walletData; + } + + private _getLocationMetaData(payload: Context["payload"]): LocationMetaData { + return { + user_id: payload.sender.id, + comment_id: payload.comment.id, + issue_id: payload.issue.id, + repository_id: payload.repository.id, + organization_id: payload.organization?.id ?? payload.repository.owner.id, + }; + } + + private async _registerNewWallet(context: Context, { address, locationMetaData, payload }: RegisterNewWallet) { + const walletData = await this._insertNewWallet(address); + await this._updateWalletId(walletData.id, payload.sender.id); + if (walletData.location_id) { + await this._enrichLocationMetaData(context, walletData, locationMetaData); + } + } + + private async _updateExistingWallet(context: Context, { address, locationMetaData, walletData }: UpdateExistingWallet) { + await this._updateWalletAddress(walletData.id, address); + if (walletData.location_id) { + await this._enrichLocationMetaData(context, walletData, locationMetaData); + } + } + + private async _insertNewWallet(address: string): Promise { + const newWallet: WalletInsert = { + address: address, + }; + + const { data: walletInsertData, error: walletInsertError } = await this.supabase.from("wallets").insert(newWallet).select().single(); + + if (walletInsertError) throw walletInsertError; + return walletInsertData as WalletRow; + } + + private async _updateWalletAddress(walletId: number, address: string) { + const basicLocationInfo = { + address: address, + } as WalletRow; + + await this.supabase.from("wallets").update(basicLocationInfo).eq("id", walletId).maybeSingle(); + } + + private async _enrichLocationMetaData(context: Context, walletData: WalletRow, locationMetaData: LocationMetaData) { + const logger = context.logger; + if (walletData.location_id === null) { + throw new Error("Location ID is null"); + } + logger.debug("Enriching wallet location metadata", locationMetaData); + return this.supabase.from("locations").update(locationMetaData).eq("id", walletData.location_id); + } +} + +interface RegisterNewWallet { + address: string; + payload: Context["payload"]; + locationMetaData: LocationMetaData; +} + +interface UpdateExistingWallet extends RegisterNewWallet { + walletData: WalletRow; +} + +interface LocationMetaData { + user_id: number; + comment_id: number; + issue_id: number; + repository_id: number; + organization_id: number; +} diff --git a/src/handlers/command-parser.ts b/src/handlers/command-parser.ts new file mode 100644 index 0000000..574d92e --- /dev/null +++ b/src/handlers/command-parser.ts @@ -0,0 +1,51 @@ +import { Command, InvalidArgumentError } from "commander"; +import packageJson from "../../package.json"; +import { Context } from "../types"; +import { registerWallet } from "./query-wallet"; + +export class CommandParser { + readonly _program; + + constructor(context: Context) { + const program = new Command(); + program + .command("/wallet") + .usage("
") + .argument("
", "Wallet address to query, e.g. 0x000000000000000000000000000000000000000", this._parseWalletAddress) + .action((address) => registerWallet(context, address)) + .helpCommand(false) + .exitOverride() + .version(packageJson.version); + program.configureOutput({ + async writeOut(str: string) { + context.logger.debug(str); + }, + async writeErr(str: string) { + context.logger.warn(str); + }, + getErrHelpWidth(): number { + return 0; + }, + getOutHelpWidth(): number { + return 0; + }, + }); + program.exitOverride(); + this._program = program; + } + + parse(args: string[]) { + return this._program.parseAsync(args, { from: "user" }); + } + + helpInformation() { + return this._program.helpInformation(); + } + + _parseWalletAddress(value: string) { + if (!value.length || value.length < 2) { + throw new InvalidArgumentError("Wallet address should be at least 2 characters long."); + } + return value; + } +} diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts new file mode 100644 index 0000000..ee94f89 --- /dev/null +++ b/src/handlers/query-wallet.ts @@ -0,0 +1,82 @@ +import { ethers } from "ethers"; +import { Context } from "../types"; + +function extractEnsName(text: string) { + const ensRegex = /^(?=.{3,40}$)([a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/gm; + const match = text.match(ensRegex); + + if (match) { + const ensName = match[0]; + return ensName?.toLowerCase(); + } +} + +export async function registerWallet(context: Context, body: string) { + const { payload, config, logger, adapters } = context; + const sender = payload.sender.login; + const regexForAddress = /(0x[a-fA-F0-9]{40})/g; + const addressMatches = body.match(regexForAddress); + let address = addressMatches ? addressMatches[0] : null; + const ensName = extractEnsName(body.replace("/wallet", "").trim()); + + if (!address && ensName) { + context.logger.debug("Trying to resolve address from ENS name", { ensName }); + address = await resolveAddress(ensName); + if (!address) { + throw new Error(`Resolving address from ENS name failed: ${ensName}`); + } + context.logger.debug("Resolved address from ENS name", { ensName, address }); + } + + if (!address) { + return context.logger.info("Skipping to register a wallet address because both address/ens doesn't exist"); + } + + if (config.registerWalletWithVerification) { + registerWalletWithVerification(context, body, address); + } + + if (address == ethers.ZeroAddress) { + return logger.error("Skipping to register a wallet address because user is trying to set their address to null address"); + } + + // Makes sure that the address is check-summed + address = ethers.getAddress(address); + + if (payload.comment) { + const { wallet } = adapters.supabase; + await wallet.upsertWalletAddress(context, address); + return context.logger.ok("Successfully registered wallet address", { sender, address }); + } else { + throw new Error("Payload comment is undefined"); + } +} + +function registerWalletWithVerification(context: Context, body: string, address: string) { + const regexForSigHash = /(0x[a-fA-F0-9]{130})/g; + const sigHashMatches = body.match(regexForSigHash); + const sigHash = sigHashMatches ? sigHashMatches[0] : null; + const messageToSign = "UbiquiBot"; + const failedSigLogMsg = `Skipping to register the wallet address because you have not provided a valid SIGNATURE_HASH.`; + + try { + const isSigHashValid = sigHash && ethers.verifyMessage(messageToSign, sigHash) == ethers.getAddress(address); + if (!isSigHashValid) { + context.logger.fatal(failedSigLogMsg); + throw new Error(failedSigLogMsg); + } + } catch (e) { + context.logger.fatal("Exception thrown by verifyMessage for /wallet: ", e, failedSigLogMsg); + throw new Error(failedSigLogMsg); + } +} + +export async function resolveAddress(ensName: string) { + // Gets the Ethereum address associated with an ENS (Ethereum Name Service) name + // Explicitly set provider to Ethereum mainnet + const provider = new ethers.JsonRpcProvider(`https://eth.drpc.org`); + return await provider.resolveName(ensName).catch((err) => { + console.trace({ err }); + return null; + }); +} diff --git a/src/plugin.ts b/src/plugin.ts index c790042..25d3aac 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,6 +1,8 @@ import { Octokit } from "@octokit/rest"; import { createClient } from "@supabase/supabase-js"; +import { CommanderError } from "commander"; import { createAdapters } from "./adapters"; +import { CommandParser } from "./handlers/command-parser"; import { Env, PluginInputs } from "./types"; import { Context } from "./types"; @@ -21,14 +23,47 @@ export async function plugin(inputs: PluginInputs, env: Env) { debug(message: unknown, ...optionalParams: unknown[]) { console.debug(message, ...optionalParams); }, - info(message: unknown, ...optionalParams: unknown[]) { + async ok(message: unknown, ...optionalParams: unknown[]) { console.log(message, ...optionalParams); + try { + await octokit.issues.createComment({ + owner: context.payload.repository.owner.login, + issue_number: context.payload.issue.number, + repo: context.payload.repository.name, + body: `\`\`\`diff\n+ ${message}`, + }); + } catch (e) { + console.error("Failed to post ok comment", e); + } + }, + async info(message: unknown, ...optionalParams: unknown[]) { + console.log(message, ...optionalParams); + try { + await octokit.issues.createComment({ + owner: context.payload.repository.owner.login, + issue_number: context.payload.issue.number, + repo: context.payload.repository.name, + body: `\`\`\`diff\n# ${message}`, + }); + } catch (e) { + console.error("Failed to post info comment", e); + } }, warn(message: unknown, ...optionalParams: unknown[]) { console.warn(message, ...optionalParams); }, - error(message: unknown, ...optionalParams: unknown[]) { + async error(message: unknown, ...optionalParams: unknown[]) { console.error(message, ...optionalParams); + try { + await octokit.issues.createComment({ + owner: context.payload.repository.owner.login, + issue_number: context.payload.issue.number, + repo: context.payload.repository.name, + body: `\`\`\`diff\n- ${message} ${optionalParams}`, + }); + } catch (e) { + console.error("Failed to post error comment", e); + } }, fatal(message: unknown, ...optionalParams: unknown[]) { console.error(message, ...optionalParams); @@ -40,8 +75,21 @@ export async function plugin(inputs: PluginInputs, env: Env) { context.adapters = createAdapters(supabase, context); if (context.eventName === "issue_comment.created") { - // do something + const commandParser = new CommandParser(context); + try { + const args = inputs.eventPayload.comment.body.trim().split(/\s+/); + await commandParser.parse(args); + } catch (e) { + if (e instanceof CommanderError) { + if (e.code !== "commander.unknownCommand") { + await context.logger.error(e.message); + } + } else { + await context.logger.error(e); + throw e; + } + } } else { - context.logger.error(`Unsupported event: ${context.eventName}`); + context.logger.warn(`Unsupported event: ${context.eventName}`); } } diff --git a/src/types/context.ts b/src/types/context.ts index 45a0266..4d5bfb8 100644 --- a/src/types/context.ts +++ b/src/types/context.ts @@ -4,7 +4,7 @@ import { createAdapters } from "../adapters"; import { Env } from "./env"; import { PluginSettings } from "./plugin-inputs"; -export type SupportedEventsU = "issue_comment.created"; // Add more events here +export type SupportedEventsU = "issue_comment.created"; export type SupportedEvents = { [K in SupportedEventsU]: K extends WebhookEventName ? WebhookEvent : never; @@ -19,9 +19,10 @@ export interface Context void; - error: (message: unknown, ...optionalParams: unknown[]) => void; + error: (message: unknown, ...optionalParams: unknown[]) => Promise; warn: (message: unknown, ...optionalParams: unknown[]) => void; - info: (message: unknown, ...optionalParams: unknown[]) => void; + info: (message: unknown, ...optionalParams: unknown[]) => Promise; + ok: (message: unknown, ...optionalParams: unknown[]) => Promise; debug: (message: unknown, ...optionalParams: unknown[]) => void; }; } diff --git a/src/types/database.ts b/src/types/database.ts new file mode 100644 index 0000000..8c30852 --- /dev/null +++ b/src/types/database.ts @@ -0,0 +1,776 @@ +export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[]; + +export type Database = { + public: { + Tables: { + access: { + Row: { + created: string; + id: number; + labels: Json | null; + location_id: number | null; + multiplier: number; + multiplier_reason: string | null; + updated: string | null; + user_id: number; + }; + Insert: { + created?: string; + id?: number; + labels?: Json | null; + location_id?: number | null; + multiplier?: number; + multiplier_reason?: string | null; + updated?: string | null; + user_id: number; + }; + Update: { + created?: string; + id?: number; + labels?: Json | null; + location_id?: number | null; + multiplier?: number; + multiplier_reason?: string | null; + updated?: string | null; + user_id?: number; + }; + Relationships: [ + { + foreignKeyName: "access_user_id_fkey"; + columns: ["user_id"]; + isOneToOne: false; + referencedRelation: "users"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_access_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_access_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + ]; + }; + credits: { + Row: { + amount: number; + created: string; + id: number; + location_id: number | null; + permit_id: number | null; + updated: string | null; + }; + Insert: { + amount: number; + created?: string; + id?: number; + location_id?: number | null; + permit_id?: number | null; + updated?: string | null; + }; + Update: { + amount?: number; + created?: string; + id?: number; + location_id?: number | null; + permit_id?: number | null; + updated?: string | null; + }; + Relationships: [ + { + foreignKeyName: "credits_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "credits_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "credits_permit_id_fkey"; + columns: ["permit_id"]; + isOneToOne: false; + referencedRelation: "permits"; + referencedColumns: ["id"]; + }, + ]; + }; + debits: { + Row: { + amount: number; + created: string; + id: number; + location_id: number | null; + token_id: number | null; + updated: string | null; + }; + Insert: { + amount: number; + created?: string; + id?: number; + location_id?: number | null; + token_id?: number | null; + updated?: string | null; + }; + Update: { + amount?: number; + created?: string; + id?: number; + location_id?: number | null; + token_id?: number | null; + updated?: string | null; + }; + Relationships: [ + { + foreignKeyName: "debits_token_id_fkey"; + columns: ["token_id"]; + isOneToOne: false; + referencedRelation: "tokens"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_debits_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_debits_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + ]; + }; + labels: { + Row: { + authorized: boolean | null; + created: string; + id: number; + label_from: string | null; + label_to: string | null; + location_id: number | null; + updated: string | null; + }; + Insert: { + authorized?: boolean | null; + created?: string; + id?: number; + label_from?: string | null; + label_to?: string | null; + location_id?: number | null; + updated?: string | null; + }; + Update: { + authorized?: boolean | null; + created?: string; + id?: number; + label_from?: string | null; + label_to?: string | null; + location_id?: number | null; + updated?: string | null; + }; + Relationships: [ + { + foreignKeyName: "labels_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "labels_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + ]; + }; + locations: { + Row: { + comment_id: number | null; + created: string; + id: number; + issue_id: number | null; + node_id: string | null; + node_type: string | null; + node_url: string | null; + organization_id: number | null; + repository_id: number | null; + updated: string | null; + user_id: number | null; + }; + Insert: { + comment_id?: number | null; + created?: string; + id?: number; + issue_id?: number | null; + node_id?: string | null; + node_type?: string | null; + node_url?: string | null; + organization_id?: number | null; + repository_id?: number | null; + updated?: string | null; + user_id?: number | null; + }; + Update: { + comment_id?: number | null; + created?: string; + id?: number; + issue_id?: number | null; + node_id?: string | null; + node_type?: string | null; + node_url?: string | null; + organization_id?: number | null; + repository_id?: number | null; + updated?: string | null; + user_id?: number | null; + }; + Relationships: []; + }; + logs: { + Row: { + created: string; + id: number; + level: string | null; + location_id: number | null; + log: string; + metadata: Json | null; + updated: string | null; + }; + Insert: { + created?: string; + id?: number; + level?: string | null; + location_id?: number | null; + log: string; + metadata?: Json | null; + updated?: string | null; + }; + Update: { + created?: string; + id?: number; + level?: string | null; + location_id?: number | null; + log?: string; + metadata?: Json | null; + updated?: string | null; + }; + Relationships: [ + { + foreignKeyName: "fk_logs_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_logs_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + ]; + }; + partners: { + Row: { + created: string; + id: number; + location_id: number | null; + updated: string | null; + wallet_id: number | null; + }; + Insert: { + created?: string; + id?: number; + location_id?: number | null; + updated?: string | null; + wallet_id?: number | null; + }; + Update: { + created?: string; + id?: number; + location_id?: number | null; + updated?: string | null; + wallet_id?: number | null; + }; + Relationships: [ + { + foreignKeyName: "fk_partners_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_partners_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "partners_wallet_id_fkey"; + columns: ["wallet_id"]; + isOneToOne: true; + referencedRelation: "wallets"; + referencedColumns: ["id"]; + }, + ]; + }; + permits: { + Row: { + amount: string; + beneficiary_id: number; + created: string; + deadline: string; + id: number; + location_id: number | null; + nonce: string; + partner_id: number | null; + signature: string; + token_id: number | null; + transaction: string | null; + updated: string | null; + }; + Insert: { + amount: string; + beneficiary_id: number; + created?: string; + deadline: string; + id?: number; + location_id?: number | null; + nonce: string; + partner_id?: number | null; + signature: string; + token_id?: number | null; + transaction?: string | null; + updated?: string | null; + }; + Update: { + amount?: string; + beneficiary_id?: number; + created?: string; + deadline?: string; + id?: number; + location_id?: number | null; + nonce?: string; + partner_id?: number | null; + signature?: string; + token_id?: number | null; + transaction?: string | null; + updated?: string | null; + }; + Relationships: [ + { + foreignKeyName: "fk_permits_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_permits_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "permits_beneficiary_id_fkey"; + columns: ["beneficiary_id"]; + isOneToOne: false; + referencedRelation: "users"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "permits_partner_id_fkey"; + columns: ["partner_id"]; + isOneToOne: false; + referencedRelation: "partners"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "permits_token_fkey"; + columns: ["token_id"]; + isOneToOne: false; + referencedRelation: "tokens"; + referencedColumns: ["id"]; + }, + ]; + }; + settlements: { + Row: { + created: string; + credit_id: number | null; + debit_id: number | null; + id: number; + location_id: number | null; + updated: string | null; + user_id: number; + }; + Insert: { + created?: string; + credit_id?: number | null; + debit_id?: number | null; + id?: number; + location_id?: number | null; + updated?: string | null; + user_id: number; + }; + Update: { + created?: string; + credit_id?: number | null; + debit_id?: number | null; + id?: number; + location_id?: number | null; + updated?: string | null; + user_id?: number; + }; + Relationships: [ + { + foreignKeyName: "fk_settlements_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "fk_settlements_location"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "settlements_credit_id_fkey"; + columns: ["credit_id"]; + isOneToOne: false; + referencedRelation: "credits"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "settlements_debit_id_fkey"; + columns: ["debit_id"]; + isOneToOne: false; + referencedRelation: "debits"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "settlements_user_id_fkey"; + columns: ["user_id"]; + isOneToOne: false; + referencedRelation: "users"; + referencedColumns: ["id"]; + }, + ]; + }; + tokens: { + Row: { + address: string; + created: string; + id: number; + location_id: number | null; + network: number; + updated: string | null; + }; + Insert: { + address: string; + created?: string; + id?: number; + location_id?: number | null; + network?: number; + updated?: string | null; + }; + Update: { + address?: string; + created?: string; + id?: number; + location_id?: number | null; + network?: number; + updated?: string | null; + }; + Relationships: [ + { + foreignKeyName: "tokens_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "tokens_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + ]; + }; + users: { + Row: { + created: string; + id: number; + location_id: number | null; + updated: string | null; + wallet_id: number | null; + }; + Insert: { + created?: string; + id: number; + location_id?: number | null; + updated?: string | null; + wallet_id?: number | null; + }; + Update: { + created?: string; + id?: number; + location_id?: number | null; + updated?: string | null; + wallet_id?: number | null; + }; + Relationships: [ + { + foreignKeyName: "users_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "users_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "users_wallet_id_fkey"; + columns: ["wallet_id"]; + isOneToOne: false; + referencedRelation: "wallets"; + referencedColumns: ["id"]; + }, + ]; + }; + wallets: { + Row: { + address: string | null; + created: string; + id: number; + location_id: number | null; + updated: string | null; + }; + Insert: { + address?: string | null; + created?: string; + id?: number; + location_id?: number | null; + updated?: string | null; + }; + Update: { + address?: string | null; + created?: string; + id?: number; + location_id?: number | null; + updated?: string | null; + }; + Relationships: [ + { + foreignKeyName: "wallets_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "issues_view"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "wallets_location_id_fkey"; + columns: ["location_id"]; + isOneToOne: false; + referencedRelation: "locations"; + referencedColumns: ["id"]; + }, + ]; + }; + }; + Views: { + issues_view: { + Row: { + comment_id: number | null; + created: string | null; + id: number | null; + issue_id: number | null; + node_id: string | null; + node_type: string | null; + node_url: string | null; + organization_id: number | null; + repository_id: number | null; + updated: string | null; + user_id: number | null; + }; + Relationships: []; + }; + }; + Functions: { + insert_with_exception_handling: { + Args: Record; + Returns: undefined; + }; + read_secret: { + Args: { + secret_name: string; + }; + Returns: string; + }; + }; + Enums: { + github_node_type: + | "App" + | "Bot" + | "CheckRun" + | "CheckSuite" + | "ClosedEvent" + | "CodeOfConduct" + | "Commit" + | "CommitComment" + | "CommitContributionsByRepository" + | "ContributingGuidelines" + | "ConvertToDraftEvent" + | "CreatedCommitContribution" + | "CreatedIssueContribution" + | "CreatedPullRequestContribution" + | "CreatedPullRequestReviewContribution" + | "CreatedRepositoryContribution" + | "CrossReferencedEvent" + | "Discussion" + | "DiscussionComment" + | "Enterprise" + | "EnterpriseUserAccount" + | "FundingLink" + | "Gist" + | "Issue" + | "IssueComment" + | "JoinedGitHubContribution" + | "Label" + | "License" + | "Mannequin" + | "MarketplaceCategory" + | "MarketplaceListing" + | "MergeQueue" + | "MergedEvent" + | "MigrationSource" + | "Milestone" + | "Organization" + | "PackageFile" + | "Project" + | "ProjectCard" + | "ProjectColumn" + | "ProjectV2" + | "PullRequest" + | "PullRequestCommit" + | "PullRequestReview" + | "PullRequestReviewComment" + | "ReadyForReviewEvent" + | "Release" + | "ReleaseAsset" + | "Repository" + | "RepositoryContactLink" + | "RepositoryTopic" + | "RestrictedContribution" + | "ReviewDismissedEvent" + | "SecurityAdvisoryReference" + | "SocialAccount" + | "SponsorsListing" + | "Team" + | "TeamDiscussion" + | "TeamDiscussionComment" + | "User" + | "Workflow" + | "WorkflowRun" + | "WorkflowRunFile"; + }; + CompositeTypes: { + [_ in never]: never; + }; + }; +}; + +type PublicSchema = Database[Extract]; + +export type Tables< + PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & PublicSchema["Views"]) | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & Database[PublicTableNameOrOptions["schema"]]["Views"]) + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { + Row: infer R; + } + ? R + : never + : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & PublicSchema["Views"]) + ? (PublicSchema["Tables"] & PublicSchema["Views"])[PublicTableNameOrOptions] extends { + Row: infer R; + } + ? R + : never + : never; + +export type TablesInsert< + PublicTableNameOrOptions extends keyof PublicSchema["Tables"] | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Insert: infer I; + } + ? I + : never + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Insert: infer I; + } + ? I + : never + : never; + +export type TablesUpdate< + PublicTableNameOrOptions extends keyof PublicSchema["Tables"] | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Update: infer U; + } + ? U + : never + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Update: infer U; + } + ? U + : never + : never; + +export type Enums< + PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] | { schema: keyof Database }, + EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] : never = never, +> = PublicEnumNameOrOptions extends { schema: keyof Database } + ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] + : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] + ? PublicSchema["Enums"][PublicEnumNameOrOptions] + : never; diff --git a/src/types/environment.d.ts b/src/types/environment.d.ts new file mode 100644 index 0000000..a91a509 --- /dev/null +++ b/src/types/environment.d.ts @@ -0,0 +1,10 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + SUPABASE_KEY: string; + SUPABASE_URL: string; + } + } +} + +export {}; diff --git a/src/types/plugin-inputs.ts b/src/types/plugin-inputs.ts index 00d0a52..ee47e51 100644 --- a/src/types/plugin-inputs.ts +++ b/src/types/plugin-inputs.ts @@ -18,7 +18,9 @@ export interface PluginInputs; diff --git a/src/worker.ts b/src/worker.ts index da9bccf..9d9ee97 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -20,7 +20,7 @@ export default { } const webhookPayload = await request.json(); - const settings = Value.Decode(pluginSettingsSchema, Value.Default(pluginSettingsSchema, JSON.parse(webhookPayload.settings))); + const settings = Value.Decode(pluginSettingsSchema, Value.Default(pluginSettingsSchema, webhookPayload.settings)); if (!pluginSettingsValidator.test(settings)) { const errors: string[] = []; @@ -44,8 +44,6 @@ export default { headers: { "content-type": "application/json" }, }); } - - webhookPayload.eventPayload = JSON.parse(webhookPayload.eventPayload); webhookPayload.settings = settings; await plugin(webhookPayload, env); return new Response(JSON.stringify("OK"), { status: 200, headers: { "content-type": "application/json" } }); diff --git a/tests/__mocks__/db-seed.json b/tests/__mocks__/db-seed.json new file mode 100644 index 0000000..aedea38 --- /dev/null +++ b/tests/__mocks__/db-seed.json @@ -0,0 +1,15 @@ +{ + "users": [ + { + "id": 1, + "login": "ubiquibot", + "wallet_id": 1 + } + ], + "wallets": [ + { + "id": 1, + "address": "0x0000000000000000000000000000000000000001" + } + ] +} diff --git a/tests/__mocks__/db.ts b/tests/__mocks__/db.ts index 7df690c..e0119b8 100644 --- a/tests/__mocks__/db.ts +++ b/tests/__mocks__/db.ts @@ -5,8 +5,13 @@ import { factory, primaryKey } from "@mswjs/data"; * Creates an object that can be used as a db to persist data within tests */ export const db = factory({ + wallets: { + id: primaryKey(Number), + address: String, + }, users: { id: primaryKey(Number), - name: String, + login: String, + wallet_id: Number, }, }); diff --git a/tests/__mocks__/handlers.ts b/tests/__mocks__/handlers.ts index 0d31c3c..e09c46f 100644 --- a/tests/__mocks__/handlers.ts +++ b/tests/__mocks__/handlers.ts @@ -1,11 +1,41 @@ import { http, HttpResponse } from "msw"; import { db } from "./db"; +console.log("HANDLERS", process.env); /** * Intercepts the routes and returns a custom payload */ export const handlers = [ - http.get("https://api.ubiquity.com/users", () => { - return HttpResponse.json(db.users.getAll()); + http.get(`${process.env.SUPABASE_URL}/rest/v1/users*`, ({ request }) => { + const url = new URL(request.url); + const id = url.searchParams.get("id"); + + if (!id) { + return HttpResponse.text("", { status: 400 }); + } + const idNumber = Number(id.match(/\d+/)?.[0]); + return HttpResponse.json(db.users.findFirst({ where: { id: { equals: idNumber } } })); + }), + http.get(`${process.env.SUPABASE_URL}/rest/v1/wallets*`, ({ request }) => { + const url = new URL(request.url); + const id = url.searchParams.get("id"); + + if (!id) { + return HttpResponse.text("", { status: 400 }); + } + const idNumber = Number(id.match(/\d+/)?.[0]); + return HttpResponse.json(db.wallets.findFirst({ where: { id: { equals: idNumber } } })); + }), + http.patch(`${process.env.SUPABASE_URL}/rest/v1/wallets*`, async ({ request }) => { + const url = new URL(request.url); + const id = url.searchParams.get("id"); + + if (!id) { + return HttpResponse.text("", { status: 400 }); + } + const idNumber = Number(id.match(/\d+/)?.[0]); + const data = (await request.json()) as object; + return HttpResponse.json(db.wallets.update({ data, where: { id: { equals: idNumber } } })); }), + http.post("https://api.github.com/repos/:owner/:repo/issues/:id/comments", () => HttpResponse.json()), ]; diff --git a/tests/__mocks__/payloads/comment-created.json b/tests/__mocks__/payloads/comment-created.json new file mode 100644 index 0000000..10aa9f1 --- /dev/null +++ b/tests/__mocks__/payloads/comment-created.json @@ -0,0 +1,246 @@ +{ + "action": "created", + "issue": { + "url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/5", + "repository_url": "https://api.github.com/repos/ubiquibot/command-wallet", + "labels_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/5/labels{/name}", + "comments_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/5/comments", + "events_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/5/events", + "html_url": "https://github.com/ubiquibot/command-wallet/issues/5", + "id": 2297627819, + "node_id": "I_kwDOLy-Pv86I8wSr", + "number": 5, + "title": "New issue", + "user": { + "login": "ubiquibot", + "id": 1, + "node_id": "MDQ6VXNlcjk4MDcwMDg=", + "avatar_url": "https://avatars.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ubiquibot", + "html_url": "https://github.com/ubiquibot", + "followers_url": "https://api.github.com/users/ubiquibot/followers", + "following_url": "https://api.github.com/users/ubiquibot/following{/other_user}", + "gists_url": "https://api.github.com/users/ubiquibot/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ubiquibot/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ubiquibot/subscriptions", + "organizations_url": "https://api.github.com/users/ubiquibot/orgs", + "repos_url": "https://api.github.com/users/ubiquibot/repos", + "events_url": "https://api.github.com/users/ubiquibot/events{/privacy}", + "received_events_url": "https://api.github.com/users/ubiquibot/received_events", + "type": "User", + "site_admin": false + }, + "labels": [], + "state": "open", + "locked": false, + "assignee": null, + "assignees": [], + "milestone": null, + "comments": 34, + "created_at": "2024-05-15T11:22:48Z", + "updated_at": "2024-05-19T11:54:24Z", + "closed_at": null, + "author_association": "CONTRIBUTOR", + "active_lock_reason": null, + "body": "Another issue.", + "reactions": { + "url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/5/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/5/timeline", + "performed_via_github_app": null, + "state_reason": null + }, + "comment": { + "url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/comments/2119208855", + "html_url": "https://github.com/ubiquibot/command-wallet/issues/5#issuecomment-2119208855", + "issue_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/5", + "id": 2119208855, + "node_id": "IC_kwDOLy-Pv85-UI-X", + "user": { + "login": "ubiquibot", + "id": 1, + "node_id": "MDQ6VXNlcjk4MDcwMDg=", + "avatar_url": "https://avatars.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ubiquibot", + "html_url": "https://github.com/ubiquibot", + "followers_url": "https://api.github.com/users/ubiquibot/followers", + "following_url": "https://api.github.com/users/ubiquibot/following{/other_user}", + "gists_url": "https://api.github.com/users/ubiquibot/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ubiquibot/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ubiquibot/subscriptions", + "organizations_url": "https://api.github.com/users/ubiquibot/orgs", + "repos_url": "https://api.github.com/users/ubiquibot/repos", + "events_url": "https://api.github.com/users/ubiquibot/events{/privacy}", + "received_events_url": "https://api.github.com/users/ubiquibot/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2024-05-19T11:54:23Z", + "updated_at": "2024-05-19T11:54:23Z", + "author_association": "CONTRIBUTOR", + "body": "/query @ubiquibot", + "reactions": { + "url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/comments/2119208855/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "performed_via_github_app": null + }, + "repository": { + "id": 791646143, + "node_id": "R_kgDOLy-Pvw", + "name": "bot", + "full_name": "ubiquibot/command-wallet", + "private": false, + "owner": { + "login": "ubiquibot", + "id": 159901852, + "node_id": "O_kgDOCYfonA", + "avatar_url": "https://avatars.githubusercontent.com/u/159901852?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ubiquibot", + "html_url": "https://github.com/ubiquibot", + "followers_url": "https://api.github.com/users/ubiquibot/followers", + "following_url": "https://api.github.com/users/ubiquibot/following{/other_user}", + "gists_url": "https://api.github.com/users/ubiquibot/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ubiquibot/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ubiquibot/subscriptions", + "organizations_url": "https://api.github.com/users/ubiquibot/orgs", + "repos_url": "https://api.github.com/users/ubiquibot/repos", + "events_url": "https://api.github.com/users/ubiquibot/events{/privacy}", + "received_events_url": "https://api.github.com/users/ubiquibot/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/ubiquibot/command-wallet", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/ubiquibot/command-wallet", + "forks_url": "https://api.github.com/repos/ubiquibot/command-wallet/forks", + "keys_url": "https://api.github.com/repos/ubiquibot/command-wallet/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/ubiquibot/command-wallet/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/ubiquibot/command-wallet/teams", + "hooks_url": "https://api.github.com/repos/ubiquibot/command-wallet/hooks", + "issue_events_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/events{/number}", + "events_url": "https://api.github.com/repos/ubiquibot/command-wallet/events", + "assignees_url": "https://api.github.com/repos/ubiquibot/command-wallet/assignees{/user}", + "branches_url": "https://api.github.com/repos/ubiquibot/command-wallet/branches{/branch}", + "tags_url": "https://api.github.com/repos/ubiquibot/command-wallet/tags", + "blobs_url": "https://api.github.com/repos/ubiquibot/command-wallet/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/ubiquibot/command-wallet/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/ubiquibot/command-wallet/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/ubiquibot/command-wallet/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/ubiquibot/command-wallet/statuses/{sha}", + "languages_url": "https://api.github.com/repos/ubiquibot/command-wallet/languages", + "stargazers_url": "https://api.github.com/repos/ubiquibot/command-wallet/stargazers", + "contributors_url": "https://api.github.com/repos/ubiquibot/command-wallet/contributors", + "subscribers_url": "https://api.github.com/repos/ubiquibot/command-wallet/subscribers", + "subscription_url": "https://api.github.com/repos/ubiquibot/command-wallet/subscription", + "commits_url": "https://api.github.com/repos/ubiquibot/command-wallet/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/ubiquibot/command-wallet/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/ubiquibot/command-wallet/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/ubiquibot/command-wallet/contents/{+path}", + "compare_url": "https://api.github.com/repos/ubiquibot/command-wallet/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/ubiquibot/command-wallet/merges", + "archive_url": "https://api.github.com/repos/ubiquibot/command-wallet/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/ubiquibot/command-wallet/downloads", + "issues_url": "https://api.github.com/repos/ubiquibot/command-wallet/issues{/number}", + "pulls_url": "https://api.github.com/repos/ubiquibot/command-wallet/pulls{/number}", + "milestones_url": "https://api.github.com/repos/ubiquibot/command-wallet/milestones{/number}", + "notifications_url": "https://api.github.com/repos/ubiquibot/command-wallet/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/ubiquibot/command-wallet/labels{/name}", + "releases_url": "https://api.github.com/repos/ubiquibot/command-wallet/releases{/id}", + "deployments_url": "https://api.github.com/repos/ubiquibot/command-wallet/deployments", + "created_at": "2024-04-25T05:19:30Z", + "updated_at": "2024-05-19T09:47:02Z", + "pushed_at": "2024-05-19T09:46:59Z", + "git_url": "git://github.com/ubiquibot/command-wallet.git", + "ssh_url": "git@github.com:ubiquibot/command-wallet.git", + "clone_url": "https://github.com/ubiquibot/command-wallet.git", + "svn_url": "https://github.com/ubiquibot/command-wallet", + "homepage": null, + "size": 56, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "custom_properties": {} + }, + "organization": { + "login": "ubiquibot", + "id": 159901852, + "node_id": "O_kgDOCYfonA", + "url": "https://api.github.com/orgs/ubiquibot", + "repos_url": "https://api.github.com/orgs/ubiquibot/repos", + "events_url": "https://api.github.com/orgs/ubiquibot/events", + "hooks_url": "https://api.github.com/orgs/ubiquibot/hooks", + "issues_url": "https://api.github.com/orgs/ubiquibot/issues", + "members_url": "https://api.github.com/orgs/ubiquibot/members{/member}", + "public_members_url": "https://api.github.com/orgs/ubiquibot/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/159901852?v=4", + "description": null + }, + "sender": { + "login": "ubiquibot", + "id": 1, + "node_id": "MDQ6VXNlcjk4MDcwMDg=", + "avatar_url": "https://avatars.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ubiquibot", + "html_url": "https://github.com/ubiquibot", + "followers_url": "https://api.github.com/users/ubiquibot/followers", + "following_url": "https://api.github.com/users/ubiquibot/following{/other_user}", + "gists_url": "https://api.github.com/users/ubiquibot/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ubiquibot/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ubiquibot/subscriptions", + "organizations_url": "https://api.github.com/users/ubiquibot/orgs", + "repos_url": "https://api.github.com/users/ubiquibot/repos", + "events_url": "https://api.github.com/users/ubiquibot/events{/privacy}", + "received_events_url": "https://api.github.com/users/ubiquibot/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 48381972, + "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uNDgzODE5NzI=" + } +} diff --git a/tests/__mocks__/users-get.json b/tests/__mocks__/users-get.json deleted file mode 100644 index 59f0200..0000000 --- a/tests/__mocks__/users-get.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "id": 1, - "name": "user1" - }, - { - "id": 2, - "name": "user2" - } -] diff --git a/tests/http/request.http b/tests/http/request.http new file mode 100644 index 0000000..a5b3c3a --- /dev/null +++ b/tests/http/request.http @@ -0,0 +1,18 @@ +### POST a successful request to the Worker +# Variables as follows: +# org_name: the organization you want to post to, e.g. "ubiquibot" +# repo_name: the target repository, e.g "command-wallet" +# issue_number: the number of the issue, same as the one you would see in the url to that issue, e.g. "1" +# command: the command you want to test, e.g. "/wallet @ubiquibot" +# token: a valid GitHub token for auth, e.g. "ghs_xxxxx" +POST http://localhost:4000/ +Content-Type: application/json + +{ + "stateId": "", + "eventName": "issue_comment.created", + "eventPayload": {"action":"created","issue":{"url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/{{issue_number}}","repository_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}","labels_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/{{issue_number}}/labels{/name}","comments_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/{{issue_number}}/comments","events_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/{{issue_number}}/events","html_url":"https://github.com/{{org_name}}/{{repo_name}}/issues/{{issue_number}}","id":2297627819,"node_id":"I_kwDOLy-Pv86I8wSr","number":5,"title":"New issue","user":{"login":"ubiquibot","id":1,"node_id":"MDQ6VXNlcjk4MDcwMDg=","avatar_url":"https://avatars.githubusercontent.com/u/1?v=4","gravatar_id":"","url":"https://api.github.com/users/ubiquibot","html_url":"https://github.com/ubiquibot","followers_url":"https://api.github.com/users/ubiquibot/followers","following_url":"https://api.github.com/users/ubiquibot/following{/other_user}","gists_url":"https://api.github.com/users/ubiquibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ubiquibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubiquibot/subscriptions","organizations_url":"https://api.github.com/users/ubiquibot/orgs","repos_url":"https://api.github.com/users/ubiquibot/repos","events_url":"https://api.github.com/users/ubiquibot/events{/privacy}","received_events_url":"https://api.github.com/users/ubiquibot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":34,"created_at":"2024-05-15T11:22:48Z","updated_at":"2024-05-19T11:54:24Z","closed_at":null,"author_association":"CONTRIBUTOR","active_lock_reason":null,"body":"Another issue.","reactions":{"url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/{{issue_number}}/reactions","total_count":0,"+1":0,"-1":0,"laugh":0,"hooray":0,"confused":0,"heart":0,"rocket":0,"eyes":0},"timeline_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/{{issue_number}}/timeline","performed_via_github_app":null,"state_reason":null},"comment":{"url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/comments/1","html_url":"https://github.com/{{org_name}}/{{repo_name}}/issues/{{issue_number}}#issuecomment-1","issue_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/{{issue_number}}","id":1,"node_id":"IC_kwDOLy-Pv85-UI-X","user":{"login":"ubiquibot","id":1,"node_id":"MDQ6VXNlcjk4MDcwMDg=","avatar_url":"https://avatars.githubusercontent.com/u/1?v=4","gravatar_id":"","url":"https://api.github.com/users/ubiquibot","html_url":"https://github.com/ubiquibot","followers_url":"https://api.github.com/users/ubiquibot/followers","following_url":"https://api.github.com/users/ubiquibot/following{/other_user}","gists_url":"https://api.github.com/users/ubiquibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ubiquibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubiquibot/subscriptions","organizations_url":"https://api.github.com/users/ubiquibot/orgs","repos_url":"https://api.github.com/users/ubiquibot/repos","events_url":"https://api.github.com/users/ubiquibot/events{/privacy}","received_events_url":"https://api.github.com/users/ubiquibot/received_events","type":"User","site_admin":false},"created_at":"2024-05-19T11:54:23Z","updated_at":"2024-05-19T11:54:23Z","author_association":"CONTRIBUTOR","body":"{{command}}","reactions":{"url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/comments/1/reactions","total_count":0,"+1":0,"-1":0,"laugh":0,"hooray":0,"confused":0,"heart":0,"rocket":0,"eyes":0},"performed_via_github_app":null},"repository":{"id":1,"node_id":"R_kgDOLy-Pvw","name":"{{repo_name}}","full_name":"{{org_name}}/{{repo_name}}","private":false,"owner":{"login":"{{org_name}}","id":1,"node_id":"O_kgDOCYfonA","avatar_url":"https://avatars.githubusercontent.com/u/1?v=4","gravatar_id":"","url":"https://api.github.com/users/{{org_name}}","html_url":"https://github.com/{{org_name}}","followers_url":"https://api.github.com/users/{{org_name}}/followers","following_url":"https://api.github.com/users/{{org_name}}/following{/other_user}","gists_url":"https://api.github.com/users/{{org_name}}/gists{/gist_id}","starred_url":"https://api.github.com/users/{{org_name}}/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/{{org_name}}/subscriptions","organizations_url":"https://api.github.com/users/{{org_name}}/orgs","repos_url":"https://api.github.com/users/{{org_name}}/repos","events_url":"https://api.github.com/users/{{org_name}}/events{/privacy}","received_events_url":"https://api.github.com/users/{{org_name}}/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/{{org_name}}/{{repo_name}}","description":null,"fork":false,"url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}","forks_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/forks","keys_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/keys{/key_id}","collaborators_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/teams","hooks_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/hooks","issue_events_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/events{/number}","events_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/events","assignees_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/assignees{/user}","branches_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/branches{/branch}","tags_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/tags","blobs_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/git/refs{/sha}","trees_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/git/trees{/sha}","statuses_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/statuses/{sha}","languages_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/languages","stargazers_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/stargazers","contributors_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/contributors","subscribers_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/subscribers","subscription_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/subscription","commits_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/commits{/sha}","git_commits_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/git/commits{/sha}","comments_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/comments{/number}","issue_comment_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues/comments{/number}","contents_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/contents/{+path}","compare_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/compare/{base}...{head}","merges_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/merges","archive_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/downloads","issues_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/issues{/number}","pulls_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/pulls{/number}","milestones_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/milestones{/number}","notifications_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/labels{/name}","releases_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/releases{/id}","deployments_url":"https://api.github.com/repos/{{org_name}}/{{repo_name}}/deployments","created_at":"2024-04-25T05:19:30Z","updated_at":"2024-05-19T09:47:02Z","pushed_at":"2024-05-19T09:46:59Z","git_url":"git://github.com/{{org_name}}/{{repo_name}}.git","ssh_url":"git@github.com:{{org_name}}/{{repo_name}}.git","clone_url":"https://github.com/{{org_name}}/{{repo_name}}.git","svn_url":"https://github.com/{{org_name}}/{{repo_name}}","homepage":null,"size":56,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":null,"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main","custom_properties":{}},"organization":{"login":"{{org_name}}","id":1,"node_id":"O_kgDOCYfonA","url":"https://api.github.com/orgs/{{org_name}}","repos_url":"https://api.github.com/orgs/{{org_name}}/repos","events_url":"https://api.github.com/orgs/{{org_name}}/events","hooks_url":"https://api.github.com/orgs/{{org_name}}/hooks","issues_url":"https://api.github.com/orgs/{{org_name}}/issues","members_url":"https://api.github.com/orgs/{{org_name}}/members{/member}","public_members_url":"https://api.github.com/orgs/{{org_name}}/public_members{/member}","avatar_url":"https://avatars.githubusercontent.com/u/1?v=4","description":null},"sender":{"login":"ubiquibot","id":1,"node_id":"MDQ6VXNlcjk4MDcwMDg=","avatar_url":"https://avatars.githubusercontent.com/u/1?v=4","gravatar_id":"","url":"https://api.github.com/users/ubiquibot","html_url":"https://github.com/ubiquibot","followers_url":"https://api.github.com/users/ubiquibot/followers","following_url":"https://api.github.com/users/ubiquibot/following{/other_user}","gists_url":"https://api.github.com/users/ubiquibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ubiquibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubiquibot/subscriptions","organizations_url":"https://api.github.com/users/ubiquibot/orgs","repos_url":"https://api.github.com/users/ubiquibot/repos","events_url":"https://api.github.com/users/ubiquibot/events{/privacy}","received_events_url":"https://api.github.com/users/ubiquibot/received_events","type":"User","site_admin":false},"installation":{"id":1,"node_id":"MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uNDgzODE5NzI="}}, + "settings": {}, + "ref": "", + "authToken": "{{token}}" +} diff --git a/tests/main.test.ts b/tests/main.test.ts index 7967004..a764cca 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -1,22 +1,58 @@ +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, jest } from "@jest/globals"; +import { ethers } from "ethers"; +import { plugin } from "../src/plugin"; +import { PluginInputs } from "../src/types"; import { db } from "./__mocks__/db"; import { server } from "./__mocks__/node"; -import usersGet from "./__mocks__/users-get.json"; -import { expect, describe, beforeAll, beforeEach, afterAll, afterEach, it } from "@jest/globals"; +import commentCreatedPayload from "./__mocks__/payloads/comment-created.json"; +import dbSeed from "./__mocks__/db-seed.json"; beforeAll(() => server.listen()); afterEach(() => server.resetHandlers()); afterAll(() => server.close()); -describe("User tests", () => { +jest.mock("ethers", () => ({ + ethers: { + JsonRpcProvider: jest.fn(() => ({ + resolveName: jest.fn(async () => "0x0000000000000000000000000000000000000001"), + })), + getAddress: (jest.requireActual("ethers") as typeof ethers).getAddress, + }, +})); + +describe("Wallet command tests", () => { beforeEach(() => { - for (const item of usersGet) { - db.users.create(item); + for (const dbTable of Object.keys(dbSeed)) { + const tableName = dbTable as keyof typeof dbSeed; + for (const dbRow of dbSeed[tableName]) { + db[tableName].create(dbRow); + } } }); - it("Should fetch all the users", async () => { - const res = await fetch("https://api.ubiquity.com/users"); - const data = await res.json(); - expect(data).toMatchObject(usersGet); + it("Should link a wallet", async () => { + const spy = jest.spyOn(console, "log"); + await plugin( + { + eventName: "issue_comment.created", + ref: "", + authToken: "", + stateId: "", + settings: { registerWalletWithVerification: false }, + eventPayload: { + ...commentCreatedPayload, + comment: { + ...commentCreatedPayload.comment, + body: "/wallet ubiquibot.eth", + }, + }, + } as PluginInputs, + { SUPABASE_URL: process.env.SUPABASE_URL, SUPABASE_KEY: process.env.SUPABASE_KEY } + ); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenLastCalledWith("Successfully registered wallet address", { + address: "0x0000000000000000000000000000000000000001", + sender: "ubiquibot", + }); }); }); diff --git a/tsconfig.json b/tsconfig.json index ba9d6b3..2841aef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + "target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ @@ -22,7 +22,7 @@ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "commonjs" /* Specify what module code is generated. */, + "module": "CommonJS" /* Specify what module code is generated. */, // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ diff --git a/wrangler.toml b/wrangler.toml index 5a0953a..3a2e0d0 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,7 +1,7 @@ -name = "your-plugin-name" +name = "ubiquibot-command-wallet" main = "src/worker.ts" -compatibility_date = "2024-05-23" +compatibility_date = "2024-06-24" node_compat = true [env.dev] -[env.prod] \ No newline at end of file +[env.prod] diff --git a/yarn.lock b/yarn.lock index d4049db..1c53f0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28,6 +28,11 @@ tunnel "^0.0.6" undici "^5.25.4" +"@adraffy/ens-normalize@1.10.1": + version "1.10.1" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" + integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw== + "@ampproject/remapping@^2.2.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.3.0.tgz#ed441b6fa600072520ce18b43d2c8cc8caecc7f4" @@ -344,10 +349,10 @@ dependencies: statuses "^2.0.1" -"@cloudflare/kv-asset-handler@0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.3.2.tgz#06437b75664729823ac9033b89f06a3b078e4f55" - integrity sha512-EeEjMobfuJrwoctj7FA1y1KEbM0+Q1xSjobIEyie9k4haVEBB7vkDvsasw1pM3rO39mL2akxIAzLMUAtrMHZhA== +"@cloudflare/kv-asset-handler@0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.3.3.tgz#3c578996f3d00b60debee8178c41600f3b21bc0b" + integrity sha512-wpE+WiWW2kUNwNE0xyl4CtTAs+STjGtouHGiZPGRaisGB7eXXdbvfZdOrQJQVKgTxZiNAgVgmc7fj0sUmd8zyA== dependencies: mime "^3.0.0" @@ -1269,6 +1274,25 @@ resolved "https://registry.yarnpkg.com/@inquirer/type/-/type-1.3.3.tgz#26b2628630fd2381c7fa1e3ab396feb9bbc575da" integrity sha512-xTUt0NulylX27/zMx04ZYar/kr1raaiFTVvQ5feljQsiAgdm0WPj4S73/ye0fbslh+15QrIuDvfCXTek7pMY5A== +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + +"@isaacs/fs-minipass@^4.0.0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz#2d59ae3ab4b38fb4270bfa23d30f8e2e86c7fe32" + integrity sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w== + dependencies: + minipass "^7.0.4" + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1555,6 +1579,18 @@ outvariant "^1.2.1" strict-event-emitter "^0.5.1" +"@noble/curves@1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" + integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== + dependencies: + "@noble/hashes" "1.3.2" + +"@noble/hashes@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -1763,6 +1799,11 @@ resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-2.1.0.tgz#0acf32f470af2ceaf47f095cdecd40d68666efda" integrity sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg== +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + "@pkgr/core@^0.1.0": version "0.1.1" resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" @@ -1960,6 +2001,11 @@ dependencies: undici-types "~5.26.4" +"@types/node@18.15.13": + version "18.15.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469" + integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q== + "@types/node@20.14.5": version "20.14.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.5.tgz#fe35e3022ebe58b8f201580eb24e1fcfc0f2487d" @@ -2125,6 +2171,18 @@ acorn@^8.8.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== +aes-js@4.0.0-beta.5: + version "4.0.0-beta.5" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-4.0.0-beta.5.tgz#8d2452c52adedebc3a3e28465d858c11ca315873" + integrity sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q== + +agent-base@^7.0.2: + version "7.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" + integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== + dependencies: + debug "^4.3.4" + aggregate-error@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" @@ -2202,7 +2260,7 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== -ansi-styles@^6.0.0, ansi-styles@^6.2.1: +ansi-styles@^6.0.0, ansi-styles@^6.1.0, ansi-styles@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== @@ -2370,6 +2428,16 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== +bin-links@^4.0.3: + version "4.0.4" + resolved "https://registry.yarnpkg.com/bin-links/-/bin-links-4.0.4.tgz#c3565832b8e287c85f109a02a17027d152a58a63" + integrity sha512-cMtq4W5ZsEwcutJrVId+a/tjt8GSbS+h0oNkdl6+6rBuEv8Ot33Bevj5KPm40t309zuhVic8NjpuL42QCiJWWA== + dependencies: + cmd-shim "^6.0.0" + npm-normalize-package-bin "^3.0.0" + read-cmd-shim "^4.0.0" + write-file-atomic "^5.0.0" + binary-extensions@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" @@ -2524,6 +2592,11 @@ chokidar@^3.5.3: optionalDependencies: fsevents "~2.3.2" +chownr@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-3.0.0.tgz#9855e64ecd240a9cc4267ce8a4aa5d24a1da15e4" + integrity sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g== + ci-info@^3.2.0: version "3.9.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" @@ -2598,6 +2671,11 @@ clone@^1.0.2: resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== +cmd-shim@^6.0.0: + version "6.0.3" + resolved "https://registry.yarnpkg.com/cmd-shim/-/cmd-shim-6.0.3.tgz#c491e9656594ba17ac83c4bd931590a9d6e26033" + integrity sha512-FMabTRlc5t5zjdenF6mS0MBeFZm0XqHqeOkcskKFb/LYCcRQ5fVgLOHVc4Lq9CqABd9zhjwPjMBCJvMCziSVtA== + co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -2637,7 +2715,7 @@ colorette@^2.0.20: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== -commander@^12.1.0, commander@~12.1.0: +commander@12.1.0, commander@^12.1.0, commander@~12.1.0: version "12.1.0" resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== @@ -2757,6 +2835,13 @@ create-jest@^29.7.0: jest-util "^29.7.0" prompts "^2.0.1" +cross-env@7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -2768,7 +2853,7 @@ cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -2905,6 +2990,11 @@ data-uri-to-buffer@^2.0.0: resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-2.0.2.tgz#d296973d5a4897a5dbe31716d118211921f04770" integrity sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA== +data-uri-to-buffer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" + integrity sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A== + data-view-buffer@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/data-view-buffer/-/data-view-buffer-1.0.1.tgz#8ea6326efec17a2e42620696e671d7d5a8bc66b2" @@ -2939,7 +3029,7 @@ date-fns@^2.21.1: dependencies: "@babel/runtime" "^7.21.0" -debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@~4.3.4: +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@~4.3.4: version "4.3.5" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== @@ -3032,11 +3122,31 @@ dot-prop@^5.1.0: dependencies: is-obj "^2.0.0" -dotenv@16.4.5: +dotenv-cli@7.4.2: + version "7.4.2" + resolved "https://registry.yarnpkg.com/dotenv-cli/-/dotenv-cli-7.4.2.tgz#c158a818de08e1fbc51d310f628cbace9075b734" + integrity sha512-SbUj8l61zIbzyhIbg0FwPJq6+wjbzdn9oEtozQpZ6kW2ihCcapKVZj49oCT3oPM+mgQm+itgvUQcG5szxVrZTA== + dependencies: + cross-spawn "^7.0.3" + dotenv "^16.3.0" + dotenv-expand "^10.0.0" + minimist "^1.2.6" + +dotenv-expand@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-10.0.0.tgz#12605d00fb0af6d0a592e6558585784032e4ef37" + integrity sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A== + +dotenv@16.4.5, dotenv@^16.3.0: version "16.4.5" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + easy-table@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/easy-table/-/easy-table-1.2.0.tgz#ba9225d7138fee307bfd4f0b5bc3c04bdc7c54eb" @@ -3066,6 +3176,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + env-paths@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" @@ -3381,6 +3496,19 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== +ethers@6.13.1: + version "6.13.1" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.1.tgz#2b9f9c7455cde9d38b30fe6589972eb083652961" + integrity sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A== + dependencies: + "@adraffy/ens-normalize" "1.10.1" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@types/node" "18.15.13" + aes-js "4.0.0-beta.5" + tslib "2.4.0" + ws "8.17.1" + eventemitter3@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" @@ -3487,6 +3615,14 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" +fetch-blob@^3.1.2, fetch-blob@^3.1.4: + version "3.2.0" + resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" + integrity sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ== + dependencies: + node-domexception "^1.0.0" + web-streams-polyfill "^3.0.3" + file-entry-cache@8.0.0, file-entry-cache@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-8.0.0.tgz#7787bddcf1131bffb92636c69457bbc0edd6d81f" @@ -3556,6 +3692,21 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +foreground-child@^3.1.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.2.1.tgz#767004ccf3a5b30df39bed90718bab43fe0a59f7" + integrity sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + +formdata-polyfill@^4.0.10: + version "4.0.10" + resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" + integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== + dependencies: + fetch-blob "^3.1.2" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -3689,6 +3840,18 @@ glob-to-regexp@^0.4.1: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== +glob@^10.3.7: + version "10.4.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.2.tgz#bed6b95dade5c1f80b4434daced233aee76160e5" + integrity sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w== + dependencies: + foreground-child "^3.1.0" + jackspeak "^3.1.2" + minimatch "^9.0.4" + minipass "^7.1.2" + package-json-from-dist "^1.0.0" + path-scurry "^1.11.1" + glob@^7.1.3, glob@^7.1.4: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" @@ -3831,6 +3994,14 @@ html-escaper@^2.0.0: resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== +https-proxy-agent@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz#8e97b841a029ad8ddc8731f26595bad868cb4168" + integrity sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg== + dependencies: + agent-base "^7.0.2" + debug "4" + human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" @@ -4206,6 +4377,15 @@ iterable-lookahead@^1.0.0: resolved "https://registry.yarnpkg.com/iterable-lookahead/-/iterable-lookahead-1.0.0.tgz#896dfcb78680bdb50036e97edb034c8b68a9737f" integrity sha512-hJnEP2Xk4+44DDwJqUQGdXal5VbyeWLaPyDl2AQc242Zr7iqz4DgpQOrEzglWVMGHMDCkguLHEKxd1+rOsmgSQ== +jackspeak@^3.1.2: + version "3.4.0" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.0.tgz#a75763ff36ad778ede6a156d8ee8b124de445b4a" + integrity sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + jest-changed-files@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.7.0.tgz#1c06d07e77c78e1585d020424dedc10d6e17ac3a" @@ -4846,6 +5026,11 @@ log-update@^6.0.0: strip-ansi "^7.1.0" wrap-ansi "^9.0.0" +lru-cache@^10.2.0: + version "10.2.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" + integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -4948,10 +5133,10 @@ mimic-response@^3.1.0: resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== -miniflare@3.20240610.0: - version "3.20240610.0" - resolved "https://registry.yarnpkg.com/miniflare/-/miniflare-3.20240610.0.tgz#6efeb60f3ba2e658a3e0395538010228fac0e719" - integrity sha512-J6aXmkII5gcq+kC4TurxKiR4rC++apPST/K8P/YjqoQQgrJ+NRPacBhf6iVh8R3ujnXYXaq+Ae+gm+LM0XHK/w== +miniflare@3.20240610.1: + version "3.20240610.1" + resolved "https://registry.yarnpkg.com/miniflare/-/miniflare-3.20240610.1.tgz#8d7d7f8d74c8b416ac1753333b8a680fb37b706e" + integrity sha512-ZkfSpBmX3nJW00yYhvF2kGvjb6f77TOimRR6+2GQvsArbwo6e0iYqLGM9aB/cnJzgFjLMvOv1qj4756iynSxJQ== dependencies: "@cspotcode/source-map-support" "0.8.1" acorn "^8.8.0" @@ -4960,11 +5145,11 @@ miniflare@3.20240610.0: exit-hook "^2.2.1" glob-to-regexp "^0.4.1" stoppable "^1.1.0" - undici "^5.28.2" + undici "^5.28.4" workerd "1.20240610.1" - ws "^8.11.0" + ws "^8.14.2" youch "^3.2.2" - zod "^3.20.6" + zod "^3.22.3" minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" @@ -4992,11 +5177,29 @@ minimisted@^2.0.0: dependencies: minimist "^1.2.5" +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.4, minipass@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707" + integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw== + +minizlib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-3.0.1.tgz#46d5329d1eb3c83924eff1d3b858ca0a31581012" + integrity sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg== + dependencies: + minipass "^7.0.4" + rimraf "^5.0.5" + mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== +mkdirp@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" + integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== + ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" @@ -5050,11 +5253,25 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +node-domexception@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" + integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== + node-fetch-native@^1.6.4: version "1.6.4" resolved "https://registry.yarnpkg.com/node-fetch-native/-/node-fetch-native-1.6.4.tgz#679fc8fd8111266d47d7e72c379f1bed9acff06e" integrity sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ== +node-fetch@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.3.2.tgz#d1e889bacdf733b4ff3b2b243eb7a12866a0b78b" + integrity sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA== + dependencies: + data-uri-to-buffer "^4.0.0" + fetch-blob "^3.1.4" + formdata-polyfill "^4.0.10" + node-forge@^1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -5085,6 +5302,11 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== +npm-normalize-package-bin@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz#25447e32a9a7de1f51362c61a559233b89947832" + integrity sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ== + npm-run-all@4.1.5: version "4.1.5" resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.5.tgz#04476202a15ee0e2e214080861bff12a51d98fba" @@ -5236,6 +5458,11 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +package-json-from-dist@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz#e501cd3094b278495eb4258d4c9f6d5ac3019f00" + integrity sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw== + pako@^1.0.10: version "1.0.11" resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" @@ -5313,6 +5540,14 @@ path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-scurry@^1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" + integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-to-regexp@^6.2.0: version "6.2.2" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.2.tgz#324377a83e5049cbecadc5554d6a63a9a4866b36" @@ -5458,6 +5693,11 @@ react-is@^18.0.0: resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== +read-cmd-shim@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz#640a08b473a49043e394ae0c7a34dd822c73b9bb" + integrity sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q== + read-pkg@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" @@ -5572,6 +5812,13 @@ rfdc@^1.3.1: resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.1.tgz#2b6d4df52dffe8bb346992a10ea9451f24373a8f" integrity sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg== +rimraf@^5.0.5: + version "5.0.7" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.7.tgz#27bddf202e7d89cb2e0381656380d1734a854a74" + integrity sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg== + dependencies: + glob "^10.3.7" + rollup-plugin-inject@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz#e4233855bfba6c0c12a312fd6649dff9a13ee9f4" @@ -5728,7 +5975,7 @@ signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== -signal-exit@^4.1.0: +signal-exit@^4.0.1, signal-exit@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== @@ -5786,7 +6033,7 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@0.6.1, source-map@^0.6.0, source-map@^0.6.1: +source-map@^0.6.0, source-map@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -5875,6 +6122,15 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -5884,6 +6140,15 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string-width@^7.0.0: version "7.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-7.1.0.tgz#d994252935224729ea3719c49f7206dc9c46550a" @@ -5943,6 +6208,13 @@ string_decoder@^1.1.1: dependencies: safe-buffer "~5.2.0" +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -5950,7 +6222,7 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" -strip-ansi@^7.1.0: +strip-ansi@^7.0.1, strip-ansi@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== @@ -5992,6 +6264,16 @@ summary@2.1.0: resolved "https://registry.yarnpkg.com/summary/-/summary-2.1.0.tgz#be8a49a0aa34eb6ceea56042cae88f8add4b0885" integrity sha512-nMIjMrd5Z2nuB2RZCKJfFMjgS3fygbeyGk9PxPPaJR1RIcyN9yn4A63Isovzm3ZtQuEkLBVgMdPup8UeLH7aQw== +supabase@1.178.2: + version "1.178.2" + resolved "https://registry.yarnpkg.com/supabase/-/supabase-1.178.2.tgz#f7efaed43031258f9770f7a287cf26becd8f5083" + integrity sha512-JdjNY56cF5PbuhFdhgdYah5qXOPRsLQn0kXaY7uapTFopdIFX4tRiFXqKSig8S0SdznF/y/f6vLdq30Sek1ZZQ== + dependencies: + bin-links "^4.0.3" + https-proxy-agent "^7.0.2" + node-fetch "^3.3.2" + tar "7.4.0" + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -6026,6 +6308,18 @@ synckit@^0.8.6: "@pkgr/core" "^0.1.0" tslib "^2.6.2" +tar@7.4.0: + version "7.4.0" + resolved "https://registry.yarnpkg.com/tar/-/tar-7.4.0.tgz#e513afef5ba20ce250fd99397b4599db07d06443" + integrity sha512-XQs0S8fuAkQWuqhDeCdMlJXDX80D7EOVLDPVFkna9yQfzS+PHKgfxcei0jf6/+QAWcjqrnC8uM3fSAnrQl+XYg== + dependencies: + "@isaacs/fs-minipass" "^4.0.0" + chownr "^3.0.0" + minipass "^7.1.2" + minizlib "^3.0.1" + mkdirp "^3.0.1" + yallist "^5.0.0" + test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" @@ -6119,6 +6413,11 @@ tsconfig-paths@^4.2.0: minimist "^1.2.6" strip-bom "^3.0.0" +tslib@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" + integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== + tslib@^2.2.0, tslib@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" @@ -6244,7 +6543,7 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici@^5.25.4, undici@^5.28.2: +undici@^5.25.4, undici@^5.28.4: version "5.28.4" resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068" integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== @@ -6351,6 +6650,11 @@ wcwidth@^1.0.1: dependencies: defaults "^1.0.3" +web-streams-polyfill@^3.0.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz#2073b91a2fdb1fbfbd401e7de0ac9f8214cecb4b" + integrity sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw== + webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" @@ -6416,29 +6720,38 @@ workerd@1.20240610.1: "@cloudflare/workerd-linux-arm64" "1.20240610.1" "@cloudflare/workerd-windows-64" "1.20240610.1" -wrangler@3.60.3: - version "3.60.3" - resolved "https://registry.yarnpkg.com/wrangler/-/wrangler-3.60.3.tgz#1b2ebd2214e10e42a143e47b425480cbe7b7be21" - integrity sha512-a6zn/KFnYaYp3nxJR/aP0TeaBvJDkrrfI89KoxUtx28H7zpya/5/VLu3CxQ3PRspEojJGF0s6f3/pddRy3F+BQ== +wrangler@3.61.0: + version "3.61.0" + resolved "https://registry.yarnpkg.com/wrangler/-/wrangler-3.61.0.tgz#a2426bef0d0cb497cbe817b558eecbd803e5563c" + integrity sha512-feVAp0986x9xL3Dc1zin0ZVXKaqzp7eZur7iPLnpEwjG1Xy4dkVEZ5a1LET94Iyejt1P+EX5lgGcz63H7EfzUw== dependencies: - "@cloudflare/kv-asset-handler" "0.3.2" + "@cloudflare/kv-asset-handler" "0.3.3" "@esbuild-plugins/node-globals-polyfill" "^0.2.3" "@esbuild-plugins/node-modules-polyfill" "^0.2.2" blake3-wasm "^2.1.5" chokidar "^3.5.3" esbuild "0.17.19" - miniflare "3.20240610.0" + miniflare "3.20240610.1" nanoid "^3.3.3" path-to-regexp "^6.2.0" resolve "^1.22.8" resolve.exports "^2.0.2" selfsigned "^2.0.1" - source-map "0.6.1" + source-map "^0.6.1" unenv "npm:unenv-nightly@1.10.0-1717606461.a117952" xxhash-wasm "^1.0.1" optionalDependencies: fsevents "~2.3.2" +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" @@ -6457,6 +6770,15 @@ wrap-ansi@^7.0.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + wrap-ansi@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-9.0.0.tgz#1a3dc8b70d85eeb8398ddfb1e4a02cd186e58b3e" @@ -6479,7 +6801,20 @@ write-file-atomic@^4.0.2: imurmurhash "^0.1.4" signal-exit "^3.0.7" -ws@^8.11.0, ws@^8.14.2: +write-file-atomic@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-5.0.1.tgz#68df4717c55c6fa4281a7860b4c2ba0a6d2b11e7" + integrity sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw== + dependencies: + imurmurhash "^0.1.4" + signal-exit "^4.0.1" + +ws@8.17.1: + version "8.17.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" + integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== + +ws@^8.14.2: version "8.17.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.0.tgz#d145d18eca2ed25aaf791a183903f7be5e295fea" integrity sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow== @@ -6509,6 +6844,11 @@ yallist@^3.0.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== +yallist@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-5.0.0.tgz#00e2de443639ed0d78fd87de0d27469fbcffb533" + integrity sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw== + yaml@^2.4.5: version "2.4.5" resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.4.5.tgz#60630b206dd6d84df97003d33fc1ddf6296cca5e" @@ -6561,7 +6901,7 @@ zod-validation-error@^3.0.3: resolved "https://registry.yarnpkg.com/zod-validation-error/-/zod-validation-error-3.3.0.tgz#2cfe81b62d044e0453d1aa3ae7c32a2f36dde9af" integrity sha512-Syib9oumw1NTqEv4LT0e6U83Td9aVRk9iTXPUQr1otyV1PuXQKOvOwhMNqZIq5hluzHP2pMgnOmHEo7kPdI2mw== -zod@^3.20.6, zod@^3.22.4: +zod@^3.22.3, zod@^3.22.4: version "3.23.8" resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==