Skip to content

Integrate a real wallet (Freighter / Stellar Wallets Kit) #35

Description

@DanielCotoJ

Effort: L — Estimate: 10-14 h — Dependencies: none (pairs with #36) — Unlocks: #36 (real data source), #41 (vault dashboard)

Context

The session/holder layer (already merged) is complete, but the connector underneath is a mock. apps/credit-history/src/session/wallet-connector.ts always resolves to a fixed address:

const MOCK_ADDRESS = 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5';
// SEAM: … return a connector based on Freighter / Stellar Wallets Kit (address G… + signTransaction)

The UI (SessionProvider, useSession, the header WalletButton) must not change — only this factory and the concrete connector class.

Goal

Clicking "Connect" opens a real wallet (Freighter via Stellar Wallets Kit), returns the holder's real G… address, exposes signTransaction, and the DID is derived from it with didStellar (#34).

Step by step

  1. Add the dependency to the app: pnpm --filter @acta-products/credit-history add @creit.tech/stellar-wallets-kit (or the Freighter API directly — justify the choice in the PR; verify Next 16 / React 19 compatibility).
  2. Implement a RealWalletConnector implements WalletConnector that: detects the wallet, requests access, returns { address }, and provides signTransaction(xdr, { networkPassphrase }). Extend the WalletConnector interface with signTransaction (kept optional if needed for Secure presentation links (signed/encrypted, not plaintext base64) #39).
  3. Make getWalletConnector() return the real connector, with a fallback to the mock when the wallet is unavailable (gate on an env flag, e.g. NEXT_PUBLIC_WALLET=real|mock, mock as default so CI/dev without an extension still works).
  4. Read the network from NEXT_PUBLIC_STELLAR_NETWORK (same var as ActaProvider) and pass the right networkPassphrase. Handle user-rejected and wallet-not-installed errors with friendly UI states.
  5. Verify session persistence still works after refresh (localStorage key acta:session:address).

Out of scope

Acceptance criteria

  • Real connect flow returns the actual G… address; DID shows did:stellar:{network}:{G…}.
  • SessionProvider / useSession / WalletButton are unchanged (only the connector/factory changed).
  • Wallet-not-installed and user-rejected are handled without crashing.
  • Mock fallback still works when NEXT_PUBLIC_WALLET is not real.
  • pnpm lint && pnpm typecheck && pnpm build pass.

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions