diff options
Diffstat (limited to 'packages/website/ts/blockchain_watcher.ts')
-rw-r--r-- | packages/website/ts/blockchain_watcher.ts | 22 |
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 |