Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development into main #5

Merged
merged 46 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
057f376
chore: init repo
gentlementlegen Jun 24, 2024
70fb75e
feat: parsing arguments and executing run
gentlementlegen Jun 24, 2024
1188e02
chore: updated cspell rules
gentlementlegen Jun 24, 2024
fd761fc
chore: typed Supabase instance
gentlementlegen Jun 24, 2024
767610a
chore: removed migration step from database.yml
gentlementlegen Jun 24, 2024
6eb27b9
chore: added wrangler deploy workflow
gentlementlegen Jun 24, 2024
559bdcc
chore: removed unused files
gentlementlegen Jun 24, 2024
4d79efe
Merge pull request #2 from Meniole/development
gentlementlegen Jun 24, 2024
f5dc9e9
chore: fixed database workflow
gentlementlegen Jun 24, 2024
edf8f99
Merge pull request #3 from Meniole/development
gentlementlegen Jun 24, 2024
bb73e4a
chore: fixed worker name
gentlementlegen Jun 24, 2024
e8519cb
Merge pull request #4 from Meniole/development
gentlementlegen Jun 24, 2024
c728812
chore: fixed request and payload JSON parsing
gentlementlegen Jun 24, 2024
4fe7e02
Merge branch 'refs/heads/meniole-development'
gentlementlegen Jun 24, 2024
2a56d91
chore: fixed wallet address argument
gentlementlegen Jun 24, 2024
6a8ba29
chore: test then
gentlementlegen Jun 24, 2024
0a05f27
chore: test await
gentlementlegen Jun 24, 2024
eb14ae0
chore: added pretty diff
gentlementlegen Jun 24, 2024
20da052
chore: added error log on ENS fail
gentlementlegen Jun 24, 2024
a89370a
chore: async await on logs
gentlementlegen Jun 25, 2024
15f3996
chore: fixed error message
gentlementlegen Jun 25, 2024
e997968
chore: added fastest rpc check
gentlementlegen Jun 25, 2024
5b04deb
chore: added fastest rpc check
gentlementlegen Jun 25, 2024
33e9d3f
chore: test rpc
gentlementlegen Jun 25, 2024
8ecca13
chore: test rpc
gentlementlegen Jun 25, 2024
e059e13
feat: added test for wallet link
gentlementlegen Jun 25, 2024
ac5c70b
chore: fixed test env
gentlementlegen Jun 25, 2024
bb2a93c
chore: fixed error posting for invalid command payload
gentlementlegen Jun 25, 2024
a6b6270
chore: fixed error posting for invalid command payload
gentlementlegen Jun 25, 2024
10a02a9
chore: updated package description
gentlementlegen Jun 25, 2024
90512f5
chore: fixed deploy node version
gentlementlegen Jun 25, 2024
db235e2
chore: log handlers
gentlementlegen Jun 25, 2024
00d80c4
chore: fixed env for tests
gentlementlegen Jun 25, 2024
8b2dd6a
chore: removed .env file to avoid duplicate env
gentlementlegen Jun 25, 2024
07c17fd
docs: update README.md
rndquu Jun 25, 2024
73d63d4
ci: fix knip
rndquu Jun 25, 2024
3a4f180
Merge pull request #1 from rndquu/ci/fix-knip
gentlementlegen Jun 25, 2024
433a6a7
fix: fixed crash when user does not exist
gentlementlegen Jun 26, 2024
fdc2cc7
chore: checksum for address
gentlementlegen Jul 1, 2024
a5e245b
chore: changed description
gentlementlegen Jul 2, 2024
3a8269a
Update src/handlers/command-parser.ts
gentlementlegen Jul 2, 2024
d83a054
chore: added ok log level
gentlementlegen Jul 3, 2024
1ec82e7
chore: fixed jest test for wallet link
gentlementlegen Jul 3, 2024
13d33b1
chore: fixed jest test for wallet link
gentlementlegen Jul 3, 2024
27c7ab1
chore: object destructuring for conciseness
gentlementlegen Jul 8, 2024
d7c5761
Merge pull request #2 from gentlementlegen/feat/command-wallet
0x4007 Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
3 changes: 2 additions & 1 deletion .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
MY_SECRET="MY_SECRET"
SUPABASE_URL=
SUPABASE_KEY=
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "the name of the plugin"
name: "command-wallet"

on:
workflow_dispatch:
Expand All @@ -18,7 +18,7 @@ on:

jobs:
compute:
name: "plugin name"
name: "command-wallet"
runs-on: ubuntu-latest
permissions: write-all
env:
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 44 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Database

on:
push:
branches:
- main

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}

