Skip to content

Adopt trustflow-sdk and consolidate hand-rolled wallet/contract integration #81

Description

@meshackyaro

Description

trustflow-sdk is not listed as a dependency anywhere in this repo's package.json. Instead, the frontend hand-rolls its own wallet integration directly against @stellar/freighter-api (hooks/useAccount.ts, components/atoms/wallet-button/) and defines its own env-var-based contract constants (shared/contracts.ts) with no code that actually invokes the SDK's contract/escrow clients. This means every piece of Soroban integration work (see the transaction-flow spike, #79) would either duplicate what the SDK already has, or need to be built twice.

Component

Frontend

Difficulty

🔴 Hard

Tasks

  • Add @trustflow/sdk as a dependency once its wallet/escrow exports are usable (coordinate with the SDK repo's hook-export fix)
  • Replace the direct @stellar/freighter-api usage in useAccount.ts with the SDK's wallet connection helpers, preserving current UI behavior
  • Replace shared/contracts.ts's standalone env constants with the SDK's ClientConfig, keeping NEXT_PUBLIC_-prefixed env vars as the source of truth
  • Audit for behavior drift between the current hand-rolled polling (setInterval(syncAccount, 2000)) and whatever connection model the SDK provides, and reconcile
  • Update the README's stated architecture to reflect the SDK now being the integration boundary

Acceptance Criteria

  • Wallet connect/disconnect/switch-account flows work identically to today from a user's perspective, now backed by the SDK
  • No direct @stellar/freighter-api imports remain outside the SDK dependency boundary
  • shared/contracts.ts sources its config from the SDK's types rather than ad hoc local constants
  • Existing pages/components using useAccount require no API changes (or changes are scoped and called out explicitly)

Estimated Time

2-3 days

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions