feat: implement scholarship co-funding for approved proposals - #1050
Merged
Anuoluwapo25 merged 5 commits intoJul 29, 2026
Merged
Conversation
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.
7 tasks
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.
Closes #1019
Summary
verifiedcolumn,UNIQUEconstraint ontx_hash, and indexes onproposal_id/donor_addresstoscholarship_contributionshorizon-verify.service.ts— verifies an on-chaindeposit()call against the ScholarshipTreasury contract via the Horizon REST API (checks contract ID, function name, donor address, and amount)scholarships.controller.ts— rewrotecontributeToScholarship(fixed broken SQL placeholders, added Horizon verification, enforces donor == authenticated user, atomic DB transaction withBEGIN/COMMIT, duplicate-tx 409 guard); addedgetProposalContributorsscholarships.routes.ts— wiredPOST /api/scholarships/:id/contribute(JWT auth + write rate-limiter) andGET /api/scholarships/:id/contributorsgovernance.controller.ts—GET /api/governance/proposals/:idnow returnscurrent_fundingand acontributorsarray (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 detectionuseProposals.ts— addedcurrentFundingandcontributorstoProposalRecord; addeduseContributemutation (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 forapproved/queuedproposalsDaoProposals.tsx—CoFundingSectionintegrated into the proposal detail panelType of Change
Checklist
cargo testpassesnpm run typecheckpassesnpm testpassesScreenshots (if applicable)
Testing
Additional Notes