Implement fetching and parsing relayer info
This commit is contained in:
committed by
Fred Carlsen
parent
e2f222b08f
commit
f6ebdd1a3f
@@ -30,6 +30,7 @@
|
||||
"@0x/tslint-config": "^1.0.9",
|
||||
"@types/axios": "^0.14.0",
|
||||
"@types/ramda": "^0.25.38",
|
||||
"@types/axios": "^0.14.0",
|
||||
"chai": "^4.1.2",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-bignumber": "^2.0.2",
|
||||
|
22
packages/pipeline/src/entities/Relayer.ts
Normal file
22
packages/pipeline/src/entities/Relayer.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Column, Entity, PrimaryColumn } from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class Relayer {
|
||||
@PrimaryColumn() public name!: string;
|
||||
|
||||
@Column() public url!: string;
|
||||
@Column({ nullable: true, type: String })
|
||||
public sraHttpEndpoint!: string | null;
|
||||
@Column({ nullable: true, type: String })
|
||||
public sraWsEndpoint!: string | null;
|
||||
@Column({ nullable: true, type: String })
|
||||
public appUrl!: string | null;
|
||||
|
||||
// TODO(albrow): Add exchange contract or protocol version?
|
||||
// TODO(albrow): Add network ids for addresses?
|
||||
|
||||
@Column({ type: 'varchar', array: true })
|
||||
public feeRecipientAddresses!: string[];
|
||||
@Column({ type: 'varchar', array: true })
|
||||
public takerAddresses!: string[];
|
||||
}
|
@@ -1,21 +1,22 @@
|
||||
import { Column, Entity, PrimaryColumn } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'relayers', schema: 'raw' })
|
||||
@Entity()
|
||||
export class Relayer {
|
||||
@PrimaryColumn() public uuid!: string;
|
||||
@PrimaryColumn() public name!: string;
|
||||
|
||||
@Column() public name!: string;
|
||||
@Column({ name: 'homepage_url', type: 'varchar' })
|
||||
public homepageUrl!: string;
|
||||
@Column({ name: 'sra_http_endpoint', type: 'varchar', nullable: true })
|
||||
@Column() public url!: string;
|
||||
@Column({ nullable: true, type: String })
|
||||
public sraHttpEndpoint!: string | null;
|
||||
@Column({ name: 'sra_ws_endpoint', type: 'varchar', nullable: true })
|
||||
@Column({ nullable: true, type: String })
|
||||
public sraWsEndpoint!: string | null;
|
||||
@Column({ name: 'app_url', type: 'varchar', nullable: true })
|
||||
@Column({ nullable: true, type: String })
|
||||
public appUrl!: string | null;
|
||||
|
||||
@Column({ name: 'fee_recipient_addresses', type: 'varchar', array: true })
|
||||
// TODO(albrow): Add exchange contract or protocol version?
|
||||
// TODO(albrow): Add network ids for addresses?
|
||||
|
||||
@Column({ type: 'varchar', array: true })
|
||||
public feeRecipientAddresses!: string[];
|
||||
@Column({ name: 'taker_addresses', type: 'varchar', array: true })
|
||||
@Column({ type: 'varchar', array: true })
|
||||
public takerAddresses!: string[];
|
||||
}
|
||||
|
@@ -4,27 +4,31 @@ import 'reflect-metadata';
|
||||
import { Connection, createConnection } from 'typeorm';
|
||||
|
||||
import { ExchangeEventsSource } from './data_sources/contract-wrappers/exchange_events';
|
||||
import { RelayerRegistrySource } from './data_sources/relayer-registry';
|
||||
import { Web3Source } from './data_sources/web3';
|
||||
import { Block } from './entities/Block';
|
||||
import { ExchangeFillEvent } from './entities/ExchangeFillEvent';
|
||||
import { Relayer } from './entities/Relayer';
|
||||
import { Transaction } from './entities/Transaction';
|
||||
import { testConfig } from './ormconfig';
|
||||
import { deployConfig } from './ormconfig';
|
||||
import { parseExchangeEvents } from './parsers/events';
|
||||
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';
|
||||
|
||||
let connection: Connection;
|
||||
|
||||
(async () => {
|
||||
connection = await createConnection(testConfig);
|
||||
connection = await createConnection(deployConfig);
|
||||
const provider = web3Factory.getRpcProvider({
|
||||
rpcUrl: 'https://mainnet.infura.io',
|
||||
});
|
||||
await getExchangeEventsAsync(provider);
|
||||
await getBlockAsync(provider);
|
||||
await getTransactionAsync(provider);
|
||||
console.log('Exiting process');
|
||||
// await getExchangeEventsAsync(provider);
|
||||
// await getBlockAsync(provider);
|
||||
// await getTransactionAsync(provider);
|
||||
await getRelayers(RELAYER_REGISTRY_URL);
|
||||
process.exit(0);
|
||||
})();
|
||||
|
||||
@@ -66,3 +70,16 @@ async function getTransactionAsync(provider: Web3ProviderEngine): Promise<void>
|
||||
await txsRepository.save(tx);
|
||||
console.log('Done saving tx.');
|
||||
}
|
||||
|
||||
async function getRelayers(url: string): Promise<void> {
|
||||
console.log('Getting relayer info...');
|
||||
const relayerRepository = connection.getRepository(Relayer);
|
||||
const relayerSource = new RelayerRegistrySource(RELAYER_REGISTRY_URL);
|
||||
const relayersResp = await relayerSource.getRelayerInfoAsync();
|
||||
const relayers = parseRelayers(relayersResp);
|
||||
console.log('Saving relayer info...');
|
||||
// for (const relayer of relayers) {
|
||||
await relayerRepository.save(relayers);
|
||||
// }
|
||||
console.log('Done saving relayers.');
|
||||
}
|
||||
|
Reference in New Issue
Block a user