aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/blockchain_watcher.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-26 07:26:34 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-26 07:26:34 +0800
commitc4e2dcafa4bd5f4b905680e2c1b80d6ddb6ab6fb (patch)
tree34653ddbd6fa97eb522f827c0b488f91f3038595 /packages/website/ts/blockchain_watcher.ts
parent53e2cda4c8d6698b5c4b69f510ad8764cb089306 (diff)
downloaddexon-0x-contracts-c4e2dcafa4bd5f4b905680e2c1b80d6ddb6ab6fb.tar.gz
dexon-0x-contracts-c4e2dcafa4bd5f4b905680e2c1b80d6ddb6ab6fb.tar.zst
dexon-0x-contracts-c4e2dcafa4bd5f4b905680e2c1b80d6ddb6ab6fb.zip
Have basic network switching working
Diffstat (limited to 'packages/website/ts/blockchain_watcher.ts')
-rw-r--r--packages/website/ts/blockchain_watcher.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/packages/website/ts/blockchain_watcher.ts b/packages/website/ts/blockchain_watcher.ts
index 8ae5e7797..5d029d4f1 100644
--- a/packages/website/ts/blockchain_watcher.ts
+++ b/packages/website/ts/blockchain_watcher.ts
@@ -7,6 +7,7 @@ export class BlockchainWatcher {
private _dispatcher: Dispatcher;
private _web3Wrapper: Web3Wrapper;
private _prevNetworkId: number;
+ private _isWatchingNetworkId: boolean = false;
private _shouldPollUserAddress: boolean;
private _watchBalanceIntervalId: NodeJS.Timer;
private _prevUserEtherBalanceInWei?: BigNumber;
@@ -18,8 +19,8 @@ export class BlockchainWatcher {
shouldPollUserAddress: boolean,
) {
this._dispatcher = dispatcher;
- this._prevNetworkId = networkIdIfExists;
this._shouldPollUserAddress = shouldPollUserAddress;
+ this._prevNetworkId = networkIdIfExists;
this._web3Wrapper = web3Wrapper;
}
public destroy(): void {
@@ -34,6 +35,16 @@ export class BlockchainWatcher {
public updatePrevUserAddress(userAddress: string): void {
this._prevUserAddressIfExists = userAddress;
}
+ // public async startEmittingInjectedProviderNetworkIdAsync(injectedProvider: any): Promise<void> {
+ // if (this._isWatchingNetworkId) {
+ // return; // we are already watching the network id
+ // }
+ // const observable = injectedProvider.publicConfigStore;
+ // if (observable && observable.subscribe) {
+ // observable.subscribe(this._handleInjectedProviderUpdate.bind(this));
+ // this._isWatchingNetworkId = true;
+ // }
+ // }
public async startEmittingUserBalanceStateAsync(): Promise<void> {
if (!_.isUndefined(this._watchBalanceIntervalId)) {
return; // we are already emitting the state
@@ -49,6 +60,15 @@ export class BlockchainWatcher {
},
);
}
+ // private _handleInjectedProviderUpdate(update: InjectedProviderUpdate): void {
+ // const updatedNetworkId = _.parseInt(update.networkVersion);
+ // if (this._prevNetworkId === updatedNetworkId) {
+ // return;
+ // }
+ // this._prevNetworkId = updatedNetworkId;
+ // this._dispatcher.updateNetworkId(updatedNetworkId);
+ // this._updateBalanceAsync();
+ // }
private async _updateBalanceAsync(): Promise<void> {
let prevNodeVersion: string;
// Check for node version changes