Skip to content

fix: persist WalletConnect session, negative-weight detection, Freighter/XBull error handling (#771–774) - #897

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
ushpraise:main
Sep 28, 2026
Merged

Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
ushpraise:main

Conversation

@ushpraise

Copy link
Copy Markdown

What & Why

This PR resolves four Wave issues in a single change-set. Each fix is scoped to the file named in the issue brief.


#774 — Persist WalletConnect session across page reloads

Problem: WalletConnectAdapter created a session but never saved it, so every page reload forced users to re-scan a QR code.

Fix:

  • Constructor now writes { topic, relayUrl, chainId, address, expiry } to localStorage under the key stellarsplit:wc:session.
  • New static factory WalletConnectAdapter.restore(client) reads the stored session, validates the WalletConnect expiry timestamp, and returns a ready adapter — no new QR scan needed.
  • disconnect() removes the persisted entry.
  • Accepts optional relayUrl and expiry constructor options.

#773 — Detect negative-weight edges in PaymentGraphChecker

Problem: Negative-weight edges could cause unbounded fund extraction when the graph is traversed greedily; the checker did not detect them.

Fix:

  • New checkGraph(graph: PaymentGraph): GraphValidationResult method on PaymentGraphChecker.
  • Returns { valid: false, reason } on the first offending edge, naming source → target and the weight in the message.
  • Zero-weight (pass-through) edges are explicitly allowed.
  • Exports PaymentGraph, PaymentGraphEdge, and GraphValidationResult types.

#772 — Handle Freighter not-installed error

Problem: FreighterAdapter propagated raw TypeError when the Freighter browser extension was absent.

Fix:

  • New exported FreighterNotInstalledError (extends Error, proper instanceof) with the install URL (https://www.freighter.app) in its message.
  • Private assertInstalled() helper called at the top of every public method (connect, sign, getAddress, signTransaction).
  • Existing connection flow is unchanged when the extension is present.

#771 — Check XBull extension version before connection

Problem: XBullAdapter connected without verifying the extension version, causing cryptic errors with older builds.

Fix:

  • Exports MIN_XBULL_VERSION = '2.0.0' — the first version supporting the current API surface.
  • New exported ExtensionVersionError with installedVersion / requiredVersion properties.
  • connect() reads window.xBullSDK.version and throws ExtensionVersionError when below the minimum.
  • If window.xBullSDK is absent (older extension that doesn't expose the namespace) the check is skipped gracefully.
  • Static XBullAdapter.compareVersions(a, b) utility for semver-style comparison.

How it was tested

  • Existing tests updated: test/walletconnect.test.ts and test/paymentGraphChecker.test.ts
  • New test files: test/freighterAdapter.test.ts, test/xbullAdapter.test.ts
  • All acceptance criteria covered by dedicated test cases.
  • 158 tests pass across 6 test files (vitest run).

closes #771
closes #772
closes #773
closes #774

…#773 Stellar-split#774

Stellar-split#774 – Persist WalletConnect session across page reloads
- WalletConnectAdapter now writes session (topic, relayUrl, chainId,
  address, expiry) to localStorage on construction.
- New static WalletConnectAdapter.restore(client) factory reads the
  stored session, validates its expiry, and returns a ready adapter
  without requiring a new QR scan.
- disconnect() clears the stored session.
- Accepts optional relayUrl and expiry constructor options.

Stellar-split#773 – Detect negative-weight edges in PaymentGraphChecker
- New checkGraph(graph: PaymentGraph): GraphValidationResult method.
- Returns { valid: false, reason } on the first negative-weight edge,
  naming the offending source → target and the weight value.
- Zero-weight (pass-through) edges are allowed.
- Exports PaymentGraph, PaymentGraphEdge, GraphValidationResult types.

Stellar-split#772 – Handle Freighter not-installed error
- New FreighterNotInstalledError class with Freighter install URL
  (https://www.freighter.app) in the message.
- All public FreighterAdapter methods (connect, sign, getAddress,
  signTransaction) call assertInstalled() before any Freighter API use.

Stellar-split#771 – Check XBull extension version before connection
- Exports MIN_XBULL_VERSION = '2.0.0'.
- New ExtensionVersionError with installedVersion/requiredVersion fields.
- connect() reads window.xBullSDK.version and throws
  ExtensionVersionError when the version is below the minimum.
- Static XBullAdapter.compareVersions() utility for semver comparison.
- If window.xBullSDK is absent the check is skipped gracefully.

Tests: 158 tests pass across 6 test files.
@drips-wave

drips-wave Bot commented Sep 25, 2026

Copy link
Copy Markdown

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

@Kingsman-99
Kingsman-99 merged commit 83e18be into Stellar-split:main Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants