diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-04 00:15:20 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-04 00:15:20 +0800 |
commit | 688b34710ea4b9262ac67d33b688751d5ca05a01 (patch) | |
tree | 637bd9efdf98a012a6b1dc14a2ed6c0e3a625367 /packages/contract-wrappers | |
parent | 671f29774b9a46420fdee33e3ecbffc7fa6f4c1a (diff) | |
download | dexon-sol-tools-688b34710ea4b9262ac67d33b688751d5ca05a01.tar dexon-sol-tools-688b34710ea4b9262ac67d33b688751d5ca05a01.tar.gz dexon-sol-tools-688b34710ea4b9262ac67d33b688751d5ca05a01.tar.bz2 dexon-sol-tools-688b34710ea4b9262ac67d33b688751d5ca05a01.tar.lz dexon-sol-tools-688b34710ea4b9262ac67d33b688751d5ca05a01.tar.xz dexon-sol-tools-688b34710ea4b9262ac67d33b688751d5ca05a01.tar.zst dexon-sol-tools-688b34710ea4b9262ac67d33b688751d5ca05a01.zip |
Update blockstream to latest version, propogate errors to top-level callers
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r-- | packages/contract-wrappers/CHANGELOG.json | 8 | ||||
-rw-r--r-- | packages/contract-wrappers/package.json | 2 | ||||
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts | 13 |
3 files changed, 20 insertions, 3 deletions
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 33d9bc4c0..e34b50c1a 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,5 +1,13 @@ [ { + "version": "0.0.6", + "changes": [ + { + "note": "Update blockstream to v5.0 and propogate up caught errors to active subscriptions" + } + ] + }, + { "timestamp": 1529397769, "version": "0.0.5", "changes": [ diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 449c64c2d..908f52a06 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -87,7 +87,7 @@ "@0xproject/utils": "^0.7.1", "@0xproject/web3-wrapper": "^0.7.1", "ethereum-types": "^0.0.2", - "ethereumjs-blockstream": "^2.0.6", + "ethereumjs-blockstream": "5.0.0", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", "js-sha3": "^0.7.0", diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 04f69bc3d..9cc661080 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -9,7 +9,7 @@ import { } from '@0xproject/types'; import { intervalUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { Block, BlockAndLogStreamer } from 'ethereumjs-blockstream'; +import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; import { @@ -39,7 +39,7 @@ export abstract class ContractWrapper { public abstract abi: ContractAbi; protected _web3Wrapper: Web3Wrapper; protected _networkId: number; - private _blockAndLogStreamerIfExists?: BlockAndLogStreamer; + private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined; private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer; private _filters: { [filterToken: string]: FilterObject }; private _filterCallbacks: { @@ -163,6 +163,7 @@ export abstract class ContractWrapper { this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper), this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), + this._onBlockAndLogStreamerError.bind(this), ); const catchAllLogFilter = {}; this._blockAndLogStreamerIfExists.addLogFilter(catchAllLogFilter); @@ -180,6 +181,14 @@ export abstract class ContractWrapper { this._onLogStateChanged.bind(this, isRemoved), ); } + private _onBlockAndLogStreamerError(err: Error): void { + // Propogate all Blockstream subscriber errors to all + // top-level subscriptions + const filterCallbacks = _.values(this._filterCallbacks); + _.each(filterCallbacks, filterCallback => { + filterCallback(err); + }); + } private _onReconcileBlockError(err: Error): void { const filterTokens = _.keys(this._filterCallbacks); _.each(filterTokens, filterToken => { |