Skip to content

Architect deterministic state machines for Freighter wallet connections #423

Description

@Fatimasanusi

Description

Handling wallet connections with boolean flags (isConnected, isConnecting) leads to impossible UI states and race conditions during fractional asset purchases.

Architecture & Context

The frontend must implement a deterministic finite state machine (using XState) to manage the wallet lifecycle. This strictly defines transitions between Disconnected, RequestingAccess, Connected, and NetworkMismatch, eliminating unhandled edge cases.

Technical Requirements

  • Define a strict XState machine for the Freighter wallet lifecycle.
  • Integrate the state machine with the React context provider.
  • Handle asynchronous wallet timeouts and user rejections explicitly.

Acceptance Criteria

  • Impossible states (e.g., isConnected && isConnecting) are mathematically prevented.
  • User rejecting the connection smoothly returns the machine to Disconnected.
  • Network changes emit a strict transition to the NetworkMismatch state.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions