Skip to content

feat: implement scholarship co-funding for approved proposals - #1050

Merged
Anuoluwapo25 merged 5 commits into
bakeronchain:mainfrom
Arowolokehinde:feat/scholarship-cofunding
Jul 29, 2026
Merged

feat: implement scholarship co-funding for approved proposals#1050
Anuoluwapo25 merged 5 commits into
bakeronchain:mainfrom
Arowolokehinde:feat/scholarship-cofunding

Conversation

@Arowolokehinde

@Arowolokehinde Arowolokehinde commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #1019

Summary

  • Migration 024 — adds verified column, UNIQUE constraint on tx_hash, and indexes on proposal_id / donor_address to scholarship_contributions
  • horizon-verify.service.ts — verifies an on-chain deposit() call against the ScholarshipTreasury contract via the Horizon REST API (checks contract ID, function name, donor address, and amount)
  • scholarships.controller.ts — rewrote contributeToScholarship (fixed broken SQL placeholders, added Horizon verification, enforces donor == authenticated user, atomic DB transaction with BEGIN/COMMIT, duplicate-tx 409 guard); added getProposalContributors
  • scholarships.routes.ts — wired POST /api/scholarships/:id/contribute (JWT auth + write rate-limiter) and GET /api/scholarships/:id/contributors
  • governance.controller.tsGET /api/governance/proposals/:id now returns current_funding and a contributors array (parallel query, no N+1)
  • contributions.test.ts — 10 Jest/supertest cases: happy path, auth errors (401/403), 404, 409 duplicate tx, 422 failed verification, full-funding detection
  • useProposals.ts — added currentFunding and contributors to ProposalRecord; added useContribute mutation (reads JWT from localStorage, invalidates proposal cache on success)
  • CoFundingSection.tsx — new component: funding progress bar, quick-select amounts, Freighter sign → Horizon submit → API record flow, contributor list; visible only for approved/queued proposals
  • DaoProposals.tsxCoFundingSection integrated into the proposal detail panel

Type of Change

  • Bug fix
  • New feature
  • Smart contract change
  • Documentation
  • Breaking change
  • Other (please describe)

Checklist

  • Tests added or updated
  • No hardcoded secrets or private keys
  • If contract change: cargo test passes
  • If frontend change: npm run typecheck passes
  • If backend change: npm test passes
  • Related issues linked (Closes #...)
  • Self-review completed
  • Code follows project style guidelines

Screenshots (if applicable)

Testing

Additional Notes

Allow donors to top up approved/queued scholarship proposals via verified
on-chain USDC deposits. Includes Horizon tx verification, atomic DB writes,
auth-gated API endpoint, and a co-funding UI on the proposal detail page.
…ps controller

- Add proper AuthRequest import instead of inline import() type cast
  (inline cast was breaking downstream module resolution in routes file)
- Wrap Hash return values in Buffer.from() for StrKey.encode* compatibility
- Cast OperationBody through unknown to call XDR union instance accessor
  (SDK v14 types invokeHostFunction as static-only in the type definitions)
…erify

The Stellar SDK's Hash type (Opaque[]) is not assignable to Buffer, so
Buffer.from(addr.ed25519()) and StrKey.encode* calls failed to compile.

Fix: use Address.fromScAddress() and Address.fromScVal() which handle
the Hash->strkey conversion internally, and scValToNative() which returns
a proper bigint for i128 values. Eliminates all raw byte manipulation.
contributeToScholarship and getProposalContributors were exported from
the controller but never imported in the routes file, causing TS2304.
@Anuoluwapo25
Anuoluwapo25 merged commit a487479 into bakeronchain:main Jul 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Scholarship co-funding — allow donors to top up approved proposals

2 participants