From 0b1ba9f9971bea9003dfb30fca535c17ce62ad08 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 6 Mar 2018 16:31:55 +0100 Subject: Move Documentation to the `@0xproject/react-docs` package --- packages/react-shared/src/ts/utils/utils.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'packages/react-shared/src/ts/utils/utils.ts') diff --git a/packages/react-shared/src/ts/utils/utils.ts b/packages/react-shared/src/ts/utils/utils.ts index 7498342b6..0d2e045b8 100644 --- a/packages/react-shared/src/ts/utils/utils.ts +++ b/packages/react-shared/src/ts/utils/utils.ts @@ -1,6 +1,9 @@ +import isMobile = require('is-mobile'); import * as _ from 'lodash'; import { scroller } from 'react-scroll'; +import { EtherscanLinkSuffixes, Networks } from '../types'; + import { constants } from './constants'; export const utils = { @@ -19,6 +22,10 @@ export const utils = { containerId, }); }, + isUserOnMobile(): boolean { + const isUserOnMobile = isMobile(); + return isUserOnMobile; + }, getIdFromName(name: string) { const id = name.replace(/ /g, '-'); return id; @@ -29,4 +36,12 @@ export const utils = { const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`; return baseUrl; }, + getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string { + const networkName = constants.NETWORK_NAME_BY_ID[networkId]; + if (_.isUndefined(networkName)) { + return undefined; + } + const etherScanPrefix = networkName === Networks.Mainnet ? '' : `${networkName.toLowerCase()}.`; + return `https://${etherScanPrefix}etherscan.io/${suffix}/${addressOrTxHash}`; + }, }; -- cgit v1.2.3