diff options
author | Jake Ellowitz <jake.ellowitz@gmail.com> | 2018-11-20 11:11:51 +0800 |
---|---|---|
committer | Fred Carlsen <fred@sjelfull.no> | 2018-12-06 19:04:25 +0800 |
commit | 72c45d9ea90237d87053fd1ddc751fc699527937 (patch) | |
tree | 140a9b62ec450fa2cfb2ac39c90265638ab2ce0c /packages/pipeline/src/parsers | |
parent | 75df8a0e8b375f198555f55bd6ed47af75c2b043 (diff) | |
download | dexon-sol-tools-72c45d9ea90237d87053fd1ddc751fc699527937.tar dexon-sol-tools-72c45d9ea90237d87053fd1ddc751fc699527937.tar.gz dexon-sol-tools-72c45d9ea90237d87053fd1ddc751fc699527937.tar.bz2 dexon-sol-tools-72c45d9ea90237d87053fd1ddc751fc699527937.tar.lz dexon-sol-tools-72c45d9ea90237d87053fd1ddc751fc699527937.tar.xz dexon-sol-tools-72c45d9ea90237d87053fd1ddc751fc699527937.tar.zst dexon-sol-tools-72c45d9ea90237d87053fd1ddc751fc699527937.zip |
metadata and trusted sources in same raw table
Diffstat (limited to 'packages/pipeline/src/parsers')
-rw-r--r-- | packages/pipeline/src/parsers/token_metadata/index.ts (renamed from packages/pipeline/src/parsers/trusted_tokens/index.ts) | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/packages/pipeline/src/parsers/trusted_tokens/index.ts b/packages/pipeline/src/parsers/token_metadata/index.ts index a6d32de35..d09def0db 100644 --- a/packages/pipeline/src/parsers/trusted_tokens/index.ts +++ b/packages/pipeline/src/parsers/token_metadata/index.ts @@ -1,36 +1,46 @@ import * as R from 'ramda'; import { MetamaskTrustedTokenMeta, ZeroExTrustedTokenMeta } from '../../data_sources/trusted_tokens'; -import { TrustedToken } from '../../entities'; +import { TokenMetadata } from '../../entities'; /** * Parses Metamask's trusted tokens list. * @param rawResp raw response from the metamask json file. */ -export function parseMetamaskTrustedTokens(rawResp: Map<string, MetamaskTrustedTokenMeta>): TrustedToken[] { +export function parseMetamaskTrustedTokens(rawResp: Map<string, MetamaskTrustedTokenMeta>): TokenMetadata[] { const parsedAsObject = R.mapObjIndexed(parseMetamaskTrustedToken, rawResp); return R.values(parsedAsObject); } -export function parseZeroExTrustedTokens(rawResp: ZeroExTrustedTokenMeta[]): TrustedToken[] { +/** + * Parses 0x's trusted tokens list. + * @param rawResp raw response from the 0x json file. + */ +export function parseZeroExTrustedTokens(rawResp: ZeroExTrustedTokenMeta[]): TokenMetadata[] { return R.map(parseZeroExTrustedToken, rawResp); } -function parseMetamaskTrustedToken(resp: MetamaskTrustedTokenMeta, address: string): TrustedToken { +function parseMetamaskTrustedToken(resp: MetamaskTrustedTokenMeta, address: string): TokenMetadata { - const trustedToken = new TrustedToken(); + const trustedToken = new TokenMetadata(); trustedToken.address = address; + trustedToken.decimals = resp.decimals; + trustedToken.symbol = resp.symbol; + trustedToken.name = resp.name; trustedToken.authority = 'metamask'; return trustedToken; } -function parseZeroExTrustedToken(resp: ZeroExTrustedTokenMeta): TrustedToken { +function parseZeroExTrustedToken(resp: ZeroExTrustedTokenMeta): TokenMetadata { - const trustedToken = new TrustedToken(); + const trustedToken = new TokenMetadata(); trustedToken.address = resp.address; + trustedToken.decimals = resp.decimals; + trustedToken.symbol = resp.symbol; + trustedToken.name = resp.name; trustedToken.authority = '0x'; return trustedToken; |