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

Network/Token icon #13630

Closed
tomasklim opened this issue Aug 2, 2024 · 5 comments · Fixed by #13921
Closed

Network/Token icon #13630

tomasklim opened this issue Aug 2, 2024 · 5 comments · Fixed by #13921
Assignees

Comments

@tomasklim
Copy link
Member

tomasklim commented Aug 2, 2024

Prerequisite #12694

Description:
Create component to show icon/logo of an asset.
Create another component which will add ring around the asset. This ring should have part filled using dominant color of the icon.

Screenshot 2024-08-02 at 22 25 38

In case file is not available, show first letter

Screenshot 2024-08-02 at 22 26 58

In case file nor text are available, show ? instead of the letters.


Files:

Assets which we have as a network are available offline in packages/components/src/images/coins

  • naming:
    • [network].svg
    • as it is svg, it can be scaled to whatever sizes

Assets available on data.trezor.io

#13768 there is change from _ separator to --

354698861-f7c9acbe-da6e-443c-b8e7-35af38ec9964

Beware of:

  • networkSymbol !== coingecko_id
    • coingecko_id is available in networksConfig.ts for each network except testnets
  • to find out how @2x should be used, visit Image.tsx
  • offline icon is preferred (just for networks) (those can have bigger size if we need it, please decide)
  • in case network is ada please try fetch 2 urls, see buildCoinUrls in coingecko.ts
    if (ticker.symbol === 'ada') {
        const { policyId } = parseAsset(contract_address);

        return [`cardano_{policyId}`, `cardano_{contract_address}`];
    }

Api:

// CoinLogo (can be deprecated in the future because we will have AssetLogo)
// ------------------------------------------
// we already use this component

type CoinLogoProps = {
  size: number; // can be any, we have it as SVG
  symbol: NetworkSymbol;
}

<CoinLogo symbol="btc" size={30} />

// AssetLogo 
// ------------------------------------------
// new component for rendering token logo
// icon is fetched from API 

type AssetLogoProps = {
  size: 20 | 24; // + inner implementation for @2x (srcSet on img)
  coingeckoId: string; // this is coingecko id, we can maybe also provide symbol and do translation inside?
  contractAddress?: string; 
  shouldTryToFetch?: boolean; // (by default true) we know that some images are not available
  placeholder: string; // letters when unavailable
}

<AssetLogo 
  coingeckoId="binance-smart-chain" 
  contractAddress="0x0203d275d2a65030889af45ed91d472be3948b92"
  size={24} 
  shouldTryToFetch={true} 
  placeholder="CATWIFHAT"
/>


// ShareIndicator
// ------------------------------------------
// - uses coin/token logos icons independently

type ShareIndicatorProps = {
  percentageShare: number; // 0-100
  image: ReactNode;
}

// ShareIndicator using coin logo
<ShareIndicator 
  percentageShare={90}
  image={<CoinLogo 
    symbol="btc" 
    size={30}
  />}
/>

// ShareIndicator using asset logo
<ShareIndicator 
  percentageShare={90}
  image={<AssetLogo 
      coingeckoId="binance-smart-chain" 
      symbol //
      contractAddress="0x0203d275d2a65030889af45ed91d472be3948b92"
      size={24} 
      shouldTryToFetch={true} 
      placeholder="CATWIFHAT"
  />}
/>
@tomasklim tomasklim changed the title Token icon Network/Token icon Aug 2, 2024
@ffrediani
Copy link

Is the download of the main token images still a prerequisite to be done ?
I see there is a pending pull request, but it seems there are issues within it ? Does that make it is still a work in progress and may not come up in the next versions to come soon ?

@ffrediani
Copy link

I can't see any token icons (ex: WBTC) inside Ethereum Coins tab in Trezor Suite. What happened ?

@Hannsek
Copy link
Contributor

Hannsek commented Aug 28, 2024

It is not released yet.

@ffrediani
Copy link

@Hannsek would share when will that become visible on Trezor Suite ?

@Hannsek
Copy link
Contributor

Hannsek commented Aug 28, 2024

It should be out next release - in 2 weeks. cc @MiroslavProchazka

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Approved
4 participants