solana-labs / explorer

Explorer for Solana clusters
https://explorer.solana.com
MIT License
225 stars 286 forks source link

explorer: Use Unified Token-list API #201

Closed jacobcreech closed 1 year ago

jacobcreech commented 2 years ago

Problem

Currently the explorer queries the following to get token-metadata:

  1. Check if Token is in the legacy token-list
  2. If not in token-list try on-chain via Metaplex Fungible token metadata

This has the following problems:

  1. Wallets do metaplex fungible token metadata first, then legacy token-list. This allows someone with a token to update their metadata by creating the on-chain account
  2. We have to load the legacy token-list on the front end to manage searching, querying, etc
  3. Searching for on-chain metadata via the searchbar is not done today, and is not feasible via getProgramAccounts (nor recommended)

Proposed Solution

Solflare created a Unified Token API that manages caching, searching, and verifying tokens via coingecko, legacy token-list, and Metaplex Fungible token metadata.

Proposal is to use it to create a faster experience for users on the explorer searching and viewing their tokens.

We have two options:

  1. Deploy our own instance and use it
  2. Use Solflare's public API https://token-list-api.solana.cloud (The team is fine with the explorer using it)

Proposing we use option 2 for speed to ship. Happy to work on it if consensus is met.

cc: @steveluscher @jstarry

ngundotra commented 1 year ago

@jacobcreech can you provide some examples where the current behavior is incorrect, or unacceptably slow?

jacobcreech commented 1 year ago

Explorer currently uses @solana/spl-token-registry which has a scary large bundlesize of 1.1MB gzipped, adding up to 23s on slower network speeds. Doing these legacy token-list lookups on a backend is much faster.

Searchbar token logos seems to have since been removed when searching.

Coingecko as a first choice when looking up metadata can be added to unified token-list as well, removing issues with certain protocols trying to update their now locked token metadata and pushing liability to coingecko. Example: Kin can't update their logo anymore and is incorrect on our explorer, while solanafm and coingecko have the updated logo.

ngundotra commented 1 year ago

Will come back to this once we've migrated the website to Next JS