Skip to content

Full asset list display for account page — backend + frontend #173

@Tinna23

Description

@Tinna23

Description

The account page currently shows only xlm_balance and asset_count. Users with multiple trust lines cannot see what assets they actually hold or at what balances. This issue adds a complete asset breakdown — backend exposes the data, frontend renders it with an expandable list.

Part 1 — Backend

The Horizon /accounts/:id response already returns a balances array. The backend needs to pass it through to the AccountExplanation response.

Add to AccountExplanation in src/explain/account.rs:

pub struct Balance {
    pub asset_code: String,      // "XLM" for native
    pub asset_issuer: String,    // "native" for XLM
    pub balance: String,         // e.g. "271.1484471"
    pub limit: String,           // "unlimited" for XLM, otherwise the trust limit
    pub is_authorized: bool,     // whether the issuer has authorized this trust line
}

pub struct AccountExplanation {
    // ... existing fields ...
    pub balances: Vec<Balance>,  // ADD THIS
}

Map from Horizon response in src/services/horizon.rs — the HorizonBalance struct already exists or needs adding with fields: balance, asset_type, asset_code, asset_issuer, limit, is_authorized.

Key files (backend):

  • packages/core/src/explain/account.rs
  • packages/core/src/services/horizon.rs
  • packages/core/src/models/account.rs

Part 2 — Frontend

Update src/types/index.ts:

export interface Balance {
  asset_code: string;
  asset_issuer: string;
  balance: string;
  limit: string;
  is_authorized: boolean;
}

// Add to AccountExplanation:
balances: Balance[];

Create src/components/account/AssetList.tsx:

  • XLM always shown first, always visible
  • Remaining assets hidden behind "Show all N assets ▼" toggle
  • Each row: asset code (bold), truncated issuer address with copy-to-clipboard, balance right-aligned, limit as subtitle
  • Zero-balance assets rendered in muted style (trust line exists but holds nothing)
  • Integrate below AccountBalances in AccountResult.tsx

Key files (frontend):

  • src/types/index.ts
  • src/components/account/AssetList.tsx
  • src/components/AccountResult.tsx

Acceptance Criteria

  • Backend: AccountExplanation JSON includes balances[] array
  • XLM appears as the first entry with asset_issuer: "native"
  • Frontend: XLM always visible, other assets collapsed by default
  • Expand toggle shows all assets with correct balances and limits
  • Zero-balance assets are visually distinct (muted)
  • Issuer address copy works with toast feedback
  • Page does not crash when balances is empty or contains only XLM
  • TypeScript compiles cleanly

Complexity: High · 200 pts
Stage: S8 — Account Depth

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendcreate high-quality web applications with the power of React components.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions