diff options
author | Jake Ellowitz <jake.ellowitz@gmail.com> | 2018-11-20 08:24:07 +0800 |
---|---|---|
committer | Fred Carlsen <fred@sjelfull.no> | 2018-12-06 19:04:25 +0800 |
commit | 75df8a0e8b375f198555f55bd6ed47af75c2b043 (patch) | |
tree | 3995136e11c3583378490796a155eadf8bf72f94 /packages/pipeline/src/parsers | |
parent | f3c28afedd6864e35a17245eb7c187d1c129c35a (diff) | |
download | dexon-0x-contracts-75df8a0e8b375f198555f55bd6ed47af75c2b043.tar dexon-0x-contracts-75df8a0e8b375f198555f55bd6ed47af75c2b043.tar.gz dexon-0x-contracts-75df8a0e8b375f198555f55bd6ed47af75c2b043.tar.bz2 dexon-0x-contracts-75df8a0e8b375f198555f55bd6ed47af75c2b043.tar.lz dexon-0x-contracts-75df8a0e8b375f198555f55bd6ed47af75c2b043.tar.xz dexon-0x-contracts-75df8a0e8b375f198555f55bd6ed47af75c2b043.tar.zst dexon-0x-contracts-75df8a0e8b375f198555f55bd6ed47af75c2b043.zip |
Pull token metadata re trusted tokens
Diffstat (limited to 'packages/pipeline/src/parsers')
-rw-r--r-- | packages/pipeline/src/parsers/ohlcv_external/index.ts | 0 | ||||
-rw-r--r-- | packages/pipeline/src/parsers/trusted_tokens/index.ts | 37 |
2 files changed, 37 insertions, 0 deletions
diff --git a/packages/pipeline/src/parsers/ohlcv_external/index.ts b/packages/pipeline/src/parsers/ohlcv_external/index.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/packages/pipeline/src/parsers/ohlcv_external/index.ts diff --git a/packages/pipeline/src/parsers/trusted_tokens/index.ts b/packages/pipeline/src/parsers/trusted_tokens/index.ts new file mode 100644 index 000000000..a6d32de35 --- /dev/null +++ b/packages/pipeline/src/parsers/trusted_tokens/index.ts @@ -0,0 +1,37 @@ +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; +} |