Skip to content

Replace any-typed walletApi with a typed Freighter API interface #32

Description

@prodbycorne

Problem

StellarWalletContext stores the Freighter module as walletApi: any and src/components/UnlockModal/UnlockModal.tsx passes it straight to unlockAssets as any. This bypasses TypeScript's type checking for every wallet call, making it easy to accidentally call a non-existent method or pass the wrong argument shape without a compile-time error.

const [walletApi, setWalletApi] = useState<any | null>(null);

Acceptance Criteria

  • src/types/freighter.ts defines a FreighterApi interface mirroring the methods actually used: isConnected(), isAllowed(), requestAccess(), getAddress(), getNetworkDetails(), signTransaction(xdr: string, opts: { networkPassphrase: string }): Promise<{ signedTxXdr: string; error?: string }>
  • StellarWalletContext types walletApi as FreighterApi | null — no more any
  • StellarWalletContextValue.walletApi exposed to consumers is typed FreighterApi | null
  • src/lib/soroban.ts all methods receiving walletApi parameter replace any with FreighterApi
  • @stellar/freighter-api is imported via dynamic import as before, but cast to FreighterApi after the isConnected check (the import type is compatible)
  • tsconfig.json has "strict": true; no @ts-ignore or as any remains in wallet-related files
  • Running tsc --noEmit produces zero errors after the change

Relevant Files

  • src/types/freighter.ts — create this file
  • src/context/StellarWalletContext.tsx — replace any
  • src/lib/soroban.tswalletApi: any in method signatures
  • src/components/UnlockModal/UnlockModal.tsx — prop type for walletApi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Official CampaignCampaign: Official CampaignhardRequires deep domain knowledge — Soroban, Stellar SDK, or complex statesecuritySecurity, signing safety, or wallet interaction hardeningwalletFreighter wallet integration, session, and network switching

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions