Draft
Conversation
Agent-Logs-Url: https://github.com/normancomics/BibleFi-API/sessions/18b17ab1-f81c-4bd9-a2cc-48473bf6421b Co-authored-by: normancomics <70556508+normancomics@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update rewards calculation for validators
Add /v1/validators CRUD endpoint
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the full validator management API backed by the
validatorsSupabase table, with on-chain registration support via Superfluid GDA pool units managed in background jobs.New:
src/routes/validators.jsGET /v1/validators?active=true|false(defaulttrue),?limit=N(default 50, max 200)GET /v1/validators/:addressPOST /v1/validatorsviem'sisAddress; 409 on duplicatePUT /v1/validators/:addressname/accuracy_score(0–100); stampsupdated_atDELETE /v1/validators/:addressactive = false) — no hard deleteAll routes return
{ error, message }on failure with a[Validators ROUTE_NAME]log prefix, consistent withstreams.js.Updated:
index.jsReplaced the stub entrypoint with the full production version from
railway/code-change-TESn9Aand mounted the new router:Also added
validators: '/v1/validators'to the discovery endpoint response.Updated:
src/db/schema.sqlAdded missing indexes on the
validatorstable:Supporting files
Brought in all
src/files (lib/,middleware/,routes/,jobs/) from therailway/code-change-TESn9Abranch so the full API surface is present on this branch.Original prompt
Context
The
normancomics/BibleFi-APIrepository has an open PR #1 (railway/code-change-TESn9A→main) that implements the full BWTYA API. Thevalidatorstable already exists insrc/db/schema.sqlwith this structure:The background job in
src/jobs/index.jsalready callscalculateValidatorRewards()every 15 minutes to updatepool_unitsandlast_reward_at.The Superfluid GDA pool is managed via
src/lib/superfluid.js. The smart contract has aregisterValidator(address)function that needs to be called on-chain when a new validator is registered.Task: Add
src/routes/validators.jsCreate a full CRUD REST endpoint at
/v1/validatorswith the following routes:GET /v1/validatorsvalidatorstable in Supabase?active=true|false(default:true),?limit=N(default: 50, max: 200){ validators: [...], count: N }messagefieldGET /v1/validators/:addressPOST /v1/validators(protected — requires JWT viarequireAuth){ address: string (EVM address), name?: string }addressis a valid EVM address usingisAddressfromviemvalidatorstable withactive: true,accuracy_score: 0,pool_units: '0'PUT /v1/validators/:address(protected — requires JWT viarequireAuth)nameand/oraccuracy_score{ name?: string, accuracy_score?: number (0-100) }accuracy_scoreis between 0 and 100 if providedupdated_attoNOW()DELETE /v1/validators/:address(protected — requires JWT viarequireAuth)active: false,updated_at: NOW()){ message: 'Validator deactivated', address }Error handling
{ error: string, message: string }with appropriate HTTP status codes[Validators ROUTE_NAME]prefixTask: Update
index.jsMount the new validators router:
Look at the existing
index.json therailway/code-change-TESn9Abranch and add the validators route in the same style as the other routes.Task: Update
src/db/schema.sqlAdd an index on
validators.activeif it doesn't already exist:Append these at the end of the validators section.
Implementation Notes
import/export default) consistent with the rest of the codebasesupabasefrom../lib/supabase.jsrequireAuthfrom../lib/auth.jsisAddressfromviemsrc/routes/streams.jsaddressfield should always be stored and queried in lowercase (.toLowerCase())copilot/validators-endpointmainThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: help me fix errors and continue to build
Assistant: Here's a full picture of the current state of
Biblefi/Biblefi-biblefi-schemas:📊 Current State
What exists on
mainLICENSEREADME.mdVERSIONING.mdschemas/agent_envelope.schema.jsonschemas/church_record.schema.jsonschemas/defi_strategy.schema.jsonschemas/scripture_record.schema.jsonschemas/security_finding.schema.jsonWhat'...
This pull request was created from Copilot chat.
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.