jobs:
generate_types:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- name: Generate Supabase Types
run: |
yarn install
yarn run "supabase:generate:remote"

- name: Commit and Push generated types
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add src/types/database.ts
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then
git commit -m "chore: updated generated Supabase types" || echo "Lint-staged check failed"
git push origin main
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy to Cloudflare Pages

on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy-to-cloudflare:
name: Automatic Cloudflare Deploy
runs-on: ubuntu-22.04
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.10.0"
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '3.61.0'
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
2 changes: 2 additions & 0 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:

env:
NODE_ENV: "test"
SUPABASE_URL: "http://127.0.0.1:3000"
SUPABASE_KEY: "supabase-key"

jobs:
testing:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/knip-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ coverage
junit.xml
cypress/screenshots
script.ts
.wrangler
.wrangler
http-client.private.env.json
test-dashboard.md
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# `@ubiquibot/plugin-template`
# `@ubiquibot/command-wallet`

Allows users to register their wallets to collect rewards.

## Prerequisites

Expand All @@ -7,38 +9,23 @@

## Getting Started

1. Create a new repository using this template.
2. Clone the repository to your local machine.
3. Install the dependencies preferably using `yarn` or `bun`.

## Creating a new plugin

- If your plugin is to be used as a slash command which should have faster response times as opposed to longer running GitHub action tasks, you should use the `worker` type.

1. Ensure you understand and have setup the [kernel](https://github.com/ubiquity/ubiquibot-kernel).
2. Update [compute.yml](./.github/workflows/compute.yml) with your plugin's name and update the `id`.
3. Update [context.ts](./src/types/context.ts) with the events that your plugin will fire on.
4. Update [plugin-inputs.ts](./src/types/plugin-inputs.ts) to match the `with:` settings in your org or repo level configuration.
1. Install the dependencies preferably using `yarn` or `bun`.
2. Copy `.dev.vars.example` to `.dev.vars` and fill the variables
3. Generate Supabase types by running
```shell
yarn prebuild
```
4. Run the project with `yarn wrangler`

- Your plugin config should look similar to this:
## Example configuration

```yml
- plugin: <plugin-org/owner>/<plugin-repo-name>:compute.yml@development
name: plugin-name
id: plugin-name-command
description: "Plugin description" # small description of what the plugin does
command: "<regex for command>" # if you are creating a plugin with a slash command
example: "<example usage>" # how to invoke the slash command
with: # these are the example settings, the kernel passes these to the plugin.
disabledCommands: []
timers:
reviewDelayTolerance: 86000
taskStaleTimeoutDuration: 2580000
miscellaneous:
maxConcurrentTasks: 3
labels:
time: []
priority: []
- plugin: ubiquibot/command-wallet
name: command-wallet
id: command-wallet
description: "Allows users to register their wallets to collect rewards."
command: "/wallet"
example: "/wallet ubiquibot.eth"
```

###### At this stage, your plugin will fire on your defined events with the required settings passed in from the kernel. You can now start writing your plugin's logic.
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "plugin-template",
"name": "command-wallet",
"version": "1.0.0",
"description": "Ubiquibot plugin template repository with TypeScript support.",
"description": "Allows users to register their wallets to collect rewards.",
"author": "Ubiquity DAO",
"license": "MIT",
"main": "src/worker.ts",
"engines": {
"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 .",
"format:cspell": "cspell **/*",
"knip": "knip --config .github/knip.ts",
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"prepare": "husky install",
"test": "jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 4000"
"test": "DOTENV_CONFIG_PATH=.dev.vars jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 4000",
"supabase:generate:local": "supabase gen types typescript --local > src/types/database.ts",
"supabase:generate:remote": "cross-env-shell \"supabase gen types typescript --project-id $SUPABASE_PROJECT_ID --schema public > src/types/database.ts\""
},
"keywords": [
"typescript",
Expand All @@ -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": {
Expand All @@ -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",
Expand All @@ -60,11 +67,12 @@
"lint-staged": "15.2.7",
"npm-run-all": "4.1.5",
"prettier": "3.3.2",
"supabase": "1.178.2",
"ts-jest": "29.1.5",
"tsx": "4.15.6",
"typescript": "5.4.5",
"typescript-eslint": "7.13.1",
"wrangler": "3.60.3"
"wrangler": "3.61.0"
},
"lint-staged": {
"*.ts": [
Expand Down
12 changes: 3 additions & 9 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -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),
},
};
}
49 changes: 0 additions & 49 deletions src/adapters/supabase/helpers/access.ts

This file was deleted.

Loading
Loading