diff options
author | Hsuan Lee <hsuan@cobinhood.com> | 2019-01-19 18:42:04 +0800 |
---|---|---|
committer | Hsuan Lee <hsuan@cobinhood.com> | 2019-01-19 18:42:04 +0800 |
commit | 7ae38906926dc09bc10670c361af0d2bf0050426 (patch) | |
tree | 5fb10ae366b987db09e4ddb4bc3ba0f75404ad08 /packages/instant/src/util/provider_state_factory.ts | |
parent | b5fd3c72a08aaa6957917d74c333387a16edf66b (diff) | |
download | dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.gz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.bz2 dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.lz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.xz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.zst dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.zip |
Update dependency packages
Diffstat (limited to 'packages/instant/src/util/provider_state_factory.ts')
-rw-r--r-- | packages/instant/src/util/provider_state_factory.ts | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/packages/instant/src/util/provider_state_factory.ts b/packages/instant/src/util/provider_state_factory.ts deleted file mode 100644 index bd2d6dad5..000000000 --- a/packages/instant/src/util/provider_state_factory.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Web3Wrapper } from '@0x/web3-wrapper'; -import { Provider } from 'ethereum-types'; -import * as _ from 'lodash'; - -import { LOADING_ACCOUNT, NO_ACCOUNT } from '../constants'; -import { Maybe, Network, OrderSource, ProviderState } from '../types'; -import { envUtil } from '../util/env'; - -import { assetBuyerFactory } from './asset_buyer_factory'; -import { providerFactory } from './provider_factory'; - -export const providerStateFactory = { - getInitialProviderState: ( - orderSource: OrderSource, - network: Network, - provider?: Provider, - walletDisplayName?: string, - ): ProviderState => { - if (!_.isUndefined(provider)) { - return providerStateFactory.getInitialProviderStateFromProvider( - orderSource, - network, - provider, - walletDisplayName, - ); - } - const providerStateFromWindowIfExits = providerStateFactory.getInitialProviderStateFromWindowIfExists( - orderSource, - network, - walletDisplayName, - ); - if (providerStateFromWindowIfExits) { - return providerStateFromWindowIfExits; - } else { - return providerStateFactory.getInitialProviderStateFallback(orderSource, network, walletDisplayName); - } - }, - getInitialProviderStateFromProvider: ( - orderSource: OrderSource, - network: Network, - provider: Provider, - walletDisplayName?: string, - ): ProviderState => { - const providerState: ProviderState = { - name: envUtil.getProviderName(provider), - displayName: walletDisplayName || envUtil.getProviderDisplayName(provider), - provider, - web3Wrapper: new Web3Wrapper(provider), - assetBuyer: assetBuyerFactory.getAssetBuyer(provider, orderSource, network), - account: LOADING_ACCOUNT, - }; - return providerState; - }, - getInitialProviderStateFromWindowIfExists: ( - orderSource: OrderSource, - network: Network, - walletDisplayName?: string, - ): Maybe<ProviderState> => { - const injectedProviderIfExists = providerFactory.getInjectedProviderIfExists(); - if (!_.isUndefined(injectedProviderIfExists)) { - const providerState: ProviderState = { - name: envUtil.getProviderName(injectedProviderIfExists), - displayName: walletDisplayName || envUtil.getProviderDisplayName(injectedProviderIfExists), - provider: injectedProviderIfExists, - web3Wrapper: new Web3Wrapper(injectedProviderIfExists), - assetBuyer: assetBuyerFactory.getAssetBuyer(injectedProviderIfExists, orderSource, network), - account: LOADING_ACCOUNT, - }; - return providerState; - } else { - return undefined; - } - }, - getInitialProviderStateFallback: ( - orderSource: OrderSource, - network: Network, - walletDisplayName?: string, - ): ProviderState => { - const provider = providerFactory.getFallbackNoSigningProvider(network); - const providerState: ProviderState = { - name: 'Fallback', - displayName: walletDisplayName || envUtil.getProviderDisplayName(provider), - provider, - web3Wrapper: new Web3Wrapper(provider), - assetBuyer: assetBuyerFactory.getAssetBuyer(provider, orderSource, network), - account: NO_ACCOUNT, - }; - return providerState; - }, -}; |