[TokenList] Improve tokentype for binance. Add TokenType

This commit is contained in:
Viktor Radchenko 2020-10-22 21:36:39 -07:00
parent 1cea1a638e
commit 9d02da5cd3
3 changed files with 147 additions and 140 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,7 @@ import { assetID } from "./asset";
import * as config from "../config"; import * as config from "../config";
import { CoinType } from "@trustwallet/wallet-core"; import { CoinType } from "@trustwallet/wallet-core";
import { toSatoshis } from "./numbers"; import { toSatoshis } from "./numbers";
import { TokenType } from "./tokentype";
enum TokenType {
BEP2 = 'BEP2',
ERC20 = 'ERC20'
}
class BinanceMarket { class BinanceMarket {
base_asset_symbol: string base_asset_symbol: string
@ -161,15 +157,21 @@ async function generateBinanceTokensList(): Promise<[TokenItem]> {
} }
return assetID(CoinType.binance, symbol) return assetID(CoinType.binance, symbol)
} }
function tokenType(symbol: string): string {
if (symbol == BNBSymbol) {
return TokenType.COIN
}
return TokenType.BEP2
}
const list = <[string]>Array.from(pairsList.values()) const list = <[string]>Array.from(pairsList.values())
return <[TokenItem]>list.map(item => { return <[TokenItem]>list.map(item => {
const token = tokensMap[item] const token = tokensMap[item]
return new TokenItem ( return new TokenItem (
asset(token.symbol), asset(token.symbol),
TokenType.BEP2, tokenType(token.symbol),
token.symbol, token.symbol,
token.name, token.name,
token.symbol, token.original_symbol,
decimals, decimals,
logoURI(token.symbol), logoURI(token.symbol),
pairsMap[token.symbol] || [] pairsMap[token.symbol] || []

View File

@ -0,0 +1,5 @@
export enum TokenType {
COIN = 'coin',
BEP2 = 'BEP2',
ERC20 = 'ERC20'
}