synapsecns/sanguine

View on GitHub
packages/rest-api/src/utils/tokenSymbolToToken.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { BRIDGE_MAP } from '../constants/bridgeMap'

export const tokenSymbolToToken = (chain: string, tokenSymbol: string) => {
  const chainData = BRIDGE_MAP[chain]
  if (!chainData) {
    return null
  }
  for (const tokenAddress in chainData) {
    if (chainData[tokenAddress].symbol === tokenSymbol) {
      return {
        address: tokenAddress,
        decimals: chainData[tokenAddress].decimals,
      }
    }
  }
  return null
}