Skip to content

Architect an EIP-6963 compatible finite state machine (XState) for deterministic Web3 wallet management #472

Description

@Damola-Sodiq

Description

Replace fragile boolean flags with a strict Finite State Machine (FSM) using XState to manage multi-wallet discovery, session timeouts, and hardware wallet connection flows.

Architecture & Context

Managing active states for Freighter, MetaMask, and hardware wallets simultaneously leads to unresolvable race conditions. An FSM strictly defines transitions (e.g., Idle -> Discovering -> Awaiting Signature -> Confirmed), making impossible UI states mathematically unreachable.

Technical Requirements

  • Define the XState v5 machine configuration mapping all potential Web3 edge cases.
  • Integrate EIP-6963 provider announcement listeners to populate the available wallet context.
  • Map the state machine seamlessly to React Context for global component consumption.

Acceptance Criteria

  • The UI never deadlocks during a wallet rejection or network disconnect.
  • Multiple injected providers are handled without overriding context.
  • State transitions are fully typed via TypeScript inferences.

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