From 881d32e73324b226bdc97f96fb583edb7a5311c1 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 5 Feb 2018 19:10:17 +0100 Subject: Temp --- .../long-lived-subscriptions-test/src/index.ts | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 packages/long-lived-subscriptions-test/src/index.ts (limited to 'packages/long-lived-subscriptions-test/src/index.ts') diff --git a/packages/long-lived-subscriptions-test/src/index.ts b/packages/long-lived-subscriptions-test/src/index.ts new file mode 100644 index 000000000..2d79dcc89 --- /dev/null +++ b/packages/long-lived-subscriptions-test/src/index.ts @@ -0,0 +1,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( + ExchangeEvents.LogFill, + {}, + (err: Error | null, event?: DecodedLogEvent) => { + if (_.isNull(err)) { + console.log('EVENT'); + console.log(event); + } else { + console.log('ERROR'); + console.log(err); + subscribe(); + } + }, + ); +}; +subscribe(); -- cgit v1.2.3