Update relayer code to use new relayer-registry format
This commit is contained in:
		@@ -26,8 +26,8 @@ export class RelayerRegistrySource {
 | 
				
			|||||||
        this._url = url;
 | 
					        this._url = url;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public async getRelayerInfoAsync(): Promise<RelayerResponse[]> {
 | 
					    public async getRelayerInfoAsync(): Promise<Map<string, RelayerResponse>> {
 | 
				
			||||||
        const resp = await axios.get<RelayerResponse[]>(this._url);
 | 
					        const resp = await axios.get<Map<string, RelayerResponse>>(this._url);
 | 
				
			||||||
        return resp.data;
 | 
					        return resp.data;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,8 +2,9 @@ import { Column, Entity, PrimaryColumn } from 'typeorm';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
@Entity()
 | 
					@Entity()
 | 
				
			||||||
export class Relayer {
 | 
					export class Relayer {
 | 
				
			||||||
    @PrimaryColumn() public name!: string;
 | 
					    @PrimaryColumn() public uuid!: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Column() public name!: string;
 | 
				
			||||||
    @Column() public url!: string;
 | 
					    @Column() public url!: string;
 | 
				
			||||||
    @Column({ nullable: true, type: String })
 | 
					    @Column({ nullable: true, type: String })
 | 
				
			||||||
    public sraHttpEndpoint!: string | null;
 | 
					    public sraHttpEndpoint!: string | null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,10 @@ import { parseRelayers } from './parsers/relayer_registry';
 | 
				
			|||||||
import { parseBlock, parseTransaction } from './parsers/web3';
 | 
					import { parseBlock, parseTransaction } from './parsers/web3';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const EXCHANGE_START_BLOCK = 6271590; // Block number when the Exchange contract was deployed to mainnet.
 | 
					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;
 | 
					let connection: Connection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,10 +3,14 @@ import * as R from 'ramda';
 | 
				
			|||||||
import { RelayerResponse, RelayerResponseNetwork } from '../../data_sources/relayer-registry';
 | 
					import { RelayerResponse, RelayerResponseNetwork } from '../../data_sources/relayer-registry';
 | 
				
			||||||
import { Relayer } from '../../entities/Relayer';
 | 
					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();
 | 
					    const relayer = new Relayer();
 | 
				
			||||||
 | 
					    relayer.uuid = uuid;
 | 
				
			||||||
    relayer.name = relayerResp.name;
 | 
					    relayer.name = relayerResp.name;
 | 
				
			||||||
    relayer.url = relayerResp.homepage_url;
 | 
					    relayer.url = relayerResp.homepage_url;
 | 
				
			||||||
    relayer.appUrl = relayerResp.app_url;
 | 
					    relayer.appUrl = relayerResp.app_url;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user