Skip to content

Commit 31bd594

Browse files
authored
feat(backend): implement missing plan management & beneficiary claim endpoints (#1051)
* feat(backend): implement missing plan management & beneficiary claim endpoints Closes #1034 Added five missing API endpoints that the frontend PlansAPI client (frontend/app/lib/api/plans.ts) expected but were absent from the Axum router in backend/src/api.rs: - GET /api/plans/{id} -> get_plan_by_id - GET /api/plans/due-for-claim -> get_plans_due_for_claim - GET /api/plans/due-for-claim/{id}-> get_plan_due_for_claim - POST /api/plans/{id}/claim -> claim_plan - POST /api/plans/{id}/cancel -> cancel_plan New request/query structs added to api.rs: DueForClaimQuery - wallet_address / page / limit query params ClaimPlanRequest - beneficiary_email + two_fa_code CancelPlanRequest - optional signed_transaction XDR Handler details: get_plan_by_id: queries plans + beneficiaries by UUID, returns wrapped { data } response with live yield projection. get_plans_due_for_claim: paginated list of plans whose status is TRIGGERED or CLAIMABLE; optionally scoped to a beneficiary wallet address via ?wallet_address=. get_plan_due_for_claim: single-plan variant of the above; returns 404 when the plan exists but is not yet claimable. claim_plan: validates 2FA code format, enforces TRIGGERED/CLAIMABLE guard, checks KYC approval for every fiat-configured beneficiary, then opens a DB transaction to insert pending payout rows (one per beneficiary, shares computed via allocation_bps) and advances the plan status to CLAIMABLE. cancel_plan: guards against re-cancelling or cancelling PAID_OUT plans; optionally validates and submits a signed XDR to Stellar before writing; sets is_active = false and status = DEACTIVATED in the DB and invalidates the plan cache. Both claim_plan and cancel_plan are placed on the signature-auth router so the existing ed25519 middleware protects them. The due-for-claim and get-by-id routes are public (no auth required) consistent with the existing GET /api/plans pattern. * style: apply rustfmt to new plan management & claim endpoints
1 parent 7284a24 commit 31bd594

1 file changed

Lines changed: 698 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)