Skip to content

Add getIconUrlFromIssuer helper#40

Merged
CassioMG merged 2 commits intomainfrom
cg-get-issuer-icon
Mar 24, 2025
Merged

Add getIconUrlFromIssuer helper#40
CassioMG merged 2 commits intomainfrom
cg-get-issuer-icon

Conversation

@CassioMG
Copy link
Copy Markdown
Contributor

This PR adds a getIconUrlFromIssuer ported from the extension's helper with same name which should be able to fetch the asset image from issuer's TOML file if any.

In a later PR we should account for caching those images to reduce the number of requests.

This helper will work in conjunction with the Asset component to display any asset image on the app.

getIconUrlFromIssuer

Retrieves an icon URL for a Stellar asset based on its issuer information.

This function follows a multi-step process to find an asset's icon URL:

  1. Queries Horizon to get the issuer account information, including home domain
  2. Retrieves the stellar.toml file from the issuer's home domain
  3. Searches the toml file's CURRENCIES section for matching asset code and issuer
  4. Returns the image URL if found, or empty string if any step fails

The process requires multiple network requests:

  • One to Horizon to get issuer info
  • One to the issuer's domain to get the stellar.toml file
  • Later, one to fetch the actual image (handled by the caller)
@example
// Get icon URL for USDC on testnet
const iconUrl = await getIconUrlFromIssuer({
  issuerKey: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
  assetCode: "USDC",
  networkDetails: TESTNET_NETWORK_DETAILS
});
Screenshot 2025-03-20 at 17 48 05

@CassioMG CassioMG merged commit 3405ea8 into main Mar 24, 2025
1 check passed
@CassioMG CassioMG deleted the cg-get-issuer-icon branch March 24, 2025 16:12
@CassioMG CassioMG self-assigned this Mar 30, 2025
@github-actions github-actions Bot mentioned this pull request Nov 24, 2025
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.

2 participants