Skip to content

Commit

Permalink
feat(blockchain-link-utils): add meta for solana BONK token
Browse files Browse the repository at this point in the history
(cherry picked from commit c8e1762)
  • Loading branch information
PeterBenc authored and komret committed Jan 4, 2024
1 parent 7397a41 commit 3e0cd26
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/blockchain-link-utils/src/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ export const WSOL_MINT = 'So11111111111111111111111111111111111111112';

// https://github.com/viaprotocol/tokenlists
// Aggregated token list with tokens listed on multiple exchanges
const solanaTokenListUrl =
const SOLANA_TOKEN_LIST_URL =
'https://cdn.jsdelivr.net/gh/viaprotocol/tokenlists/all_tokens/solana.json';

const LOCAL_TOKEN_METADATA: TokenDetailByMint = {
DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263: {
name: 'Bonk',
symbol: 'BONK',
},
};

export const getTokenMetadata = async (): Promise<TokenDetailByMint> => {
const tokenListResult: { address: string; name: string; symbol: string }[] = await (
await fetch(solanaTokenListUrl)
await fetch(SOLANA_TOKEN_LIST_URL)
).json();

const tokenMap = tokenListResult.reduce(
Expand All @@ -52,7 +59,7 @@ export const getTokenMetadata = async (): Promise<TokenDetailByMint> => {
// Explicitly set Wrapped SOL symbol to WSOL instead of the official 'SOL' which leads to confusion in UI
tokenMap[WSOL_MINT].symbol = 'WSOL';

return tokenMap;
return { ...LOCAL_TOKEN_METADATA, ...tokenMap };
};

export const getTokenNameAndSymbol = (mint: string, tokenDetailByMint: TokenDetailByMint) => {
Expand Down

0 comments on commit 3e0cd26

Please sign in to comment.