Skip to content

feat: Add GET /account/:id/trustlines endpoint with TOML resolution#32

Merged
Sulex45 merged 2 commits into
stellarkit-lab-devtools:mainfrom
Babigdk:feature/add-trustlines-endpoint
May 30, 2026
Merged

feat: Add GET /account/:id/trustlines endpoint with TOML resolution#32
Sulex45 merged 2 commits into
stellarkit-lab-devtools:mainfrom
Babigdk:feature/add-trustlines-endpoint

Conversation

@Babigdk
Copy link
Copy Markdown
Contributor

@Babigdk Babigdk commented May 26, 2026

Close #19

Add GET /account/:id/trustlines with TOML Resolution

Overview

This PR implements a new endpoint that returns all trustlines for a Stellar account with asset metadata resolved from the issuer's stellar.toml file.

Changes

New Features

  1. New Endpoint: GET /account/:id/trustlines

    • Returns all trustlines (non-native asset balances) for a given account
    • For each trustline, resolves the issuer's account information
    • Automatically fetches and parses the issuer's stellar.toml file
    • Extracts asset metadata (name, description, image) from TOML
    • Gracefully handles missing or unreachable TOML files
  2. New Utility: TOML Resolver (src/utils/tomlResolver.js)

    • fetchStellarToml(homeDomain): Fetches and parses TOML from a domain
    • getAssetMetadataFromToml(homeDomain, assetCode): Extracts asset metadata from TOML
    • Implements robust error handling with 5-second timeout
    • Returns null gracefully for network errors, timeouts, or malformed TOML

Modified Files

src/routes/account.js

  • Added import for TOML resolver utility
  • Implemented /:id/trustlines route with:
    • Account ID validation
    • Trustline fetching from Horizon
    • Parallel TOML resolution for all assets
    • Comprehensive error handling

src/index.js

  • Updated API documentation to include the new endpoint

tests/api.test.js

  • Added test suite for the trustlines endpoint
  • Tests for invalid account ID validation
  • Tests for graceful error handling

Acceptance Criteria ✅

  • For each asset, resolves issuer home_domain and fetches stellar.toml
  • Returns name, description, image from TOML if available
  • Gracefully handles missing or unreachable TOML
  • Tests added

API Usage

Request

- Implement new endpoint that returns all trustlines for an account
- Resolve issuer home_domain and fetch stellar.toml for each asset
- Extract and return asset metadata (name, description, image) from TOML
- Gracefully handle missing or unreachable TOML files
- Add comprehensive test coverage for validation and edge cases
- Update API documentation to include the new endpoint

Closes stellarkit-lab-devtools#19
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 26, 2026

@Babigdk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Sulex45
Copy link
Copy Markdown
Contributor

Sulex45 commented May 27, 2026

Resolve src/routes/account.js and tests/api.test.js before i can merge

@Sulex45
Copy link
Copy Markdown
Contributor

Sulex45 commented May 27, 2026

Resolve src/index.js, src/routes/account.js and tests/api.test.js

@Babigdk
Copy link
Copy Markdown
Contributor Author

Babigdk commented May 30, 2026

Resolved

@Sulex45 Sulex45 merged commit 8e9a19a into stellarkit-lab-devtools:main May 30, 2026
1 of 3 checks passed
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.

Add GET /account/:id/trustlines with TOML resolution

2 participants