aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/pipeline/src/index.ts')
-rw-r--r--packages/pipeline/src/index.ts43
1 files changed, 17 insertions, 26 deletions
diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts
index a1dbb35ff..77c92cc34 100644
--- a/packages/pipeline/src/index.ts
+++ b/packages/pipeline/src/index.ts
@@ -1,52 +1,43 @@
import { HttpClient } from '@0xproject/connect';
+import { web3Factory } from '@0xproject/dev-utils';
import 'reflect-metadata';
import { Connection, createConnection } from 'typeorm';
-import { Etherscan } from './data_sources/etherscan';
-import { parseExchangeEvents } from './data_types/events/exchange_events';
-import { parseSraOrders } from './data_types/sra_orders';
-import { ExchangeCancelEvent } from './entities/ExchangeCancelEvent';
-import { ExchangeCancelUpToEvent } from './entities/ExchangeCancelUpToEvent';
-import { ExchangeFillEvent } from './entities/ExchangeFillEvent';
+import { ExchangeEventsSource } from './data_sources/contract-wrappers/exchange_events';
import { SraOrder } from './entities/SraOrder';
import { config } from './ormconfig';
-
-const etherscan = new Etherscan(process.env.ETHERSCAN_API_KEY as string);
-const EXCHANGE_ADDRESS = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b';
+import { parseExchangeEvents } from './parsers/events';
+import { parseSraOrders } from './parsers/sra_orders';
let connection: Connection;
(async () => {
connection = await createConnection(config);
await getExchangeEventsAsync();
- await getSraOrdersAsync();
+ // await getSraOrdersAsync();
})();
+// TODO(albrow): Separately: Errors do not appear to be handled correctly. If you use the
+// wrong rpcUrl it just returns early with no error.
async function getExchangeEventsAsync(): Promise<void> {
- const fillRepository = connection.getRepository(ExchangeFillEvent);
- const cancelRepository = connection.getRepository(ExchangeCancelEvent);
- const cancelUpToRepository = connection.getRepository(ExchangeCancelUpToEvent);
- console.log(
- `found ${(await fillRepository.count()) +
- (await cancelRepository.count()) +
- (await cancelUpToRepository.count())} existing events`,
- );
- const rawEvents = await etherscan.getContractEventsAsync(EXCHANGE_ADDRESS);
- const events = parseExchangeEvents(rawEvents);
+ const provider = web3Factory.getRpcProvider({
+ rpcUrl: 'https://mainnet.infura.io',
+ });
+ const exchangeEvents = new ExchangeEventsSource(provider, 1);
+ const eventLogs = await exchangeEvents.getFillEventsAsync();
+ const events = parseExchangeEvents(eventLogs);
+ console.log('Got events: ' + events.length);
for (const event of events) {
await event.save();
}
- console.log(
- `now there are ${(await fillRepository.count()) +
- (await cancelRepository.count()) +
- (await cancelUpToRepository.count())} total events`,
- );
+ console.log('Saved events.');
+ console.log('Exiting process');
+ process.exit(0);
}
async function getSraOrdersAsync(): Promise<void> {
const orderRepository = connection.getRepository(SraOrder);
console.log(`found ${await orderRepository.count()} existing orders`);
-
const sraUrl = 'https://api.radarrelay.com/0x/v2';
const connect = new HttpClient(sraUrl);
const rawOrders = await connect.getOrdersAsync();