Skip to content

feat: auto-refresh contract state every 30s and wire landlord release action#2

Closed
arandomogg wants to merge 1 commit into
mainfrom
feat/auto-refresh-and-release-wiring
Closed

feat: auto-refresh contract state every 30s and wire landlord release action#2
arandomogg wants to merge 1 commit into
mainfrom
feat/auto-refresh-and-release-wiring

Conversation

@arandomogg
Copy link
Copy Markdown
Owner

Summary

  • Resolves merge conflicts in app/escrow/[contractId]/page.tsx and lib/stellar/queries.ts, restoring all previously missing query infrastructure (getLandlord, getTotal, getDeadline, etc.) alongside both getContractState and getFeeStats.
  • Creates hooks/useContractPolling.ts: polls getContractState every 30 s via setInterval; pauses automatically when the browser tab is hidden via visibilitychange; cleans up on unmount.
  • Replaces the mock fetchData in EscrowDashboardClient.tsx with the new polling hook and adds an inline error/retry state.
  • Refactors lib/stellar/actions/release.ts: fixes the stale window.freighter guard to use freighterApi.isConnected(), and splits the flow into buildReleaseXdr (assert funded + simulate) and signAndSubmitRelease (Freighter sign + Horizon submit); the original releaseEscrow convenience wrapper is kept.
  • Adds a Release Funds button in EscrowDashboardClient.tsx that renders only when isConnected && publicKey === landlord; clicking it builds the prepared XDR, opens the TransactionReview security modal, then signs and submits on confirm, shows a "Funds released to landlord." toast, and refreshes state.

Test plan

  • Confirm useContractPolling calls getContractState on mount and again after 30 s (mock two RPC responses and advance fake timers).
  • Confirm polling is skipped while document.visibilityState === "hidden" and fires immediately when the tab becomes visible.
  • Confirm the Release Funds button is absent for non-landlord wallets and present for the landlord wallet.
  • Mock buildReleaseXdr + signAndSubmitRelease; confirm success toast and state refresh on confirm.
  • Confirm the modal cancel path clears error and XDR state without submitting.

closes Ogstevyn#501
closes Ogstevyn#502

… action

Resolves merge conflicts in page.tsx and queries.ts, introduces 30-second
contract state polling that pauses when the browser tab is hidden, and wires
the Release Funds button so only the connected landlord can trigger a Freighter-
signed release transaction with a TransactionReview security modal.

closes Ogstevyn#501
closes Ogstevyn#502
@arandomogg arandomogg force-pushed the feat/auto-refresh-and-release-wiring branch from 7a75932 to b0e78db Compare April 25, 2026 08:43
@arandomogg
Copy link
Copy Markdown
Owner Author

Opening against the correct upstream repo Ogstevyn/payeasy instead.

@arandomogg arandomogg closed this Apr 25, 2026
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.

[Issue #83] Dashboard: Landlord Release Action Wiring [Issue #82] Dashboard: Auto-Refresh Contract State Every 30s

1 participant