aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/utils.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-09 15:39:38 +0800
committerFabio Berger <me@fabioberger.com>2018-03-09 15:39:38 +0800
commit9699ee4eff8a6594bd862883cac35de80dfbcf56 (patch)
tree01c5a092bd0180101dcc012e3d21320d9addb073 /packages/website/ts/utils/utils.ts
parentda277f5b2743c666a9a66e4fadf6678edd44fd69 (diff)
parent0eeaac1f2b5095441f7cd04bc948515d600d1f3a (diff)
downloaddexon-sol-tools-9699ee4eff8a6594bd862883cac35de80dfbcf56.tar
dexon-sol-tools-9699ee4eff8a6594bd862883cac35de80dfbcf56.tar.gz
dexon-sol-tools-9699ee4eff8a6594bd862883cac35de80dfbcf56.tar.bz2
dexon-sol-tools-9699ee4eff8a6594bd862883cac35de80dfbcf56.tar.lz
dexon-sol-tools-9699ee4eff8a6594bd862883cac35de80dfbcf56.tar.xz
dexon-sol-tools-9699ee4eff8a6594bd862883cac35de80dfbcf56.tar.zst
dexon-sol-tools-9699ee4eff8a6594bd862883cac35de80dfbcf56.zip
Merge branch 'development' into addPackagePublishConfig
* development: (94 commits) Update CHANGELOG Add solc 0.4.20 and 0.4.21 Prettier sra-report README Add new packages to top level README Updated @0xproject/utils in top level package.json Publish Updated CHANGELOGs Detail tests in the README Add support for ropsten and rinkeby Fix yarn.lock Update list of packages and organize them alphabetically Fix prettier issues Add support for going back to previous hashes via the browser back button to wiki Scroll to previous hashed elements when user clicks back button Add back strict null checks to react-shared package and fix issues remove ability to have implicit dependencies and add missing deps update license remove no-implicit-this Add example & screenshot to npmignore Remove `;` to be nice to windows users ...
Diffstat (limited to 'packages/website/ts/utils/utils.ts')
-rw-r--r--packages/website/ts/utils/utils.ts63
1 files changed, 11 insertions, 52 deletions
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index a1e045af7..308b4bb5c 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -1,20 +1,10 @@
import { ECSignature, ExchangeContractErrs, ZeroEx, ZeroExError } from '0x.js';
+import { constants as sharedConstants, EtherscanLinkSuffixes, Networks } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils';
import deepEqual = require('deep-equal');
-import isMobile = require('is-mobile');
import * as _ from 'lodash';
import * as moment from 'moment';
-import { scroller } from 'react-scroll';
-import {
- EtherscanLinkSuffixes,
- Networks,
- Order,
- ScreenWidths,
- Side,
- SideToAssetToken,
- Token,
- TokenByAddress,
-} from 'ts/types';
+import { Order, ScreenWidths, Side, SideToAssetToken, Token, TokenByAddress } from 'ts/types';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
import * as u2f from 'ts/vendor/u2f_api';
@@ -140,21 +130,6 @@ export const utils = {
return ScreenWidths.Sm;
}
},
- isUserOnMobile(): boolean {
- const isUserOnMobile = isMobile();
- return isUserOnMobile;
- },
- 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}`;
- },
- setUrlHash(anchorId: string) {
- window.location.hash = anchorId;
- },
async isU2FSupportedAsync(): Promise<boolean> {
const w = window as any;
return new Promise((resolve: (isSupported: boolean) => void) => {
@@ -202,10 +177,6 @@ export const utils = {
return 'production';
}
},
- getIdFromName(name: string) {
- const id = name.replace(/ /g, '-');
- return id;
- },
getAddressBeginAndEnd(address: string): string {
const truncatedAddress = `${address.substring(0, 6)}...${address.substr(-4)}`; // 0x3d5a...b287
return truncatedAddress;
@@ -283,32 +254,14 @@ export const utils = {
isTestNetwork(networkId: number): boolean {
const isTestNetwork = _.includes(
[
- constants.NETWORK_ID_BY_NAME[Networks.Kovan],
- constants.NETWORK_ID_BY_NAME[Networks.Rinkeby],
- constants.NETWORK_ID_BY_NAME[Networks.Ropsten],
+ sharedConstants.NETWORK_ID_BY_NAME[Networks.Kovan],
+ sharedConstants.NETWORK_ID_BY_NAME[Networks.Rinkeby],
+ sharedConstants.NETWORK_ID_BY_NAME[Networks.Ropsten],
],
networkId,
);
return isTestNetwork;
},
- getCurrentBaseUrl() {
- const port = window.location.port;
- const hasPort = !_.isUndefined(port);
- const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`;
- return baseUrl;
- },
- scrollToHash(hash: string, containerId: string): void {
- let finalHash = hash;
- if (_.isEmpty(hash)) {
- finalHash = configs.SCROLL_TOP_ID; // scroll to the top
- }
-
- scroller.scrollTo(finalHash, {
- duration: 0,
- offset: 0,
- containerId,
- });
- },
async onPageLoadAsync(): Promise<void> {
if (document.readyState === 'complete') {
return; // Already loaded
@@ -317,4 +270,10 @@ export const utils = {
window.onload = () => resolve();
});
},
+ getCurrentBaseUrl() {
+ const port = window.location.port;
+ const hasPort = !_.isUndefined(port);
+ const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`;
+ return baseUrl;
+ },
};