Skip to content

feat(logic): Implement Vesting Schedule UI and Claim Flow for Stream/Vault Dashboard #1269

Description

@Emmyt24

Description

The streaming/vesting contract module (contracts/token-factory/src/streaming.rs) and the vault backend routes (backend/src/routes/vaults.ts) are in place, but the VaultDashboard.tsx component in frontend/src/components/Vaults/ lacks the ability to display active vesting schedules with a visual progress indicator, or to let a beneficiary claim a matured vault. This issue implements the end-to-end vesting claim flow — from schedule display to on-chain transaction.


Requirements and Context

  • Backend endpoints already exist: GET /api/vaults/beneficiary/:address and GET /api/vaults/:id in backend/src/routes/vaults.ts.
  • The StreamProjectionService in backend/src/services/streamProjectionService.ts maintains vault state derived from on-chain events.
  • The useVaultContract hook in frontend/src/hooks/useVaultContract.ts must be extended (or a new useVaultClaim hook created) to invoke the on-chain claim_stream contract function.
  • A vesting progress bar must show percentage elapsed based on (currentLedger - startLedger) / (endLedger - startLedger) — not wall-clock time, since Stellar uses ledger numbers.
  • Only the designated recipient address may claim — the UI must disable the claim button for connected wallets that are not the beneficiary.

Suggested Execution

Branch naming convention:

feat/vesting-schedule-claim-flow

Implement Changes

  • Extend frontend/src/components/Vaults/VaultDashboard.tsx to fetch the connected wallet's beneficiary vaults via GET /api/vaults/beneficiary/:address and render each as a VaultCard showing: token, creator, amount, unlock progress bar, and status badge.
  • Create frontend/src/components/Vaults/VaultCard.tsx with a ledger-based progress bar (percentage filled) and a Claim button that is enabled only when the vault is fully vested and the connected wallet matches the recipient.
  • Extend useVaultContract.ts with a claimVault(streamId: number) function that signs and submits the claim_stream Soroban transaction.
  • Add a success toast and a confetti animation (reuse useConfetti hook) on successful claim.

Test and Commit

  • Write unit tests for the ledger-based progress calculation utility function.
  • Add integration tests for VaultCard with mocked API responses covering: not-yet-vested vault (claim button disabled), matured vault (claim button enabled), and already-claimed vault (status badge).
  • Test the claimVault hook with a mocked Soroban client to verify the correct transaction parameters.
  • Ensure VaultDashboard renders an accessible empty state when the wallet has no vaults.

Example Commit Message

feat(frontend): add vesting schedule progress display and on-chain claim flow to vault dashboard

Closes #<issue-number>

Guidelines

  • Keep PRs focused: one logical change per PR.
  • The progress bar must be computed from ledger numbers fetched from the Stellar Horizon API — do not use Date.now() as a proxy.
  • Follow the existing vault route patterns in backend/src/routes/vaults.ts for any new backend routes needed.
  • Request a review from at least one maintainer before merging.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions