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/env.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/env.ts')
-rw-r--r-- | packages/instant/src/util/env.ts | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/packages/instant/src/util/env.ts b/packages/instant/src/util/env.ts deleted file mode 100644 index 7d4f836ff..000000000 --- a/packages/instant/src/util/env.ts +++ /dev/null @@ -1,77 +0,0 @@ -import * as bowser from 'bowser'; -import { Provider } from 'ethereum-types'; -import * as _ from 'lodash'; - -import { PROVIDER_TYPE_TO_NAME } from '../constants'; -import { Browser, OperatingSystem, ProviderType } from '../types'; - -export const envUtil = { - getBrowser(): Browser { - if (bowser.chrome) { - return Browser.Chrome; - } else if (bowser.firefox) { - return Browser.Firefox; - } else if (bowser.opera) { - return Browser.Opera; - } else if (bowser.msedge) { - return Browser.Edge; - } else if (bowser.safari) { - return Browser.Safari; - } else { - return Browser.Other; - } - }, - isMobileOperatingSystem(): boolean { - return bowser.mobile; - }, - getOperatingSystem(): OperatingSystem { - if (bowser.android) { - return OperatingSystem.Android; - } else if (bowser.ios) { - return OperatingSystem.iOS; - } else if (bowser.mac) { - return OperatingSystem.Mac; - } else if (bowser.windows) { - return OperatingSystem.Windows; - } else if (bowser.windowsphone) { - return OperatingSystem.WindowsPhone; - } else if (bowser.linux) { - return OperatingSystem.Linux; - } else { - return OperatingSystem.Other; - } - }, - getProviderType(provider: Provider): ProviderType | undefined { - const anyProvider = provider as any; - if (provider.constructor.name === 'EthereumProvider') { - return ProviderType.Mist; - } else if (anyProvider.isTrust) { - return ProviderType.TrustWallet; - } else if (anyProvider.isParity) { - return ProviderType.Parity; - } else if (anyProvider.isMetaMask) { - return ProviderType.MetaMask; - } else if (!_.isUndefined(_.get(window, 'SOFA'))) { - return ProviderType.CoinbaseWallet; - } else if (!_.isUndefined(_.get(window, '__CIPHER__'))) { - return ProviderType.Cipher; - } else if (envUtil.getBrowser() === Browser.Opera && !anyProvider.isMetaMask) { - return ProviderType.Opera; - } - return; - }, - getProviderName(provider: Provider): string { - const providerTypeIfExists = envUtil.getProviderType(provider); - if (_.isUndefined(providerTypeIfExists)) { - return provider.constructor.name; - } - return PROVIDER_TYPE_TO_NAME[providerTypeIfExists]; - }, - getProviderDisplayName(provider: Provider): string { - const providerTypeIfExists = envUtil.getProviderType(provider); - if (_.isUndefined(providerTypeIfExists)) { - return 'Wallet'; - } - return PROVIDER_TYPE_TO_NAME[providerTypeIfExists]; - }, -}; |