diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-11-08 07:29:34 +0800 |
---|---|---|
committer | Fred Carlsen <fred@sjelfull.no> | 2018-12-06 19:04:24 +0800 |
commit | 62412b8551d1171844c9cdb30f2b2fe0ab2ba66b (patch) | |
tree | 41d3165343b75a802f3004fae1dcea081ac01a11 /packages/pipeline | |
parent | 374d51309007ceef8112b5999195e20e49b26c5f (diff) | |
download | dexon-sol-tools-62412b8551d1171844c9cdb30f2b2fe0ab2ba66b.tar dexon-sol-tools-62412b8551d1171844c9cdb30f2b2fe0ab2ba66b.tar.gz dexon-sol-tools-62412b8551d1171844c9cdb30f2b2fe0ab2ba66b.tar.bz2 dexon-sol-tools-62412b8551d1171844c9cdb30f2b2fe0ab2ba66b.tar.lz dexon-sol-tools-62412b8551d1171844c9cdb30f2b2fe0ab2ba66b.tar.xz dexon-sol-tools-62412b8551d1171844c9cdb30f2b2fe0ab2ba66b.tar.zst dexon-sol-tools-62412b8551d1171844c9cdb30f2b2fe0ab2ba66b.zip |
Update relayer code to use new relayer-registry format
Diffstat (limited to 'packages/pipeline')
-rw-r--r-- | packages/pipeline/src/data_sources/relayer-registry/index.ts | 4 | ||||
-rw-r--r-- | packages/pipeline/src/entities/Relayer.ts | 3 | ||||
-rw-r--r-- | packages/pipeline/src/index.ts | 5 | ||||
-rw-r--r-- | packages/pipeline/src/parsers/relayer_registry/index.ts | 8 |
4 files changed, 14 insertions, 6 deletions
diff --git a/packages/pipeline/src/data_sources/relayer-registry/index.ts b/packages/pipeline/src/data_sources/relayer-registry/index.ts index c97b50d27..8199dae14 100644 --- a/packages/pipeline/src/data_sources/relayer-registry/index.ts +++ b/packages/pipeline/src/data_sources/relayer-registry/index.ts @@ -26,8 +26,8 @@ export class RelayerRegistrySource { this._url = url; } - public async getRelayerInfoAsync(): Promise<RelayerResponse[]> { - const resp = await axios.get<RelayerResponse[]>(this._url); + public async getRelayerInfoAsync(): Promise<Map<string, RelayerResponse>> { + const resp = await axios.get<Map<string, RelayerResponse>>(this._url); return resp.data; } } diff --git a/packages/pipeline/src/entities/Relayer.ts b/packages/pipeline/src/entities/Relayer.ts index ebdcbf345..605355fa8 100644 --- a/packages/pipeline/src/entities/Relayer.ts +++ b/packages/pipeline/src/entities/Relayer.ts @@ -2,8 +2,9 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; @Entity() export class Relayer { - @PrimaryColumn() public name!: string; + @PrimaryColumn() public uuid!: string; + @Column() public name!: string; @Column() public url!: string; @Column({ nullable: true, type: String }) public sraHttpEndpoint!: string | null; diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts index 9483eb257..b42256d87 100644 --- a/packages/pipeline/src/index.ts +++ b/packages/pipeline/src/index.ts @@ -16,7 +16,10 @@ import { parseRelayers } from './parsers/relayer_registry'; import { parseBlock, parseTransaction } from './parsers/web3'; const EXCHANGE_START_BLOCK = 6271590; // Block number when the Exchange contract was deployed to mainnet. -const RELAYER_REGISTRY_URL = 'https://raw.githubusercontent.com/0xProject/0x-relayer-registry/master/relayers.json'; +// NOTE(albrow): We need to manually update this URL for now. Fix this when we +// have the relayer-registry behind semantic versioning. +const RELAYER_REGISTRY_URL = + 'https://raw.githubusercontent.com/0xProject/0x-relayer-registry/4701c85677d161ea729a466aebbc1826c6aa2c0b/relayers.json'; let connection: Connection; diff --git a/packages/pipeline/src/parsers/relayer_registry/index.ts b/packages/pipeline/src/parsers/relayer_registry/index.ts index 6eca10167..50fd12443 100644 --- a/packages/pipeline/src/parsers/relayer_registry/index.ts +++ b/packages/pipeline/src/parsers/relayer_registry/index.ts @@ -3,10 +3,14 @@ import * as R from 'ramda'; import { RelayerResponse, RelayerResponseNetwork } from '../../data_sources/relayer-registry'; import { Relayer } from '../../entities/Relayer'; -export const parseRelayers = R.map(parseRelayer); +export function parseRelayers(rawResp: Map<string, RelayerResponse>): Relayer[] { + const parsedAsObject = R.mapObjIndexed(parseRelayer, rawResp); + return R.values(parsedAsObject); +} -function parseRelayer(relayerResp: RelayerResponse): Relayer { +function parseRelayer(relayerResp: RelayerResponse, uuid: string): Relayer { const relayer = new Relayer(); + relayer.uuid = uuid; relayer.name = relayerResp.name; relayer.url = relayerResp.homepage_url; relayer.appUrl = relayerResp.app_url; |