blob: 2d79dcc89665d0dca222772463e03e40dfe95302 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { DecodedLogEvent, ExchangeEvents, LogFillContractEventArgs, ZeroEx } from '0x.js';
import * as _ from 'lodash';
import * as Web3 from 'web3';
const zeroExConfig = {
networkId: 1,
};
const RPC_URL = 'https://mainnet.infura.io/T5WSC8cautR4KXyYgsRs';
// const RPC_URL = 'https://mainnet.0xproject.com';
const web3 = new Web3(new Web3.providers.HttpProvider(RPC_URL));
const zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
const subscribe = () => {
console.log('subscribing...');
zeroEx.exchange.subscribe<LogFillContractEventArgs>(
ExchangeEvents.LogFill,
{},
(err: Error | null, event?: DecodedLogEvent<LogFillContractEventArgs>) => {
if (_.isNull(err)) {
console.log('EVENT');
console.log(event);
} else {
console.log('ERROR');
console.log(err);
subscribe();
}
},
);
};
subscribe();
|