From 057f376c7af11a29c507a26a5ec82a00845887e4 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 13:57:35 +0200 Subject: [PATCH 01/40] chore: init repo --- .env.example | 3 +- .github/workflows/compute.yml | 6 +-- .github/workflows/conventional-commits.yml | 2 +- .gitignore | 3 +- README.md | 28 +++++--------- package.json | 6 +-- tests/http/request.http | 18 +++++++++ wrangler.toml | 6 +-- yarn.lock | 44 +++++++++++----------- 9 files changed, 64 insertions(+), 52 deletions(-) create mode 100644 tests/http/request.http diff --git a/.env.example b/.env.example index e49d79a..f21929f 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -MY_SECRET="MY_SECRET" +SUPABASE_URL= +SUPABASE_KEY= 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/.gitignore b/.gitignore index a033be6..f864c04 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ coverage junit.xml cypress/screenshots script.ts -.wrangler \ No newline at end of file +.wrangler +http-client.private.env.json diff --git a/README.md b/README.md index 4dcb9f1..057638d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# `@ubiquibot/plugin-template` +# `@ubiquibot/command-wallet` + +Helps users retrieving their wallet, or setting it to collect subsequent task rewards. ## Prerequisites @@ -20,25 +22,15 @@ 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. -- 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: "Helps users retrieving their wallet, or setting it to collect subsequent task rewards." + command: "/wallet" + example: "/wallet @user" ``` ###### 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/package.json b/package.json index cbe5fb0..a59281e 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": "Helps users retrieving their wallet, or setting it to collect subsequent task rewards.", "author": "Ubiquity DAO", "license": "MIT", "main": "src/worker.ts", @@ -64,7 +64,7 @@ "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/tests/http/request.http b/tests/http/request.http new file mode 100644 index 0000000..52134f1 --- /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/wrangler.toml b/wrangler.toml index 5a0953a..8c03e78 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,7 +1,7 @@ -name = "your-plugin-name" +name = "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..d94d1c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -344,10 +344,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" @@ -4948,10 +4948,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 +4960,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" @@ -5786,7 +5786,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== @@ -6244,7 +6244,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== @@ -6416,24 +6416,24 @@ 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: @@ -6479,7 +6479,7 @@ write-file-atomic@^4.0.2: imurmurhash "^0.1.4" signal-exit "^3.0.7" -ws@^8.11.0, ws@^8.14.2: +ws@^8.14.2: version "8.17.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.0.tgz#d145d18eca2ed25aaf791a183903f7be5e295fea" integrity sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow== @@ -6561,7 +6561,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== From 70fb75e6e970d6439f5d9ba64ee51caa5edaf269 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:09:21 +0200 Subject: [PATCH 02/40] feat: parsing arguments and executing run --- .dev.vars.example | 3 +- .github/workflows/database.yml | 67 +++++ README.md | 19 +- package.json | 10 +- src/adapters/index.ts | 12 +- src/adapters/supabase/helpers/user.ts | 9 +- src/adapters/supabase/helpers/wallet.ts | 192 +++++++++++++ src/handlers/command-parser.ts | 55 ++++ src/handlers/query-wallet.ts | 85 ++++++ src/plugin.ts | 17 +- src/types/plugin-inputs.ts | 4 +- tsconfig.json | 4 +- yarn.lock | 354 +++++++++++++++++++++++- 13 files changed, 789 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/database.yml create mode 100644 src/adapters/supabase/helpers/wallet.ts create mode 100644 src/handlers/command-parser.ts create mode 100644 src/handlers/query-wallet.ts 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/.github/workflows/database.yml b/.github/workflows/database.yml new file mode 100644 index 0000000..4569ea1 --- /dev/null +++ b/.github/workflows/database.yml @@ -0,0 +1,67 @@ +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: + run-migration: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.10.0" + + - uses: supabase/setup-cli@v1 + with: + version: latest + + - name: Link Supabase project + run: supabase link --project-ref $SUPABASE_PROJECT_ID + + - name: Run migrations + run: supabase db push + + generate_types: + runs-on: ubuntu-latest + needs: + - run-migration + 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/README.md b/README.md index 057638d..b22553d 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,13 @@ Helps users retrieving their wallet, or setting it to collect subsequent task re ## 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 `env.example` and `.dev.vars.example` to `.env` and `.dev.vars` respectively, and fill the variables +3. Generate Supabase types by running + ```shell + yarn prebuild + ``` +4. Run the project with `yarn wrangler` ## Example configuration diff --git a/package.json b/package.json index a59281e..4472f1f 100644 --- a/package.json +++ b/package.json @@ -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 .", @@ -17,7 +18,9 @@ "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" + "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,6 +67,7 @@ "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", 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/user.ts b/src/adapters/supabase/helpers/user.ts index fa8b687..efce7f6 100644 --- a/src/adapters/supabase/helpers/user.ts +++ b/src/adapters/supabase/helpers/user.ts @@ -1,19 +1,12 @@ import { SupabaseClient } from "@supabase/supabase-js"; import { Super } from "./supabase"; -import { Context } from "../../../types/context"; +import { Context } from "../../../types"; 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); } diff --git a/src/adapters/supabase/helpers/wallet.ts b/src/adapters/supabase/helpers/wallet.ts new file mode 100644 index 0000000..31cada0 --- /dev/null +++ b/src/adapters/supabase/helpers/wallet.ts @@ -0,0 +1,192 @@ +import { PostgrestError, SupabaseClient } from "@supabase/supabase-js"; +import { Context } from "../../../types"; +import { Database } from "../../../types/database"; +import { Super } from "./supabase"; + +type LocationRow = Database["public"]["Tables"]["locations"]["Row"]; +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): Promise { + 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): Promise { + 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 { + // const payload = Runtime.getState().latestEventContext.payload; + + 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).single()) as { + data: LocationRow; + error: PostgrestError | null; + }; + + 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 /* other fields if necessary */ }]) + .single(); + + if (userError) { + throw new Error(userError.message); + } + + return userData as UserRow; + } + + private async _checkIfWalletExists(userData: UserRow): Promise<{ data: WalletRow | null; error: PostgrestError | null }> { + const { data, error } = await this.supabase.from("wallets").select("*").eq("id", userData.wallet_id).maybeSingle(); + + return { data: data as WalletRow, 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): Promise { + const walletResponse = await this._checkIfWalletExists(userData); + const walletData = walletResponse.data as WalletRow; + 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, + } as LocationMetaData; + } + + 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).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; + logger.info("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..7ee4ffd --- /dev/null +++ b/src/handlers/command-parser.ts @@ -0,0 +1,55 @@ +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 to query, e.g. @ubiquibot", this._parseUser) + .action((username) => registerWallet(context, username)) + .helpCommand(false) + .exitOverride() + .version(packageJson.version); + program.configureOutput({ + writeOut(str: string) { + context.logger.info(str); + }, + writeErr(str: string) { + context.logger.error(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(); + } + + _parseUser(value: string) { + if (!value.length || value.length < 2) { + throw new InvalidArgumentError("Username should be at least 2 characters long."); + } + if (value[0] !== "@") { + throw new InvalidArgumentError("Username should start with @."); + } + // Remove @ character + return value.slice(1); + } +} diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts new file mode 100644 index 0000000..2accf7b --- /dev/null +++ b/src/handlers/query-wallet.ts @@ -0,0 +1,85 @@ +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 = context.payload; + const config = context.config; + const logger = context.logger; + const sender = payload.sender.login; + const adapters = context.adapters; + + 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.info("Trying to resolve address from ENS name", { ensName }); + address = await resolveAddress(ensName); + if (!address) { + const errorMessage = `Resolving address from ENS name failed: ${ensName}`; + context.logger.fatal(errorMessage); + throw new Error(errorMessage); + } + context.logger.info("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"); + } + + if (payload.comment) { + const { wallet } = adapters.supabase; + await wallet.upsertWalletAddress(context, address); + return context.logger.info("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://rpc-bot.ubq.fi/v1/mainnet`); + return await provider.resolveName(ensName).catch((err) => { + console.trace({ err }); + return null; + }); +} diff --git a/src/plugin.ts b/src/plugin.ts index c790042..0466912 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"; @@ -40,7 +42,20 @@ 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") { + context.logger.fatal(e); + } + } else { + context.logger.error("error", e); + throw e; + } + } } else { context.logger.error(`Unsupported event: ${context.eventName}`); } 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/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/yarn.lock b/yarn.lock index d94d1c9..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" @@ -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" @@ -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== @@ -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" @@ -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" @@ -6439,6 +6743,15 @@ wrangler@3.61.0: 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,6 +6801,19 @@ write-file-atomic@^4.0.2: imurmurhash "^0.1.4" signal-exit "^3.0.7" +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" @@ -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" From 1188e025c3ec46941fbf6b19adb90abc77384be6 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:13:30 +0200 Subject: [PATCH 03/40] chore: updated cspell rules --- .cspell.json | 2 +- .github/knip.ts | 2 +- eslint.config.mjs | 2 +- src/types/database.ts | 776 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 779 insertions(+), 3 deletions(-) create mode 100644 src/types/database.ts 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/.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/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/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; From fd761fcee51c455b9272da1b7d8b8b81ca66118e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:20:31 +0200 Subject: [PATCH 04/40] chore: typed Supabase instance --- src/adapters/supabase/helpers/supabase.ts | 7 +++--- src/adapters/supabase/helpers/wallet.ts | 30 +++++++++++------------ 2 files changed, 19 insertions(+), 18 deletions(-) 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/wallet.ts b/src/adapters/supabase/helpers/wallet.ts index 31cada0..6833d38 100644 --- a/src/adapters/supabase/helpers/wallet.ts +++ b/src/adapters/supabase/helpers/wallet.ts @@ -1,20 +1,19 @@ -import { PostgrestError, SupabaseClient } from "@supabase/supabase-js"; +import { SupabaseClient } from "@supabase/supabase-js"; import { Context } from "../../../types"; import { Database } from "../../../types/database"; import { Super } from "./supabase"; -type LocationRow = Database["public"]["Tables"]["locations"]["Row"]; 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) { + constructor(supabase: SupabaseClient, context: Context) { super(supabase, context); } - public async getAddress(id: number): Promise { + public async getAddress(id: number) { const userWithWallet = await this._getUserWithWallet(id); return this._validateAndGetWalletAddress(userWithWallet); } @@ -43,15 +42,13 @@ export class Wallet extends Super { } } - private async _getUserWithWallet(id: number): Promise { + 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 { - // const payload = Runtime.getState().latestEventContext.payload; - 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; @@ -74,10 +71,7 @@ export class Wallet extends Super { 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).single()) as { - data: LocationRow; - error: PostgrestError | null; - }; + const { data: locationData, error: locationError } = await this.supabase.from("locations").insert(locationMetaData).select().single(); if (locationError) { throw new Error(locationError.message); @@ -99,7 +93,10 @@ export class Wallet extends Super { return userData as UserRow; } - private async _checkIfWalletExists(userData: UserRow): Promise<{ data: WalletRow | null; error: PostgrestError | null }> { + private async _checkIfWalletExists(userData: UserRow) { + if (userData.wallet_id === null) { + throw new Error("Wallet ID is null."); + } const { data, error } = await this.supabase.from("wallets").select("*").eq("id", userData.wallet_id).maybeSingle(); return { data: data as WalletRow, error }; @@ -113,9 +110,9 @@ export class Wallet extends Super { } } - private async _getRegisteredWalletData(userData: UserRow): Promise { + private async _getRegisteredWalletData(userData: UserRow) { const walletResponse = await this._checkIfWalletExists(userData); - const walletData = walletResponse.data as WalletRow; + const walletData = walletResponse.data; const walletError = walletResponse.error; if (walletError) throw walletError; @@ -129,7 +126,7 @@ export class Wallet extends Super { issue_id: payload.issue.id, repository_id: payload.repository.id, organization_id: payload.organization?.id ?? payload.repository.owner.id, - } as LocationMetaData; + }; } private async _registerNewWallet(context: Context, { address, locationMetaData, payload }: RegisterNewWallet) { @@ -168,6 +165,9 @@ export class Wallet extends Super { 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.info("Enriching wallet location metadata", locationMetaData); return this.supabase.from("locations").update(locationMetaData).eq("id", walletData.location_id); } From 767610aa6531261d9e1eba1cedc92fee1e8cbab4 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:23:50 +0200 Subject: [PATCH 05/40] chore: removed migration step from database.yml --- .github/workflows/database.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml index 4569ea1..c7ca2b9 100644 --- a/.github/workflows/database.yml +++ b/.github/workflows/database.yml @@ -11,27 +11,6 @@ env: SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }} jobs: - run-migration: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: "20.10.0" - - - uses: supabase/setup-cli@v1 - with: - version: latest - - - name: Link Supabase project - run: supabase link --project-ref $SUPABASE_PROJECT_ID - - - name: Run migrations - run: supabase db push - generate_types: runs-on: ubuntu-latest needs: From 6eb27b930be7a5318844bfbeea6a5bb429f4121a Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:25:11 +0200 Subject: [PATCH 06/40] chore: added wrangler deploy workflow --- .github/workflows/deploy.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b86fe2b --- /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" + - 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 }} From 559bdccd62c51cab3fc1a98f62faaec04fb0eb96 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:28:32 +0200 Subject: [PATCH 07/40] chore: removed unused files --- src/adapters/supabase/helpers/access.ts | 49 ---------------- src/adapters/supabase/helpers/label.ts | 52 ----------------- src/adapters/supabase/helpers/user.ts | 77 ------------------------- 3 files changed, 178 deletions(-) delete mode 100644 src/adapters/supabase/helpers/access.ts delete mode 100644 src/adapters/supabase/helpers/label.ts delete mode 100644 src/adapters/supabase/helpers/user.ts 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/user.ts b/src/adapters/supabase/helpers/user.ts deleted file mode 100644 index efce7f6..0000000 --- a/src/adapters/supabase/helpers/user.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { SupabaseClient } from "@supabase/supabase-js"; -import { Super } from "./supabase"; -import { Context } from "../../../types"; - -type Wallet = { - address: string; -}; - -export class User extends Super { - 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"; From f5dc9e9a77e7699d9397edf5b7f0d7d7052d6114 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:30:18 +0200 Subject: [PATCH 08/40] chore: fixed database workflow --- .github/workflows/database.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml index c7ca2b9..412923c 100644 --- a/.github/workflows/database.yml +++ b/.github/workflows/database.yml @@ -13,8 +13,6 @@ env: jobs: generate_types: runs-on: ubuntu-latest - needs: - - run-migration permissions: contents: write steps: From bb73e4aee34d3102bad8c7b5159726f6ce6b567d Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 24 Jun 2024 18:38:14 +0200 Subject: [PATCH 09/40] chore: fixed worker name --- wrangler.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrangler.toml b/wrangler.toml index 8c03e78..3a2e0d0 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,4 +1,4 @@ -name = "command-wallet" +name = "ubiquibot-command-wallet" main = "src/worker.ts" compatibility_date = "2024-06-24" node_compat = true From c728812c7c735fdec103425485ef69a10fdb5f02 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 00:54:27 +0200 Subject: [PATCH 10/40] chore: fixed request and payload JSON parsing --- src/worker.ts | 4 +--- tests/http/request.http | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) 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/http/request.http b/tests/http/request.http index 52134f1..a5b3c3a 100644 --- a/tests/http/request.http +++ b/tests/http/request.http @@ -11,8 +11,8 @@ 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": "{}", + "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}}" } From 2a56d91139c0ceacbc841287c22a8ccc8e4e7e4c Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 01:23:48 +0200 Subject: [PATCH 11/40] chore: fixed wallet address argument --- src/handlers/command-parser.ts | 16 ++++++---------- src/plugin.ts | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/handlers/command-parser.ts b/src/handlers/command-parser.ts index 7ee4ffd..cdfa23b 100644 --- a/src/handlers/command-parser.ts +++ b/src/handlers/command-parser.ts @@ -10,9 +10,9 @@ export class CommandParser { const program = new Command(); program .command("/wallet") - .usage("@") - .argument("", "Wallet to query, e.g. @ubiquibot", this._parseUser) - .action((username) => registerWallet(context, username)) + .usage("") + .argument("", "Wallet address to query, e.g. 0x000000000000000000000000000000000000000", this._parseWalletAddress) + .action((wallet) => registerWallet(context, wallet)) .helpCommand(false) .exitOverride() .version(packageJson.version); @@ -42,14 +42,10 @@ export class CommandParser { return this._program.helpInformation(); } - _parseUser(value: string) { + _parseWalletAddress(value: string) { if (!value.length || value.length < 2) { - throw new InvalidArgumentError("Username should be at least 2 characters long."); + throw new InvalidArgumentError("Wallet address should be at least 2 characters long."); } - if (value[0] !== "@") { - throw new InvalidArgumentError("Username should start with @."); - } - // Remove @ character - return value.slice(1); + return value; } } diff --git a/src/plugin.ts b/src/plugin.ts index 0466912..60ab745 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -23,14 +23,30 @@ export async function plugin(inputs: PluginInputs, env: Env) { debug(message: unknown, ...optionalParams: unknown[]) { console.debug(message, ...optionalParams); }, - info(message: unknown, ...optionalParams: unknown[]) { + async info(message: unknown, ...optionalParams: unknown[]) { console.log(message, ...optionalParams); + 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 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); + 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 fatal comment", e)); }, fatal(message: unknown, ...optionalParams: unknown[]) { console.error(message, ...optionalParams); From 6a8ba29c93a6ea8b86672add84922485e77c2921 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 01:30:41 +0200 Subject: [PATCH 12/40] chore: test then --- src/plugin.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugin.ts b/src/plugin.ts index 60ab745..d4e451e 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -32,6 +32,7 @@ export async function plugin(inputs: PluginInputs, env: Env) { repo: context.payload.repository.name, body: `\`\`\`diff\n${message} ${optionalParams}`, }) + .then(() => console.log("posted info")) .catch((e) => console.error("Failed to post info comment", e)); }, warn(message: unknown, ...optionalParams: unknown[]) { From 0a05f27bf0b03066c63a47fa802fe24b600345e2 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 01:33:12 +0200 Subject: [PATCH 13/40] chore: test await --- src/plugin.ts | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index d4e451e..e2ad421 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -25,29 +25,24 @@ export async function plugin(inputs: PluginInputs, env: Env) { }, async info(message: unknown, ...optionalParams: unknown[]) { console.log(message, ...optionalParams); - 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}`, - }) - .then(() => console.log("posted info")) - .catch((e) => console.error("Failed to post info comment", e)); + 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}`, + }); }, warn(message: unknown, ...optionalParams: unknown[]) { console.warn(message, ...optionalParams); }, async error(message: unknown, ...optionalParams: unknown[]) { console.error(message, ...optionalParams); - 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 fatal comment", e)); + 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}`, + }); }, fatal(message: unknown, ...optionalParams: unknown[]) { console.error(message, ...optionalParams); From eb14ae048fd4a34445ace236c889c041133af694 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 01:50:09 +0200 Subject: [PATCH 14/40] chore: added pretty diff --- src/handlers/query-wallet.ts | 8 ++++---- src/plugin.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 2accf7b..c5eee2b 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -24,18 +24,18 @@ export async function registerWallet(context: Context, body: string) { const ensName = extractEnsName(body.replace("/wallet", "").trim()); if (!address && ensName) { - context.logger.info("Trying to resolve address from ENS name", { ensName }); + context.logger.debug("Trying to resolve address from ENS name", { ensName }); address = await resolveAddress(ensName); if (!address) { const errorMessage = `Resolving address from ENS name failed: ${ensName}`; context.logger.fatal(errorMessage); throw new Error(errorMessage); } - context.logger.info("Resolved address from ENS name", { ensName, address }); + 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"); + return context.logger.info("# Skipping to register a wallet address because both address/ens doesn't exist"); } if (config.registerWalletWithVerification) { @@ -49,7 +49,7 @@ export async function registerWallet(context: Context, body: string) { if (payload.comment) { const { wallet } = adapters.supabase; await wallet.upsertWalletAddress(context, address); - return context.logger.info("Successfully registered wallet address", { sender, address }); + return context.logger.info("+ Successfully registered wallet address", { sender, address }); } else { throw new Error("Payload comment is undefined"); } diff --git a/src/plugin.ts b/src/plugin.ts index e2ad421..34ce6c7 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -29,7 +29,7 @@ export async function plugin(inputs: PluginInputs, env: Env) { owner: context.payload.repository.owner.login, issue_number: context.payload.issue.number, repo: context.payload.repository.name, - body: `\`\`\`diff\n${message} ${optionalParams}`, + body: `\`\`\`diff\n${message}`, }); }, warn(message: unknown, ...optionalParams: unknown[]) { From 20da052cafa2e747f2ddfd2cdb192ec43df102cd Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 01:54:36 +0200 Subject: [PATCH 15/40] chore: added error log on ENS fail --- src/handlers/query-wallet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index c5eee2b..f936284 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -28,7 +28,7 @@ export async function registerWallet(context: Context, body: string) { address = await resolveAddress(ensName); if (!address) { const errorMessage = `Resolving address from ENS name failed: ${ensName}`; - context.logger.fatal(errorMessage); + context.logger.error(errorMessage); throw new Error(errorMessage); } context.logger.debug("Resolved address from ENS name", { ensName, address }); From a89370a8f85d8a4048e1f287f0c721f639361071 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 02:07:30 +0200 Subject: [PATCH 16/40] chore: async await on logs --- src/handlers/command-parser.ts | 8 ++++---- src/handlers/query-wallet.ts | 2 +- src/plugin.ts | 4 ++-- src/types/context.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/handlers/command-parser.ts b/src/handlers/command-parser.ts index cdfa23b..a7fbec4 100644 --- a/src/handlers/command-parser.ts +++ b/src/handlers/command-parser.ts @@ -17,11 +17,11 @@ export class CommandParser { .exitOverride() .version(packageJson.version); program.configureOutput({ - writeOut(str: string) { - context.logger.info(str); + async writeOut(str: string) { + await context.logger.info(str); }, - writeErr(str: string) { - context.logger.error(str); + async writeErr(str: string) { + await context.logger.error(str); }, getErrHelpWidth(): number { return 0; diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index f936284..2dcca34 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -28,7 +28,7 @@ export async function registerWallet(context: Context, body: string) { address = await resolveAddress(ensName); if (!address) { const errorMessage = `Resolving address from ENS name failed: ${ensName}`; - context.logger.error(errorMessage); + await context.logger.error(errorMessage); throw new Error(errorMessage); } context.logger.debug("Resolved address from ENS name", { ensName, address }); diff --git a/src/plugin.ts b/src/plugin.ts index 34ce6c7..5464cd7 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -64,11 +64,11 @@ export async function plugin(inputs: PluginInputs, env: Env) { context.logger.fatal(e); } } else { - context.logger.error("error", e); + await context.logger.error("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..9679cf7 100644 --- a/src/types/context.ts +++ b/src/types/context.ts @@ -19,9 +19,9 @@ 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; debug: (message: unknown, ...optionalParams: unknown[]) => void; }; } From 15f39964b4c699094f3efb4e263bdc8de411c071 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 02:12:14 +0200 Subject: [PATCH 17/40] chore: fixed error message --- src/handlers/query-wallet.ts | 4 +--- src/plugin.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 2dcca34..635aca5 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -27,9 +27,7 @@ export async function registerWallet(context: Context, body: string) { context.logger.debug("Trying to resolve address from ENS name", { ensName }); address = await resolveAddress(ensName); if (!address) { - const errorMessage = `Resolving address from ENS name failed: ${ensName}`; - await context.logger.error(errorMessage); - throw new Error(errorMessage); + throw new Error(`Resolving address from ENS name failed: ${ensName}`); } context.logger.debug("Resolved address from ENS name", { ensName, address }); } diff --git a/src/plugin.ts b/src/plugin.ts index 5464cd7..8d3418e 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -64,7 +64,7 @@ export async function plugin(inputs: PluginInputs, env: Env) { context.logger.fatal(e); } } else { - await context.logger.error("error", e); + await context.logger.error(e); throw e; } } From e997968e0e2fba6183f4b24159f87c209fb62173 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 02:21:39 +0200 Subject: [PATCH 18/40] chore: added fastest rpc check --- package.json | 1 + src/handlers/query-wallet.ts | 17 +- yarn.lock | 351 ++++++++++++++++++++++++++++++++++- 3 files changed, 367 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4472f1f..c01d3f9 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "@octokit/webhooks": "13.2.7", "@sinclair/typebox": "0.32.33", "@supabase/supabase-js": "2.43.5", + "@ubiquity-dao/rpc-handler": "1.1.0", "commander": "12.1.0", "dotenv": "16.4.5", "ethers": "6.13.1", diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 635aca5..5d25660 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -1,3 +1,4 @@ +import { HandlerConstructorConfig, RPCHandler } from "@ubiquity-dao/rpc-handler"; import { ethers } from "ethers"; import { Context } from "../types"; @@ -72,10 +73,24 @@ function registerWalletWithVerification(context: Context, body: string, address: } } +function useHandler(networkId: number) { + const config: HandlerConstructorConfig = { + networkId, + rpcTimeout: 1500, + autoStorage: false, + cacheRefreshCycles: 10, + networkName: null, + networkRpcs: null, + runtimeRpcs: null, + }; + return new RPCHandler(config); +} + 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://rpc-bot.ubq.fi/v1/mainnet`); + const handler = useHandler(1); + const provider = await handler.getFastestRpcProvider(); return await provider.resolveName(ensName).catch((err) => { console.trace({ err }); return null; diff --git a/yarn.lock b/yarn.lock index 1c53f0b..6845bc0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1222,6 +1222,219 @@ resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.4.tgz#9e69f8bb4031e11df79e03db09f9dbbae1740843" integrity sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ== +"@ethersproject/abstract-provider@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz#b0a8550f88b6bf9d51f90e4795d48294630cb9ef" + integrity sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/networks" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/web" "^5.7.0" + +"@ethersproject/abstract-signer@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz#13f4f32117868452191a4649723cb086d2b596b2" + integrity sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ== + dependencies: + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + +"@ethersproject/address@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.7.0.tgz#19b56c4d74a3b0a46bfdbb6cfcc0a153fc697f37" + integrity sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + +"@ethersproject/base64@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.7.0.tgz#ac4ee92aa36c1628173e221d0d01f53692059e1c" + integrity sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ== + dependencies: + "@ethersproject/bytes" "^5.7.0" + +"@ethersproject/basex@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.7.0.tgz#97034dc7e8938a8ca943ab20f8a5e492ece4020b" + integrity sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + +"@ethersproject/bignumber@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.7.0.tgz#e2f03837f268ba655ffba03a57853e18a18dc9c2" + integrity sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + bn.js "^5.2.1" + +"@ethersproject/bytes@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.7.0.tgz#a00f6ea8d7e7534d6d87f47188af1148d71f155d" + integrity sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A== + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/constants@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.7.0.tgz#df80a9705a7e08984161f09014ea012d1c75295e" + integrity sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + +"@ethersproject/hash@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.7.0.tgz#eb7aca84a588508369562e16e514b539ba5240a7" + integrity sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g== + dependencies: + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/base64" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@ethersproject/keccak256@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.7.0.tgz#3186350c6e1cd6aba7940384ec7d6d9db01f335a" + integrity sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg== + dependencies: + "@ethersproject/bytes" "^5.7.0" + js-sha3 "0.8.0" + +"@ethersproject/logger@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.7.0.tgz#6ce9ae168e74fecf287be17062b590852c311892" + integrity sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig== + +"@ethersproject/networks@^5.7.0": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.7.1.tgz#118e1a981d757d45ccea6bb58d9fd3d9db14ead6" + integrity sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ== + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/properties@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.7.0.tgz#a6e12cb0439b878aaf470f1902a176033067ed30" + integrity sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw== + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/providers@5.7.2": + version "5.7.2" + resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb" + integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg== + dependencies: + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/base64" "^5.7.0" + "@ethersproject/basex" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/networks" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/random" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + "@ethersproject/sha2" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/web" "^5.7.0" + bech32 "1.1.4" + ws "7.4.6" + +"@ethersproject/random@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.7.0.tgz#af19dcbc2484aae078bb03656ec05df66253280c" + integrity sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/rlp@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.7.0.tgz#de39e4d5918b9d74d46de93af80b7685a9c21304" + integrity sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/sha2@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.7.0.tgz#9a5f7a7824ef784f7f7680984e593a800480c9fb" + integrity sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + hash.js "1.1.7" + +"@ethersproject/signing-key@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.7.0.tgz#06b2df39411b00bc57c7c09b01d1e41cf1b16ab3" + integrity sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + bn.js "^5.2.1" + elliptic "6.5.4" + hash.js "1.1.7" + +"@ethersproject/strings@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.7.0.tgz#54c9d2a7c57ae8f1205c88a9d3a56471e14d5ed2" + integrity sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/transactions@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.7.0.tgz#91318fc24063e057885a6af13fdb703e1f993d3b" + integrity sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ== + dependencies: + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + "@ethersproject/signing-key" "^5.7.0" + +"@ethersproject/web@^5.7.0": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.7.1.tgz#de1f285b373149bee5928f4eb7bcb87ee5fbb4ae" + integrity sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w== + dependencies: + "@ethersproject/base64" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + "@fastify/busboy@^2.0.0": version "2.1.1" resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" @@ -2143,6 +2356,15 @@ "@typescript-eslint/types" "7.13.1" eslint-visitor-keys "^3.4.3" +"@ubiquity-dao/rpc-handler@1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@ubiquity-dao/rpc-handler/-/rpc-handler-1.1.0.tgz#5a17e98de8c611ea19315ff946166b20d6f7f629" + integrity sha512-EzbwAoHx+jPEymAdJbKt1O7C9RB/R3IWcBPRbDzFs8iBOuFktClsR8e95xvFrV9n2jTmr2ZHxpXE/rOLOEWfPA== + dependencies: + "@ethersproject/providers" "5.7.2" + axios "^1.7.1" + node-fetch "^3.3.2" + JSONStream@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -2346,6 +2568,11 @@ async-lock@^1.4.1: resolved "https://registry.yarnpkg.com/async-lock/-/async-lock-1.4.1.tgz#56b8718915a9b68b10fce2f2a9a3dddf765ef53f" integrity sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ== +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + available-typed-arrays@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846" @@ -2353,6 +2580,15 @@ available-typed-arrays@^1.0.7: dependencies: possible-typed-array-names "^1.0.0" +axios@^1.7.1: + version "1.7.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621" + integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + babel-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" @@ -2423,6 +2659,11 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +bech32@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" + integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== + before-after-hook@^2.2.0: version "2.2.3" resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" @@ -2448,6 +2689,16 @@ blake3-wasm@^2.1.5: resolved "https://registry.yarnpkg.com/blake3-wasm/-/blake3-wasm-2.1.5.tgz#b22dbb84bc9419ed0159caa76af4b1b132e6ba52" integrity sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g== +bn.js@^4.11.9: + version "4.12.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== + +bn.js@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" + integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -2470,6 +2721,11 @@ braces@^3.0.3, braces@~3.0.2: dependencies: fill-range "^7.1.1" +brorand@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== + browserslist@^4.22.2: version "4.23.0" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.0.tgz#8f3acc2bbe73af7213399430890f86c63a5674ab" @@ -2715,6 +2971,13 @@ colorette@^2.0.20: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.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" @@ -3088,6 +3351,11 @@ defu@^6.1.4: resolved "https://registry.yarnpkg.com/defu/-/defu-6.1.4.tgz#4e0c9cf9ff68fe5f3d7f2765cc1a012dfdcb0479" integrity sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg== +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + deprecation@^2.0.0: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" @@ -3161,6 +3429,19 @@ electron-to-chromium@^1.4.668: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.788.tgz#a3545959d5cfa0a266d3e551386c040be34e7e06" integrity sha512-ubp5+Ev/VV8KuRoWnfP2QF2Bg+O2ZFdb49DiiNbz2VmgkIqrnyYaqIOqj8A6K/3p1xV0QcU5hBQ1+BmB6ot1OA== +elliptic@6.5.4: + version "6.5.4" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + emittery@^0.13.1: version "0.13.1" resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad" @@ -3685,6 +3966,11 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== +follow-redirects@^1.15.6: + version "1.15.6" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== + for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -3700,6 +3986,15 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + formdata-polyfill@^4.0.10: version "4.0.10" resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" @@ -3972,6 +4267,14 @@ has-tostringtag@^1.0.0, has-tostringtag@^1.0.2: dependencies: has-symbols "^1.0.3" +hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: + version "1.1.7" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" + integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.1" + hasown@^2.0.0, hasown@^2.0.1, hasown@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" @@ -3984,6 +4287,15 @@ headers-polyfill@^4.0.2: resolved "https://registry.yarnpkg.com/headers-polyfill/-/headers-polyfill-4.0.3.tgz#922a0155de30ecc1f785bcf04be77844ca95ad07" integrity sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ== +hmac-drbg@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== + dependencies: + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" + hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" @@ -4071,7 +4383,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@^2.0.3: +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -4771,6 +5083,11 @@ jiti@^1.21.0: resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.6.tgz#6c7f7398dd4b3142767f9a168af2f317a428d268" integrity sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w== +js-sha3@0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" + integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== + js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -5113,6 +5430,18 @@ micromatch@^4.0.4, micromatch@^4.0.5, micromatch@^4.0.7, micromatch@~4.0.7: braces "^3.0.3" picomatch "^2.3.1" +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + mime@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7" @@ -5151,6 +5480,16 @@ miniflare@3.20240610.1: youch "^3.2.2" zod "^3.22.3" +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== + minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -5673,6 +6012,11 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.5" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + punycode@^2.1.0: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" @@ -6809,6 +7153,11 @@ write-file-atomic@^5.0.0: imurmurhash "^0.1.4" signal-exit "^4.0.1" +ws@7.4.6: + version "7.4.6" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" + integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== + ws@8.17.1: version "8.17.1" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" From 5b04deb44938e55a42c9b55f86876c021849ac86 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 02:33:29 +0200 Subject: [PATCH 19/40] chore: added fastest rpc check --- src/handlers/query-wallet.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 5d25660..35a03ab 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -1,3 +1,4 @@ +// @ts-expect-error err import { HandlerConstructorConfig, RPCHandler } from "@ubiquity-dao/rpc-handler"; import { ethers } from "ethers"; import { Context } from "../types"; @@ -91,7 +92,8 @@ export async function resolveAddress(ensName: string) { // Explicitly set provider to Ethereum mainnet const handler = useHandler(1); const provider = await handler.getFastestRpcProvider(); - return await provider.resolveName(ensName).catch((err) => { + console.log("trying to resolve address from ENS address", ensName); + return await provider.resolveName(ensName).catch((err: object) => { console.trace({ err }); return null; }); From 33e9d3ff9cc75fd6a03a12fdc751816b21854e78 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 02:39:37 +0200 Subject: [PATCH 20/40] chore: test rpc --- src/handlers/query-wallet.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 35a03ab..37f4cf7 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -1,5 +1,3 @@ -// @ts-expect-error err -import { HandlerConstructorConfig, RPCHandler } from "@ubiquity-dao/rpc-handler"; import { ethers } from "ethers"; import { Context } from "../types"; @@ -74,26 +72,11 @@ function registerWalletWithVerification(context: Context, body: string, address: } } -function useHandler(networkId: number) { - const config: HandlerConstructorConfig = { - networkId, - rpcTimeout: 1500, - autoStorage: false, - cacheRefreshCycles: 10, - networkName: null, - networkRpcs: null, - runtimeRpcs: null, - }; - return new RPCHandler(config); -} - 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 handler = useHandler(1); - const provider = await handler.getFastestRpcProvider(); - console.log("trying to resolve address from ENS address", ensName); - return await provider.resolveName(ensName).catch((err: object) => { + const provider = new ethers.JsonRpcProvider(`https://eth.drpc.org`); + return await provider.resolveName(ensName).catch((err) => { console.trace({ err }); return null; }); From 8ecca13c1998ff17960cd3801f64109031a03467 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 02:44:52 +0200 Subject: [PATCH 21/40] chore: test rpc --- package.json | 1 - yarn.lock | 351 +-------------------------------------------------- 2 files changed, 1 insertion(+), 351 deletions(-) diff --git a/package.json b/package.json index c01d3f9..4472f1f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "@octokit/webhooks": "13.2.7", "@sinclair/typebox": "0.32.33", "@supabase/supabase-js": "2.43.5", - "@ubiquity-dao/rpc-handler": "1.1.0", "commander": "12.1.0", "dotenv": "16.4.5", "ethers": "6.13.1", diff --git a/yarn.lock b/yarn.lock index 6845bc0..1c53f0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1222,219 +1222,6 @@ resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.4.tgz#9e69f8bb4031e11df79e03db09f9dbbae1740843" integrity sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ== -"@ethersproject/abstract-provider@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz#b0a8550f88b6bf9d51f90e4795d48294630cb9ef" - integrity sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw== - dependencies: - "@ethersproject/bignumber" "^5.7.0" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/networks" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - "@ethersproject/transactions" "^5.7.0" - "@ethersproject/web" "^5.7.0" - -"@ethersproject/abstract-signer@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz#13f4f32117868452191a4649723cb086d2b596b2" - integrity sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ== - dependencies: - "@ethersproject/abstract-provider" "^5.7.0" - "@ethersproject/bignumber" "^5.7.0" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - -"@ethersproject/address@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.7.0.tgz#19b56c4d74a3b0a46bfdbb6cfcc0a153fc697f37" - integrity sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA== - dependencies: - "@ethersproject/bignumber" "^5.7.0" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/keccak256" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/rlp" "^5.7.0" - -"@ethersproject/base64@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.7.0.tgz#ac4ee92aa36c1628173e221d0d01f53692059e1c" - integrity sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ== - dependencies: - "@ethersproject/bytes" "^5.7.0" - -"@ethersproject/basex@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.7.0.tgz#97034dc7e8938a8ca943ab20f8a5e492ece4020b" - integrity sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw== - dependencies: - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - -"@ethersproject/bignumber@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.7.0.tgz#e2f03837f268ba655ffba03a57853e18a18dc9c2" - integrity sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw== - dependencies: - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - bn.js "^5.2.1" - -"@ethersproject/bytes@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.7.0.tgz#a00f6ea8d7e7534d6d87f47188af1148d71f155d" - integrity sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A== - dependencies: - "@ethersproject/logger" "^5.7.0" - -"@ethersproject/constants@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.7.0.tgz#df80a9705a7e08984161f09014ea012d1c75295e" - integrity sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA== - dependencies: - "@ethersproject/bignumber" "^5.7.0" - -"@ethersproject/hash@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.7.0.tgz#eb7aca84a588508369562e16e514b539ba5240a7" - integrity sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g== - dependencies: - "@ethersproject/abstract-signer" "^5.7.0" - "@ethersproject/address" "^5.7.0" - "@ethersproject/base64" "^5.7.0" - "@ethersproject/bignumber" "^5.7.0" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/keccak256" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - "@ethersproject/strings" "^5.7.0" - -"@ethersproject/keccak256@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.7.0.tgz#3186350c6e1cd6aba7940384ec7d6d9db01f335a" - integrity sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg== - dependencies: - "@ethersproject/bytes" "^5.7.0" - js-sha3 "0.8.0" - -"@ethersproject/logger@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.7.0.tgz#6ce9ae168e74fecf287be17062b590852c311892" - integrity sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig== - -"@ethersproject/networks@^5.7.0": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.7.1.tgz#118e1a981d757d45ccea6bb58d9fd3d9db14ead6" - integrity sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ== - dependencies: - "@ethersproject/logger" "^5.7.0" - -"@ethersproject/properties@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.7.0.tgz#a6e12cb0439b878aaf470f1902a176033067ed30" - integrity sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw== - dependencies: - "@ethersproject/logger" "^5.7.0" - -"@ethersproject/providers@5.7.2": - version "5.7.2" - resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb" - integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg== - dependencies: - "@ethersproject/abstract-provider" "^5.7.0" - "@ethersproject/abstract-signer" "^5.7.0" - "@ethersproject/address" "^5.7.0" - "@ethersproject/base64" "^5.7.0" - "@ethersproject/basex" "^5.7.0" - "@ethersproject/bignumber" "^5.7.0" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/constants" "^5.7.0" - "@ethersproject/hash" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/networks" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - "@ethersproject/random" "^5.7.0" - "@ethersproject/rlp" "^5.7.0" - "@ethersproject/sha2" "^5.7.0" - "@ethersproject/strings" "^5.7.0" - "@ethersproject/transactions" "^5.7.0" - "@ethersproject/web" "^5.7.0" - bech32 "1.1.4" - ws "7.4.6" - -"@ethersproject/random@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.7.0.tgz#af19dcbc2484aae078bb03656ec05df66253280c" - integrity sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ== - dependencies: - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - -"@ethersproject/rlp@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.7.0.tgz#de39e4d5918b9d74d46de93af80b7685a9c21304" - integrity sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w== - dependencies: - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - -"@ethersproject/sha2@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.7.0.tgz#9a5f7a7824ef784f7f7680984e593a800480c9fb" - integrity sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw== - dependencies: - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - hash.js "1.1.7" - -"@ethersproject/signing-key@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.7.0.tgz#06b2df39411b00bc57c7c09b01d1e41cf1b16ab3" - integrity sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q== - dependencies: - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - bn.js "^5.2.1" - elliptic "6.5.4" - hash.js "1.1.7" - -"@ethersproject/strings@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.7.0.tgz#54c9d2a7c57ae8f1205c88a9d3a56471e14d5ed2" - integrity sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg== - dependencies: - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/constants" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - -"@ethersproject/transactions@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.7.0.tgz#91318fc24063e057885a6af13fdb703e1f993d3b" - integrity sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ== - dependencies: - "@ethersproject/address" "^5.7.0" - "@ethersproject/bignumber" "^5.7.0" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/constants" "^5.7.0" - "@ethersproject/keccak256" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - "@ethersproject/rlp" "^5.7.0" - "@ethersproject/signing-key" "^5.7.0" - -"@ethersproject/web@^5.7.0": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.7.1.tgz#de1f285b373149bee5928f4eb7bcb87ee5fbb4ae" - integrity sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w== - dependencies: - "@ethersproject/base64" "^5.7.0" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/logger" "^5.7.0" - "@ethersproject/properties" "^5.7.0" - "@ethersproject/strings" "^5.7.0" - "@fastify/busboy@^2.0.0": version "2.1.1" resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" @@ -2356,15 +2143,6 @@ "@typescript-eslint/types" "7.13.1" eslint-visitor-keys "^3.4.3" -"@ubiquity-dao/rpc-handler@1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@ubiquity-dao/rpc-handler/-/rpc-handler-1.1.0.tgz#5a17e98de8c611ea19315ff946166b20d6f7f629" - integrity sha512-EzbwAoHx+jPEymAdJbKt1O7C9RB/R3IWcBPRbDzFs8iBOuFktClsR8e95xvFrV9n2jTmr2ZHxpXE/rOLOEWfPA== - dependencies: - "@ethersproject/providers" "5.7.2" - axios "^1.7.1" - node-fetch "^3.3.2" - JSONStream@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -2568,11 +2346,6 @@ async-lock@^1.4.1: resolved "https://registry.yarnpkg.com/async-lock/-/async-lock-1.4.1.tgz#56b8718915a9b68b10fce2f2a9a3dddf765ef53f" integrity sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ== -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - available-typed-arrays@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846" @@ -2580,15 +2353,6 @@ available-typed-arrays@^1.0.7: dependencies: possible-typed-array-names "^1.0.0" -axios@^1.7.1: - version "1.7.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621" - integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw== - dependencies: - follow-redirects "^1.15.6" - form-data "^4.0.0" - proxy-from-env "^1.1.0" - babel-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" @@ -2659,11 +2423,6 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -bech32@1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" - integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== - before-after-hook@^2.2.0: version "2.2.3" resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" @@ -2689,16 +2448,6 @@ blake3-wasm@^2.1.5: resolved "https://registry.yarnpkg.com/blake3-wasm/-/blake3-wasm-2.1.5.tgz#b22dbb84bc9419ed0159caa76af4b1b132e6ba52" integrity sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g== -bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== - -bn.js@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" - integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -2721,11 +2470,6 @@ braces@^3.0.3, braces@~3.0.2: dependencies: fill-range "^7.1.1" -brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== - browserslist@^4.22.2: version "4.23.0" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.0.tgz#8f3acc2bbe73af7213399430890f86c63a5674ab" @@ -2971,13 +2715,6 @@ colorette@^2.0.20: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.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" @@ -3351,11 +3088,6 @@ defu@^6.1.4: resolved "https://registry.yarnpkg.com/defu/-/defu-6.1.4.tgz#4e0c9cf9ff68fe5f3d7f2765cc1a012dfdcb0479" integrity sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg== -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - deprecation@^2.0.0: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" @@ -3429,19 +3161,6 @@ electron-to-chromium@^1.4.668: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.788.tgz#a3545959d5cfa0a266d3e551386c040be34e7e06" integrity sha512-ubp5+Ev/VV8KuRoWnfP2QF2Bg+O2ZFdb49DiiNbz2VmgkIqrnyYaqIOqj8A6K/3p1xV0QcU5hBQ1+BmB6ot1OA== -elliptic@6.5.4: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - emittery@^0.13.1: version "0.13.1" resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad" @@ -3966,11 +3685,6 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== -follow-redirects@^1.15.6: - version "1.15.6" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" - integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== - for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -3986,15 +3700,6 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" -form-data@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" - integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - formdata-polyfill@^4.0.10: version "4.0.10" resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" @@ -4267,14 +3972,6 @@ has-tostringtag@^1.0.0, has-tostringtag@^1.0.2: dependencies: has-symbols "^1.0.3" -hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - hasown@^2.0.0, hasown@^2.0.1, hasown@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" @@ -4287,15 +3984,6 @@ headers-polyfill@^4.0.2: resolved "https://registry.yarnpkg.com/headers-polyfill/-/headers-polyfill-4.0.3.tgz#922a0155de30ecc1f785bcf04be77844ca95ad07" integrity sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ== -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" @@ -4383,7 +4071,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4: +inherits@2, inherits@^2.0.1, inherits@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -5083,11 +4771,6 @@ jiti@^1.21.0: resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.6.tgz#6c7f7398dd4b3142767f9a168af2f317a428d268" integrity sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w== -js-sha3@0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" - integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== - js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -5430,18 +5113,6 @@ micromatch@^4.0.4, micromatch@^4.0.5, micromatch@^4.0.7, micromatch@~4.0.7: braces "^3.0.3" picomatch "^2.3.1" -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - mime@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7" @@ -5480,16 +5151,6 @@ miniflare@3.20240610.1: youch "^3.2.2" zod "^3.22.3" -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== - minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -6012,11 +5673,6 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.5" -proxy-from-env@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" - integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== - punycode@^2.1.0: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" @@ -7153,11 +6809,6 @@ write-file-atomic@^5.0.0: imurmurhash "^0.1.4" signal-exit "^4.0.1" -ws@7.4.6: - version "7.4.6" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" - integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== - ws@8.17.1: version "8.17.1" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" From e059e1329da781194a4f7a928be17015d2b28962 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 14:32:29 +0200 Subject: [PATCH 22/40] feat: added test for wallet link --- jest.config.json | 3 +- src/adapters/supabase/helpers/wallet.ts | 4 +- src/handlers/command-parser.ts | 4 +- src/plugin.ts | 32 ++- src/types/environment.d.ts | 10 + tests/__mocks__/db-seed.json | 15 ++ tests/__mocks__/db.ts | 7 +- tests/__mocks__/handlers.ts | 33 ++- tests/__mocks__/payloads/comment-created.json | 246 ++++++++++++++++++ tests/__mocks__/users-get.json | 10 - tests/main.test.ts | 50 +++- 11 files changed, 376 insertions(+), 38 deletions(-) create mode 100644 src/types/environment.d.ts create mode 100644 tests/__mocks__/db-seed.json create mode 100644 tests/__mocks__/payloads/comment-created.json delete mode 100644 tests/__mocks__/users-get.json 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/src/adapters/supabase/helpers/wallet.ts b/src/adapters/supabase/helpers/wallet.ts index 6833d38..505ff6b 100644 --- a/src/adapters/supabase/helpers/wallet.ts +++ b/src/adapters/supabase/helpers/wallet.ts @@ -99,7 +99,7 @@ export class Wallet extends Super { } const { data, error } = await this.supabase.from("wallets").select("*").eq("id", userData.wallet_id).maybeSingle(); - return { data: data as WalletRow, error }; + return { data, error }; } private async _updateWalletId(walletId: number, userId: number) { @@ -168,7 +168,7 @@ export class Wallet extends Super { if (walletData.location_id === null) { throw new Error("Location ID is null"); } - logger.info("Enriching wallet location metadata", locationMetaData); + logger.debug("Enriching wallet location metadata", locationMetaData); return this.supabase.from("locations").update(locationMetaData).eq("id", walletData.location_id); } } diff --git a/src/handlers/command-parser.ts b/src/handlers/command-parser.ts index a7fbec4..a14d29f 100644 --- a/src/handlers/command-parser.ts +++ b/src/handlers/command-parser.ts @@ -18,10 +18,10 @@ export class CommandParser { .version(packageJson.version); program.configureOutput({ async writeOut(str: string) { - await context.logger.info(str); + context.logger.debug(str); }, async writeErr(str: string) { - await context.logger.error(str); + context.logger.warn(str); }, getErrHelpWidth(): number { return 0; diff --git a/src/plugin.ts b/src/plugin.ts index 8d3418e..5a7f04b 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -25,24 +25,32 @@ export async function plugin(inputs: PluginInputs, env: Env) { }, async info(message: unknown, ...optionalParams: unknown[]) { console.log(message, ...optionalParams); - 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}`, - }); + 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); }, async error(message: unknown, ...optionalParams: unknown[]) { console.error(message, ...optionalParams); - 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}`, - }); + 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); 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/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..9912ead 100644 --- a/tests/__mocks__/handlers.ts +++ b/tests/__mocks__/handlers.ts @@ -5,7 +5,36 @@ import { db } from "./db"; * 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/main.test.ts b/tests/main.test.ts index 7967004..c0a50ea 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -1,22 +1,56 @@ +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, jest } from "@jest/globals"; +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()); +jest.mock("ethers", () => ({ + ethers: { + JsonRpcProvider: jest.fn(() => ({ + resolveName: jest.fn(async () => "0x0000000000000000000000000000000000000001"), + })), + }, +})); + describe("User 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", + }); }); }); From ac5c70be2b688e817e6cb45de7b990f00ba7400e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 14:35:04 +0200 Subject: [PATCH 23/40] chore: fixed test env --- .github/workflows/jest-testing.yml | 2 ++ tests/main.test.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml index 7f8747e..4b0ab4a 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/tests/main.test.ts b/tests/main.test.ts index c0a50ea..53ba92b 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -18,7 +18,7 @@ jest.mock("ethers", () => ({ }, })); -describe("User tests", () => { +describe("Wallet command tests", () => { beforeEach(() => { for (const dbTable of Object.keys(dbSeed)) { const tableName = dbTable as keyof typeof dbSeed; From bb2a93c4ace63f306f00c69685f2f132d28d5616 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 14:58:02 +0200 Subject: [PATCH 24/40] chore: fixed error posting for invalid command payload --- src/handlers/command-parser.ts | 6 +++--- src/plugin.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/handlers/command-parser.ts b/src/handlers/command-parser.ts index a14d29f..c1d73f5 100644 --- a/src/handlers/command-parser.ts +++ b/src/handlers/command-parser.ts @@ -10,9 +10,9 @@ export class CommandParser { const program = new Command(); program .command("/wallet") - .usage("") - .argument("", "Wallet address to query, e.g. 0x000000000000000000000000000000000000000", this._parseWalletAddress) - .action((wallet) => registerWallet(context, wallet)) + .usage("
") + .argument("
", "Wallet address to query, e.g. 0x000000000000000000000000000000000000001", this._parseWalletAddress) + .action((address) => registerWallet(context, address)) .helpCommand(false) .exitOverride() .version(packageJson.version); diff --git a/src/plugin.ts b/src/plugin.ts index 5a7f04b..27af348 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -69,10 +69,10 @@ export async function plugin(inputs: PluginInputs, env: Env) { } catch (e) { if (e instanceof CommanderError) { if (e.code !== "commander.unknownCommand") { - context.logger.fatal(e); + await context.logger.error(e.message); } } else { - await context.logger.error(e); + context.logger.fatal(e); throw e; } } From a6b62702c32999eb5d467c84af0f9213e05e9f5f Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 15:02:14 +0200 Subject: [PATCH 25/40] chore: fixed error posting for invalid command payload --- src/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index 27af348..bf6c274 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -72,7 +72,7 @@ export async function plugin(inputs: PluginInputs, env: Env) { await context.logger.error(e.message); } } else { - context.logger.fatal(e); + await context.logger.error(e); throw e; } } From 10a02a91a8c047bd02830d4f45c59f2e6a32dd4e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 15:10:45 +0200 Subject: [PATCH 26/40] chore: updated package description --- README.md | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b22553d..004190f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # `@ubiquibot/command-wallet` -Helps users retrieving their wallet, or setting it to collect subsequent task rewards. +Helps users setting their wallet to collect subsequent task rewards. ## Prerequisites @@ -23,9 +23,9 @@ Helps users retrieving their wallet, or setting it to collect subsequent task re - plugin: ubiquibot/command-wallet name: command-wallet id: command-wallet - description: "Helps users retrieving their wallet, or setting it to collect subsequent task rewards." + description: "Helps users setting their wallet to collect subsequent task rewards." command: "/wallet" - example: "/wallet @user" + 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/package.json b/package.json index 4472f1f..abe12d0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "command-wallet", "version": "1.0.0", - "description": "Helps users retrieving their wallet, or setting it to collect subsequent task rewards.", + "description": "Helps users setting their wallet to collect subsequent task rewards.", "author": "Ubiquity DAO", "license": "MIT", "main": "src/worker.ts", From 90512f5355394f152b7b651fb7654c2df2748331 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 15:11:32 +0200 Subject: [PATCH 27/40] chore: fixed deploy node version --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b86fe2b..4d57466 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,7 +14,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "20.10.0" - uses: actions/checkout@v4 - uses: cloudflare/wrangler-action@v3 with: From db235e205797b6a1637b8948ca10c232081e2e66 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 15:21:05 +0200 Subject: [PATCH 28/40] chore: log handlers --- tests/__mocks__/handlers.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/__mocks__/handlers.ts b/tests/__mocks__/handlers.ts index 9912ead..e09c46f 100644 --- a/tests/__mocks__/handlers.ts +++ b/tests/__mocks__/handlers.ts @@ -1,6 +1,7 @@ import { http, HttpResponse } from "msw"; import { db } from "./db"; +console.log("HANDLERS", process.env); /** * Intercepts the routes and returns a custom payload */ From 00d80c4b4f11b3cd088678c3b5bf9ca2e5e4f371 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 15:24:45 +0200 Subject: [PATCH 29/40] chore: fixed env for tests --- .github/workflows/jest-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml index 4b0ab4a..dab2af6 100644 --- a/.github/workflows/jest-testing.yml +++ b/.github/workflows/jest-testing.yml @@ -5,7 +5,7 @@ on: env: NODE_ENV: "test" - SUPABASE_URL: "http://127.0.0.1:3000/" + SUPABASE_URL: "http://127.0.0.1:3000" SUPABASE_KEY: "supabase-key" jobs: From 8b2dd6aa31fb54a3b5ff05311ea0b443f310a044 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 25 Jun 2024 17:14:33 +0200 Subject: [PATCH 30/40] chore: removed .env file to avoid duplicate env --- .env.example | 2 -- .gitignore | 1 + package.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index f21929f..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -SUPABASE_URL= -SUPABASE_KEY= diff --git a/.gitignore b/.gitignore index f864c04..0ed9687 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ cypress/screenshots script.ts .wrangler http-client.private.env.json +test-dashboard.md diff --git a/package.json b/package.json index abe12d0..dbb2f23 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "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", + "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\"" From 07c17fd9ad9bbdb805156956f20ea51d0a5fcf4c Mon Sep 17 00:00:00 2001 From: rndquu <119500907+rndquu@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:37:23 +0300 Subject: [PATCH 31/40] docs: update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 004190f..5dc5a59 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Helps users setting their wallet to collect subsequent task rewards. ## Getting Started 1. Install the dependencies preferably using `yarn` or `bun`. -2. Copy `env.example` and `.dev.vars.example` to `.env` and `.dev.vars` respectively, and fill the variables +2. Copy `.dev.vars.example` to `.dev.vars` and fill the variables 3. Generate Supabase types by running ```shell yarn prebuild From 73d63d47b73f124cd3698ad5d67daa1bb58d201a Mon Sep 17 00:00:00 2001 From: rndquu Date: Tue, 25 Jun 2024 21:12:18 +0300 Subject: [PATCH 32/40] ci: fix knip --- .github/workflows/knip-reporter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 433a6a7c3f19b2722df75e7b826bc6b8e0244a1e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 26 Jun 2024 12:29:50 +0200 Subject: [PATCH 33/40] fix: fixed crash when user does not exist --- src/adapters/supabase/helpers/wallet.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/adapters/supabase/helpers/wallet.ts b/src/adapters/supabase/helpers/wallet.ts index 505ff6b..7949315 100644 --- a/src/adapters/supabase/helpers/wallet.ts +++ b/src/adapters/supabase/helpers/wallet.ts @@ -84,6 +84,7 @@ export class Wallet extends Super { const { data: userData, error: userError } = await this.supabase .from("users") .insert([{ id: user.id, location_id: locationId /* other fields if necessary */ }]) + .select() .single(); if (userError) { @@ -95,7 +96,7 @@ export class Wallet extends Super { private async _checkIfWalletExists(userData: UserRow) { if (userData.wallet_id === null) { - throw new Error("Wallet ID is null."); + return { data: null, error: null }; } const { data, error } = await this.supabase.from("wallets").select("*").eq("id", userData.wallet_id).maybeSingle(); @@ -149,7 +150,7 @@ export class Wallet extends Super { address: address, }; - const { data: walletInsertData, error: walletInsertError } = await this.supabase.from("wallets").insert(newWallet).single(); + const { data: walletInsertData, error: walletInsertError } = await this.supabase.from("wallets").insert(newWallet).select().single(); if (walletInsertError) throw walletInsertError; return walletInsertData as WalletRow; From fdc2cc70444431d5f5bcbb111dc55ce8cdde50a7 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Jul 2024 20:26:16 +0200 Subject: [PATCH 34/40] chore: checksum for address --- src/adapters/supabase/helpers/wallet.ts | 2 +- src/handlers/query-wallet.ts | 3 +++ tests/main.test.ts | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/adapters/supabase/helpers/wallet.ts b/src/adapters/supabase/helpers/wallet.ts index 7949315..161b0ea 100644 --- a/src/adapters/supabase/helpers/wallet.ts +++ b/src/adapters/supabase/helpers/wallet.ts @@ -83,7 +83,7 @@ export class Wallet extends Super { // 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 /* other fields if necessary */ }]) + .insert([{ id: user.id, location_id: locationId }]) .select() .single(); diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 37f4cf7..561273c 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -44,6 +44,9 @@ export async function registerWallet(context: Context, body: string) { 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); diff --git a/tests/main.test.ts b/tests/main.test.ts index 53ba92b..4fb5666 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -1,4 +1,5 @@ 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"; @@ -15,6 +16,7 @@ jest.mock("ethers", () => ({ JsonRpcProvider: jest.fn(() => ({ resolveName: jest.fn(async () => "0x0000000000000000000000000000000000000001"), })), + getAddress: (jest.requireActual("ethers") as typeof ethers).getAddress, }, })); From a5e245b4622d1fc1d8349a60632c7f675ea4d8e6 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 2 Jul 2024 18:58:27 +0200 Subject: [PATCH 35/40] chore: changed description --- README.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5dc5a59..4493990 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # `@ubiquibot/command-wallet` -Helps users setting their wallet to collect subsequent task rewards. +Allows users to register their wallets to collect rewards. ## Prerequisites @@ -23,7 +23,7 @@ Helps users setting their wallet to collect subsequent task rewards. - plugin: ubiquibot/command-wallet name: command-wallet id: command-wallet - description: "Helps users setting their wallet to collect subsequent task rewards." + description: "Allows users to register their wallets to collect rewards." command: "/wallet" example: "/wallet ubiquibot.eth" ``` diff --git a/package.json b/package.json index dbb2f23..c6d9822 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "command-wallet", "version": "1.0.0", - "description": "Helps users setting their wallet to collect subsequent task rewards.", + "description": "Allows users to register their wallets to collect rewards.", "author": "Ubiquity DAO", "license": "MIT", "main": "src/worker.ts", From 3a8269a5f39c8c49e1ef3bfaa70c971b0c1b61b1 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Wed, 3 Jul 2024 00:13:22 +0200 Subject: [PATCH 36/40] Update src/handlers/command-parser.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: アレクサンダー.eth <4975670+0x4007@users.noreply.github.com> --- src/handlers/command-parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/command-parser.ts b/src/handlers/command-parser.ts index c1d73f5..574d92e 100644 --- a/src/handlers/command-parser.ts +++ b/src/handlers/command-parser.ts @@ -11,7 +11,7 @@ export class CommandParser { program .command("/wallet") .usage("
") - .argument("
", "Wallet address to query, e.g. 0x000000000000000000000000000000000000001", this._parseWalletAddress) + .argument("
", "Wallet address to query, e.g. 0x000000000000000000000000000000000000000", this._parseWalletAddress) .action((address) => registerWallet(context, address)) .helpCommand(false) .exitOverride() From d83a054d4487e48b5092976aef5370e3a401db04 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 3 Jul 2024 09:35:48 +0200 Subject: [PATCH 37/40] chore: added ok log level --- src/handlers/query-wallet.ts | 4 ++-- src/plugin.ts | 15 ++++++++++++++- src/types/context.ts | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 561273c..7cb6df9 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -33,7 +33,7 @@ export async function registerWallet(context: Context, body: string) { } if (!address) { - return context.logger.info("# Skipping to register a wallet address because both address/ens doesn't exist"); + return context.logger.info("Skipping to register a wallet address because both address/ens doesn't exist"); } if (config.registerWalletWithVerification) { @@ -50,7 +50,7 @@ export async function registerWallet(context: Context, body: string) { if (payload.comment) { const { wallet } = adapters.supabase; await wallet.upsertWalletAddress(context, address); - return context.logger.info("+ Successfully registered wallet address", { sender, address }); + return context.logger.ok("Successfully registered wallet address", { sender, address }); } else { throw new Error("Payload comment is undefined"); } diff --git a/src/plugin.ts b/src/plugin.ts index bf6c274..34edc4a 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -23,6 +23,19 @@ export async function plugin(inputs: PluginInputs, env: Env) { debug(message: unknown, ...optionalParams: unknown[]) { console.debug(message, ...optionalParams); }, + async ok(message: unknown, ...optionalParams: unknown[]) { + console.debug(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 { @@ -30,7 +43,7 @@ export async function plugin(inputs: PluginInputs, env: Env) { owner: context.payload.repository.owner.login, issue_number: context.payload.issue.number, repo: context.payload.repository.name, - body: `\`\`\`diff\n${message}`, + body: `\`\`\`diff\n# ${message}`, }); } catch (e) { console.error("Failed to post info comment", e); diff --git a/src/types/context.ts b/src/types/context.ts index 9679cf7..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; @@ -22,6 +22,7 @@ export interface Context Promise; warn: (message: unknown, ...optionalParams: unknown[]) => void; info: (message: unknown, ...optionalParams: unknown[]) => Promise; + ok: (message: unknown, ...optionalParams: unknown[]) => Promise; debug: (message: unknown, ...optionalParams: unknown[]) => void; }; } From 1ec82e73284fec6628f0ccb69cb1f2d26ebca5ef Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 3 Jul 2024 09:41:31 +0200 Subject: [PATCH 38/40] chore: fixed jest test for wallet link --- tests/main.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/main.test.ts b/tests/main.test.ts index 4fb5666..b0df114 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -51,7 +51,7 @@ describe("Wallet command tests", () => { ); expect(spy).toHaveBeenCalledTimes(1); expect(spy).toHaveBeenLastCalledWith("+ Successfully registered wallet address", { - address: "0x0000000000000000000000000000000000000001", + address: "0x0000000000000000000000000000000000000000", sender: "ubiquibot", }); }); From 13d33b1716ab7c60d81f5dbd6741249c1a28bc93 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 3 Jul 2024 09:44:48 +0200 Subject: [PATCH 39/40] chore: fixed jest test for wallet link --- src/plugin.ts | 2 +- tests/main.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index 34edc4a..25d3aac 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -24,7 +24,7 @@ export async function plugin(inputs: PluginInputs, env: Env) { console.debug(message, ...optionalParams); }, async ok(message: unknown, ...optionalParams: unknown[]) { - console.debug(message, ...optionalParams); + console.log(message, ...optionalParams); try { await octokit.issues.createComment({ owner: context.payload.repository.owner.login, diff --git a/tests/main.test.ts b/tests/main.test.ts index b0df114..a764cca 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -50,8 +50,8 @@ describe("Wallet command tests", () => { { SUPABASE_URL: process.env.SUPABASE_URL, SUPABASE_KEY: process.env.SUPABASE_KEY } ); expect(spy).toHaveBeenCalledTimes(1); - expect(spy).toHaveBeenLastCalledWith("+ Successfully registered wallet address", { - address: "0x0000000000000000000000000000000000000000", + expect(spy).toHaveBeenLastCalledWith("Successfully registered wallet address", { + address: "0x0000000000000000000000000000000000000001", sender: "ubiquibot", }); }); From 27c7ab11a62415cd1939d59a6469b8d5206b5160 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:29:43 +0900 Subject: [PATCH 40/40] chore: object destructuring for conciseness --- src/handlers/query-wallet.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 7cb6df9..ee94f89 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -12,12 +12,8 @@ function extractEnsName(text: string) { } export async function registerWallet(context: Context, body: string) { - const payload = context.payload; - const config = context.config; - const logger = context.logger; + const { payload, config, logger, adapters } = context; const sender = payload.sender.login; - const adapters = context.adapters; - const regexForAddress = /(0x[a-fA-F0-9]{40})/g; const addressMatches = body.match(regexForAddress); let address = addressMatches ? addressMatches[0] : null;