Add utilities for getting tokens from tokensByAddress
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
import { configs } from 'ts/utils/configs';
|
||||
import { constants } from 'ts/utils/constants';
|
||||
import * as u2f from 'ts/vendor/u2f_api';
|
||||
import { Container } from '../components/ui/container';
|
||||
|
||||
const LG_MIN_EM = 64;
|
||||
const MD_MIN_EM = 52;
|
||||
@@ -322,8 +323,14 @@ export const utils = {
|
||||
return this.isDevelopment() || this.isStaging() || this.isDogfood();
|
||||
},
|
||||
getEthToken(tokenByAddress: TokenByAddress): Token {
|
||||
return utils.getTokenBySymbol(constants.ETHER_TOKEN_SYMBOL, tokenByAddress);
|
||||
},
|
||||
getZrxToken(tokenByAddress: TokenByAddress): Token {
|
||||
return utils.getTokenBySymbol(constants.ZRX_TOKEN_SYMBOL, tokenByAddress);
|
||||
},
|
||||
getTokenBySymbol(symbol: string, tokenByAddress: TokenByAddress): Token {
|
||||
const tokens = _.values(tokenByAddress);
|
||||
const etherToken = _.find(tokens, { symbol: constants.ETHER_TOKEN_SYMBOL });
|
||||
return etherToken;
|
||||
const token = _.find(tokens, { symbol });
|
||||
return token;
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user