Skip to content

feat: expired trade refund flow (#71)#100

Open
JafetCHVDev wants to merge 1 commit into
ericmt-98:mainfrom
JafetCHVDev:feat/expired-trade-refund
Open

feat: expired trade refund flow (#71)#100
JafetCHVDev wants to merge 1 commit into
ericmt-98:mainfrom
JafetCHVDev:feat/expired-trade-refund

Conversation

@JafetCHVDev
Copy link
Copy Markdown

Summary

Implements the expired trade refund flow for the Trade Detail screen. When a trade expires, the buyer can now recover their funds by triggering an on-chain refund via the Soroban contract.

Changes

Backend

  • stellar.service.ts — Added callRefundOnChain() to invoke the Soroban escrow contract's refund() function after the timeout ledger has been reached
  • trade.service.ts — Added refundTrade() with full validation: verifies the caller is the buyer, the trade is past expiration, and on-chain funds exist (lock_tx_hash). Transitions the trade to refunded status and stores the refund transaction hash
  • routes/trades.ts — Added POST /trades/:id/refund endpoint

Frontend

  • TradeDetail.tsx:
    • ExpiredView now shows a "Recuperar fondos" button when the current user is the buyer
    • RefundConfirmDialog provides a two-step confirmation with amount breakdown and gas fee warning
    • RefundedView displays the terminal refunded state with the Stellar transaction hash and explorer link
    • Added refunded to STATUS_CONFIG with purple styling and undo icon
  • api.ts — Added refundTradeRequest() function and RefundTradeResponse type
  • History.tsx — Added refunded filter tab ("Reembolsados") and status label

Acceptance Criteria

  • Expired trade shows "Recuperar fondos" button for the buyer
  • Flow completes calling refund() on Soroban and updates state to refunded
  • Refund tx hash visible in detail view
  • Refund errors (already claimed, not yet expired) show a clear message
  • refunded state appears in history with visual distinction from completed

Closes #71

- Add callRefundOnChain() to Stellar service for Soroban contract refund
- Add refundTrade() service with validation (buyer-only, expired, lock_tx_hash)
- Add POST /trades/:id/refund endpoint
- Add refundTradeRequest() to frontend API client
- Show 'Recuperar fondos' button on expired trades for buyer in TradeDetail
- Add RefundedView with tx hash and Stellar explorer link
- Add RefundConfirmDialog with amount detail and gas fee warning
- Add refunded status to STATUS_CONFIG, History filters, and trade history
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@JafetCHVDev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Expired trade refund flow

1 participant