Skip to content

Implement a Read-Only Cross-Chain Timelock State Simulator#197

Open
Damilorlar wants to merge 1 commit into
karagozemin:masterfrom
Damilorlar:feat/refund-simulator
Open

Implement a Read-Only Cross-Chain Timelock State Simulator#197
Damilorlar wants to merge 1 commit into
karagozemin:masterfrom
Damilorlar:feat/refund-simulator

Conversation

@Damilorlar

Copy link
Copy Markdown
Contributor

##closed #165

The application currently lacks a clear way for users and developers to understand the state of a cross-chain swap based on its timelock configuration. This enhancement introduces a frontend or SDK helper that simulates the lifecycle of a swap using the source chain direction and lock timestamps, without performing or submitting any blockchain transactions.

The simulator should provide a clear, read-only explanation of the swap's current state by displaying the source and destination timelock expiry times, identifying who is eligible to claim before expiry, who can refund after expiry, and whether the current simulated state is claimable, refundable, or waiting. The feature should support both ETH → XLM and XLM → ETH swap scenarios and clearly indicate that the output is a simulation intended for informational purposes only.

Implementation should be placed within the SDK or frontend components where appropriate, promoting code reuse and avoiding changes to existing refund execution logic.

##Acceptance Criteria
Implement a read-only helper in the SDK or frontend to simulate swap state based on source direction and lock timestamps.
Display:
Source timelock expiry.
Destination timelock expiry.
Who can claim before expiry.
Who can refund after expiry.
Current simulated state (Waiting, Claimable, or Refundable).
Support simulation for both ETH → XLM and XLM → ETH flows.
Clearly indicate that the feature is a simulation and does not execute blockchain transactions.
Reuse RefundDialog.tsx only if integration is clean and maintainable.
Add unit tests covering at least:
Waiting state.
Claimable state.
Refundable state.
Ensure no existing refund execution behavior or transaction logic is modified.

- Add simulateRefund() to SDK state-machine returning phase
  (claimable/waiting/refundable), per-leg timelock info, claim/refund
  parties, and human-readable summary
- Add 10 unit tests covering all three phases, both directions,
  mixed expiry, default now, and readonly marker
- Add RefundSimulator frontend component with disclaimer, phase badge,
  leg cards, live clock tick, and expandable summary
- Add 11 frontend unit tests covering all phases and metadata
- No changes to existing RefundDialog or refund execution paths
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Damilorlar is attempting to deploy a commit to the karagoz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Damilorlar 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

@karagozemin

Copy link
Copy Markdown
Owner

Thanks for the refund simulator work. The SDK side looks good in focused checks:

  • pnpm --filter @oversync/sdk test => 45 passing tests
  • pnpm --filter @oversync/sdk build => passed
  • pnpm --filter @oversync/frontend exec tsc --noEmit => passed

I cannot merge yet because the frontend test suite fails:

pnpm --filter @oversync/frontend test -- --run

The new frontend/src/components/RefundSimulator.test.tsx has 7 failing tests. The failures are Testing Library query collisions caused by duplicate visible text, for example:

  • multiple elements match /read-only simulation/i
  • multiple elements match /ETH → XLM/
  • multiple elements match /Stellar/ / /Ethereum/
  • multiple elements match /Claim before expiry/

Please update the component tests to use scoped queries, getAllBy*, roles/labels, or more specific text so they match the rendered component intentionally. After that, rerun the SDK and frontend checks above plus git diff --check origin/master...HEAD.

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.

[SCF high] Add public refund-path simulator for reviewer demos

2 participants