diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-06-01 02:40:21 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-06-01 02:54:25 +0800 |
commit | df27f4f1183e5d5879aa0768b2edfef091750ec5 (patch) | |
tree | 9b9ba591f9cc1cc34c56440e4368433150acb99d /packages/website/ts/blockchain_watcher.ts | |
parent | bee26daf0c2497a11dfe944d355c4958329d1f50 (diff) | |
download | dexon-0x-contracts-df27f4f1183e5d5879aa0768b2edfef091750ec5.tar.gz dexon-0x-contracts-df27f4f1183e5d5879aa0768b2edfef091750ec5.tar.zst dexon-0x-contracts-df27f4f1183e5d5879aa0768b2edfef091750ec5.zip |
Change userEtherBalanceInWei to optional so we can know if its loading
Diffstat (limited to 'packages/website/ts/blockchain_watcher.ts')
-rw-r--r-- | packages/website/ts/blockchain_watcher.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/packages/website/ts/blockchain_watcher.ts b/packages/website/ts/blockchain_watcher.ts index c420a98a4..0d376bc74 100644 --- a/packages/website/ts/blockchain_watcher.ts +++ b/packages/website/ts/blockchain_watcher.ts @@ -10,7 +10,7 @@ export class BlockchainWatcher { private _prevNetworkId: number; private _shouldPollUserAddress: boolean; private _watchNetworkAndBalanceIntervalId: NodeJS.Timer; - private _prevUserEtherBalanceInWei: BigNumber; + private _prevUserEtherBalanceInWei?: BigNumber; private _prevUserAddressIfExists: string; constructor( dispatcher: Dispatcher, @@ -41,7 +41,7 @@ export class BlockchainWatcher { } let prevNodeVersion: string; - this._prevUserEtherBalanceInWei = new BigNumber(0); + this._prevUserEtherBalanceInWei = undefined; this._dispatcher.updateNetworkId(this._prevNetworkId); this._watchNetworkAndBalanceIntervalId = intervalUtils.setAsyncExcludingInterval( async () => { @@ -94,7 +94,7 @@ export class BlockchainWatcher { } private async _updateUserWeiBalanceAsync(userAddress: string): Promise<void> { const balanceInWei = await this._web3Wrapper.getBalanceInWeiAsync(userAddress); - if (!balanceInWei.eq(this._prevUserEtherBalanceInWei)) { + if (_.isUndefined(this._prevUserEtherBalanceInWei) || !balanceInWei.eq(this._prevUserEtherBalanceInWei)) { this._prevUserEtherBalanceInWei = balanceInWei; this._dispatcher.updateUserWeiBalance(balanceInWei); } |