Skip to content

[simplex]: show the BRIDGE balance as soon as a top-up is delivered - #1403

Merged
seunlanlege merged 2 commits into
mainfrom
fix/simplex-bridge-balance-on-delivery
Oct 15, 2026
Merged

seunlanlege merged 2 commits into
mainfrom
fix/simplex-bridge-balance-on-delivery

Conversation

@seunlanlege

Copy link
Copy Markdown
Member

The dashboard's BRIDGE balance stayed stale for up to a minute after a top-up completed.

Why: the Hyperbridge balance is not part of BalanceProvider.refresh(). trackHyperbridgeBalance reads it once at boot and then on the same once-a-minute interval as the EVM chains, because the substrate read is cheap to cache and rarely urgent. When a top-up flips to delivered, the UI reloads balances immediately (OperatorOverview calls onBalancesChanged on the delivered transition, and GET /api/balances?refresh=1 re-reads the EVM chains) — but the snapshot's hyperbridge field was whatever the last interval tick had read.

Fix:

  • BalanceProvider.refreshHyperbridgeBalance() — the interval's read, now public and safe to call any time. No-op until tracking is initialized; a failed read keeps the last snapshot.
  • BridgeTopUp takes an optional refreshBridgeBalance dep, called — best-effort and awaited — in readDelivery where the record transitions to delivered. Awaited inside the sync is what makes the dashboard's follow-up /api/balances read fresh rather than racing a fire-and-forget refresh.
  • Wired in boot.ts to the balance provider.

Validation

  • bridge-top-up suite: 14 passed, including a new assertion that the balance refresh fires exactly once on delivery.
  • balance-provider suite: 12 passed.
  • Biome: clean on changed files.
  • tsc shows only the pre-existing errors on main (verified by stashing).

The Hyperbridge balance is not part of the per-minute EVM refresh:
trackHyperbridgeBalance reads it once at boot and then on its own
interval. That left the dashboard showing the pre-top-up balance for up
to a minute after delivery — the UI reloads balances the moment the
delivered stage is seen, but the snapshot's hyperbridge field was
whatever the last interval tick had read.

BalanceProvider.refreshHyperbridgeBalance() is the interval read, made
public and safe to call any time (a no-op until tracking initializes; a
failed read keeps the last snapshot). BridgeTopUp takes an optional
refreshBridgeBalance and awaits it, best-effort, where readDelivery
transitions the record to delivered, wired in boot.ts. Awaiting it
inside the sync is what makes the dashboard's follow-up balances read
fresh instead of racing a fire-and-forget refresh.
@seunlanlege
seunlanlege merged commit e41d16f into main Oct 15, 2026
15 of 16 checks passed
@seunlanlege
seunlanlege deleted the fix/simplex-bridge-balance-on-delivery branch October 15, 2026 12:59
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.

1 participant