From fb0b7efc4563c7c561866ab8691361ce6919160b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 18 Dec 2017 19:30:25 +0100 Subject: Refactor configs and constants, standardize on uppercase/snakecase, alphebetize, rename for logical grouping --- .../components/dialogs/blockchain_err_dialog.tsx | 24 +++++++++++----------- .../ts/components/dialogs/ledger_config_dialog.tsx | 5 +++-- .../dialogs/u2f_not_supported_dialog.tsx | 2 +- .../ts/components/eth_weth_conversion_button.tsx | 2 +- packages/website/ts/components/eth_wrappers.tsx | 12 ++++++----- packages/website/ts/components/fill_order_json.tsx | 3 ++- packages/website/ts/components/footer.tsx | 10 ++++----- .../ts/components/inputs/eth_amount_input.tsx | 4 ++-- packages/website/ts/components/order_json.tsx | 5 ++--- packages/website/ts/components/portal.tsx | 6 +++--- packages/website/ts/components/token_balances.tsx | 18 ++++++++-------- packages/website/ts/components/top_bar.tsx | 6 +++--- 12 files changed, 50 insertions(+), 47 deletions(-) (limited to 'packages/website/ts/components') diff --git a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx index aea5fcdd1..9a5cd90d7 100644 --- a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx +++ b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx @@ -71,9 +71,9 @@ export class BlockchainErrDialog extends React.Component You were disconnected from the backing Ethereum node. - {' '}If using + {' '}If using Metamask - or Mist try refreshing + or Mist try refreshing {' '}the page. If using a locally hosted Ethereum node, make sure it's still running. ); @@ -97,7 +97,7 @@ export class BlockchainErrDialog extends React.Component1. Metamask chrome extension
You can install the{' '} - + Metamask Chrome extension Ethereum wallet. Once installed and set up, refresh this page.
@@ -107,11 +107,11 @@ export class BlockchainErrDialog extends React.Component

Parity Signer

- The Parity Signer + The Parity Signer Chrome extension{' '}lets you connect to a locally running Parity node. Make sure you have started your local Parity node with{' '} - {configs.isMainnetEnabled && '`parity ui` or'} `parity --chain kovan ui`{' '} - in order to connect to {configs.isMainnetEnabled ? 'mainnet or Kovan respectively.' : 'Kovan.'} + {configs.IS_MAINNET_ENABLED && '`parity ui` or'} `parity --chain kovan ui`{' '} + in order to connect to {configs.IS_MAINNET_ENABLED ? 'mainnet or Kovan respectively.' : 'Kovan.'}
Note: @@ -130,24 +130,24 @@ export class BlockchainErrDialog extends React.Component

Metamask

If you are using{' '} - + Metamask , you can switch networks in the top left corner of the extension popover.

Parity Signer

