Skip to content

feat: wallet transaction history with Stellar Horizon API#126

Open
victorjzq wants to merge 1 commit intosorosave-protocol:mainfrom
victorjzq:feat/transaction-history-horizon
Open

feat: wallet transaction history with Stellar Horizon API#126
victorjzq wants to merge 1 commit intosorosave-protocol:mainfrom
victorjzq:feat/transaction-history-horizon

Conversation

@victorjzq
Copy link

/claim #63

Summary

Implements on-chain transaction history for connected wallets using the Stellar Horizon REST API, as specified in issue #63.

New files

src/lib/horizon.ts — Horizon API client:

  • fetchAccountTransactions(accountId, network, cursor) — paginated operations for any Stellar account
  • fetchContractTransactions(contractId, network, cursor) — operations for Soroban contract addresses
  • Full TypeScript types for Horizon operations and parsed results
  • Cursor-based pagination following HAL _links from Horizon responses
  • 30-second in-memory cache keyed by network:account:cursor to reduce redundant requests
  • Operation type normalisation (payment, invoke_host_function, path_payment, etc.)
  • Stellar Expert explorer URL generation for both Testnet and Mainnet

src/app/transactions/page.tsx/transactions page:

  • Table listing type, date, amount/asset, and linked transaction hash
  • Testnet / Mainnet network switcher dropdown
  • Previous / Next pagination with page counter
  • Loading spinner, error banner with retry button, empty-state fallback
  • Graceful handling of accounts not yet on-chain (404 → empty list)
  • Wallet-not-connected guard with prompt

Modified files

src/components/Navbar.tsx — adds a "Transactions" link to the nav bar.

Acceptance Criteria

  • Query Horizon API for transactions involving the connected wallet
  • Parse operation types (payments, contract invocations, and others)
  • Display in a formatted transaction list
  • Add pagination for large histories
  • Cache results to reduce API calls

Test plan

  • Connect Freighter wallet on Testnet → transactions table populates
  • Switch to Mainnet → table reloads for mainnet
  • Click Next / Previous → page advances and retreats correctly
  • Disconnect wallet → empty-state message shown
  • Account with no history → "No transactions found" shown

- Add src/lib/horizon.ts: typed Horizon API client with fetchAccountTransactions
  and fetchContractTransactions, cursor-based pagination, 30s in-memory cache,
  operation label/icon helpers, and Stellar Expert explorer links
- Add src/app/transactions/page.tsx: full-page transaction history UI with
  table view, testnet/mainnet network switcher, prev/next pagination, loading
  spinner, error state with retry, and empty state handling
- Update Navbar to include a Transactions nav link

Closes sorosave-protocol#63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant