feat: add refund eligibility computation logic and API endpoints for … - #230
feat: add refund eligibility computation logic and API endpoints for …#230toniasteve15-ui wants to merge 2 commits into
Conversation
|
@Oluwasuyi-Oluwatimilehin-Daniel is attempting to deploy a commit to the karagoz's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@toniasteve15-ui 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! 🚀 |
|
@karagozemin please review and merge |
|
Refund eligibility helper/endpoint incelendi: SDK 15/15 test ve coordinator route testleri 3/3 geçti; frontend production build de başarılı. Ancak güncel |
|
Ek olarak |
dd26364 to
7c0ded8
Compare
|
@karagozemin please review and merge |
#closes #72
PR Description: Read-only refund eligibility endpoint for transaction history (#72)
Summary
This PR implements a read-only refund eligibility helper and API endpoint to allow transaction history interfaces and external consumers to determine when a stuck cross-chain order can be refunded on-chain without initiating transactions.
Changes Included
1. SDK Core (
@oversync/sdk)computeRefundEligibilityHelper: ImplementedcomputeRefundEligibility(input)inpackages/sdk/src/state-machine/refund-eligibility.ts.computeRefundEligibilityand its associated types (RefundEligibilityReasonCode,RefundEligibilityInput,RefundEligibilityResult) from@oversync/sdk.not_expired("not expired"): Timelock is still active or not yet locked on-chain.already_claimed("already claimed"): Order status iscompletedorsecret_revealed.already_refunded("already refunded"): Order status isrefunded.eligible("eligible"): Timelock has passed and order is in a refundable state (announced,src_locked,dst_locked,failed,expired).unknown_order("unknown order"): Order is not found or null.2. Coordinator API (
@oversync/coordinator)OrderService.getRefundEligibility: AddedgetRefundEligibility(publicId, nowUnixSeconds?)method inOrderService.GET /api/orders/:id/refund-eligibilityendpoint returning JSON:{ "id": "order-id", "refundEligibility": { "eligible": true, "reasonCode": "eligible", "reason": "eligible", "timeRemainingSeconds": 0 } }404 Not FoundwithreasonCode: "unknown_order"if the order does not exist.serialiseOrderinroutes/orders.tsto includerefundEligibilityseamlessly onGET /api/orders/:idandGET /api/orders/historywithout breaking existing consumers.3. Frontend & Transaction History (
@oversync/frontend)refundEligibilitymetadata inTransactionHistory.tsxto expose refund eligibility and reason codes.4. Tests
packages/sdk/test/refund-eligibility.test.tswith 15 tests covering ETH->XLM and XLM->ETH orders across all order statuses and timelock conditions.coordinator/test/refund-eligibility-route.test.tsverifying HTTP responses for valid orders, unknown orders, and history integration.Guardrails Adherence
Verification
@oversync/sdkunit tests: 142/142 passed (11/11 test files).@oversync/coordinatorunit and route tests: 143/143 passed (14/14 test files).@oversync/frontendbuild: Vite build succeeded cleanly (dist/created in 13.76s).#closes