diff options
author | Jake Ellowitz <jake.ellowitz@gmail.com> | 2018-11-20 11:11:51 +0800 |
---|---|---|
committer | Fred Carlsen <fred@sjelfull.no> | 2018-12-13 01:17:26 +0800 |
commit | b538fabdef06d734661997a00960bc8a628506f2 (patch) | |
tree | f400ace4fdf86649b5109e832ae5f7acfbda4a44 /packages/pipeline/src/parsers | |
parent | 01716e0d5105afffeae4257cf918509de3963a5d (diff) | |
download | dexon-sol-tools-b538fabdef06d734661997a00960bc8a628506f2.tar dexon-sol-tools-b538fabdef06d734661997a00960bc8a628506f2.tar.gz dexon-sol-tools-b538fabdef06d734661997a00960bc8a628506f2.tar.bz2 dexon-sol-tools-b538fabdef06d734661997a00960bc8a628506f2.tar.lz dexon-sol-tools-b538fabdef06d734661997a00960bc8a628506f2.tar.xz dexon-sol-tools-b538fabdef06d734661997a00960bc8a628506f2.tar.zst dexon-sol-tools-b538fabdef06d734661997a00960bc8a628506f2.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 | 10 | ||||
-rw-r--r-- | packages/pipeline/src/parsers/trusted_tokens/index.ts | 37 |
2 files changed, 5 insertions, 42 deletions
diff --git a/packages/pipeline/src/parsers/token_metadata/index.ts b/packages/pipeline/src/parsers/token_metadata/index.ts index 3b3e05d76..d09def0db 100644 --- a/packages/pipeline/src/parsers/token_metadata/index.ts +++ b/packages/pipeline/src/parsers/token_metadata/index.ts @@ -1,9 +1,7 @@ -import { BigNumber } from '@0x/utils'; import * as R from 'ramda'; import { MetamaskTrustedTokenMeta, ZeroExTrustedTokenMeta } from '../../data_sources/trusted_tokens'; import { TokenMetadata } from '../../entities'; -import {} from '../../utils'; /** * Parses Metamask's trusted tokens list. @@ -16,17 +14,18 @@ export function parseMetamaskTrustedTokens(rawResp: Map<string, MetamaskTrustedT /** * Parses 0x's trusted tokens list. - * @param rawResp raw response from the 0x trusted tokens file. + * @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): TokenMetadata { + const trustedToken = new TokenMetadata(); trustedToken.address = address; - trustedToken.decimals = new BigNumber(resp.decimals); + trustedToken.decimals = resp.decimals; trustedToken.symbol = resp.symbol; trustedToken.name = resp.name; trustedToken.authority = 'metamask'; @@ -35,10 +34,11 @@ function parseMetamaskTrustedToken(resp: MetamaskTrustedTokenMeta, address: stri } function parseZeroExTrustedToken(resp: ZeroExTrustedTokenMeta): TokenMetadata { + const trustedToken = new TokenMetadata(); trustedToken.address = resp.address; - trustedToken.decimals = new BigNumber(resp.decimals); + trustedToken.decimals = resp.decimals; trustedToken.symbol = resp.symbol; trustedToken.name = resp.name; trustedToken.authority = '0x'; diff --git a/packages/pipeline/src/parsers/trusted_tokens/index.ts b/packages/pipeline/src/parsers/trusted_tokens/index.ts deleted file mode 100644 index a6d32de35..000000000 --- a/packages/pipeline/src/parsers/trusted_tokens/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import * as R from 'ramda'; - -import { MetamaskTrustedTokenMeta, ZeroExTrustedTokenMeta } from '../../data_sources/trusted_tokens'; -import { TrustedToken } 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[] { - const parsedAsObject = R.mapObjIndexed(parseMetamaskTrustedToken, rawResp); - return R.values(parsedAsObject); -} - -export function parseZeroExTrustedTokens(rawResp: ZeroExTrustedTokenMeta[]): TrustedToken[] { - return R.map(parseZeroExTrustedToken, rawResp); -} - -function parseMetamaskTrustedToken(resp: MetamaskTrustedTokenMeta, address: string): TrustedToken { - - const trustedToken = new TrustedToken(); - - trustedToken.address = address; - trustedToken.authority = 'metamask'; - - return trustedToken; -} - -function parseZeroExTrustedToken(resp: ZeroExTrustedTokenMeta): TrustedToken { - - const trustedToken = new TrustedToken(); - - trustedToken.address = resp.address; - trustedToken.authority = '0x'; - - return trustedToken; -} |