diff options
author | Leonid <logvinov.leon@gmail.com> | 2018-01-19 20:39:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-19 20:39:57 +0800 |
commit | 6091f818da7cddcb4a22a573f7726ba9b76b398e (patch) | |
tree | 5769ca73d50c497e46e6c6c927700ae0fa00bec9 /packages/website/ts/blockchain.ts | |
parent | a45f9b480233d207fa5ba80a8e47cc3193c243d8 (diff) | |
parent | 9ccf63b44afe1ae6ccc2b9298ee35697d6be9e30 (diff) | |
download | dexon-sol-tools-6091f818da7cddcb4a22a573f7726ba9b76b398e.tar dexon-sol-tools-6091f818da7cddcb4a22a573f7726ba9b76b398e.tar.gz dexon-sol-tools-6091f818da7cddcb4a22a573f7726ba9b76b398e.tar.bz2 dexon-sol-tools-6091f818da7cddcb4a22a573f7726ba9b76b398e.tar.lz dexon-sol-tools-6091f818da7cddcb4a22a573f7726ba9b76b398e.tar.xz dexon-sol-tools-6091f818da7cddcb4a22a573f7726ba9b76b398e.tar.zst dexon-sol-tools-6091f818da7cddcb4a22a573f7726ba9b76b398e.zip |
Merge branch 'development' into feature/separate-deployer
Diffstat (limited to 'packages/website/ts/blockchain.ts')
-rw-r--r-- | packages/website/ts/blockchain.ts | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index 1320fbeb9..5530701c0 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -368,14 +368,22 @@ export class Blockchain { const [currBalance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address); - this._zrxPollIntervalId = intervalUtils.setAsyncExcludingInterval(async () => { - const [balance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address); - if (!balance.eq(currBalance)) { - this._dispatcher.replaceTokenBalanceByAddress(token.address, balance); - clearInterval(this._zrxPollIntervalId); + this._zrxPollIntervalId = intervalUtils.setAsyncExcludingInterval( + async () => { + const [balance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address); + if (!balance.eq(currBalance)) { + this._dispatcher.replaceTokenBalanceByAddress(token.address, balance); + intervalUtils.clearAsyncExcludingInterval(this._zrxPollIntervalId); + delete this._zrxPollIntervalId; + } + }, + 5000, + (err: Error) => { + utils.consoleLog(`Polling tokenBalance failed: ${err}`); + intervalUtils.clearAsyncExcludingInterval(this._zrxPollIntervalId); delete this._zrxPollIntervalId; - } - }, 5000); + }, + ); } public async signOrderHashAsync(orderHash: string): Promise<SignatureData> { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); @@ -471,7 +479,7 @@ export class Blockchain { this._web3Wrapper.updatePrevUserAddress(newUserAddress); } public destroy() { - clearInterval(this._zrxPollIntervalId); + intervalUtils.clearAsyncExcludingInterval(this._zrxPollIntervalId); this._web3Wrapper.destroy(); this._stopWatchingExchangeLogFillEvents(); } |