Skip to content

Soroban transaction polling — implement exponential back-off and FAILED status handling in UnlockModal #26

Description

@prodbycorne

Problem

UnlockModal.tsx calls unlockAssets from src/lib/soroban.ts and awaits a TransactionResult. The underlying SorobanService.unlockAssets method submits the transaction and is expected to poll rpcServer.getTransaction(hash) for the final status, but the polling loop is not yet implemented — it returns immediately after sendTransaction.

A transaction can remain in the PENDING or NOT_FOUND state for up to 30 seconds on a loaded network. During this window the UI has no feedback and the user may close the modal or click again, causing a double submission.

Expected Behaviour

After sendTransaction the frontend polls getTransaction(hash) with exponential back-off until SUCCESS, FAILED, or a configurable timeout (30 s). The UnlockModal shows the transaction hash as a clickable Stellar Expert link and a polling spinner during the wait.

Acceptance Criteria

  • SorobanService gains a pollTransactionStatus(hash, timeoutMs = 30000) private method implementing exponential back-off starting at 1 s, doubling each attempt, capped at 5 s
  • The method returns { status: 'SUCCESS' | 'FAILED' | 'TIMEOUT'; resultXdr?: string; errorCode?: string }
  • unlockAssets (and the future lockAssets) call pollTransactionStatus before resolving
  • UnlockModal displays three distinct states: SigningSubmittingConfirming (hash link)Success / Error
  • On FAILED, the contract error code extracted from the result XDR is decoded (e.g. Error::Locked = 1 → "Assets are still locked") and shown to the user
  • On TIMEOUT, the modal shows the hash and invites the user to check Stellar Expert manually
  • A Vitest test simulates getTransaction returning NOT_FOUND twice then SUCCESS and verifies the result is SUCCESS after 3 calls

Relevant Files

  • src/lib/soroban.tsunlockAssets, add pollTransactionStatus
  • src/components/UnlockModal/UnlockModal.tsx — multi-step UI state

Metadata

Metadata

Assignees

Labels

Official CampaignCampaign: Official CampaignhardRequires deep domain knowledge — Soroban, Stellar SDK, or complex statesorobanSoroban smart-contract integration (XDR, RPC, transaction building)uxUser experience, interaction design, loading states

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions