A NestJS service that automatically updates vToken voting results based on the target chain's referendum outcomes.
The service can be triggered in two ways:
- Scheduled Task: Automatically runs at configured intervals (default: every Monday 9:00 AM)
- Manual Trigger: Can be triggered via HTTP endpoint anytime
- Monitors referendums on Polkadot, Kusama, and Bifrost chains
- Automatically updates vToken voting results when target chain referendums conclude
- Supports manual trigger via API endpoint
- Configurable execution schedule via CRON expression
- Clone the repository:
git clone https://github.com/bifrost-finance/update_referendum.git
cd update_referendum
- Install dependencies:
yarn install
- Configure environment:
cp .env.example .env
# Edit .env with your settings
- Start the service:
yarn start
- Trigger manually:
curl -X POST http://localhost:3000/manual/update
Create a .env
file in the root directory:
# Required endpoints
BIFROST_ENDPOINT=wss://bifrost-polkadot-rpc.dwellir.com
POLKADOT_ENDPOINT=wss://rpc.polkadot.io
KUSAMA_ENDPOINT=wss://kusama-rpc.polkadot.io
# Vault configuration
# If VAULT_ADDR is not configured or NODE_ENV=development, will use test account //Alice
VAULT_ADDR=http://127.0.0.1:8200
VAULT_TOKEN=your_vault_token
KEY_NAME=your_key_name
VAULT_GOV_SECRET=your_gov_secret
# Environment
# development: use test account //Alice
# production: use account configured in Vault
NODE_ENV=development
# Schedule configuration (format: second minute hour day month weekday)
# Examples:
# "0 0 9 * * 1" - Execute every Monday at 9:00 AM
# "*/5 * * * * *" - Execute every 5 seconds
CRON_EXPRESSION="0 0 9 * * 1"
# Manual trigger:
# curl -X POST http://localhost:3000/manual/update
-
Query Task
- Connects to all chains
- Retrieves ongoing referendums from Bifrost vtokenVoting
- Checks target chain referendum status
- Returns referendums that need updating
-
Construct Task
- Constructs update transactions for each referendum
- Batches transactions if multiple updates needed
- Prepares governance proposal
-
Governance Task
- Submits governance proposal through Fellowship Bot
- Handles preimage and proposal submission