updating comment for 0x trusted tokens
This commit is contained in:
committed by
Alex Browne
parent
dea89c4e22
commit
1aa3f9d69f
@@ -1,10 +1,8 @@
|
||||
import {MigrationInterface, QueryRunner} from 'typeorm';
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class NewMetadataAndOHLCVTables1542655823221 implements MigrationInterface {
|
||||
|
||||
// tslint:disable-next-line
|
||||
public async up(queryRunner: QueryRunner): Promise<any> {
|
||||
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE raw.token_metadata (
|
||||
address VARCHAR NOT NULL,
|
||||
@@ -44,7 +42,6 @@ export class NewMetadataAndOHLCVTables1542655823221 implements MigrationInterfac
|
||||
|
||||
// tslint:disable-next-line
|
||||
public async down(queryRunner: QueryRunner): Promise<any> {
|
||||
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE raw.token_on_chain_metadata (
|
||||
address VARCHAR NOT NULL,
|
||||
@@ -60,5 +57,4 @@ export class NewMetadataAndOHLCVTables1542655823221 implements MigrationInterfac
|
||||
|
||||
await queryRunner.dropTable('raw.ohlcv_external');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,14 +14,13 @@ export function parseMetamaskTrustedTokens(rawResp: Map<string, MetamaskTrustedT
|
||||
|
||||
/**
|
||||
* Parses 0x's trusted tokens list.
|
||||
* @param rawResp raw response from the 0x json file.
|
||||
* @param rawResp raw response from the 0x trusted tokens 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;
|
||||
@@ -34,7 +33,6 @@ function parseMetamaskTrustedToken(resp: MetamaskTrustedTokenMeta, address: stri
|
||||
}
|
||||
|
||||
function parseZeroExTrustedToken(resp: ZeroExTrustedTokenMeta): TokenMetadata {
|
||||
|
||||
const trustedToken = new TokenMetadata();
|
||||
|
||||
trustedToken.address = resp.address;
|
||||
|
||||
@@ -10,8 +10,7 @@ import { handleError } from '../utils';
|
||||
const METAMASK_TRUSTED_TOKENS_URL =
|
||||
'https://raw.githubusercontent.com/MetaMask/eth-contract-metadata/master/contract-map.json';
|
||||
|
||||
const ZEROEX_TRUSTED_TOKENS_URL =
|
||||
'https://website-api.0xproject.com/tokens';
|
||||
const ZEROEX_TRUSTED_TOKENS_URL = 'https://website-api.0xproject.com/tokens';
|
||||
|
||||
let connection: Connection;
|
||||
|
||||
@@ -26,14 +25,16 @@ async function getMetamaskTrustedTokens(): Promise<void> {
|
||||
// tslint:disable-next-line
|
||||
console.log('Getting latest metamask trusted tokens list ...');
|
||||
const trustedTokensRepository = connection.getRepository(TokenMetadata);
|
||||
const trustedTokensSource = new TrustedTokenSource<Map<string, MetamaskTrustedTokenMeta>>(METAMASK_TRUSTED_TOKENS_URL);
|
||||
const trustedTokensSource = new TrustedTokenSource<Map<string, MetamaskTrustedTokenMeta>>(
|
||||
METAMASK_TRUSTED_TOKENS_URL,
|
||||
);
|
||||
const resp = await trustedTokensSource.getTrustedTokenMetaAsync();
|
||||
const trustedTokens = parseMetamaskTrustedTokens(resp);
|
||||
// tslint:disable-next-line
|
||||
console.log('Saving metamask trusted tokens list');
|
||||
await trustedTokensRepository.save(trustedTokens);
|
||||
// tslint:disable-next-line
|
||||
console.log('Done saving metamask trusted tokens.')
|
||||
console.log('Done saving metamask trusted tokens.');
|
||||
}
|
||||
|
||||
async function getZeroExTrustedTokens(): Promise<void> {
|
||||
|
||||
@@ -56,5 +56,5 @@ export const bigNumberTransformer = new BigNumberTransformer();
|
||||
export function getHourInUnixTime(): number {
|
||||
const currentTime: number = Date.now();
|
||||
// tslint:disable-next-line
|
||||
return currentTime - (currentTime % (3600 * 1000));
|
||||
return currentTime - currentTime % (3600 * 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user