aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-shared/src/ts/utils/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/react-shared/src/ts/utils/utils.ts')
-rw-r--r--packages/react-shared/src/ts/utils/utils.ts15
1 files changed, 15 insertions, 0 deletions
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}`;
+ },
};