aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/parsers
diff options
context:
space:
mode:
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;
+}