aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-10-25 09:34:20 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-13 01:13:26 +0800
commitf6ebdd1a3f7a387d099aae3c81b81c38c16c7caa (patch)
tree8a3b138dfbe418d1fedba083009e5b285507d974
parente2f222b08f0162fb067260bbbf1f58056b1badd7 (diff)
downloaddexon-sol-tools-f6ebdd1a3f7a387d099aae3c81b81c38c16c7caa.tar
dexon-sol-tools-f6ebdd1a3f7a387d099aae3c81b81c38c16c7caa.tar.gz
dexon-sol-tools-f6ebdd1a3f7a387d099aae3c81b81c38c16c7caa.tar.bz2
dexon-sol-tools-f6ebdd1a3f7a387d099aae3c81b81c38c16c7caa.tar.lz
dexon-sol-tools-f6ebdd1a3f7a387d099aae3c81b81c38c16c7caa.tar.xz
dexon-sol-tools-f6ebdd1a3f7a387d099aae3c81b81c38c16c7caa.tar.zst
dexon-sol-tools-f6ebdd1a3f7a387d099aae3c81b81c38c16c7caa.zip
Implement fetching and parsing relayer info
-rw-r--r--packages/pipeline/package.json1
-rw-r--r--packages/pipeline/src/entities/Relayer.ts22
-rw-r--r--packages/pipeline/src/entities/relayer.ts21
-rw-r--r--packages/pipeline/src/index.ts29
4 files changed, 57 insertions, 16 deletions
diff --git a/packages/pipeline/package.json b/packages/pipeline/package.json
index abd8f28fd..5b8d7a33e 100644
--- a/packages/pipeline/package.json
+++ b/packages/pipeline/package.json
@@ -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",
diff --git a/packages/pipeline/src/entities/Relayer.ts b/packages/pipeline/src/entities/Relayer.ts
new file mode 100644
index 000000000..ebdcbf345
--- /dev/null
+++ b/packages/pipeline/src/entities/Relayer.ts
@@ -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[];
+}
diff --git a/packages/pipeline/src/entities/relayer.ts b/packages/pipeline/src/entities/relayer.ts
index 5af8578b4..ebdcbf345 100644
--- a/packages/pipeline/src/entities/relayer.ts
+++ b/packages/pipeline/src/entities/relayer.ts
@@ -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[];
}
diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts
index ad0e4c68f..9483eb257 100644
--- a/packages/pipeline/src/index.ts
+++ b/packages/pipeline/src/index.ts
@@ -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.');
+}