aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/parsers
diff options
context:
space:
mode:
authorJake Ellowitz <jake.ellowitz@gmail.com>2018-11-20 08:24:07 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-12-05 06:24:48 +0800
commitc6af5131b0b06433d6294260274e187ad61f4ef7 (patch)
tree338aaeaaa2673ea4c33773e3f99c53e4a10e3c42 /packages/pipeline/src/parsers
parent9986717671fe8e14c2168f7479bdaffe406bedc0 (diff)
downloaddexon-sol-tools-c6af5131b0b06433d6294260274e187ad61f4ef7.tar
dexon-sol-tools-c6af5131b0b06433d6294260274e187ad61f4ef7.tar.gz
dexon-sol-tools-c6af5131b0b06433d6294260274e187ad61f4ef7.tar.bz2
dexon-sol-tools-c6af5131b0b06433d6294260274e187ad61f4ef7.tar.lz
dexon-sol-tools-c6af5131b0b06433d6294260274e187ad61f4ef7.tar.xz
dexon-sol-tools-c6af5131b0b06433d6294260274e187ad61f4ef7.tar.zst
dexon-sol-tools-c6af5131b0b06433d6294260274e187ad61f4ef7.zip
Pull token metadata re trusted tokens
Diffstat (limited to 'packages/pipeline/src/parsers')
-rw-r--r--packages/pipeline/src/parsers/ohlcv_external/index.ts0
-rw-r--r--packages/pipeline/src/parsers/trusted_tokens/index.ts37
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;
+}