aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-01-30 18:15:36 +0800
committerFabio Berger <me@fabioberger.com>2018-01-30 18:15:36 +0800
commitc0facfc28f65495a52f9405613fe4a08aff5d164 (patch)
treea216ce9f7464296293554aa37138d8d33ff945ad /packages/website
parentbb0cedd2de44a0b6533df37133ae6f576ee84b2a (diff)
downloaddexon-sol-tools-c0facfc28f65495a52f9405613fe4a08aff5d164.tar
dexon-sol-tools-c0facfc28f65495a52f9405613fe4a08aff5d164.tar.gz
dexon-sol-tools-c0facfc28f65495a52f9405613fe4a08aff5d164.tar.bz2
dexon-sol-tools-c0facfc28f65495a52f9405613fe4a08aff5d164.tar.lz
dexon-sol-tools-c0facfc28f65495a52f9405613fe4a08aff5d164.tar.xz
dexon-sol-tools-c0facfc28f65495a52f9405613fe4a08aff5d164.tar.zst
dexon-sol-tools-c0facfc28f65495a52f9405613fe4a08aff5d164.zip
Call destroy ealier so that web3Wrapper stops polling for userAddress/networkId updates before we prep for the batchDispatch
Diffstat (limited to 'packages/website')
-rw-r--r--packages/website/ts/blockchain.ts7
-rw-r--r--packages/website/ts/web3_wrapper.ts4
2 files changed, 8 insertions, 3 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index fd8d536ed..aba438e8d 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -199,6 +199,8 @@ export class Blockchain {
this._cachedProviderNetworkId = this.networkId;
}
+ this._web3Wrapper.destroy();
+
this._userAddress = '';
this._dispatcher.updateUserAddress(''); // Clear old userAddress
@@ -212,7 +214,6 @@ export class Blockchain {
provider.addProvider(new FilterSubprovider());
provider.addProvider(new RedundantRPCSubprovider(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId]));
provider.start();
- this._web3Wrapper.destroy();
this.networkId = networkId;
this._dispatcher.updateNetworkId(this.networkId);
const shouldPollUserAddress = false;
@@ -228,10 +229,12 @@ export class Blockchain {
if (_.isUndefined(this._cachedProvider)) {
return; // Going from injected to injected, so we noop
}
+
+ this._web3Wrapper.destroy();
+
const provider = this._cachedProvider;
this.networkId = this._cachedProviderNetworkId;
- this._web3Wrapper.destroy();
const shouldPollUserAddress = true;
this._web3Wrapper = new Web3Wrapper(this._dispatcher, provider, this.networkId, shouldPollUserAddress);
diff --git a/packages/website/ts/web3_wrapper.ts b/packages/website/ts/web3_wrapper.ts
index 00b18a266..1e2f8ff5d 100644
--- a/packages/website/ts/web3_wrapper.ts
+++ b/packages/website/ts/web3_wrapper.ts
@@ -150,6 +150,8 @@ export class Web3Wrapper {
}
}
private _stopEmittingNetworkConnectionAndUserBalanceStateAsync() {
- intervalUtils.clearAsyncExcludingInterval(this._watchNetworkAndBalanceIntervalId);
+ if (!_.isUndefined(this._watchNetworkAndBalanceIntervalId)) {
+ intervalUtils.clearAsyncExcludingInterval(this._watchNetworkAndBalanceIntervalId);
+ }
}
}