Allows users to register their wallets to collect rewards.
Command Wallet is built as a serverless application using Cloudflare Workers, with a Supabase PostgreSQL database for data persistence. The application processes commands received through GitHub comments, manages wallet addresses, and provides a plugin system for extensibility.
- Entry point for the Cloudflare Worker
- Handles incoming HTTP requests
- Processes GitHub webhook events
- Manages environment variables and context
- Parses commands from GitHub comments
- Supports commands like:
- Adding wallets
- Querying wallet information
- Managing wallet metadata
- Uses regex patterns for command recognition
- Validates command syntax and parameters
- Provides extensibility through plugins
- Plugins can:
- Process commands
- Add new functionality
- Integrate with external services
- Plugin interface defines:
- Command processing
- Error handling
- Context management
- Uses Supabase as the PostgreSQL database provider
- Schema includes:
- Wallet addresses
- User associations
- Metadata storage
- Helpers for:
- Wallet management
- Data validation
- Query operations
- Jest-based test suite
- Mock data and handlers for:
- Database operations
- GitHub events
- Command processing
- HTTP request testing capabilities
- GitHub comment webhook triggers the Worker
- Worker validates the request and extracts command
- Command parser identifies and validates the command
- Plugin system processes the command
- Database operations are performed if needed
- Response is sent back to GitHub
- A good understanding of how the kernel works and how to interact with it.
- A basic understanding of the Ubiquibot configuration and how to define your plugin's settings.
- Install the dependencies preferably using
bun
. - Copy
.dev.vars.example
to.dev.vars
and fill the variables - Generate Supabase types by running
bun prebuild
- Run the project with
bun wrangler
- plugin: https://ubiquibot-command-wallet.ubiquity.workers.dev
id: command-wallet
with:
registerWalletWithVerification: false
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.
- Start building your plugin by adding your logic to the plugin.ts file.
yarn/bun worker
- to run the worker locally.- To trigger the worker,
POST
requests to http://localhost:4000/ with an event payload similar to:
await fetch("http://localhost:4000/", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
stateId: "",
eventName: "",
eventPayload: "",
settings: "",
ref: "",
authToken: "",
}),
});
A full example can be found here.
- Ensure the kernel is running and listening for events.
- Fire an event in/to the repo where the kernel is installed. This can be done in a number of ways, the easiest being via the GitHub UI or using the GitHub API, such as posting a comment, opening an issue, etc in the org/repo where the kernel is installed.
- The kernel will process the event and dispatch it using the settings defined in your
.ubiquibot-config.yml
. - The
compute.yml
workflow will run and execute your plugin's logic. - You can view the logs in the Actions tab of your repo.
Nektos Act - a tool for running GitHub Actions locally.
- Full Ubiquibot Configuration - helpful for defining your plugin's settings as they are strongly typed and will be validated by the kernel.
- Ubiquibot V1 - helpful for porting V1 functionality to V2, helper/utility functions, types, etc. Everything is based on the V1 codebase but with a more modular approach. When using V1 code, keep in mind that most all code will need refactored to work with the new V2 architecture.
- Start/Stop Slash Command - simple
- Assistive Pricing Plugin - complex
- Conversation Rewards - really complex