- If using the Parity Signer + If using the Parity Signer Chrome extension, make sure to start your local Parity node with{' '} - {configs.isMainnetEnabled ? + {configs.IS_MAINNET_ENABLED ? '`parity ui` or `parity --chain Kovan ui` in order to connect to mainnet \ or Kovan respectively.' : '`parity --chain kovan ui` in order to connect to Kovan.' diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx index 05a15526f..ddd1f2cf2 100644 --- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx +++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx @@ -17,6 +17,7 @@ import {Blockchain} from 'ts/blockchain'; import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; import {Dispatcher} from 'ts/redux/dispatcher'; import {colors} from 'ts/utils/colors'; +import {configs} from 'ts/utils/configs'; import {constants} from 'ts/utils/constants'; import {utils} from 'ts/utils/utils'; @@ -52,7 +53,7 @@ export class LedgerConfigDialog extends React.Component Firefox with{' '} diff --git a/packages/website/ts/components/eth_weth_conversion_button.tsx b/packages/website/ts/components/eth_weth_conversion_button.tsx index 5464f8df0..351dfd9a4 100644 --- a/packages/website/ts/components/eth_weth_conversion_button.tsx +++ b/packages/website/ts/components/eth_weth_conversion_button.tsx @@ -89,7 +89,7 @@ export class EthWethConversionButton extends try { if (direction === Side.Deposit) { await this.props.blockchain.convertEthToWrappedEthTokensAsync(value); - const ethAmount = ZeroEx.toUnitAmount(value, constants.ETH_DECIMAL_PLACES); + const ethAmount = ZeroEx.toUnitAmount(value, constants.DECIMAL_PLACES_ETH); this.props.dispatcher.showFlashMessage(`Successfully wrapped ${ethAmount.toString()} ETH to WETH`); balance = balance.plus(value); } else { diff --git a/packages/website/ts/components/eth_wrappers.tsx b/packages/website/ts/components/eth_wrappers.tsx index ef1379e59..59353d18c 100644 --- a/packages/website/ts/components/eth_wrappers.tsx +++ b/packages/website/ts/components/eth_wrappers.tsx @@ -82,7 +82,7 @@ export class EthWrappers extends React.Component @@ -155,7 +155,7 @@ export class EthWrappers extends React.Component
Wrapped Ether @@ -241,7 +241,7 @@ export class EthWrappers extends React.Component { const outdatedWETH = outdatedWETHByNetworkId[this.props.networkId]; const timestampMsRange = outdatedWETH.timestampMsRange; @@ -260,7 +260,9 @@ export class EthWrappers extends React.Component { + const outdatedWETHAddresses = _.map(configs.OUTDATED_WRAPPED_ETHERS, outdatedWrappedEther => { return outdatedWrappedEther[this.props.networkId].address; }); return outdatedWETHAddresses; diff --git a/packages/website/ts/components/fill_order_json.tsx b/packages/website/ts/components/fill_order_json.tsx index 393e46bee..4a4bdac9f 100644 --- a/packages/website/ts/components/fill_order_json.tsx +++ b/packages/website/ts/components/fill_order_json.tsx @@ -41,9 +41,10 @@ export class FillOrderJSON extends React.Component { public render() { const amount = this.props.amount ? - ZeroEx.toUnitAmount(this.props.amount, constants.ETH_DECIMAL_PLACES) : + ZeroEx.toUnitAmount(this.props.amount, constants.DECIMAL_PLACES_ETH) : undefined; return (
@@ -45,7 +45,7 @@ export class EthAmountInput extends React.Component { const longUrl = encodeURIComponent(this.getOrderUrl()); - const bitlyRequestUrl = constants.BITLY_ENDPOINT + '/v3/shorten?' + - 'access_token=' + constants.BITLY_ACCESS_TOKEN + - '&longUrl=' + longUrl; + const bitlyRequestUrl = + `${constants.URL_BITLY_API}/v3/shorten?access_token=${configs.BITLY_ACCESS_TOKEN}&longUrl=${longUrl}`; const response = await fetch(bitlyRequestUrl); const responseBody = await response.text(); const bodyObj = JSON.parse(responseBody); diff --git a/packages/website/ts/components/portal.tsx b/packages/website/ts/components/portal.tsx index c292e0a92..521dd2b5f 100644 --- a/packages/website/ts/components/portal.tsx +++ b/packages/website/ts/components/portal.tsx @@ -87,7 +87,7 @@ export class Portal extends React.Component { } public componentWillMount() { this.blockchain = new Blockchain(this.props.dispatcher); - const didAcceptPortalDisclaimer = localStorage.getItemIfExists(constants.ACCEPT_DISCLAIMER_LOCAL_STORAGE_KEY); + const didAcceptPortalDisclaimer = localStorage.getItemIfExists(constants.LOCAL_STORAGE_KEY_ACCEPT_DISCLAIMER); const hasAcceptedDisclaimer = !_.isUndefined(didAcceptPortalDisclaimer) && !_.isEmpty(didAcceptPortalDisclaimer); this.setState({ @@ -153,7 +153,7 @@ export class Portal extends React.Component { />
- {!configs.isMainnetEnabled && this.props.networkId === constants.MAINNET_NETWORK_ID ? + {!configs.IS_MAINNET_ENABLED && this.props.networkId === constants.NETWORK_ID_MAINNET ?
Mainnet unavailable
@@ -300,7 +300,7 @@ export class Portal extends React.Component { ); } private onPortalDisclaimerAccepted() { - localStorage.setItem(constants.ACCEPT_DISCLAIMER_LOCAL_STORAGE_KEY, 'set'); + localStorage.setItem(constants.LOCAL_STORAGE_KEY_ACCEPT_DISCLAIMER, 'set'); this.setState({ hasAcceptedDisclaimer: true, }); diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index 61aea6a88..ecaf63af9 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -115,7 +115,7 @@ export class TokenBalances extends React.Component, ]; - const isTestNetwork = this.props.networkId === constants.TESTNET_NETWORK_ID; + const isTestNetwork = this.props.networkId === constants.NETWORK_ID_TESTNET; const dharmaButtonColumnStyle = { paddingLeft: 3, display: isTestNetwork ? 'table-cell' : 'none', @@ -380,8 +380,8 @@ export class TokenBalances extends React.Component } - {token.symbol === ZRX_TOKEN_SYMBOL && this.props.networkId === constants.TESTNET_NETWORK_ID && + {token.symbol === ZRX_TOKEN_SYMBOL && this.props.networkId === constants.NETWORK_ID_TESTNET && Our faucet can only send test Ether to addresses on the {constants.TESTNET_NAME} - {' '}testnet (networkId {constants.TESTNET_NETWORK_ID}). Please make sure you are + {' '}testnet (networkId {constants.NETWORK_ID_TESTNET}). Please make sure you are {' '}connected to the {constants.TESTNET_NAME} testnet and try requesting ether again.
); @@ -604,7 +604,7 @@ export class TokenBalances extends React.Component ${responseBody}`); diff --git a/packages/website/ts/components/top_bar.tsx b/packages/website/ts/components/top_bar.tsx index bcb8efd07..b731ee173 100644 --- a/packages/website/ts/components/top_bar.tsx +++ b/packages/website/ts/components/top_bar.tsx @@ -106,7 +106,7 @@ export class TopBar extends React.Component { key="subMenuItem-standard-relayer-api" target="_blank" className="text-decoration-none" - href={constants.STANDARD_RELAYER_API_GITHUB} + href={constants.URL_STANDARD_RELAYER_API_GITHUB} >
, @@ -114,7 +114,7 @@ export class TopBar extends React.Component { key="subMenuItem-github" target="_blank" className="text-decoration-none" - href={constants.GITHUB_URL} + href={constants.URL_GITHUB_ORG} > , @@ -254,7 +254,7 @@ export class TopBar extends React.Component { Blog -- cgit v1.2.3