diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-02-06 05:16:46 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-02-06 05:16:46 +0800 |
commit | 99b1f81e89e3ac929c7829552ea7ae19998524e9 (patch) | |
tree | 534161a9fa8bcf8bb5572d7ef0aa311fe9b9d116 /packages/long-lived-subscriptions-test/src/index.ts | |
parent | 6577d607332e2fb1a442d663e260ecb969457c36 (diff) | |
parent | 46ad7b1b38df0f302821258629ffa749e7dd00b9 (diff) | |
download | dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.gz dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.bz2 dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.lz dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.xz dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.zst dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.zip |
Merge branch 'development' into feature/testnet-faucets/order-dispenser
* development: (37 commits)
Add dates to CHANGELOGs
Change CHANGELOGs
Add .editorconfig
Fix a typo
Temp
Use forEach instead of map
Add PR number
Fix an exception when a signature collision happens
Fix prettier
Add regression tests
Improve the comment and fix an exception
Add missing comas
Lerna-ignore tslint and tsconfig
Update contract versions, fix tests
Rename directories
Rename previous contracts, fix imports, add nested file structure
Move all contracts into a single directory
Update import
Fix import
Get rid of suffixed contract versioning and replace it with a poor-mans package manager. Versions are stored locally, and are generated in a copy-on-write basis as required
...
Diffstat (limited to 'packages/long-lived-subscriptions-test/src/index.ts')
-rw-r--r-- | packages/long-lived-subscriptions-test/src/index.ts | 32 |
1 files changed, 32 insertions, 0 deletions
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<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(); |