aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJake Ellowitz <jake.ellowitz@gmail.com>2018-11-20 08:24:07 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-13 01:17:13 +0800
commit01716e0d5105afffeae4257cf918509de3963a5d (patch)
tree8aa92e354c3ef75316e0673bb858789ae2460d45 /packages
parent7cd3f3ceadeb6de152648d8398051a6384d7c14d (diff)
downloaddexon-sol-tools-01716e0d5105afffeae4257cf918509de3963a5d.tar
dexon-sol-tools-01716e0d5105afffeae4257cf918509de3963a5d.tar.gz
dexon-sol-tools-01716e0d5105afffeae4257cf918509de3963a5d.tar.bz2
dexon-sol-tools-01716e0d5105afffeae4257cf918509de3963a5d.tar.lz
dexon-sol-tools-01716e0d5105afffeae4257cf918509de3963a5d.tar.xz
dexon-sol-tools-01716e0d5105afffeae4257cf918509de3963a5d.tar.zst
dexon-sol-tools-01716e0d5105afffeae4257cf918509de3963a5d.zip
Pull token metadata re trusted tokens
Diffstat (limited to 'packages')
-rw-r--r--packages/pipeline/src/entities/token_on_chain_metadata.ts6
-rw-r--r--packages/pipeline/src/entities/trusted_tokens.ts7
-rw-r--r--packages/pipeline/src/ormconfig.ts2
-rw-r--r--packages/pipeline/src/parsers/ohlcv_external/index.ts0
-rw-r--r--packages/pipeline/src/parsers/trusted_tokens/index.ts37
5 files changed, 52 insertions, 0 deletions
diff --git a/packages/pipeline/src/entities/token_on_chain_metadata.ts b/packages/pipeline/src/entities/token_on_chain_metadata.ts
index 325d28e91..ca1f1827b 100644
--- a/packages/pipeline/src/entities/token_on_chain_metadata.ts
+++ b/packages/pipeline/src/entities/token_on_chain_metadata.ts
@@ -14,3 +14,9 @@ export class TokenOnChainMetadata {
@Column({ type: 'nvarchar', nullable: false })
public name!: string;
}
+
+@Entity({ name: 'trusted_tokens', schema: 'raw' })
+export class TrustedTokens {
+ @PrimaryColumn() public address!: string;
+ @PrimaryColumn() public authority!: string;
+}
diff --git a/packages/pipeline/src/entities/trusted_tokens.ts b/packages/pipeline/src/entities/trusted_tokens.ts
new file mode 100644
index 000000000..6ec27c963
--- /dev/null
+++ b/packages/pipeline/src/entities/trusted_tokens.ts
@@ -0,0 +1,7 @@
+import { Column, Entity, PrimaryColumn } from 'typeorm';
+
+@Entity({ name: 'trusted_tokens', schema: 'raw' })
+export class TrustedToken {
+ @PrimaryColumn() public address!: string;
+ @PrimaryColumn() public authority!: string;
+}
diff --git a/packages/pipeline/src/ormconfig.ts b/packages/pipeline/src/ormconfig.ts
index 9f7815b4e..b60703790 100644
--- a/packages/pipeline/src/ormconfig.ts
+++ b/packages/pipeline/src/ormconfig.ts
@@ -13,6 +13,7 @@ import {
TokenMetadata,
TokenOrderbookSnapshot,
Transaction,
+ TrustedToken,
} from './entities';
const entities = [
@@ -28,6 +29,7 @@ const entities = [
TokenMetadata,
TokenOrderbookSnapshot,
Transaction,
+ TrustedToken,
];
const config: ConnectionOptions = {
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;
+}