feat: add refund eligibility computation logic and API endpoints for … - #230
Open
toniasteve15-ui wants to merge 1 commit into
Open
Conversation
…order status transitions
|
@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! 🚀 |
Author
|
@karagozemin please review and merge |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#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