From c2645b26b457c66b3adcb98a5c089eba3e72f458 Mon Sep 17 00:00:00 2001
From: Brandon Millman <brandon.millman@gmail.com>
Date: Wed, 31 Oct 2018 15:09:12 -0700
Subject: feat(instant): add interactive overlay presentation to umd bundle

---
 .../src/components/zero_ex_instant_provider.tsx    | 108 +++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 packages/instant/src/components/zero_ex_instant_provider.tsx

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
new file mode 100644
index 000000000..8c1025723
--- /dev/null
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -0,0 +1,108 @@
+import { AssetBuyer } from '@0x/asset-buyer';
+import { ObjectMap, SignedOrder } from '@0x/types';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { Provider } from 'react-redux';
+
+import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
+import { asyncData } from '../redux/async_data';
+import { INITIAL_STATE, State } from '../redux/reducer';
+import { store, Store } from '../redux/store';
+import { fonts } from '../style/fonts';
+import { AssetMetaData, Network } from '../types';
+import { assetUtils } from '../util/asset';
+import { BigNumberInput } from '../util/big_number_input';
+import { errorFlasher } from '../util/error_flasher';
+import { gasPriceEstimator } from '../util/gas_price_estimator';
+import { getProvider } from '../util/provider';
+import { web3Wrapper } from '../util/web3_wrapper';
+
+fonts.include();
+
+export type ZeroExInstantProviderProps = ZeroExInstantProviderRequiredProps &
+    Partial<ZeroExInstantProviderOptionalProps>;
+
+export interface ZeroExInstantProviderRequiredProps {
+    // TODO: Change API when we allow the selection of different assetDatas
+    assetData: string;
+    liquiditySource: string | SignedOrder[];
+}
+
+export interface ZeroExInstantProviderOptionalProps {
+    defaultAssetBuyAmount?: number;
+    additionalAssetMetaDataMap: ObjectMap<AssetMetaData>;
+    networkId: Network;
+}
+
+export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
+    private readonly _store: Store;
+    private static _mergeInitialStateWithProps(props: ZeroExInstantProviderProps, state: State = INITIAL_STATE): State {
+        const networkId = props.networkId || state.network;
+        // TODO: Provider needs to not be hard-coded to injected web3.
+        const provider = getProvider();
+        const assetBuyerOptions = {
+            networkId,
+        };
+        let assetBuyer;
+        if (_.isString(props.liquiditySource)) {
+            assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(
+                provider,
+                props.liquiditySource,
+                assetBuyerOptions,
+            );
+        } else {
+            assetBuyer = AssetBuyer.getAssetBuyerForProvidedOrders(provider, props.liquiditySource, assetBuyerOptions);
+        }
+        const completeAssetMetaDataMap = {
+            ...props.additionalAssetMetaDataMap,
+            ...state.assetMetaDataMap,
+        };
+        const storeStateFromProps: State = {
+            ...state,
+            assetBuyer,
+            network: networkId,
+            selectedAsset: assetUtils.createAssetFromAssetData(props.assetData, completeAssetMetaDataMap, networkId),
+            selectedAssetAmount: _.isUndefined(props.defaultAssetBuyAmount)
+                ? state.selectedAssetAmount
+                : new BigNumberInput(props.defaultAssetBuyAmount),
+            assetMetaDataMap: completeAssetMetaDataMap,
+        };
+        return storeStateFromProps;
+    }
+    constructor(props: ZeroExInstantProviderProps) {
+        super(props);
+        const initialAppState = ZeroExInstantProvider._mergeInitialStateWithProps(this.props, INITIAL_STATE);
+        this._store = store.create(initialAppState);
+    }
+
+    public componentDidMount(): void {
+        // tslint:disable-next-line:no-floating-promises
+        asyncData.fetchAndDispatchToStore(this._store);
+
+        // warm up the gas price estimator cache just in case we can't
+        // grab the gas price estimate when submitting the transaction
+        // tslint:disable-next-line:no-floating-promises
+        gasPriceEstimator.getFastAmountInWeiAsync();
+
+        // tslint:disable-next-line:no-floating-promises
+        this._flashErrorIfWrongNetwork();
+    }
+
+    public render(): React.ReactNode {
+        return (
+            <Provider store={this._store}>
+                <SelectedAssetThemeProvider>{this.props.children}</SelectedAssetThemeProvider>
+            </Provider>
+        );
+    }
+
+    private readonly _flashErrorIfWrongNetwork = async (): Promise<void> => {
+        const msToShowError = 30000; // 30 seconds
+        const network = this._store.getState().network;
+        const networkOfProvider = await web3Wrapper.getNetworkIdAsync();
+        if (network !== networkOfProvider) {
+            const errorMessage = `Wrong network detected. Try switching to ${Network[network]}.`;
+            errorFlasher.flashNewErrorMessage(this._store.dispatch, errorMessage, msToShowError);
+        }
+    };
+}
-- 
cgit v1.2.3


