aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Ellowitz <jake.ellowitz@gmail.com>2018-11-20 11:11:51 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-13 01:17:26 +0800
commitb538fabdef06d734661997a00960bc8a628506f2 (patch)
treef400ace4fdf86649b5109e832ae5f7acfbda4a44
parent01716e0d5105afffeae4257cf918509de3963a5d (diff)
downloaddexon-0x-contracts-b538fabdef06d734661997a00960bc8a628506f2.tar
dexon-0x-contracts-b538fabdef06d734661997a00960bc8a628506f2.tar.gz
dexon-0x-contracts-b538fabdef06d734661997a00960bc8a628506f2.tar.bz2
dexon-0x-contracts-b538fabdef06d734661997a00960bc8a628506f2.tar.lz
dexon-0x-contracts-b538fabdef06d734661997a00960bc8a628506f2.tar.xz
dexon-0x-contracts-b538fabdef06d734661997a00960bc8a628506f2.tar.zst
dexon-0x-contracts-b538fabdef06d734661997a00960bc8a628506f2.zip
metadata and trusted sources in same raw table
-rw-r--r--packages/pipeline/src/entities/token_on_chain_metadata.ts22
-rw-r--r--packages/pipeline/src/entities/trusted_tokens.ts7
-rw-r--r--packages/pipeline/src/parsers/token_metadata/index.ts10
-rw-r--r--packages/pipeline/src/parsers/trusted_tokens/index.ts37
4 files changed, 5 insertions, 71 deletions
diff --git a/packages/pipeline/src/entities/token_on_chain_metadata.ts b/packages/pipeline/src/entities/token_on_chain_metadata.ts
deleted file mode 100644
index ca1f1827b..000000000
--- a/packages/pipeline/src/entities/token_on_chain_metadata.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Column, Entity, PrimaryColumn } from 'typeorm';
-
-@Entity({ name: 'token_on_chain_metadata', schema: 'raw' })
-export class TokenOnChainMetadata {
- @PrimaryColumn({ type: 'nvarchar', nullable: false })
- public address!: string;
-
- @Column({ type: 'integer', nullable: false })
- public decimals!: number;
-
- @Column({ type: 'nvarchar', nullable: false })
- public symbol!: string;
-
- @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
deleted file mode 100644
index 6ec27c963..000000000
--- a/packages/pipeline/src/entities/trusted_tokens.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-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/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;
-}