Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solana Explorer: Token display names vs addresses in detailed mode #207

Open
amilz opened this issue Jan 10, 2023 · 1 comment
Open

Solana Explorer: Token display names vs addresses in detailed mode #207

amilz opened this issue Jan 10, 2023 · 1 comment

Comments

@amilz
Copy link
Contributor

amilz commented Jan 10, 2023

Problem

Solana Explorer Token Details tab loses known token names for some tokens (my hunch is those with newer Metaplex metadata post token registry). See example below:

Screen.Recording.2023-01-09.at.7.15.04.PM.mov

Expected Results: either mint token display name is displayed for all tokens in or the public key is show for all in detailed mode (not a mix of both).

Experienced: (see video) some tokens toggle to Public Key in detailed mode while others maintain their display name (eg, Samo).
Link to example

Proposed Solution

My hunch is there's a state issue with the token registry and the newer metaplex metadata. Probably an easy fix. I'll try to do some research when I have more time.

@amilz
Copy link
Contributor Author

amilz commented Jan 10, 2023

The <Address > component for mint is passed with parameters link and truncate at line 133: https://github.com/solana-labs/solana/blob/db0bff06686c9b1778fd99f2fa376aa72b99d749/explorer/src/components/account/OwnedTokensCard.tsx#L133

Here's where the addressLabel is defined:
https://github.com/solana-labs/solana/blob/db0bff06686c9b1778fd99f2fa376aa72b99d749/explorer/src/components/common/Address.tsx#L46-59

  let addressLabel = raw
    ? address
    : displayAddress(address, cluster, tokenRegistry);

  var metaplexData = useTokenMetadata(useMetadata, address);
  if (metaplexData && metaplexData.data)
    addressLabel = metaplexData.data.data.name;
  if (truncateChars && addressLabel === address) {
    addressLabel = addressLabel.slice(0, truncateChars) + "…";
  }

  if (overrideText) {
    addressLabel = overrideText;
  }

Since raw is not called in <Address>, any token in the tokenRegisry will return their name.
useMetaData, however, is not called, so newer tokens would not return their name.

Proposed Solution
Update https://github.com/solana-labs/solana/blob/db0bff06686c9b1778fd99f2fa376aa72b99d749/explorer/src/components/account/OwnedTokensCard.tsx#L133
with

  • Option A: add raw : <Address pubkey={tokenAccount.info.mint} link truncate raw />
    outcome: display only truncated addresses for all
  • Option B: add useMetadata : <Address pubkey={tokenAccount.info.mint} link truncate useMetadata />
    outcome: display names for any with names (should match the basic view)

Personally, I prefer option B even in detail but I think there's a strong case for Option A.
I'll try and give these a test later this week and can get a PR put together. LMK if you have an opinion!

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

No branches or pull requests

2 participants
@amilz and others