From a2e1bf0e6287e86c226b0801311f6f4498c893ed Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Thu, 1 Nov 2018 16:32:14 -0700
Subject: Getting rid of BigNumberInput in favor of BigNumber

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 8c1025723..9391c03f7 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -1,5 +1,6 @@
 import { AssetBuyer } from '@0x/asset-buyer';
 import { ObjectMap, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
 import * as _ from 'lodash';
 import * as React from 'react';
 import { Provider } from 'react-redux';
@@ -11,7 +12,6 @@ import { store, Store } from '../redux/store';
 import { fonts } from '../style/fonts';
 import { AssetMetaData, Network } from '../types';
 import { assetUtils } from '../util/asset';
-import { BigNumberInput } from '../util/big_number_input';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
 import { getProvider } from '../util/provider';
@@ -64,7 +64,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             selectedAsset: assetUtils.createAssetFromAssetData(props.assetData, completeAssetMetaDataMap, networkId),
             selectedAssetAmount: _.isUndefined(props.defaultAssetBuyAmount)
                 ? state.selectedAssetAmount
-                : new BigNumberInput(props.defaultAssetBuyAmount),
+                : new BigNumber(props.defaultAssetBuyAmount),
             assetMetaDataMap: completeAssetMetaDataMap,
         };
         return storeStateFromProps;
-- 
cgit v1.2.3


From 180f176716b57d43e2988b5db3a2423c7974177e Mon Sep 17 00:00:00 2001
From: fragosti <francesco.agosti93@gmail.com>
Date: Thu, 1 Nov 2018 16:41:08 -0700
Subject: feat: use withTheme to use ColorOption to color Icon

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 2 --
 1 file changed, 2 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 8552a7fb5..ce939c144 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -17,8 +17,6 @@ import { gasPriceEstimator } from '../util/gas_price_estimator';
 import { getProvider } from '../util/provider';
 import { web3Wrapper } from '../util/web3_wrapper';
 
-import { ZeroExInstantContainer } from './zero_ex_instant_container';
-
 fonts.include();
 
 export type ZeroExInstantProviderProps = ZeroExInstantProviderRequiredProps &
-- 
cgit v1.2.3


From 5e66cc8a40759658a8763f85996163e5ae013fcd Mon Sep 17 00:00:00 2001
From: Brandon Millman <brandon.millman@gmail.com>
Date: Thu, 1 Nov 2018 18:24:32 -0700
Subject: feat(instant): implement affiliateFeeInfo prop

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index a7aecab9c..fce03a280 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -9,7 +9,7 @@ import { asyncData } from '../redux/async_data';
 import { INITIAL_STATE, State } from '../redux/reducer';
 import { store, Store } from '../redux/store';
 import { fonts } from '../style/fonts';
-import { AssetMetaData, Network } from '../types';
+import { AffiliateInfo, AssetMetaData, Network } from '../types';
 import { assetUtils } from '../util/asset';
 import { BigNumberInput } from '../util/big_number_input';
 import { errorFlasher } from '../util/error_flasher';
@@ -29,9 +29,10 @@ export interface ZeroExInstantProviderRequiredProps {
 }
 
 export interface ZeroExInstantProviderOptionalProps {
-    defaultAssetBuyAmount?: number;
+    defaultAssetBuyAmount: number;
     additionalAssetMetaDataMap: ObjectMap<AssetMetaData>;
     networkId: Network;
+    affiliateInfo: AffiliateInfo;
 }
 
 export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
@@ -66,6 +67,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
                 ? state.selectedAssetAmount
                 : new BigNumberInput(props.defaultAssetBuyAmount),
             assetMetaDataMap: completeAssetMetaDataMap,
+            affiliateInfo: props.affiliateInfo,
         };
         return storeStateFromProps;
     }
-- 
cgit v1.2.3


From 5fc2483be776cab90e7ff868b27536a85d6764c9 Mon Sep 17 00:00:00 2001
From: Brandon Millman <brandon.millman@gmail.com>
Date: Fri, 2 Nov 2018 13:48:31 -0700
Subject: feat(instant): pass in provider through props, fallback to injected
 provider

