-
Notifications
You must be signed in to change notification settings - Fork 28
Refactor bounty logic and data structures to align with backend schema #112
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
Merged
0xdevcollins
merged 4 commits into
boundlessfi:main
from
Ekene001:feat/Align-frontend-GraphQL-schema-with-backend
Feb 23, 2026
+3,362
−3,363
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ebbc724
Refactor bounty logic and data structures to align with backend schema
Ekene001 8125eb4
chore: synchronize frontend GraphQL schema with backend
Ekene001 e54dd16
fixed coderabbit
Ekene001 79d2f13
chore: add @next/swc-wasm-nodejs dependency to package-lock.json
Ekene001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Check schema sync | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main", "master"] | ||
| pull_request: | ||
| branches: ["main", "master"] | ||
|
|
||
| jobs: | ||
| check-schema: | ||
| name: Check schema is in sync | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Checkout canonical schema repo (private) | ||
| if: ${{ secrets.BOUNDLESS_NESTJS_TOKEN != '' }} | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: boundlessfi/boundless-nestjs | ||
| path: boundless-nestjs | ||
| token: ${{ secrets.BOUNDLESS_NESTJS_TOKEN }} | ||
|
|
||
| - name: Note about private repo | ||
| if: ${{ secrets.BOUNDLESS_NESTJS_TOKEN == '' }} | ||
| run: | | ||
| echo "No secret BOUNDLESS_NESTJS_TOKEN provided; skipping checkout of private repo." | ||
| echo "If the canonical schema is in the private repo, add a repository secret named BOUNDLESS_NESTJS_TOKEN with a PAT that has access to boundlessfi/boundless-nestjs." | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Run schema check | ||
| run: node ./scripts/sync-schema.js --check | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,60 +1,75 @@ | ||
| import { NextResponse } from 'next/server'; | ||
| import { BountyStore } from '@/lib/store'; | ||
| import { addDays } from 'date-fns'; | ||
| import { getCurrentUser } from '@/lib/server-auth'; | ||
| import { NextResponse } from "next/server"; | ||
| import { BountyStore } from "@/lib/store"; | ||
| import { getCurrentUser } from "@/lib/server-auth"; | ||
|
|
||
| export async function POST( | ||
| request: Request, | ||
| { params }: { params: Promise<{ id: string }> } | ||
| request: Request, | ||
| { params }: { params: Promise<{ id: string }> }, | ||
| ) { | ||
| const { id: bountyId } = await params; | ||
|
|
||
| try { | ||
| const user = await getCurrentUser(); | ||
| if (!user) { | ||
| return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); | ||
| } | ||
|
|
||
| const body = await request.json(); | ||
| const { contributorId } = body; | ||
|
|
||
| // If client sends contributorId, ensure it matches the authenticated user | ||
| if (contributorId && contributorId !== user.id) { | ||
| return NextResponse.json({ error: 'Contributor ID mismatch' }, { status: 403 }); | ||
| } | ||
|
|
||
| const bounty = BountyStore.getBountyById(bountyId); | ||
| if (!bounty) { | ||
| return NextResponse.json({ error: 'Bounty not found' }, { status: 404 }); | ||
| } | ||
|
|
||
| if (bounty.claimingModel !== 'single-claim') { | ||
| return NextResponse.json({ error: 'Invalid claiming model for this action' }, { status: 400 }); | ||
| } | ||
|
|
||
| if (bounty.status !== 'open') { | ||
| return NextResponse.json({ error: 'Bounty is not available' }, { status: 409 }); | ||
| } | ||
|
|
||
| const now = new Date(); | ||
| const updates = { | ||
| status: 'claimed' as const, | ||
| claimedBy: user.id, // Use authenticated user ID | ||
| claimedAt: now.toISOString(), | ||
| claimExpiresAt: addDays(now, 7).toISOString(), | ||
| updatedAt: now.toISOString() | ||
| }; | ||
|
|
||
| const updatedBounty = BountyStore.updateBounty(bountyId, updates); | ||
|
|
||
| if (!updatedBounty) { | ||
| return NextResponse.json({ success: false, error: 'Failed to update bounty' }, { status: 500 }); | ||
| } | ||
|
|
||
| return NextResponse.json({ success: true, data: updatedBounty }); | ||
|
|
||
| } catch (error) { | ||
| console.error('Error claiming bounty:', error); | ||
| return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }); | ||
| const { id: bountyId } = await params; | ||
|
|
||
| try { | ||
| const user = await getCurrentUser(); | ||
| if (!user) { | ||
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | ||
| } | ||
|
|
||
| const body = await request.json(); | ||
| const { contributorId } = body; | ||
|
|
||
| // If client sends contributorId, ensure it matches the authenticated user | ||
| if (contributorId && contributorId !== user.id) { | ||
| return NextResponse.json( | ||
| { error: "Contributor ID mismatch" }, | ||
| { status: 403 }, | ||
| ); | ||
| } | ||
|
|
||
| // Use the validated contributorId or default to the authenticated user | ||
| const finalContributorId = contributorId ?? user.id; | ||
|
|
||
| const bounty = BountyStore.getBountyById(bountyId); | ||
| if (!bounty) { | ||
| return NextResponse.json({ error: "Bounty not found" }, { status: 404 }); | ||
| } | ||
|
|
||
| if (bounty.type !== "FIXED_PRICE") { | ||
| return NextResponse.json( | ||
| { error: "Invalid bounty type for this action" }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
|
|
||
| if (bounty.status !== "OPEN") { | ||
| return NextResponse.json( | ||
| { error: "Bounty is not available" }, | ||
| { status: 409 }, | ||
| ); | ||
| } | ||
|
|
||
| const now = new Date(); | ||
| const updates = { | ||
| status: "IN_PROGRESS" as const, | ||
| updatedAt: now.toISOString(), | ||
| claimedBy: finalContributorId, | ||
| claimedAt: now.toISOString(), | ||
| }; | ||
|
|
||
| const updatedBounty = BountyStore.updateBounty(bountyId, updates); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (!updatedBounty) { | ||
| return NextResponse.json( | ||
| { success: false, error: "Failed to update bounty" }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
|
|
||
| return NextResponse.json({ success: true, data: updatedBounty }); | ||
| } catch (error) { | ||
| console.error("Error claiming bounty:", error); | ||
| return NextResponse.json( | ||
| { error: "Internal Server Error" }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,69 @@ | ||
| import { NextResponse } from 'next/server'; | ||
| import { BountyStore } from '@/lib/store'; | ||
| import { CompetitionParticipation } from '@/types/participation'; | ||
| import { getCurrentUser } from '@/lib/server-auth'; | ||
| import { NextResponse } from "next/server"; | ||
| import { BountyStore } from "@/lib/store"; | ||
| import { CompetitionParticipation } from "@/types/participation"; | ||
| import { getCurrentUser } from "@/lib/server-auth"; | ||
|
|
||
| const generateId = () => crypto.randomUUID(); | ||
|
|
||
| export async function POST( | ||
| request: Request, | ||
| { params }: { params: Promise<{ id: string }> } | ||
| request: Request, | ||
| { params }: { params: Promise<{ id: string }> }, | ||
| ) { | ||
| const { id: bountyId } = await params; | ||
|
|
||
| try { | ||
| const user = await getCurrentUser(); | ||
| if (!user) { | ||
| return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); | ||
| } | ||
|
|
||
| const bounty = BountyStore.getBountyById(bountyId); | ||
| if (!bounty) { | ||
| return NextResponse.json({ error: 'Bounty not found' }, { status: 404 }); | ||
| } | ||
|
|
||
| if (bounty.claimingModel !== 'competition') { | ||
| return NextResponse.json({ error: 'Invalid claiming model for this action' }, { status: 400 }); | ||
| } | ||
|
|
||
| // Validate status is open | ||
| if (bounty.status !== 'open') { | ||
| return NextResponse.json({ error: 'Bounty is not open for registration' }, { status: 409 }); | ||
| } | ||
|
|
||
| const existing = BountyStore.getCompetitionParticipationsByBounty(bountyId) | ||
| .find(p => p.contributorId === user.id); | ||
|
|
||
| if (existing) { | ||
| return NextResponse.json({ error: 'Already joined this competition' }, { status: 409 }); | ||
| } | ||
|
|
||
| const participation: CompetitionParticipation = { | ||
| id: generateId(), | ||
| bountyId, | ||
| contributorId: user.id, // Use authenticated user ID | ||
| status: 'registered', | ||
| registeredAt: new Date().toISOString() | ||
| }; | ||
|
|
||
| BountyStore.addCompetitionParticipation(participation); | ||
|
|
||
| return NextResponse.json({ success: true, data: participation }); | ||
|
|
||
| } catch (error) { | ||
| console.error('Error joining competition:', error); | ||
| return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }); | ||
| const { id: bountyId } = await params; | ||
|
|
||
| try { | ||
| const user = await getCurrentUser(); | ||
| if (!user) { | ||
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | ||
| } | ||
|
|
||
| const bounty = BountyStore.getBountyById(bountyId); | ||
| if (!bounty) { | ||
| return NextResponse.json({ error: "Bounty not found" }, { status: 404 }); | ||
| } | ||
|
|
||
| if (bounty.type !== "COMPETITION") { | ||
| return NextResponse.json( | ||
| { error: "Invalid bounty type for this action" }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
|
|
||
| // Validate status is open | ||
| if (bounty.status !== "OPEN") { | ||
| return NextResponse.json( | ||
| { error: "Bounty is not open for registration" }, | ||
| { status: 409 }, | ||
| ); | ||
| } | ||
|
|
||
| const existing = BountyStore.getCompetitionParticipationsByBounty( | ||
| bountyId, | ||
| ).find((p) => p.contributorId === user.id); | ||
|
|
||
| if (existing) { | ||
| return NextResponse.json( | ||
| { error: "Already joined this competition" }, | ||
| { status: 409 }, | ||
| ); | ||
| } | ||
|
|
||
| const participation: CompetitionParticipation = { | ||
| id: generateId(), | ||
| bountyId, | ||
| contributorId: user.id, // Use authenticated user ID | ||
| status: "registered", | ||
| registeredAt: new Date().toISOString(), | ||
| }; | ||
|
|
||
| BountyStore.addCompetitionParticipation(participation); | ||
|
|
||
| return NextResponse.json({ success: true, data: participation }); | ||
| } catch (error) { | ||
| console.error("Error joining competition:", error); | ||
| return NextResponse.json( | ||
| { error: "Internal Server Error" }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
secretscontext is not permitted in stepifconditions — both conditional steps will never evaluate correctly.The GitHub Actions documentation explicitly states that "Secrets cannot be directly referenced in
if:conditionals" and recommends "setting secrets as job-level environment variables, then referencing the environment variables to conditionally run steps in the job." Theactionlinttool confirms this — lines 18 and 26 will produce "Unrecognized named-value: 'secrets'" errors at parse time, causing the checkout step to never run regardless of whether the token is set.🔧 Proposed fix — expose the secret as a job-level env var
jobs: check-schema: name: Check schema is in sync runs-on: ubuntu-latest + env: + NESTJS_TOKEN: ${{ secrets.BOUNDLESS_NESTJS_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Checkout canonical schema repo (private) - if: ${{ secrets.BOUNDLESS_NESTJS_TOKEN != '' }} + if: ${{ env.NESTJS_TOKEN != '' }} uses: actions/checkout@v4 with: repository: boundlessfi/boundless-nestjs path: boundless-nestjs token: ${{ secrets.BOUNDLESS_NESTJS_TOKEN }} - name: Note about private repo - if: ${{ secrets.BOUNDLESS_NESTJS_TOKEN == '' }} + if: ${{ env.NESTJS_TOKEN == '' }} run: |🧰 Tools
🪛 actionlint (1.7.11)
[error] 18-18: context "secrets" is not allowed here. available contexts are "env", "github", "inputs", "job", "matrix", "needs", "runner", "steps", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(expression)
[error] 26-26: context "secrets" is not allowed here. available contexts are "env", "github", "inputs", "job", "matrix", "needs", "runner", "steps", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(expression)
🤖 Prompt for AI Agents