diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-06 02:10:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-06 02:10:17 +0800 |
commit | 881d32e73324b226bdc97f96fb583edb7a5311c1 (patch) | |
tree | 78e3b30e47d5fd03ee169afc9e33d8e6a45f8d43 /packages/long-lived-subscriptions-test | |
parent | c7ad6ebad6ab65a4b1e4a2084e744c6ca2bc09b8 (diff) | |
download | dexon-sol-tools-881d32e73324b226bdc97f96fb583edb7a5311c1.tar dexon-sol-tools-881d32e73324b226bdc97f96fb583edb7a5311c1.tar.gz dexon-sol-tools-881d32e73324b226bdc97f96fb583edb7a5311c1.tar.bz2 dexon-sol-tools-881d32e73324b226bdc97f96fb583edb7a5311c1.tar.lz dexon-sol-tools-881d32e73324b226bdc97f96fb583edb7a5311c1.tar.xz dexon-sol-tools-881d32e73324b226bdc97f96fb583edb7a5311c1.tar.zst dexon-sol-tools-881d32e73324b226bdc97f96fb583edb7a5311c1.zip |
Temp
Diffstat (limited to 'packages/long-lived-subscriptions-test')
5 files changed, 77 insertions, 0 deletions
diff --git a/packages/long-lived-subscriptions-test/Dockerfile b/packages/long-lived-subscriptions-test/Dockerfile new file mode 100644 index 000000000..47d24ec08 --- /dev/null +++ b/packages/long-lived-subscriptions-test/Dockerfile @@ -0,0 +1,10 @@ +FROM node + +WORKDIR /src + +COPY package.json . +RUN yarn install + +COPY . . + +CMD ["./lib/index.js"] diff --git a/packages/long-lived-subscriptions-test/package.json b/packages/long-lived-subscriptions-test/package.json new file mode 100644 index 000000000..ec45d631a --- /dev/null +++ b/packages/long-lived-subscriptions-test/package.json @@ -0,0 +1,25 @@ +{ + "name": "long-lived-subscriptions-test", + "version": "0.0.1", + "description": "", + "scripts": { + "build:watch": "tsc -w", + "build": "tsc", + "start": "node lib/index.js", + "clean": "shx rm -rf lib", + "lint": "tslint --project . 'src/**/*.ts'" + }, + "dependencies": { + "0x.js": "^0.31.1", + "lodash": "^4.17.4", + "web3": "^0.20.0" + }, + "devDependencies": { + "@0xproject/tslint-config": "^0.4.6", + "@types/lodash": "^4.14.86", + "shx": "^0.2.2", + "tslint": "5.8.0", + "typescript": "2.7.1", + "web3-typescript-typings": "^0.9.8" + } +} 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(); diff --git a/packages/long-lived-subscriptions-test/tsconfig.json b/packages/long-lived-subscriptions-test/tsconfig.json new file mode 100644 index 000000000..3d967d05f --- /dev/null +++ b/packages/long-lived-subscriptions-test/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib" + }, + "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] +} diff --git a/packages/long-lived-subscriptions-test/tslint.json b/packages/long-lived-subscriptions-test/tslint.json new file mode 100644 index 000000000..ffaefe83a --- /dev/null +++ b/packages/long-lived-subscriptions-test/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0xproject/tslint-config"] +} |