---
 .../src/components/zero_ex_instant_provider.tsx    | 30 ++++++++++++++--------
 1 file changed, 19 insertions(+), 11 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index fce03a280..4bc840862 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -1,8 +1,11 @@
 import { AssetBuyer } from '@0x/asset-buyer';
 import { ObjectMap, SignedOrder } from '@0x/types';
+import { Web3Wrapper } from '@0x/web3-wrapper';
+import { Provider } from 'ethereum-types';
 import * as _ from 'lodash';
 import * as React from 'react';
-import { Provider } from 'react-redux';
+import { Provider as ReduxProvider } from 'react-redux';
+import { oc } from 'ts-optchain';
 
 import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
 import { asyncData } from '../redux/async_data';
@@ -14,8 +17,7 @@ import { assetUtils } from '../util/asset';
 import { BigNumberInput } from '../util/big_number_input';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
-import { getProvider } from '../util/provider';
-import { web3Wrapper } from '../util/web3_wrapper';
+import { getInjectedProvider } from '../util/injected_provider';
 
 fonts.include();
 
@@ -29,6 +31,7 @@ export interface ZeroExInstantProviderRequiredProps {
 }
 
 export interface ZeroExInstantProviderOptionalProps {
+    provider: Provider;
     defaultAssetBuyAmount: number;
     additionalAssetMetaDataMap: ObjectMap<AssetMetaData>;
     networkId: Network;
@@ -39,8 +42,8 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
     private readonly _store: Store;
     private static _mergeInitialStateWithProps(props: ZeroExInstantProviderProps, state: State = INITIAL_STATE): State {
         const networkId = props.networkId || state.network;
-        // TODO: Provider needs to not be hard-coded to injected web3.
-        const provider = getProvider();
+        // TODO: Proper wallet connect flow
+        const provider = props.provider || getInjectedProvider();
         const assetBuyerOptions = {
             networkId,
         };
@@ -92,19 +95,24 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
 
     public render(): React.ReactNode {
         return (
-            <Provider store={this._store}>
+            <ReduxProvider store={this._store}>
                 <SelectedAssetThemeProvider>{this.props.children}</SelectedAssetThemeProvider>
-            </Provider>
+            </ReduxProvider>
         );
     }
 
     private readonly _flashErrorIfWrongNetwork = async (): Promise<void> => {
         const msToShowError = 30000; // 30 seconds
         const network = this._store.getState().network;
-        const networkOfProvider = await web3Wrapper.getNetworkIdAsync();
-        if (network !== networkOfProvider) {
-            const errorMessage = `Wrong network detected. Try switching to ${Network[network]}.`;
-            errorFlasher.flashNewErrorMessage(this._store.dispatch, errorMessage, msToShowError);
+        const assetBuyerIfExists = this._store.getState().assetBuyer;
+        const providerIfExists = oc(assetBuyerIfExists).provider();
+        if (!_.isUndefined(providerIfExists)) {
+            const web3Wrapper = new Web3Wrapper(providerIfExists);
+            const networkOfProvider = await web3Wrapper.getNetworkIdAsync();
+            if (network !== networkOfProvider) {
+                const errorMessage = `Wrong network detected. Try switching to ${Network[network]}.`;
+                errorFlasher.flashNewErrorMessage(this._store.dispatch, errorMessage, msToShowError);
+            }
         }
     };
 }
-- 
cgit v1.2.3


From dfbf10c94bfbbdbca353531c5cae6707e05981f0 Mon Sep 17 00:00:00 2001
From: Brandon Millman <brandon.millman@gmail.com>
Date: Tue, 6 Nov 2018 20:25:30 -0800
Subject: feat(instant): fallback to an empty wallet provider when none is
 injected

---
 .../src/components/zero_ex_instant_provider.tsx    | 86 ++++++++++++----------
 1 file changed, 46 insertions(+), 40 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 0b9408329..ed0fabdf3 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -1,23 +1,22 @@
-import { AssetBuyer } from '@0x/asset-buyer';
-import { ObjectMap, SignedOrder } from '@0x/types';
+import { ObjectMap } from '@0x/types';
 import { BigNumber } from '@0x/utils';
 import { Web3Wrapper } from '@0x/web3-wrapper';
 import { Provider } from 'ethereum-types';
 import * as _ from 'lodash';
 import * as React from 'react';
 import { Provider as ReduxProvider } from 'react-redux';
-import { oc } from 'ts-optchain';
 
 import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
 import { asyncData } from '../redux/async_data';
-import { INITIAL_STATE, State } from '../redux/reducer';
+import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
 import { store, Store } from '../redux/store';
 import { fonts } from '../style/fonts';
-import { AffiliateInfo, AssetMetaData, Network } from '../types';
+import { AffiliateInfo, AssetMetaData, Network, OrderSource, ProviderState, ProviderType } from '../types';
 import { assetUtils } from '../util/asset';
+import { assetBuyerFactory } from '../util/asset_buyer_factory';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
-import { getInjectedProvider } from '../util/injected_provider';
+import { providerFactory } from '../util/provider_factory';
 
 fonts.include();
 
@@ -25,7 +24,7 @@ export type ZeroExInstantProviderProps = ZeroExInstantProviderRequiredProps &
     Partial<ZeroExInstantProviderOptionalProps>;
 
 export interface ZeroExInstantProviderRequiredProps {
-    orderSource: string | SignedOrder[];
+    orderSource: OrderSource;
 }
 
 export interface ZeroExInstantProviderOptionalProps {
@@ -41,30 +40,43 @@ export interface ZeroExInstantProviderOptionalProps {
 export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
     private readonly _store: Store;
     // TODO(fragosti): Write tests for this beast once we inject a provider.
-    private static _mergeInitialStateWithProps(props: ZeroExInstantProviderProps, state: State = INITIAL_STATE): State {
-        const networkId = props.networkId || state.network;
-        // TODO: Proper wallet connect flow
-        const provider = props.provider || getInjectedProvider();
-        const assetBuyerOptions = {
-            networkId,
-        };
-        let assetBuyer;
-        if (_.isString(props.orderSource)) {
-            assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(
-                provider,
-                props.orderSource,
-                assetBuyerOptions,
-            );
+    private static _mergeDefaultStateWithProps(
+        props: ZeroExInstantProviderProps,
+        defaultState: DefaultState = DEFAULT_STATE,
+    ): State {
+        // use the networkId passed in with the props, otherwise default to that of the default state (1, mainnet)
+        const networkId = props.networkId || defaultState.network;
+        // construct the ProviderState
+        let provider: Provider;
+        let providerType: ProviderType;
+        if (!_.isUndefined(props.provider)) {
+            provider = props.provider;
+            providerType = ProviderType.Props;
         } else {
-            assetBuyer = AssetBuyer.getAssetBuyerForProvidedOrders(provider, props.orderSource, assetBuyerOptions);
+            const injectedProviderIfExists = providerFactory.getInjectedProviderIfExists();
+            if (!_.isUndefined(injectedProviderIfExists)) {
+                provider = injectedProviderIfExists;
+                providerType = ProviderType.Injected;
+            } else {
+                provider = providerFactory.getFallbackNoSigningProvider(networkId);
+                providerType = ProviderType.FallbackEmptyWallet;
+            }
         }
+        const providerState: ProviderState = {
+            provider,
+            type: providerType,
+            web3Wrapper: new Web3Wrapper(provider),
+            assetBuyer: assetBuyerFactory.getAssetBuyer(provider, props.orderSource, networkId),
+        };
+        // merge the additional additionalAssetMetaDataMap with our default map
         const completeAssetMetaDataMap = {
             ...props.additionalAssetMetaDataMap,
-            ...state.assetMetaDataMap,
+            ...defaultState.assetMetaDataMap,
         };
+        // construct the final state
         const storeStateFromProps: State = {
-            ...state,
-            assetBuyer,
+            ...defaultState,
+            providerState,
             network: networkId,
             selectedAsset: _.isUndefined(props.defaultSelectedAssetData)
                 ? undefined
@@ -74,7 +86,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
                       networkId,
                   ),
             selectedAssetAmount: _.isUndefined(props.defaultAssetBuyAmount)
-                ? state.selectedAssetAmount
+                ? undefined
                 : new BigNumber(props.defaultAssetBuyAmount),
             availableAssets: _.isUndefined(props.availableAssetDatas)
                 ? undefined
@@ -86,10 +98,9 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
     }
     constructor(props: ZeroExInstantProviderProps) {
         super(props);
-        const initialAppState = ZeroExInstantProvider._mergeInitialStateWithProps(this.props, INITIAL_STATE);
+        const initialAppState = ZeroExInstantProvider._mergeDefaultStateWithProps(this.props);
         this._store = store.create(initialAppState);
     }
-
     public componentDidMount(): void {
         const state = this._store.getState();
         // tslint:disable-next-line:no-floating-promises
@@ -108,7 +119,6 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         // tslint:disable-next-line:no-floating-promises
         this._flashErrorIfWrongNetwork();
     }
-
     public render(): React.ReactNode {
         return (
             <ReduxProvider store={this._store}>
@@ -116,19 +126,15 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             </ReduxProvider>
         );
     }
-
     private readonly _flashErrorIfWrongNetwork = async (): Promise<void> => {
         const msToShowError = 30000; // 30 seconds
-        const network = this._store.getState().network;
-        const assetBuyerIfExists = this._store.getState().assetBuyer;
-        const providerIfExists = oc(assetBuyerIfExists).provider();
-        if (!_.isUndefined(providerIfExists)) {
-            const web3Wrapper = new Web3Wrapper(providerIfExists);
-            const networkOfProvider = await web3Wrapper.getNetworkIdAsync();
-            if (network !== networkOfProvider) {
-                const errorMessage = `Wrong network detected. Try switching to ${Network[network]}.`;
-                errorFlasher.flashNewErrorMessage(this._store.dispatch, errorMessage, msToShowError);
-            }
+        const state = this._store.getState();
+        const network = state.network;
+        const web3Wrapper = state.providerState.web3Wrapper;
+        const networkOfProvider = await web3Wrapper.getNetworkIdAsync();
+        if (network !== networkOfProvider) {
+            const errorMessage = `Wrong network detected. Try switching to ${Network[network]}.`;
+            errorFlasher.flashNewErrorMessage(this._store.dispatch, errorMessage, msToShowError);
         }
     };
 }
-- 
cgit v1.2.3


From 28df5bfd94e817cb90689059d7255495ca6522ad Mon Sep 17 00:00:00 2001
From: Brandon Millman <brandon.millman@gmail.com>
Date: Tue, 6 Nov 2018 22:33:58 -0800
Subject: feat(instant): add Account to the ProviderState

---
 .../src/components/zero_ex_instant_provider.tsx    | 32 +++++-----------------
 1 file changed, 7 insertions(+), 25 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index ed0fabdf3..1fb5cf64f 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -1,6 +1,5 @@
 import { ObjectMap } from '@0x/types';
 import { BigNumber } from '@0x/utils';
-import { Web3Wrapper } from '@0x/web3-wrapper';
 import { Provider } from 'ethereum-types';
 import * as _ from 'lodash';
 import * as React from 'react';
@@ -11,12 +10,11 @@ import { asyncData } from '../redux/async_data';
 import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
 import { store, Store } from '../redux/store';
 import { fonts } from '../style/fonts';
-import { AffiliateInfo, AssetMetaData, Network, OrderSource, ProviderState, ProviderType } from '../types';
+import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
 import { assetUtils } from '../util/asset';
-import { assetBuyerFactory } from '../util/asset_buyer_factory';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
-import { providerFactory } from '../util/provider_factory';
+import { providerStateFactory } from '../util/provider_state_factory';
 
 fonts.include();
 
@@ -47,27 +45,11 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         // use the networkId passed in with the props, otherwise default to that of the default state (1, mainnet)
         const networkId = props.networkId || defaultState.network;
         // construct the ProviderState
-        let provider: Provider;
-        let providerType: ProviderType;
-        if (!_.isUndefined(props.provider)) {
-            provider = props.provider;
-            providerType = ProviderType.Props;
-        } else {
-            const injectedProviderIfExists = providerFactory.getInjectedProviderIfExists();
-            if (!_.isUndefined(injectedProviderIfExists)) {
-                provider = injectedProviderIfExists;
-                providerType = ProviderType.Injected;
-            } else {
-                provider = providerFactory.getFallbackNoSigningProvider(networkId);
-                providerType = ProviderType.FallbackEmptyWallet;
-            }
-        }
-        const providerState: ProviderState = {
-            provider,
-            type: providerType,
-            web3Wrapper: new Web3Wrapper(provider),
-            assetBuyer: assetBuyerFactory.getAssetBuyer(provider, props.orderSource, networkId),
-        };
+        const providerState = providerStateFactory.getInitialProviderState(
+            props.orderSource,
+            networkId,
+            props.provider,
+        );
         // merge the additional additionalAssetMetaDataMap with our default map
         const completeAssetMetaDataMap = {
             ...props.additionalAssetMetaDataMap,
-- 
cgit v1.2.3


From d0c009adff53d94414cf51028eff490e0452a3c9 Mon Sep 17 00:00:00 2001
From: Brandon Millman <brandon.millman@gmail.com>
Date: Wed, 7 Nov 2018 18:02:24 -0800
Subject: feat(instant): fetch account address at startup and drive account
 state changes

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 1fb5cf64f..fa0588b71 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -92,12 +92,12 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             // tslint:disable-next-line:no-floating-promises
             asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
         }
-
+        // tslint:disable-next-line:no-floating-promises
+        asyncData.fetchAccountInfoAndDispatchToStore(this._store);
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
         // tslint:disable-next-line:no-floating-promises
         gasPriceEstimator.getGasInfoAsync();
-
         // tslint:disable-next-line:no-floating-promises
         this._flashErrorIfWrongNetwork();
     }
-- 
cgit v1.2.3


From 7acaae37a969339d1b4971f80d7fd842266bb60b Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Thu, 8 Nov 2018 14:57:39 -0800
Subject: feat(instant): Heartbeat for updating account info

---
 .../instant/src/components/zero_ex_instant_provider.tsx     | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index fa0588b71..02f14c5b6 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -5,6 +5,7 @@ import * as _ from 'lodash';
 import * as React from 'react';
 import { Provider as ReduxProvider } from 'react-redux';
 
+import { ACCOUNT_UPDATE_INTERVAL_TIME_MS } from '../constants';
 import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
 import { asyncData } from '../redux/async_data';
 import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
@@ -14,6 +15,7 @@ import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
 import { assetUtils } from '../util/asset';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
+import { AccountUpdateHeartbeat } from '../util/hearbeats';
 import { providerStateFactory } from '../util/provider_state_factory';
 
 fonts.include();
@@ -37,6 +39,7 @@ export interface ZeroExInstantProviderOptionalProps {
 
 export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
     private readonly _store: Store;
+    private _accountUpdateHeartbeat?: AccountUpdateHeartbeat;
     // TODO(fragosti): Write tests for this beast once we inject a provider.
     private static _mergeDefaultStateWithProps(
         props: ZeroExInstantProviderProps,
@@ -93,7 +96,10 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
         }
         // tslint:disable-next-line:no-floating-promises
-        asyncData.fetchAccountInfoAndDispatchToStore(this._store);
+        // asyncData.fetchAccountInfoAndDispatchToStore(this._store);
+        this._accountUpdateHeartbeat = new AccountUpdateHeartbeat();
+        this._accountUpdateHeartbeat.start(this._store, ACCOUNT_UPDATE_INTERVAL_TIME_MS);
+
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
         // tslint:disable-next-line:no-floating-promises
@@ -101,6 +107,11 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         // tslint:disable-next-line:no-floating-promises
         this._flashErrorIfWrongNetwork();
     }
+    public componentWillUnmount(): void {
+        if (this._accountUpdateHeartbeat) {
+            this._accountUpdateHeartbeat.stop();
+        }
+    }
     public render(): React.ReactNode {
         return (
             <ReduxProvider store={this._store}>
-- 
cgit v1.2.3


From e45b6c7e98a33de0e13f4ab7db8b630900dbb960 Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Thu, 8 Nov 2018 16:54:45 -0800
Subject: Make heartbeat more generic

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 02f14c5b6..1805a11af 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -15,7 +15,7 @@ import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
 import { assetUtils } from '../util/asset';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
-import { AccountUpdateHeartbeat } from '../util/hearbeats';
+import { generateAccountHeartbeater, Heartbeater } from '../util/hearbeats';
 import { providerStateFactory } from '../util/provider_state_factory';
 
 fonts.include();
@@ -39,7 +39,7 @@ export interface ZeroExInstantProviderOptionalProps {
 
 export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
     private readonly _store: Store;
-    private _accountUpdateHeartbeat?: AccountUpdateHeartbeat;
+    private _accountUpdateHeartbeat?: Heartbeater;
     // TODO(fragosti): Write tests for this beast once we inject a provider.
     private static _mergeDefaultStateWithProps(
         props: ZeroExInstantProviderProps,
@@ -97,8 +97,9 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         }
         // tslint:disable-next-line:no-floating-promises
         // asyncData.fetchAccountInfoAndDispatchToStore(this._store);
-        this._accountUpdateHeartbeat = new AccountUpdateHeartbeat();
-        this._accountUpdateHeartbeat.start(this._store, ACCOUNT_UPDATE_INTERVAL_TIME_MS);
+
+        this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store);
+        this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
 
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
-- 
cgit v1.2.3


From 1e39d56cf751fd922d6fec86ecc8bc70b20bc6bb Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Thu, 8 Nov 2018 17:09:26 -0800
Subject: wip: BuyQuote heartbeat

---
 .../instant/src/components/zero_ex_instant_provider.tsx     | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 1805a11af..24ae0c4b6 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -5,7 +5,7 @@ import * as _ from 'lodash';
 import * as React from 'react';
 import { Provider as ReduxProvider } from 'react-redux';
 
-import { ACCOUNT_UPDATE_INTERVAL_TIME_MS } from '../constants';
+import { ACCOUNT_UPDATE_INTERVAL_TIME_MS, BUY_QUOTE_UPDATE_INTERVAL_TIME_MS } from '../constants';
 import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
 import { asyncData } from '../redux/async_data';
 import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
@@ -15,7 +15,7 @@ import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
 import { assetUtils } from '../util/asset';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
-import { generateAccountHeartbeater, Heartbeater } from '../util/hearbeats';
+import { generateAccountHeartbeater, Heartbeater, generateBuyQuoteHeartbeater } from '../util/hearbeats';
 import { providerStateFactory } from '../util/provider_state_factory';
 
 fonts.include();
@@ -40,6 +40,8 @@ export interface ZeroExInstantProviderOptionalProps {
 export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
     private readonly _store: Store;
     private _accountUpdateHeartbeat?: Heartbeater;
+    private _buyQuoteHeartbeat?: Heartbeater;
+
     // TODO(fragosti): Write tests for this beast once we inject a provider.
     private static _mergeDefaultStateWithProps(
         props: ZeroExInstantProviderProps,
@@ -101,6 +103,10 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store);
         this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
 
+        // TODO assign and stop on unmount
+        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater(this._store);
+        this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
+
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
         // tslint:disable-next-line:no-floating-promises
@@ -112,6 +118,9 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         if (this._accountUpdateHeartbeat) {
             this._accountUpdateHeartbeat.stop();
         }
+        if (this._buyQuoteHeartbeat) {
+            this._buyQuoteHeartbeat.stop();
+        }
     }
     public render(): React.ReactNode {
         return (
-- 
cgit v1.2.3


From 297a62fe80142897250f6dd6fddb4cdf1d3fe3ee Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Thu, 8 Nov 2018 17:13:22 -0800
Subject: move files around and rename

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 24ae0c4b6..bbc20dab6 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -15,7 +15,8 @@ import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
 import { assetUtils } from '../util/asset';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
-import { generateAccountHeartbeater, Heartbeater, generateBuyQuoteHeartbeater } from '../util/hearbeats';
+import { Heartbeater } from '../util/heartbeater';
+import { generateAccountHeartbeater, generateBuyQuoteHeartbeater } from '../util/heartbeater_factory';
 import { providerStateFactory } from '../util/provider_state_factory';
 
 fonts.include();
-- 
cgit v1.2.3


From fd12bdbbd5eb52af4758fd3821c6e09617f2ecb3 Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Thu, 8 Nov 2018 17:13:33 -0800
Subject: Remove old TODO

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 1 -
 1 file changed, 1 deletion(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index bbc20dab6..34257d25f 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -104,7 +104,6 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store);
         this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
 
-        // TODO assign and stop on unmount
         this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater(this._store);
         this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
 
-- 
cgit v1.2.3


From 2e8f74abce7be3a5799bb93a0360d299de55b621 Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Fri, 9 Nov 2018 10:40:47 -0800
Subject: Use existing functions instead of writing our own

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 34257d25f..f5605a187 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -99,13 +99,13 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
         }
         // tslint:disable-next-line:no-floating-promises
-        // asyncData.fetchAccountInfoAndDispatchToStore(this._store);
 
-        this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store);
+        this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store, true);
         this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
 
-        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater(this._store);
+        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater(this._store, false);
         this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
+        asyncData.fetchCurrentBuyQuoteAndDispatchToStore(this._store, true);
 
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
-- 
cgit v1.2.3


From 474db7c18de63429f72511796291ff135c77f10b Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Fri, 9 Nov 2018 11:22:46 -0800
Subject: Emulate named parameters with interface

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index f5605a187..20d677dc2 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -100,12 +100,15 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         }
         // tslint:disable-next-line:no-floating-promises
 
-        this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store, true);
+        this._accountUpdateHeartbeat = generateAccountHeartbeater({
+            store: this._store,
+            performImmediatelyOnStart: true,
+        });
         this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
 
-        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater(this._store, false);
+        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({ store: this._store, performImmediatelyOnStart: false });
         this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
-        asyncData.fetchCurrentBuyQuoteAndDispatchToStore(this._store, true);
+        asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, setPending: true });
 
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
-- 
cgit v1.2.3


From cc8debe53b9a6efc75b91f1b6c47f0820c3beb8c Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Fri, 9 Nov 2018 11:39:36 -0800
Subject: Linting and renaming variables

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 20d677dc2..1223b477e 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -98,17 +98,20 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             // tslint:disable-next-line:no-floating-promises
             asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
         }
-        // tslint:disable-next-line:no-floating-promises
 
         this._accountUpdateHeartbeat = generateAccountHeartbeater({
             store: this._store,
-            performImmediatelyOnStart: true,
+            shouldPerformImmediatelyOnStart: true,
         });
         this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
 
-        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({ store: this._store, performImmediatelyOnStart: false });
+        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({
+            store: this._store,
+            shouldPerformImmediatelyOnStart: false,
+        });
         this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
-        asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, setPending: true });
+        // tslint:disable-next-line:no-floating-promises
+        asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, shouldSetPending: true });
 
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
-- 
cgit v1.2.3


From 4072076965fba42ee02b689db1e97d9a970620f4 Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Fri, 9 Nov 2018 15:40:13 -0800
Subject: Don't start heartbeat if no account

---
 .../instant/src/components/zero_ex_instant_provider.tsx    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 1223b477e..fbe0e977f 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -11,7 +11,7 @@ import { asyncData } from '../redux/async_data';
 import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
 import { store, Store } from '../redux/store';
 import { fonts } from '../style/fonts';
-import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
+import { AffiliateInfo, AssetMetaData, Network, OrderSource, AccountState } from '../types';
 import { assetUtils } from '../util/asset';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
@@ -99,11 +99,13 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
         }
 
-        this._accountUpdateHeartbeat = generateAccountHeartbeater({
-            store: this._store,
-            shouldPerformImmediatelyOnStart: true,
-        });
-        this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
+        if (state.providerState.account.state !== AccountState.None) {
+            this._accountUpdateHeartbeat = generateAccountHeartbeater({
+                store: this._store,
+                shouldPerformImmediatelyOnStart: true,
+            });
+            this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
+        }
 
         this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({
             store: this._store,
-- 
cgit v1.2.3


From fd83ca2cb893ab7cc027efd6829ba2eb07cdb539 Mon Sep 17 00:00:00 2001
From: Steve Klebanoff <steve.klebanoff@gmail.com>
Date: Fri, 9 Nov 2018 15:52:25 -0800
Subject: linting

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index fbe0e977f..11f867abc 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -11,7 +11,7 @@ import { asyncData } from '../redux/async_data';
 import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
 import { store, Store } from '../redux/store';
 import { fonts } from '../style/fonts';
-import { AffiliateInfo, AssetMetaData, Network, OrderSource, AccountState } from '../types';
+import { AccountState, AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
 import { assetUtils } from '../util/asset';
 import { errorFlasher } from '../util/error_flasher';
 import { gasPriceEstimator } from '../util/gas_price_estimator';
-- 
cgit v1.2.3


From 38896c9358c07d722b2a24d458e6c949b802fa37 Mon Sep 17 00:00:00 2001
From: Brandon Millman <brandon.millman@gmail.com>
Date: Fri, 9 Nov 2018 00:42:50 -0800
Subject: feat(instant): handle privacy mode in wallets

---
 packages/instant/src/components/zero_ex_instant_provider.tsx | 2 --
 1 file changed, 2 deletions(-)

(limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')

diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 11f867abc..411f118cc 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -98,7 +98,6 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
             // tslint:disable-next-line:no-floating-promises
             asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
         }
-
         if (state.providerState.account.state !== AccountState.None) {
             this._accountUpdateHeartbeat = generateAccountHeartbeater({
                 store: this._store,
@@ -114,7 +113,6 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
         this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
         // tslint:disable-next-line:no-floating-promises
         asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, shouldSetPending: true });
-
         // warm up the gas price estimator cache just in case we can't
         // grab the gas price estimate when submitting the transaction
         // tslint:disable-next-line:no-floating-promises
-- 
cgit v1.2.3

