From e744e4cd989bd3ae1070c59f7baa8097f18b8b06 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 22 Dec 2017 15:05:32 +0100 Subject: Apply prettier config --- packages/website/ts/blockchain.ts | 249 ++++++------ .../components/dialogs/blockchain_err_dialog.tsx | 97 +++-- .../dialogs/eth_weth_conversion_dialog.tsx | 89 ++--- .../ts/components/dialogs/ledger_config_dialog.tsx | 99 ++--- .../dialogs/portal_disclaimer_dialog.tsx | 32 +- .../website/ts/components/dialogs/send_dialog.tsx | 22 +- .../dialogs/track_token_confirmation_dialog.tsx | 25 +- .../dialogs/u2f_not_supported_dialog.tsx | 24 +- .../dialogs/wrapped_eth_section_notice_dialog.tsx | 19 +- .../ts/components/eth_weth_conversion_button.tsx | 33 +- packages/website/ts/components/eth_wrappers.tsx | 268 ++++++------- packages/website/ts/components/fill_order.tsx | 235 ++++++------ packages/website/ts/components/fill_order_json.tsx | 36 +- .../website/ts/components/fill_warning_dialog.tsx | 16 +- .../flash_messages/token_send_completed.tsx | 23 +- .../flash_messages/transaction_submitted.tsx | 8 +- packages/website/ts/components/footer.tsx | 87 ++--- .../ts/components/generate_order/asset_picker.tsx | 76 ++-- .../generate_order/generate_order_form.tsx | 92 +++-- .../components/generate_order/new_token_form.tsx | 47 +-- .../website/ts/components/inputs/address_input.tsx | 20 +- .../ts/components/inputs/allowance_toggle.tsx | 16 +- .../ts/components/inputs/balance_bounded_input.tsx | 65 ++-- .../ts/components/inputs/eth_amount_input.tsx | 26 +- .../ts/components/inputs/expiration_input.tsx | 26 +- .../website/ts/components/inputs/hash_input.tsx | 16 +- .../components/inputs/identicon_address_input.tsx | 17 +- .../ts/components/inputs/token_amount_input.tsx | 28 +- .../website/ts/components/inputs/token_input.tsx | 23 +- packages/website/ts/components/order_json.tsx | 115 +++--- packages/website/ts/components/portal.tsx | 115 +++--- packages/website/ts/components/portal_menu.tsx | 12 +- packages/website/ts/components/send_button.tsx | 16 +- packages/website/ts/components/token_balances.tsx | 313 ++++++--------- packages/website/ts/components/top_bar.tsx | 162 ++++---- .../website/ts/components/top_bar_menu_item.tsx | 30 +- .../ts/components/track_token_confirmation.tsx | 32 +- .../ts/components/trade_history/trade_history.tsx | 12 +- .../trade_history/trade_history_item.tsx | 65 ++-- packages/website/ts/components/ui/alert.tsx | 6 +- packages/website/ts/components/ui/badge.tsx | 2 +- packages/website/ts/components/ui/copy_icon.tsx | 38 +- .../ts/components/ui/drop_down_menu_item.tsx | 29 +- .../website/ts/components/ui/ethereum_address.tsx | 13 +- .../website/ts/components/ui/etherscan_icon.tsx | 35 +- .../website/ts/components/ui/fake_text_field.tsx | 6 +- .../website/ts/components/ui/flash_message.tsx | 4 +- packages/website/ts/components/ui/help_tooltip.tsx | 4 +- packages/website/ts/components/ui/identicon.tsx | 18 +- packages/website/ts/components/ui/input_label.tsx | 6 +- .../ts/components/ui/lifecycle_raised_button.tsx | 21 +- packages/website/ts/components/ui/loading.tsx | 21 +- packages/website/ts/components/ui/menu_item.tsx | 4 +- packages/website/ts/components/ui/party.tsx | 126 +++--- .../website/ts/components/ui/required_label.tsx | 6 +- .../website/ts/components/ui/simple_loading.tsx | 11 +- packages/website/ts/components/ui/swap_icon.tsx | 9 +- packages/website/ts/components/ui/token_icon.tsx | 14 +- packages/website/ts/components/visual_order.tsx | 12 +- .../ts/containers/connect_documentation.tsx | 51 +-- .../website/ts/containers/generate_order_form.tsx | 15 +- packages/website/ts/containers/portal.tsx | 43 +-- .../containers/smart_contracts_documentation.tsx | 42 +- .../ts/containers/zero_ex_js_documentation.tsx | 52 +-- packages/website/ts/globals.d.ts | 26 +- packages/website/ts/index.tsx | 61 ++- packages/website/ts/lazy_component.tsx | 13 +- .../ts/local_storage/tracked_token_storage.ts | 12 +- .../ts/local_storage/trade_history_storage.tsx | 18 +- packages/website/ts/pages/about/about.tsx | 97 ++--- packages/website/ts/pages/about/profile.tsx | 54 +-- .../website/ts/pages/documentation/comment.tsx | 7 +- .../website/ts/pages/documentation/custom_enum.tsx | 9 +- .../website/ts/pages/documentation/docs_info.ts | 9 +- .../ts/pages/documentation/documentation.tsx | 246 ++++++------ packages/website/ts/pages/documentation/enum.tsx | 6 +- .../ts/pages/documentation/event_definition.tsx | 36 +- .../website/ts/pages/documentation/interface.tsx | 32 +- .../ts/pages/documentation/method_block.tsx | 106 ++--- .../ts/pages/documentation/method_signature.tsx | 60 +-- .../website/ts/pages/documentation/source_link.tsx | 17 +- packages/website/ts/pages/documentation/type.tsx | 113 +++--- .../ts/pages/documentation/type_definition.tsx | 68 ++-- packages/website/ts/pages/faq/faq.tsx | 374 ++++++++---------- packages/website/ts/pages/faq/question.tsx | 18 +- packages/website/ts/pages/landing/landing.tsx | 427 +++++++++------------ packages/website/ts/pages/not_found.tsx | 13 +- packages/website/ts/pages/shared/anchor_title.tsx | 21 +- .../ts/pages/shared/markdown_code_block.tsx | 8 +- .../website/ts/pages/shared/markdown_section.tsx | 23 +- .../ts/pages/shared/nested_sidebar_menu.tsx | 107 +++--- .../website/ts/pages/shared/section_header.tsx | 10 +- .../website/ts/pages/shared/version_drop_down.tsx | 10 +- packages/website/ts/pages/wiki/wiki.tsx | 96 +++-- packages/website/ts/redux/dispatcher.ts | 66 ++-- packages/website/ts/redux/reducer.ts | 6 +- packages/website/ts/schemas/order_schema.ts | 27 +- packages/website/ts/schemas/order_taker_schema.ts | 8 +- .../website/ts/schemas/signature_data_schema.ts | 8 +- packages/website/ts/schemas/token_schema.ts | 8 +- packages/website/ts/schemas/validator.ts | 10 +- packages/website/ts/types.ts | 77 ++-- packages/website/ts/utils/colors.ts | 2 +- packages/website/ts/utils/configs.ts | 97 +++-- packages/website/ts/utils/constants.ts | 10 +- packages/website/ts/utils/doc_utils.ts | 15 +- packages/website/ts/utils/doxity_utils.ts | 74 ++-- packages/website/ts/utils/error_reporter.ts | 10 +- packages/website/ts/utils/mui_theme.ts | 4 +- packages/website/ts/utils/typedoc_utils.ts | 182 +++++---- packages/website/ts/utils/utils.ts | 81 ++-- packages/website/ts/web3_wrapper.ts | 16 +- 112 files changed, 2774 insertions(+), 3298 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index 3d21a5046..4ed1fe371 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -21,16 +21,16 @@ import { LedgerWalletSubprovider, RedundantRPCSubprovider, } from '@0xproject/subproviders'; -import {intervalUtils, promisify} from '@0xproject/utils'; +import { intervalUtils, promisify } from '@0xproject/utils'; import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as React from 'react'; import contract = require('truffle-contract'); -import {TokenSendCompleted} from 'ts/components/flash_messages/token_send_completed'; -import {TransactionSubmitted} from 'ts/components/flash_messages/transaction_submitted'; -import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; -import {tradeHistoryStorage} from 'ts/local_storage/trade_history_storage'; -import {Dispatcher} from 'ts/redux/dispatcher'; +import { TokenSendCompleted } from 'ts/components/flash_messages/token_send_completed'; +import { TransactionSubmitted } from 'ts/components/flash_messages/transaction_submitted'; +import { trackedTokenStorage } from 'ts/local_storage/tracked_token_storage'; +import { tradeHistoryStorage } from 'ts/local_storage/trade_history_storage'; +import { Dispatcher } from 'ts/redux/dispatcher'; import { BlockchainCallErrs, BlockchainErrs, @@ -43,11 +43,11 @@ import { TokenByAddress, TokenStateByAddress, } from 'ts/types'; -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; -import {errorReporter} from 'ts/utils/error_reporter'; -import {utils} from 'ts/utils/utils'; -import {Web3Wrapper} from 'ts/web3_wrapper'; +import { configs } from 'ts/utils/configs'; +import { constants } from 'ts/utils/constants'; +import { errorReporter } from 'ts/utils/error_reporter'; +import { utils } from 'ts/utils/utils'; +import { Web3Wrapper } from 'ts/web3_wrapper'; import Web3 = require('web3'); import ProviderEngine = require('web3-provider-engine'); import FilterSubprovider = require('web3-provider-engine/subproviders/filters'); @@ -101,9 +101,7 @@ export class Blockchain { provider = new ProviderEngine(); provider.addProvider(new InjectedWeb3Subprovider(injectedWeb3)); provider.addProvider(new FilterSubprovider()); - provider.addProvider(new RedundantRPCSubprovider( - publicNodeUrlsIfExistsForNetworkId, - )); + provider.addProvider(new RedundantRPCSubprovider(publicNodeUrlsIfExistsForNetworkId)); provider.start(); } else if (doesInjectedWeb3Exist) { // Since no public node for this network, all requests go to injectedWeb3 instance @@ -114,12 +112,8 @@ export class Blockchain { // injected into their browser. provider = new ProviderEngine(); provider.addProvider(new FilterSubprovider()); - const networkId = configs.IS_MAINNET_ENABLED ? - constants.NETWORK_ID_MAINNET : - constants.NETWORK_ID_TESTNET; - provider.addProvider(new RedundantRPCSubprovider( - configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], - )); + const networkId = configs.IS_MAINNET_ENABLED ? constants.NETWORK_ID_MAINNET : constants.NETWORK_ID_TESTNET; + provider.addProvider(new RedundantRPCSubprovider(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId])); provider.start(); } @@ -162,8 +156,7 @@ export class Blockchain { // already in the tokenRegistry. // TODO: Remove this hack once we've updated the TokenRegistries // Airtable task: https://airtable.com/tblFe0Q9JuKJPYbTn/viwsOG2Y97qdIeCIO/recv3VGmIorFzHBVz - if (configs.SHOULD_DEPRECATE_OLD_WETH_TOKEN && - tokenAddress === configs.NEW_WRAPPED_ETHERS[this.networkId]) { + if (configs.SHOULD_DEPRECATE_OLD_WETH_TOKEN && tokenAddress === configs.NEW_WRAPPED_ETHERS[this.networkId]) { return true; } const tokenIfExists = await this._zeroEx.tokenRegistry.getTokenIfExistsAsync(tokenAddress); @@ -213,12 +206,10 @@ export class Blockchain { this._ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs); provider.addProvider(this._ledgerSubprovider); provider.addProvider(new FilterSubprovider()); - const networkId = configs.IS_MAINNET_ENABLED ? - constants.NETWORK_ID_MAINNET : - constants.NETWORK_ID_TESTNET; - provider.addProvider(new RedundantRPCSubprovider( - configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], - )); + const networkId = configs.IS_MAINNET_ENABLED + ? constants.NETWORK_ID_MAINNET + : constants.NETWORK_ID_TESTNET; + provider.addProvider(new RedundantRPCSubprovider(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId])); provider.start(); this._web3Wrapper.destroy(); const shouldPollUserAddress = false; @@ -254,32 +245,46 @@ export class Blockchain { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); const txHash = await this._zeroEx.token.setProxyAllowanceAsync( - token.address, this._userAddress, amountInBaseUnits, + token.address, + this._userAddress, + amountInBaseUnits, ); await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); const allowance = amountInBaseUnits; this._dispatcher.replaceTokenAllowanceByAddress(token.address, allowance); } - public async transferAsync(token: Token, toAddress: string, - amountInBaseUnits: BigNumber): Promise { + public async transferAsync(token: Token, toAddress: string, amountInBaseUnits: BigNumber): Promise { const txHash = await this._zeroEx.token.transferAsync( - token.address, this._userAddress, toAddress, amountInBaseUnits, + token.address, + this._userAddress, + toAddress, + amountInBaseUnits, ); await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.Tx); - this._dispatcher.showFlashMessage(React.createElement(TokenSendCompleted, { - etherScanLinkIfExists, - token, - toAddress, - amountInBaseUnits, - })); - } - public portalOrderToSignedOrder(maker: string, taker: string, makerTokenAddress: string, - takerTokenAddress: string, makerTokenAmount: BigNumber, - takerTokenAmount: BigNumber, makerFee: BigNumber, - takerFee: BigNumber, expirationUnixTimestampSec: BigNumber, - feeRecipient: string, - signatureData: SignatureData, salt: BigNumber): SignedOrder { + this._dispatcher.showFlashMessage( + React.createElement(TokenSendCompleted, { + etherScanLinkIfExists, + token, + toAddress, + amountInBaseUnits, + }), + ); + } + public portalOrderToSignedOrder( + maker: string, + taker: string, + makerTokenAddress: string, + takerTokenAddress: string, + makerTokenAmount: BigNumber, + takerTokenAmount: BigNumber, + makerFee: BigNumber, + takerFee: BigNumber, + expirationUnixTimestampSec: BigNumber, + feeRecipient: string, + signatureData: SignatureData, + salt: BigNumber, + ): SignedOrder { const ecSignature = signatureData; const exchangeContractAddress = this.getExchangeContractAddressIfExists(); const takerOrNullAddress = _.isEmpty(taker) ? constants.NULL_ADDRESS : taker; @@ -300,33 +305,32 @@ export class Blockchain { }; return signedOrder; } - public async fillOrderAsync(signedOrder: SignedOrder, - fillTakerTokenAmount: BigNumber): Promise { + public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber): Promise { utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); const shouldThrowOnInsufficientBalanceOrAllowance = true; const txHash = await this._zeroEx.exchange.fillOrderAsync( - signedOrder, fillTakerTokenAmount, shouldThrowOnInsufficientBalanceOrAllowance, this._userAddress, + signedOrder, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + this._userAddress, ); const receipt = await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); const logs: Array> = receipt.logs as any; this._zeroEx.exchange.throwLogErrorsAsErrors(logs); - const logFill = _.find(logs, {event: 'LogFill'}); - const args = logFill.args as any as LogFillContractEventArgs; + const logFill = _.find(logs, { event: 'LogFill' }); + const args = (logFill.args as any) as LogFillContractEventArgs; const filledTakerTokenAmount = args.filledTakerTokenAmount; return filledTakerTokenAmount; } - public async cancelOrderAsync(signedOrder: SignedOrder, - cancelTakerTokenAmount: BigNumber): Promise { - const txHash = await this._zeroEx.exchange.cancelOrderAsync( - signedOrder, cancelTakerTokenAmount, - ); + public async cancelOrderAsync(signedOrder: SignedOrder, cancelTakerTokenAmount: BigNumber): Promise { + const txHash = await this._zeroEx.exchange.cancelOrderAsync(signedOrder, cancelTakerTokenAmount); const receipt = await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); const logs: Array> = receipt.logs as any; this._zeroEx.exchange.throwLogErrorsAsErrors(logs); - const logCancel = _.find(logs, {event: ExchangeEvents.LogCancel}); - const args = logCancel.args as any as LogCancelContractEventArgs; + const logCancel = _.find(logs, { event: ExchangeEvents.LogCancel }); + const args = (logCancel.args as any) as LogCancelContractEventArgs; const cancelledTakerTokenAmount = args.cancelledTakerTokenAmount; return cancelledTakerTokenAmount; } @@ -339,14 +343,21 @@ export class Blockchain { public getExchangeContractAddressIfExists() { return this._exchangeAddress; } - public async validateFillOrderThrowIfInvalidAsync(signedOrder: SignedOrder, - fillTakerTokenAmount: BigNumber, - takerAddress: string): Promise { + public async validateFillOrderThrowIfInvalidAsync( + signedOrder: SignedOrder, + fillTakerTokenAmount: BigNumber, + takerAddress: string, + ): Promise { await this._zeroEx.exchange.validateFillOrderThrowIfInvalidAsync( - signedOrder, fillTakerTokenAmount, takerAddress); + signedOrder, + fillTakerTokenAmount, + takerAddress, + ); } - public async validateCancelOrderThrowIfInvalidAsync(order: Order, - cancelTakerTokenAmount: BigNumber): Promise { + public async validateCancelOrderThrowIfInvalidAsync( + order: Order, + cancelTakerTokenAmount: BigNumber, + ): Promise { await this._zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(order, cancelTakerTokenAmount); } public isValidAddress(address: string): boolean { @@ -415,11 +426,10 @@ export class Blockchain { return doesContractExist; } public async getCurrentUserTokenBalanceAndAllowanceAsync(tokenAddress: string): Promise { - const tokenBalanceAndAllowance = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, tokenAddress); - return tokenBalanceAndAllowance; + const tokenBalanceAndAllowance = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, tokenAddress); + return tokenBalanceAndAllowance; } - public async getTokenBalanceAndAllowanceAsync(ownerAddress: string, tokenAddress: string): - Promise { + public async getTokenBalanceAndAllowanceAsync(ownerAddress: string, tokenAddress: string): Promise { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); if (_.isEmpty(ownerAddress)) { @@ -440,10 +450,7 @@ export class Blockchain { let balance = new BigNumber(0); let allowance = new BigNumber(0); if (this._doesUserAddressExist()) { - [ - balance, - allowance, - ] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address); + [balance, allowance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address); } const tokenState = { balance, @@ -470,11 +477,14 @@ export class Blockchain { this._stopWatchingExchangeLogFillEvents(); } private async _showEtherScanLinkAndAwaitTransactionMinedAsync( - txHash: string): Promise { + txHash: string, + ): Promise { const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.Tx); - this._dispatcher.showFlashMessage(React.createElement(TransactionSubmitted, { - etherScanLinkIfExists, - })); + this._dispatcher.showFlashMessage( + React.createElement(TransactionSubmitted, { + etherScanLinkIfExists, + }), + ); const receipt = await this._zeroEx.awaitTransactionMinedAsync(txHash); return receipt; } @@ -506,29 +516,31 @@ export class Blockchain { // Start a subscription for new logs this._zeroEx.exchange.subscribe( - ExchangeEvents.LogFill, indexFilterValues, + ExchangeEvents.LogFill, + indexFilterValues, async (err: Error, decodedLogEvent: DecodedLogEvent) => { - if (err) { - // Note: it's not entirely clear from the documentation which - // errors will be thrown by `watch`. For now, let's log the error - // to rollbar and stop watching when one occurs - // tslint:disable-next-line:no-floating-promises - errorReporter.reportAsync(err); // fire and forget - return; - } else { - const decodedLog = decodedLogEvent.log; - if (!this._doesLogEventInvolveUser(decodedLog)) { - return; // We aren't interested in the fill event - } - this._updateLatestFillsBlockIfNeeded(decodedLog.blockNumber); - const fill = await this._convertDecodedLogToFillAsync(decodedLog); - if (decodedLogEvent.isRemoved) { - tradeHistoryStorage.removeFillFromUser(this._userAddress, this.networkId, fill); + if (err) { + // Note: it's not entirely clear from the documentation which + // errors will be thrown by `watch`. For now, let's log the error + // to rollbar and stop watching when one occurs + // tslint:disable-next-line:no-floating-promises + errorReporter.reportAsync(err); // fire and forget + return; } else { - tradeHistoryStorage.addFillToUser(this._userAddress, this.networkId, fill); + const decodedLog = decodedLogEvent.log; + if (!this._doesLogEventInvolveUser(decodedLog)) { + return; // We aren't interested in the fill event + } + this._updateLatestFillsBlockIfNeeded(decodedLog.blockNumber); + const fill = await this._convertDecodedLogToFillAsync(decodedLog); + if (decodedLogEvent.isRemoved) { + tradeHistoryStorage.removeFillFromUser(this._userAddress, this.networkId, fill); + } else { + tradeHistoryStorage.addFillToUser(this._userAddress, this.networkId, fill); + } } - } - }); + }, + ); } private async _fetchHistoricalExchangeLogFillEventsAsync(indexFilterValues: IndexedFilterValues) { const fromBlock = tradeHistoryStorage.getFillsLatestBlock(this._userAddress, this.networkId); @@ -537,7 +549,9 @@ export class Blockchain { toBlock: 'latest' as BlockParam, }; const decodedLogs = await this._zeroEx.exchange.getLogsAsync( - ExchangeEvents.LogFill, blockRange, indexFilterValues, + ExchangeEvents.LogFill, + blockRange, + indexFilterValues, ); for (const decodedLog of decodedLogs) { if (!this._doesLogEventInvolveUser(decodedLog)) { @@ -569,8 +583,7 @@ export class Blockchain { } private _doesLogEventInvolveUser(decodedLog: LogWithDecodedArgs) { const args = decodedLog.args; - const isUserMakerOrTaker = args.maker === this._userAddress || - args.taker === this._userAddress; + const isUserMakerOrTaker = args.maker === this._userAddress || args.taker === this._userAddress; return isUserMakerOrTaker; } private _updateLatestFillsBlockIfNeeded(blockNumber: number) { @@ -582,9 +595,8 @@ export class Blockchain { // would still attempt to re-fetch events from the previous 50 blocks, but won't need to // re-fetch all events in all blocks. // TODO: Debug if this is a race condition, and apply a more precise fix - const blockNumberToSet = blockNumber - BLOCK_NUMBER_BACK_TRACK < 0 ? - 0 : - blockNumber - BLOCK_NUMBER_BACK_TRACK; + const blockNumberToSet = + blockNumber - BLOCK_NUMBER_BACK_TRACK < 0 ? 0 : blockNumber - BLOCK_NUMBER_BACK_TRACK; tradeHistoryStorage.setFillsLatestBlock(this._userAddress, this.networkId, blockNumberToSet); } } @@ -608,10 +620,10 @@ export class Blockchain { // Airtable task: https://airtable.com/tblFe0Q9JuKJPYbTn/viwsOG2Y97qdIeCIO/recv3VGmIorFzHBVz let address = t.address; if (configs.SHOULD_DEPRECATE_OLD_WETH_TOKEN && t.symbol === 'WETH') { - const newEtherTokenAddressIfExists = configs.NEW_WRAPPED_ETHERS[this.networkId]; - if (!_.isUndefined(newEtherTokenAddressIfExists)) { - address = newEtherTokenAddressIfExists; - } + const newEtherTokenAddressIfExists = configs.NEW_WRAPPED_ETHERS[this.networkId]; + if (!_.isUndefined(newEtherTokenAddressIfExists)) { + address = newEtherTokenAddressIfExists; + } } const token: Token = { iconUrl, @@ -646,10 +658,9 @@ export class Blockchain { } const provider = await Blockchain._getProviderAsync(injectedWeb3, networkIdIfExists); - const networkId = !_.isUndefined(networkIdIfExists) ? networkIdIfExists : - configs.IS_MAINNET_ENABLED ? - constants.NETWORK_ID_MAINNET : - constants.NETWORK_ID_TESTNET; + const networkId = !_.isUndefined(networkIdIfExists) + ? networkIdIfExists + : configs.IS_MAINNET_ENABLED ? constants.NETWORK_ID_MAINNET : constants.NETWORK_ID_TESTNET; const zeroExConfigs = { networkId, }; @@ -667,14 +678,16 @@ export class Blockchain { } private _updateProviderName(injectedWeb3: Web3) { const doesInjectedWeb3Exist = !_.isUndefined(injectedWeb3); - const providerName = doesInjectedWeb3Exist ? - Blockchain._getNameGivenProvider(injectedWeb3.currentProvider) : - constants.PROVIDER_NAME_PUBLIC; + const providerName = doesInjectedWeb3Exist + ? Blockchain._getNameGivenProvider(injectedWeb3.currentProvider) + : constants.PROVIDER_NAME_PUBLIC; this._dispatcher.updateInjectedProviderName(providerName); } private async _fetchTokenInformationAsync() { - utils.assert(!_.isUndefined(this.networkId), - 'Cannot call fetchTokenInformationAsync if disconnected from Ethereum node'); + utils.assert( + !_.isUndefined(this.networkId), + 'Cannot call fetchTokenInformationAsync if disconnected from Ethereum node', + ); this._dispatcher.updateBlockchainIsLoaded(false); this._dispatcher.clearTokenByAddress(); @@ -717,8 +730,8 @@ export class Blockchain { await this.updateTokenBalancesAndAllowancesAsync(trackedTokensIfExists); const mostPopularTradingPairTokens: Token[] = [ - _.find(allTokens, {symbol: configs.DEFAULT_TRACKED_TOKEN_SYMBOLS[0]}), - _.find(allTokens, {symbol: configs.DEFAULT_TRACKED_TOKEN_SYMBOLS[1]}), + _.find(allTokens, { symbol: configs.DEFAULT_TRACKED_TOKEN_SYMBOLS[0] }), + _.find(allTokens, { symbol: configs.DEFAULT_TRACKED_TOKEN_SYMBOLS[1] }), ]; this._dispatcher.updateChosenAssetTokenAddress(Side.Deposit, mostPopularTradingPairTokens[0].address); this._dispatcher.updateChosenAssetTokenAddress(Side.Receive, mostPopularTradingPairTokens[1].address); @@ -746,9 +759,7 @@ export class Blockchain { } try { - const contractInstance = _.isUndefined(address) ? - await c.deployed() : - await c.at(address); + const contractInstance = _.isUndefined(address) ? await c.deployed() : await c.at(address); return contractInstance; } catch (err) { const errMsg = `${err}`; diff --git a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx index 900d0e193..f555ca6b1 100644 --- a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx +++ b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx @@ -2,11 +2,11 @@ import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; -import {Blockchain} from 'ts/blockchain'; -import {BlockchainErrs} from 'ts/types'; -import {colors} from 'ts/utils/colors'; -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; +import { Blockchain } from 'ts/blockchain'; +import { BlockchainErrs } from 'ts/types'; +import { colors } from 'ts/utils/colors'; +import { configs } from 'ts/utils/configs'; +import { constants } from 'ts/utils/constants'; interface BlockchainErrDialogProps { blockchain: Blockchain; @@ -32,14 +32,14 @@ export class BlockchainErrDialog extends React.Component -
+
{this._renderExplanation(hasWalletAddress)}
@@ -70,54 +70,55 @@ export class BlockchainErrDialog extends React.Component - You were disconnected from the backing Ethereum node. - {' '}If using + You were disconnected from the backing Ethereum node. If using{' '} + Metamask - or Mist try refreshing - {' '}the page. If using a locally hosted Ethereum node, make sure it's still running. + {' '} + or{' '} + + Mist + {' '} + try refreshing the page. If using a locally hosted Ethereum node, make sure it's still running.
); } private _renderUnexpectedErrorExplanation() { - return ( -
- We encountered an unexpected error. Please try refreshing the page. -
- ); + return
We encountered an unexpected error. Please try refreshing the page.
; } private _renderNoWalletFoundExplanation() { return (
- We were unable to access an Ethereum wallet you control. In order to interact - {' '}with the 0x portal dApp, - we need a way to interact with one of your Ethereum wallets. - {' '}There are two easy ways you can enable us to do that: + We were unable to access an Ethereum wallet you control. In order to interact with the 0x portal + dApp, we need a way to interact with one of your Ethereum wallets. There are two easy ways you can + enable us to do that:

1. Metamask chrome extension

You can install the{' '} Metamask - Chrome extension Ethereum wallet. Once installed and set up, refresh this page. + {' '} + Chrome extension Ethereum wallet. Once installed and set up, refresh this page.
- Note: - {' '}If you already have Metamask installed, make sure it is unlocked. + Note: If you already have Metamask installed, make sure it is + unlocked.

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.IS_MAINNET_ENABLED && '`parity ui` or'} `parity --chain kovan ui`{' '} - in order to connect to {configs.IS_MAINNET_ENABLED ? 'mainnet or Kovan respectively.' : 'Kovan.'} + 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.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: - {' '}If you have done one of the above steps and are still seeing this message, - {' '}we might still be unable to retrieve an Ethereum address by calling `web3.eth.accounts`. - {' '}Make sure you have created at least one Ethereum address. + Note: If you have done one of the above steps and are still seeing + this message, we might still be unable to retrieve an Ethereum address by calling + `web3.eth.accounts`. Make sure you have created at least one Ethereum address.
); @@ -126,15 +127,12 @@ export class BlockchainErrDialog extends React.Component
- The 0x smart contracts are not deployed on the Ethereum network you are - {' '}currently connected to (network Id: {this.props.networkId}). - {' '}In order to use the 0x portal dApp, - {' '}please connect to the - {' '}{constants.TESTNET_NAME} testnet (network Id: {constants.NETWORK_ID_TESTNET}) - {configs.IS_MAINNET_ENABLED ? - ` or ${constants.MAINNET_NAME} (network Id: ${constants.NETWORK_ID_MAINNET}).` : - `.` - } + The 0x smart contracts are not deployed on the Ethereum network you are currently connected to + (network Id: {this.props.networkId}). In order to use the 0x portal dApp, please connect to the{' '} + {constants.TESTNET_NAME} testnet (network Id: {constants.NETWORK_ID_TESTNET}) + {configs.IS_MAINNET_ENABLED + ? ` or ${constants.MAINNET_NAME} (network Id: ${constants.NETWORK_ID_MAINNET}).` + : `.`}

Metamask

@@ -145,13 +143,14 @@ export class BlockchainErrDialog extends React.Component

Parity Signer

- If using the Parity Signer - Chrome extension, make sure to start your local Parity node with{' '} - {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.' - } + If using the{' '} + + Parity Signer Chrome extension + , make sure to start your local Parity node with{' '} + {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/eth_weth_conversion_dialog.tsx b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx index d78cbdc29..ae4328976 100644 --- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx +++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx @@ -2,10 +2,10 @@ import BigNumber from 'bignumber.js'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; -import {EthAmountInput} from 'ts/components/inputs/eth_amount_input'; -import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; -import {Side, Token, TokenState} from 'ts/types'; -import {colors} from 'ts/utils/colors'; +import { EthAmountInput } from 'ts/components/inputs/eth_amount_input'; +import { TokenAmountInput } from 'ts/components/inputs/token_amount_input'; +import { Side, Token, TokenState } from 'ts/types'; +import { colors } from 'ts/utils/colors'; interface EthWethConversionDialogProps { direction: Side; @@ -23,8 +23,10 @@ interface EthWethConversionDialogState { hasErrors: boolean; } -export class EthWethConversionDialog extends - React.Component { +export class EthWethConversionDialog extends React.Component< + EthWethConversionDialogProps, + EthWethConversionDialogState +> { constructor() { super(); this.state = { @@ -34,25 +36,16 @@ export class EthWethConversionDialog extends } public render() { const convertDialogActions = [ - , - , + , + , ]; - const title = this.props.direction === Side.Deposit ? 'Wrap ETH' : 'Unwrap WETH'; + const title = this.props.direction === Side.Deposit ? 'Wrap ETH' : 'Unwrap WETH'; return ( {this._renderConversionDialogBody()} @@ -60,31 +53,24 @@ export class EthWethConversionDialog extends ); } private _renderConversionDialogBody() { - const explanation = this.props.direction === Side.Deposit ? - 'Convert your Ether into a tokenized, tradable form.' : - 'Convert your Wrapped Ether back into it\'s native form.'; + const explanation = + this.props.direction === Side.Deposit + ? 'Convert your Ether into a tokenized, tradable form.' + : "Convert your Wrapped Ether back into it's native form."; const isWrappedVersion = this.props.direction === Side.Receive; return (
-
- {explanation} -
-
+
{explanation}
+
{this._renderCurrency(isWrappedVersion)} -
- +
+
{this._renderCurrency(!isWrappedVersion)}
-
- {this.props.direction === Side.Receive ? +
+ {this.props.direction === Side.Receive ? ( : + /> + ) : ( - } -
+ )} +
1 ETH = 1 WETH
- {this.props.direction === Side.Receive && + {this.props.direction === Side.Receive && (
Max
- } + )}
@@ -130,16 +118,13 @@ export class EthWethConversionDialog extends const symbol = isWrappedVersion ? 'WETH' : 'ETH'; return (
-
+
{name}
- +
-
+
({symbol})
diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx index cc68ef2df..ae7117a70 100644 --- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx +++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx @@ -2,24 +2,17 @@ import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; -import { - Table, - TableBody, - TableHeader, - TableHeaderColumn, - TableRow, - TableRowColumn, -} from 'material-ui/Table'; +import { Table, TableBody, TableHeader, TableHeaderColumn, TableRow, TableRowColumn } from 'material-ui/Table'; import TextField from 'material-ui/TextField'; import * as React from 'react'; import ReactTooltip = require('react-tooltip'); -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'; +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'; const VALID_ETHEREUM_DERIVATION_PATH_PREFIX = `44'/60'`; @@ -59,32 +52,23 @@ export class LedgerConfigDialog extends React.Component, + , ]; - const dialogTitle = this.state.stepIndex === LedgerSteps.CONNECT ? - 'Connect to your Ledger' : - 'Select desired address'; + const dialogTitle = + this.state.stepIndex === LedgerSteps.CONNECT ? 'Connect to your Ledger' : 'Select desired address'; return ( -
- {this.state.stepIndex === LedgerSteps.CONNECT && - this._renderConnectStep() - } - {this.state.stepIndex === LedgerSteps.SELECT_ADDRESS && - this._renderSelectAddressStep() - } +
+ {this.state.stepIndex === LedgerSteps.CONNECT && this._renderConnectStep()} + {this.state.stepIndex === LedgerSteps.SELECT_ADDRESS && this._renderSelectAddressStep()}
); @@ -92,19 +76,15 @@ export class LedgerConfigDialog extends React.Component -
- Follow these instructions before proceeding: -
+
Follow these instructions before proceeding:
    -
  1. - Connect your Ledger Nano S & Open the Ethereum application -
  2. -
  3. - Verify that Browser Support is enabled in Settings -
  4. +
  5. Connect your Ledger Nano S & Open the Ethereum application
  6. +
  7. Verify that Browser Support is enabled in Settings
  8. If no Browser Support is found in settings, verify that you have{' '} - Firmware >1.2 + + Firmware >1.2 +
@@ -115,11 +95,11 @@ export class LedgerConfigDialog extends React.Component - {this.state.didConnectFail && -
+ {this.state.didConnectFail && ( +
Failed to connect. Follow the instructions and try again.
- } + )}
); @@ -128,33 +108,28 @@ export class LedgerConfigDialog extends React.Component
- +
Address Balance - - {this._renderAddressTableRows()} - + {this._renderAddressTableRows()}
-
-
+
+
-
+
+ -
+
{userAddress}
{userAddress} -
+
{balanceString}
{balanceString} diff --git a/packages/website/ts/components/dialogs/portal_disclaimer_dialog.tsx b/packages/website/ts/components/dialogs/portal_disclaimer_dialog.tsx index ffe55794f..3ecc454a0 100644 --- a/packages/website/ts/components/dialogs/portal_disclaimer_dialog.tsx +++ b/packages/website/ts/components/dialogs/portal_disclaimer_dialog.tsx @@ -1,7 +1,7 @@ import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; -import {colors} from 'ts/utils/colors'; +import { colors } from 'ts/utils/colors'; interface PortalDisclaimerDialogProps { isOpen: boolean; @@ -12,31 +12,23 @@ export function PortalDisclaimerDialog(props: PortalDisclaimerDialogProps) { return ( , - ]} + titleStyle={{ fontWeight: 100 }} + actions={[]} open={props.isOpen} onRequestClose={props.onToggleDialog} autoScrollBodyContent={true} modal={true} > -
+
- 0x Portal is a free software-based tool intended to help users to - buy and sell ERC20-compatible blockchain tokens through the 0x protocol - on a purely peer-to-peer basis. 0x portal is not a regulated marketplace, - exchange or intermediary of any kind, and therefore, you should only use - 0x portal to exchange tokens that are not securities, commodity interests, - or any other form of regulated instrument. 0x has not attempted to screen - or otherwise limit the tokens that you may enter in 0x Portal. By clicking - “I Agree” below, you understand that you are solely responsible for using 0x - Portal and buying and selling tokens using 0x Portal in compliance with all - applicable laws and regulations. + 0x Portal is a free software-based tool intended to help users to buy and sell ERC20-compatible + blockchain tokens through the 0x protocol on a purely peer-to-peer basis. 0x portal is not a + regulated marketplace, exchange or intermediary of any kind, and therefore, you should only use 0x + portal to exchange tokens that are not securities, commodity interests, or any other form of + regulated instrument. 0x has not attempted to screen or otherwise limit the tokens that you may + enter in 0x Portal. By clicking “I Agree” below, you understand that you are solely responsible for + using 0x Portal and buying and selling tokens using 0x Portal in compliance with all applicable laws + and regulations.
diff --git a/packages/website/ts/components/dialogs/send_dialog.tsx b/packages/website/ts/components/dialogs/send_dialog.tsx index 9a85ea8b1..cd29b34e6 100644 --- a/packages/website/ts/components/dialogs/send_dialog.tsx +++ b/packages/website/ts/components/dialogs/send_dialog.tsx @@ -3,9 +3,9 @@ import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; -import {AddressInput} from 'ts/components/inputs/address_input'; -import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; -import {Token, TokenState} from 'ts/types'; +import { AddressInput } from 'ts/components/inputs/address_input'; +import { TokenAmountInput } from 'ts/components/inputs/token_amount_input'; +import { Token, TokenState } from 'ts/types'; interface SendDialogProps { onComplete: (recipient: string, value: BigNumber) => void; @@ -33,11 +33,7 @@ export class SendDialog extends React.Component, + , @@ -59,8 +55,8 @@ export class SendDialog extends React.Component -
+
+
{ +export class TrackTokenConfirmationDialog extends React.Component< + TrackTokenConfirmationDialogProps, + TrackTokenConfirmationDialogState +> { constructor(props: TrackTokenConfirmationDialogProps) { super(props); this.state = { @@ -36,7 +38,7 @@ export class TrackTokenConfirmationDialog extends return ( , - ]} + titleStyle={{ fontWeight: 100 }} + actions={[]} open={props.isOpen} onRequestClose={props.onToggleDialog.bind(this)} autoScrollBodyContent={true} > -
+
- It looks like your browser does not support U2F connections - required for us to communicate with your hardware wallet. - Please use a browser that supports U2F connections and try - again. + It looks like your browser does not support U2F connections required for us to communicate with your + hardware wallet. Please use a browser that supports U2F connections and try again.
); } diff --git a/packages/website/ts/pages/shared/section_header.tsx b/packages/website/ts/pages/shared/section_header.tsx index 5ea9fc681..a5f5f52cf 100644 --- a/packages/website/ts/pages/shared/section_header.tsx +++ b/packages/website/ts/pages/shared/section_header.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; -import {Element as ScrollElement} from 'react-scroll'; -import {AnchorTitle} from 'ts/pages/shared/anchor_title'; -import {HeaderSizes} from 'ts/types'; -import {utils} from 'ts/utils/utils'; +import { Element as ScrollElement } from 'react-scroll'; +import { AnchorTitle } from 'ts/pages/shared/anchor_title'; +import { HeaderSizes } from 'ts/types'; +import { utils } from 'ts/utils/utils'; interface SectionHeaderProps { sectionName: string; @@ -34,7 +34,7 @@ export class SectionHeader extends React.Component {sectionName}} + title={{sectionName}} id={id} shouldShowAnchor={this.state.shouldShowAnchor} /> diff --git a/packages/website/ts/pages/shared/version_drop_down.tsx b/packages/website/ts/pages/shared/version_drop_down.tsx index 8d3322d72..b922e1048 100644 --- a/packages/website/ts/pages/shared/version_drop_down.tsx +++ b/packages/website/ts/pages/shared/version_drop_down.tsx @@ -14,7 +14,7 @@ interface VersionDropDownState {} export class VersionDropDown extends React.Component { public render() { return ( -
+
{ - return ( - - ); + return ; }); return items; } diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx index 72da94a20..d065614ba 100644 --- a/packages/website/ts/pages/wiki/wiki.tsx +++ b/packages/website/ts/pages/wiki/wiki.tsx @@ -2,18 +2,16 @@ import * as _ from 'lodash'; import CircularProgress from 'material-ui/CircularProgress'; import * as React from 'react'; import DocumentTitle = require('react-document-title'); -import { - scroller, -} from 'react-scroll'; -import {TopBar} from 'ts/components/top_bar'; -import {MarkdownSection} from 'ts/pages/shared/markdown_section'; -import {NestedSidebarMenu} from 'ts/pages/shared/nested_sidebar_menu'; -import {SectionHeader} from 'ts/pages/shared/section_header'; -import {Article, ArticlesBySection, HeaderSizes, Styles, WebsitePaths} from 'ts/types'; -import {colors} from 'ts/utils/colors'; -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; +import { scroller } from 'react-scroll'; +import { TopBar } from 'ts/components/top_bar'; +import { MarkdownSection } from 'ts/pages/shared/markdown_section'; +import { NestedSidebarMenu } from 'ts/pages/shared/nested_sidebar_menu'; +import { SectionHeader } from 'ts/pages/shared/section_header'; +import { Article, ArticlesBySection, HeaderSizes, Styles, WebsitePaths } from 'ts/types'; +import { colors } from 'ts/utils/colors'; +import { configs } from 'ts/utils/configs'; +import { constants } from 'ts/utils/constants'; +import { utils } from 'ts/utils/utils'; const WIKI_NOT_READY_BACKOUT_TIMEOUT_MS = 5000; @@ -62,40 +60,37 @@ export class Wiki extends React.Component { } public render() { const menuSubsectionsBySection = _.isUndefined(this.state.articlesBySection) - ? {} - : this._getMenuSubsectionsBySection(this.state.articlesBySection); + ? {} + : this._getMenuSubsectionsBySection(this.state.articlesBySection); return (
- + - {_.isUndefined(this.state.articlesBySection) ? -
+ {_.isUndefined(this.state.articlesBySection) ? ( +
-
Loading wiki...
+
+ Loading wiki... +
-
: -
+
+ ) : ( +
{
); } @@ -143,12 +132,9 @@ export class Wiki extends React.Component { headerSize={HeaderSizes.H2} githubLink={githubLink} /> -
+ @@ -156,10 +142,7 @@ export class Wiki extends React.Component { ); }); return ( -
+
{renderedArticles}
@@ -172,7 +155,11 @@ export class Wiki extends React.Component { hash = '0xProtocolWiki'; // scroll to the top } - scroller.scrollTo(hash, {duration: 0, offset: 0, containerId: 'documentation'}); + scroller.scrollTo(hash, { + duration: 0, + offset: 0, + containerId: 'documentation', + }); } private async _fetchArticlesBySectionAsync(): Promise { const endpoint = `${configs.BACKEND_BASE_URL}${WebsitePaths.Wiki}`; @@ -192,15 +179,18 @@ export class Wiki extends React.Component { return; } const articlesBySection = await response.json(); - this.setState({ - articlesBySection, - }, () => { - this._scrollToHash(); - }); + this.setState( + { + articlesBySection, + }, + () => { + this._scrollToHash(); + }, + ); } private _getMenuSubsectionsBySection(articlesBySection: ArticlesBySection) { const sectionNames = _.keys(articlesBySection); - const menuSubsectionsBySection: {[section: string]: string[]} = {}; + const menuSubsectionsBySection: { [section: string]: string[] } = {}; for (const sectionName of sectionNames) { const articles = articlesBySection[sectionName]; const articleNames = _.map(articles, article => article.title); diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts index 0723fae30..184ef0a05 100644 --- a/packages/website/ts/redux/dispatcher.ts +++ b/packages/website/ts/redux/dispatcher.ts @@ -1,6 +1,6 @@ import BigNumber from 'bignumber.js'; -import {Dispatch} from 'redux'; -import {State} from 'ts/redux/reducer'; +import { Dispatch } from 'redux'; +import { State } from 'ts/redux/reducer'; import { ActionTypes, AssetToken, @@ -98,44 +98,44 @@ export class Dispatcher { } public encounteredBlockchainError(err: BlockchainErrs) { this._dispatch({ - data: err, - type: ActionTypes.BlockchainErrEncountered, - }); + data: err, + type: ActionTypes.BlockchainErrEncountered, + }); } public updateBlockchainIsLoaded(isLoaded: boolean) { this._dispatch({ - data: isLoaded, - type: ActionTypes.UpdateBlockchainIsLoaded, - }); + data: isLoaded, + type: ActionTypes.UpdateBlockchainIsLoaded, + }); } public addTokenToTokenByAddress(token: Token) { this._dispatch({ - data: token, - type: ActionTypes.AddTokenToTokenByAddress, - }); + data: token, + type: ActionTypes.AddTokenToTokenByAddress, + }); } public removeTokenToTokenByAddress(token: Token) { this._dispatch({ - data: token, - type: ActionTypes.RemoveTokenFromTokenByAddress, - }); + data: token, + type: ActionTypes.RemoveTokenFromTokenByAddress, + }); } public clearTokenByAddress() { this._dispatch({ type: ActionTypes.ClearTokenByAddress, - }); + }); } public updateTokenByAddress(tokens: Token[]) { this._dispatch({ - data: tokens, - type: ActionTypes.UpdateTokenByAddress, - }); + data: tokens, + type: ActionTypes.UpdateTokenByAddress, + }); } public updateTokenStateByAddress(tokenStateByAddress: TokenStateByAddress) { this._dispatch({ - data: tokenStateByAddress, - type: ActionTypes.UpdateTokenStateByAddress, - }); + data: tokenStateByAddress, + type: ActionTypes.UpdateTokenStateByAddress, + }); } public removeFromTokenStateByAddress(tokenAddress: string) { this._dispatch({ @@ -146,8 +146,8 @@ export class Dispatcher { public replaceTokenAllowanceByAddress(address: string, allowance: BigNumber) { this._dispatch({ data: { - address, - allowance, + address, + allowance, }, type: ActionTypes.ReplaceTokenAllowanceByAddress, }); @@ -172,21 +172,21 @@ export class Dispatcher { } public updateSignatureData(signatureData: SignatureData) { this._dispatch({ - data: signatureData, - type: ActionTypes.UpdateOrderSignatureData, - }); + data: signatureData, + type: ActionTypes.UpdateOrderSignatureData, + }); } public updateUserEtherBalance(balance: BigNumber) { this._dispatch({ - data: balance, - type: ActionTypes.UpdateUserEtherBalance, - }); + data: balance, + type: ActionTypes.UpdateUserEtherBalance, + }); } public updateNetworkId(networkId: number) { this._dispatch({ - data: networkId, - type: ActionTypes.UpdateNetworkId, - }); + data: networkId, + type: ActionTypes.UpdateNetworkId, + }); } public updateOrderFillAmount(amount: BigNumber) { this._dispatch({ @@ -210,7 +210,7 @@ export class Dispatcher { } // Shared - public showFlashMessage(msg: string|React.ReactNode) { + public showFlashMessage(msg: string | React.ReactNode) { this._dispatch({ data: msg, type: ActionTypes.ShowFlashMessage, diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index ccf87ae18..cc7d57a3a 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -1,4 +1,4 @@ -import {ZeroEx} from '0x.js'; +import { ZeroEx } from '0x.js'; import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import { @@ -15,7 +15,7 @@ import { TokenState, TokenStateByAddress, } from 'ts/types'; -import {utils} from 'ts/utils/utils'; +import { utils } from 'ts/utils/utils'; // Instead of defaulting the docs version to an empty string, we pre-populate it with // a valid version value. This does not need to be updated however, since onLoad, it @@ -48,7 +48,7 @@ export interface State { availableDocVersions: string[]; // Shared - flashMessage: string|React.ReactNode; + flashMessage: string | React.ReactNode; providerType: ProviderType; injectedProviderName: string; } diff --git a/packages/website/ts/schemas/order_schema.ts b/packages/website/ts/schemas/order_schema.ts index 61b93d273..bfbf9eb8b 100644 --- a/packages/website/ts/schemas/order_schema.ts +++ b/packages/website/ts/schemas/order_schema.ts @@ -1,24 +1,15 @@ export const orderSchema = { id: '/Order', properties: { - maker: {$ref: '/OrderTaker'}, - taker: {$ref: '/OrderTaker'}, - salt: {type: 'string'}, - signature: {$ref: '/SignatureData'}, - expiration: {type: 'string'}, - feeRecipient: {type: 'string'}, - exchangeContract: {type: 'string'}, - networkId: {type: 'number'}, + maker: { $ref: '/OrderTaker' }, + taker: { $ref: '/OrderTaker' }, + salt: { type: 'string' }, + signature: { $ref: '/SignatureData' }, + expiration: { type: 'string' }, + feeRecipient: { type: 'string' }, + exchangeContract: { type: 'string' }, + networkId: { type: 'number' }, }, - required: [ - 'maker', - 'taker', - 'salt', - 'signature', - 'expiration', - 'feeRecipient', - 'exchangeContract', - 'networkId', - ], + required: ['maker', 'taker', 'salt', 'signature', 'expiration', 'feeRecipient', 'exchangeContract', 'networkId'], type: 'object', }; diff --git a/packages/website/ts/schemas/order_taker_schema.ts b/packages/website/ts/schemas/order_taker_schema.ts index 6b484a60d..c784c29c5 100644 --- a/packages/website/ts/schemas/order_taker_schema.ts +++ b/packages/website/ts/schemas/order_taker_schema.ts @@ -1,10 +1,10 @@ export const orderTakerSchema = { id: '/OrderTaker', properties: { - address: {type: 'string'}, - token: {$ref: '/Token'}, - amount: {type: 'string'}, - feeAmount: {type: 'string'}, + address: { type: 'string' }, + token: { $ref: '/Token' }, + amount: { type: 'string' }, + feeAmount: { type: 'string' }, }, required: ['address', 'token', 'amount', 'feeAmount'], type: 'object', diff --git a/packages/website/ts/schemas/signature_data_schema.ts b/packages/website/ts/schemas/signature_data_schema.ts index d208cc438..8d3f15926 100644 --- a/packages/website/ts/schemas/signature_data_schema.ts +++ b/packages/website/ts/schemas/signature_data_schema.ts @@ -1,10 +1,10 @@ export const signatureDataSchema = { id: '/SignatureData', properties: { - hash: {type: 'string'}, - r: {type: 'string'}, - s: {type: 'string'}, - v: {type: 'number'}, + hash: { type: 'string' }, + r: { type: 'string' }, + s: { type: 'string' }, + v: { type: 'number' }, }, required: ['hash', 'r', 's', 'v'], type: 'object', diff --git a/packages/website/ts/schemas/token_schema.ts b/packages/website/ts/schemas/token_schema.ts index c15f57429..92b53a463 100644 --- a/packages/website/ts/schemas/token_schema.ts +++ b/packages/website/ts/schemas/token_schema.ts @@ -1,10 +1,10 @@ export const tokenSchema = { id: '/Token', properties: { - name: {type: 'string'}, - symbol: {type: 'string'}, - decimals: {type: 'number'}, - address: {type: 'string'}, + name: { type: 'string' }, + symbol: { type: 'string' }, + decimals: { type: 'number' }, + address: { type: 'string' }, }, required: ['name', 'symbol', 'decimals', 'address'], type: 'object', diff --git a/packages/website/ts/schemas/validator.ts b/packages/website/ts/schemas/validator.ts index 832b093e5..5177501c6 100644 --- a/packages/website/ts/schemas/validator.ts +++ b/packages/website/ts/schemas/validator.ts @@ -1,8 +1,8 @@ -import {Schema as JSONSchema, Validator} from 'jsonschema'; -import {orderSchema} from 'ts/schemas/order_schema'; -import {orderTakerSchema} from 'ts/schemas/order_taker_schema'; -import {signatureDataSchema} from 'ts/schemas/signature_data_schema'; -import {tokenSchema} from 'ts/schemas/token_schema'; +import { Schema as JSONSchema, Validator } from 'jsonschema'; +import { orderSchema } from 'ts/schemas/order_schema'; +import { orderTakerSchema } from 'ts/schemas/order_taker_schema'; +import { signatureDataSchema } from 'ts/schemas/signature_data_schema'; +import { tokenSchema } from 'ts/schemas/token_schema'; export class SchemaValidator { private _validator: Validator; diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index e4b05367f..86b6f5f90 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -221,9 +221,9 @@ export interface ContractEvent { export type InputErrMsg = React.ReactNode | string | undefined; export type ValidatedBigNumberCallback = (isValid: boolean, amount?: BigNumber) => void; export enum ScreenWidths { - Sm = 'SM', - Md = 'MD', - Lg = 'LG', + Sm = 'SM', + Md = 'MD', + Lg = 'LG', } export enum AlertTypes { @@ -232,8 +232,8 @@ export enum AlertTypes { } export enum EtherscanLinkSuffixes { - Address = 'address', - Tx = 'tx', + Address = 'address', + Tx = 'tx', } export enum BlockchainErrs { @@ -243,23 +243,23 @@ export enum BlockchainErrs { } export enum BlockchainCallErrs { - ContractDoesNotExist = 'CONTRACT_DOES_NOT_EXIST', - UserHasNoAssociatedAddresses = 'USER_HAS_NO_ASSOCIATED_ADDRESSES', - UnhandledError = 'UNHANDLED_ERROR', - TokenAddressIsInvalid = 'TOKEN_ADDRESS_IS_INVALID', + ContractDoesNotExist = 'CONTRACT_DOES_NOT_EXIST', + UserHasNoAssociatedAddresses = 'USER_HAS_NO_ASSOCIATED_ADDRESSES', + UnhandledError = 'UNHANDLED_ERROR', + TokenAddressIsInvalid = 'TOKEN_ADDRESS_IS_INVALID', } // Exception: We don't make the values uppercase because these KindString's need to // match up those returned by TypeDoc export enum KindString { - Constructor = 'Constructor', - Property = 'Property', - Method = 'Method', - Interface = 'Interface', - TypeAlias = 'Type alias', - Variable = 'Variable', - Function = 'Function', - Enumeration = 'Enumeration', + Constructor = 'Constructor', + Property = 'Property', + Method = 'Method', + Interface = 'Interface', + TypeAlias = 'Type alias', + Variable = 'Variable', + Function = 'Function', + Enumeration = 'Enumeration', } export interface EnumValue { @@ -336,8 +336,8 @@ export interface DocAgnosticFormat { export interface DocSection { comment: string; - constructors: Array; - methods: Array; + constructors: Array; + methods: Array; properties: Property[]; types: CustomType[]; events?: Event[]; @@ -364,7 +364,7 @@ export interface Property { export interface BaseMethod { isConstructor: boolean; name: string; - returnComment?: string|undefined; + returnComment?: string | undefined; callPath: string; parameters: Parameter[]; returnType: Type; @@ -457,8 +457,8 @@ export interface MenuSubsectionsBySection { } export enum ProviderType { - Injected = 'INJECTED', - Ledger = 'LEDGER', + Injected = 'INJECTED', + Ledger = 'LEDGER', } export interface Fact { @@ -479,8 +479,11 @@ interface LedgerCommunication { close_async: () => Promise; } export interface LedgerEthConnection { - getAddress_async: (derivationPath: string, askForDeviceConfirmation: boolean, - shouldGetChainCode: boolean) => Promise; + getAddress_async: ( + derivationPath: string, + askForDeviceConfirmation: boolean, + shouldGetChainCode: boolean, + ) => Promise; signPersonalMessage_async: (derivationPath: string, messageHex: string) => Promise; signTransaction_async: (derivationPath: string, txHex: string) => Promise; comm: LedgerCommunication; @@ -636,19 +639,19 @@ export interface SectionsMap { } export interface DocsInfoConfig { - displayName: string; - packageUrl: string; - websitePath: string; - docsJsonRoot: string; - menu: DocsMenu; - sections: SectionsMap; - sectionNameToMarkdown: {[sectionName: string]: string}; - visibleConstructors: string[]; - convertToDocAgnosticFormatFn: (docObj: DoxityDocObj|TypeDocNode, docsInfo?: any) => DocAgnosticFormat; - subPackageName?: string; - publicTypes?: string[]; - sectionNameToModulePath?: {[sectionName: string]: string[]}; - menuSubsectionToVersionWhenIntroduced?: {[sectionName: string]: string}; + displayName: string; + packageUrl: string; + websitePath: string; + docsJsonRoot: string; + menu: DocsMenu; + sections: SectionsMap; + sectionNameToMarkdown: { [sectionName: string]: string }; + visibleConstructors: string[]; + convertToDocAgnosticFormatFn: (docObj: DoxityDocObj | TypeDocNode, docsInfo?: any) => DocAgnosticFormat; + subPackageName?: string; + publicTypes?: string[]; + sectionNameToModulePath?: { [sectionName: string]: string[] }; + menuSubsectionToVersionWhenIntroduced?: { [sectionName: string]: string }; } export interface TimestampMsRange { diff --git a/packages/website/ts/utils/colors.ts b/packages/website/ts/utils/colors.ts index c65a3a622..58ce667e3 100644 --- a/packages/website/ts/utils/colors.ts +++ b/packages/website/ts/utils/colors.ts @@ -1,4 +1,4 @@ -import {colors as materialUiColors} from 'material-ui/styles'; +import { colors as materialUiColors } from 'material-ui/styles'; export const colors = { ...materialUiColors, diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts index 4a05799b8..52b400d57 100644 --- a/packages/website/ts/utils/configs.ts +++ b/packages/website/ts/utils/configs.ts @@ -9,11 +9,10 @@ import { } from 'ts/types'; const BASE_URL = window.location.origin; -const isDevelopment = _.includes([ - 'https://0xproject.localhost:3572', - 'https://localhost:3572', - 'https://127.0.0.1', - ], BASE_URL); +const isDevelopment = _.includes( + ['https://0xproject.localhost:3572', 'https://localhost:3572', 'https://127.0.0.1'], + BASE_URL, +); const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs'; export const configs = { @@ -50,46 +49,46 @@ export const configs = { DOMAIN_PRODUCTION: '0xproject.com', ENVIRONMENT: isDevelopment ? Environments.DEVELOPMENT : Environments.PRODUCTION, ICON_URL_BY_SYMBOL: { - 'REP': '/images/token_icons/augur.png', - 'DGD': '/images/token_icons/digixdao.png', - 'WETH': '/images/token_icons/ether_erc20.png', - 'MLN': '/images/token_icons/melon.png', - 'GNT': '/images/token_icons/golem.png', - 'MKR': '/images/token_icons/makerdao.png', - 'ZRX': '/images/token_icons/zero_ex.png', - 'ANT': '/images/token_icons/aragon.png', - 'BNT': '/images/token_icons/bancor.png', - 'BAT': '/images/token_icons/basicattentiontoken.png', - 'CVC': '/images/token_icons/civic.png', - 'EOS': '/images/token_icons/eos.png', - 'FUN': '/images/token_icons/funfair.png', - 'GNO': '/images/token_icons/gnosis.png', - 'ICN': '/images/token_icons/iconomi.png', - 'OMG': '/images/token_icons/omisego.png', - 'SNT': '/images/token_icons/status.png', - 'STORJ': '/images/token_icons/storjcoinx.png', - 'PAY': '/images/token_icons/tenx.png', - 'QTUM': '/images/token_icons/qtum.png', - 'DNT': '/images/token_icons/district0x.png', - 'SNGLS': '/images/token_icons/singularity.png', - 'EDG': '/images/token_icons/edgeless.png', + REP: '/images/token_icons/augur.png', + DGD: '/images/token_icons/digixdao.png', + WETH: '/images/token_icons/ether_erc20.png', + MLN: '/images/token_icons/melon.png', + GNT: '/images/token_icons/golem.png', + MKR: '/images/token_icons/makerdao.png', + ZRX: '/images/token_icons/zero_ex.png', + ANT: '/images/token_icons/aragon.png', + BNT: '/images/token_icons/bancor.png', + BAT: '/images/token_icons/basicattentiontoken.png', + CVC: '/images/token_icons/civic.png', + EOS: '/images/token_icons/eos.png', + FUN: '/images/token_icons/funfair.png', + GNO: '/images/token_icons/gnosis.png', + ICN: '/images/token_icons/iconomi.png', + OMG: '/images/token_icons/omisego.png', + SNT: '/images/token_icons/status.png', + STORJ: '/images/token_icons/storjcoinx.png', + PAY: '/images/token_icons/tenx.png', + QTUM: '/images/token_icons/qtum.png', + DNT: '/images/token_icons/district0x.png', + SNGLS: '/images/token_icons/singularity.png', + EDG: '/images/token_icons/edgeless.png', '1ST': '/images/token_icons/firstblood.jpg', - 'WINGS': '/images/token_icons/wings.png', - 'BQX': '/images/token_icons/bitquence.png', - 'LUN': '/images/token_icons/lunyr.png', - 'RLC': '/images/token_icons/iexec.png', - 'MCO': '/images/token_icons/monaco.png', - 'ADT': '/images/token_icons/adtoken.png', - 'CFI': '/images/token_icons/cofound-it.png', - 'ROL': '/images/token_icons/etheroll.png', - 'WGNT': '/images/token_icons/golem.png', - 'MTL': '/images/token_icons/metal.png', - 'NMR': '/images/token_icons/numeraire.png', - 'SAN': '/images/token_icons/santiment.png', - 'TAAS': '/images/token_icons/taas.png', - 'TKN': '/images/token_icons/tokencard.png', - 'TRST': '/images/token_icons/trust.png', - } as {[symbol: string]: string}, + WINGS: '/images/token_icons/wings.png', + BQX: '/images/token_icons/bitquence.png', + LUN: '/images/token_icons/lunyr.png', + RLC: '/images/token_icons/iexec.png', + MCO: '/images/token_icons/monaco.png', + ADT: '/images/token_icons/adtoken.png', + CFI: '/images/token_icons/cofound-it.png', + ROL: '/images/token_icons/etheroll.png', + WGNT: '/images/token_icons/golem.png', + MTL: '/images/token_icons/metal.png', + NMR: '/images/token_icons/numeraire.png', + SAN: '/images/token_icons/santiment.png', + TAAS: '/images/token_icons/taas.png', + TKN: '/images/token_icons/tokencard.png', + TRST: '/images/token_icons/trust.png', + } as { [symbol: string]: string }, IS_MAINNET_ENABLED: true, LAST_LOCAL_STORAGE_FILL_CLEARANCE_DATE: '2017-11-22', LAST_LOCAL_STORAGE_TRACKED_TOKEN_CLEARANCE_DATE: '2017-12-19', @@ -98,7 +97,7 @@ export const configs = { NEW_WRAPPED_ETHERS: { 1: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 42: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', - } as {[networkId: string]: string}, + } as { [networkId: string]: string }, OUTDATED_WRAPPED_ETHERS: [ { 42: { @@ -119,12 +118,8 @@ export const configs = { ] as OutdatedWrappedEtherByNetworkId[], // The order matters. We first try first node and only then fall back to others. PUBLIC_NODE_URLS_BY_NETWORK_ID: { - [1]: [ - `https://mainnet.infura.io/${INFURA_API_KEY}`, - ], - [42]: [ - `https://kovan.infura.io/${INFURA_API_KEY}`, - ], + [1]: [`https://mainnet.infura.io/${INFURA_API_KEY}`], + [42]: [`https://kovan.infura.io/${INFURA_API_KEY}`], } as PublicNodeUrlsByNetworkId, SHOULD_DEPRECATE_OLD_WETH_TOKEN: true, SYMBOLS_OF_MINTABLE_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'], diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts index facaf5dd6..073745ef6 100644 --- a/packages/website/ts/utils/constants.ts +++ b/packages/website/ts/utils/constants.ts @@ -1,7 +1,5 @@ import BigNumber from 'bignumber.js'; -import { - Networks, -} from 'ts/types'; +import { Networks } from 'ts/types'; export const constants = { DECIMAL_PLACES_ETH: 18, @@ -12,7 +10,7 @@ export const constants = { 1: 4145578, 42: 3117574, 50: 0, - } as {[networkId: number]: number}, + } as { [networkId: number]: number }, HOME_SCROLL_DURATION_MS: 500, HTTP_NO_CONTENT_STATUS_CODE: 204, LOCAL_STORAGE_KEY_ACCEPT_DISCLAIMER: 'didAcceptPortalDisclaimer', @@ -28,13 +26,13 @@ export const constants = { 3: Networks.ropsten, 4: Networks.rinkeby, 42: Networks.kovan, - } as {[symbol: number]: string}, + } as { [symbol: number]: string }, NETWORK_ID_BY_NAME: { [Networks.mainnet]: 1, [Networks.ropsten]: 3, [Networks.rinkeby]: 4, [Networks.kovan]: 42, - } as {[networkName: string]: number}, + } as { [networkName: string]: number }, NULL_ADDRESS: '0x0000000000000000000000000000000000000000', PROVIDER_NAME_LEDGER: 'Ledger', PROVIDER_NAME_METAMASK: 'Metamask', diff --git a/packages/website/ts/utils/doc_utils.ts b/packages/website/ts/utils/doc_utils.ts index ea210a3fa..0bc670d76 100644 --- a/packages/website/ts/utils/doc_utils.ts +++ b/packages/website/ts/utils/doc_utils.ts @@ -1,12 +1,11 @@ import findVersions = require('find-versions'); import * as _ from 'lodash'; -import {DoxityDocObj, S3FileObject, TypeDocNode, VersionToFileName} from 'ts/types'; -import {utils} from 'ts/utils/utils'; +import { DoxityDocObj, S3FileObject, TypeDocNode, VersionToFileName } from 'ts/types'; +import { utils } from 'ts/utils/utils'; import convert = require('xml-js'); export const docUtils = { - async getVersionToFileNameAsync(s3DocJsonRoot: string): - Promise { + async getVersionToFileNameAsync(s3DocJsonRoot: string): Promise { const versionFileNames = await this.getVersionFileNamesAsync(s3DocJsonRoot); const versionToFileName: VersionToFileName = {}; _.each(versionFileNames, fileName => { @@ -28,16 +27,16 @@ export const docUtils = { compact: true, }); const responseObj = JSON.parse(responseJSONString); - const fileObjs: S3FileObject[] = (_.isArray(responseObj.ListBucketResult.Contents)) ? - responseObj.ListBucketResult.Contents as S3FileObject[] : - [responseObj.ListBucketResult.Contents]; + const fileObjs: S3FileObject[] = _.isArray(responseObj.ListBucketResult.Contents) + ? (responseObj.ListBucketResult.Contents as S3FileObject[]) + : [responseObj.ListBucketResult.Contents]; const versionFileNames = _.map(fileObjs, fileObj => { return fileObj.Key._text; }); return versionFileNames; }, - async getJSONDocFileAsync(fileName: string, s3DocJsonRoot: string): Promise { + async getJSONDocFileAsync(fileName: string, s3DocJsonRoot: string): Promise { const endpoint = `${s3DocJsonRoot}/${fileName}`; const response = await fetch(endpoint); if (response.status !== 200) { diff --git a/packages/website/ts/utils/doxity_utils.ts b/packages/website/ts/utils/doxity_utils.ts index 26e555b16..5f1d02132 100644 --- a/packages/website/ts/utils/doxity_utils.ts +++ b/packages/website/ts/utils/doxity_utils.ts @@ -36,41 +36,46 @@ export const doxityUtils = { constructors.push(constructor); } - const doxityMethods: DoxityAbiDoc[] = _.filter - (doxityContractObj.abiDocs, (abiDoc: DoxityAbiDoc) => { - return this._isMethod(abiDoc); - }); - const methods: SolidityMethod[] = _.map(doxityMethods, + const doxityMethods: DoxityAbiDoc[] = _.filter( + doxityContractObj.abiDocs, + (abiDoc: DoxityAbiDoc) => { + return this._isMethod(abiDoc); + }, + ); + const methods: SolidityMethod[] = _.map( + doxityMethods, (doxityMethod: DoxityAbiDoc) => { - // We assume that none of our functions returns more then a single value - const outputIfExists = !_.isUndefined(doxityMethod.outputs) ? - doxityMethod.outputs[0] : - undefined; - const returnTypeIfExists = !_.isUndefined(outputIfExists) ? - this._convertType(outputIfExists.type) : - undefined; - // For ZRXToken, we want to convert it to zrxToken, rather then simply zRXToken - const callPath = contractName !== 'ZRXToken' ? - `${contractName[0].toLowerCase()}${contractName.slice(1)}.` : - `${contractName.slice(0, 3).toLowerCase()}${contractName.slice(3)}.`; - const method = { - isConstructor: false, - isConstant: doxityMethod.constant, - isPayable: doxityMethod.payable, - name: doxityMethod.name, - comment: doxityMethod.details, - returnComment: doxityMethod.return, - callPath, - parameters: this._convertParameters(doxityMethod.inputs), - returnType: returnTypeIfExists, - }; - return method; - }); + // We assume that none of our functions returns more then a single value + const outputIfExists = !_.isUndefined(doxityMethod.outputs) ? doxityMethod.outputs[0] : undefined; + const returnTypeIfExists = !_.isUndefined(outputIfExists) + ? this._convertType(outputIfExists.type) + : undefined; + // For ZRXToken, we want to convert it to zrxToken, rather then simply zRXToken + const callPath = + contractName !== 'ZRXToken' + ? `${contractName[0].toLowerCase()}${contractName.slice(1)}.` + : `${contractName.slice(0, 3).toLowerCase()}${contractName.slice(3)}.`; + const method = { + isConstructor: false, + isConstant: doxityMethod.constant, + isPayable: doxityMethod.payable, + name: doxityMethod.name, + comment: doxityMethod.details, + returnComment: doxityMethod.return, + callPath, + parameters: this._convertParameters(doxityMethod.inputs), + returnType: returnTypeIfExists, + }; + return method; + }, + ); - const doxityProperties: DoxityAbiDoc[] = _.filter - (doxityContractObj.abiDocs, (abiDoc: DoxityAbiDoc) => { - return this._isProperty(abiDoc); - }); + const doxityProperties: DoxityAbiDoc[] = _.filter( + doxityContractObj.abiDocs, + (abiDoc: DoxityAbiDoc) => { + return this._isProperty(abiDoc); + }, + ); const properties = _.map(doxityProperties, (doxityProperty: DoxityAbiDoc) => { // We assume that none of our functions return more then a single return value let typeName = doxityProperty.outputs[0].type; @@ -87,7 +92,8 @@ export const doxityUtils = { }); const doxityEvents = _.filter( - doxityContractObj.abiDocs, (abiDoc: DoxityAbiDoc) => abiDoc.type === AbiTypes.Event, + doxityContractObj.abiDocs, + (abiDoc: DoxityAbiDoc) => abiDoc.type === AbiTypes.Event, ); const events = _.map(doxityEvents, doxityEvent => { const event = { diff --git a/packages/website/ts/utils/error_reporter.ts b/packages/website/ts/utils/error_reporter.ts index 67be117e0..0bd247c5b 100644 --- a/packages/website/ts/utils/error_reporter.ts +++ b/packages/website/ts/utils/error_reporter.ts @@ -1,7 +1,7 @@ -import {Environments} from 'ts/types'; -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; +import { Environments } from 'ts/types'; +import { configs } from 'ts/utils/configs'; +import { constants } from 'ts/utils/constants'; +import { utils } from 'ts/utils/utils'; // Suggested way to include Rollbar with Webpack // https://github.com/rollbar/rollbar.js/tree/master/examples/webpack @@ -23,7 +23,7 @@ const rollbarConfig = { 'TypeError: Failed to fetch', 'Exchange has not been deployed to detected network (network/artifact mismatch)', // Source: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/7VU0_VvC7mE - 'undefined is not an object (evaluating \'__gCrWeb.autofill.extractForms\')', + "undefined is not an object (evaluating '__gCrWeb.autofill.extractForms')", // Source: http://stackoverflow.com/questions/43399818/securityerror-from-facebook-and-cross-domain-messaging 'SecurityError (DOM Exception 18)', ], diff --git a/packages/website/ts/utils/mui_theme.ts b/packages/website/ts/utils/mui_theme.ts index 60c58f595..d73e80606 100644 --- a/packages/website/ts/utils/mui_theme.ts +++ b/packages/website/ts/utils/mui_theme.ts @@ -1,5 +1,5 @@ -import {getMuiTheme} from 'material-ui/styles'; -import {colors} from 'ts/utils/colors'; +import { getMuiTheme } from 'material-ui/styles'; +import { colors } from 'ts/utils/colors'; export const muiTheme = getMuiTheme({ appBar: { diff --git a/packages/website/ts/utils/typedoc_utils.ts b/packages/website/ts/utils/typedoc_utils.ts index ed8834a87..11ec8da58 100644 --- a/packages/website/ts/utils/typedoc_utils.ts +++ b/packages/website/ts/utils/typedoc_utils.ts @@ -1,5 +1,5 @@ import * as _ from 'lodash'; -import {DocsInfo} from 'ts/pages/documentation/docs_info'; +import { DocsInfo } from 'ts/pages/documentation/docs_info'; import { CustomType, CustomTypeChild, @@ -16,15 +16,17 @@ import { TypeParameter, TypescriptMethod, } from 'ts/types'; -import {utils} from 'ts/utils/utils'; +import { utils } from 'ts/utils/utils'; export const typeDocUtils = { isType(entity: TypeDocNode): boolean { - return entity.kindString === KindString.Interface || - entity.kindString === KindString.Function || - entity.kindString === KindString.TypeAlias || - entity.kindString === KindString.Variable || - entity.kindString === KindString.Enumeration; + return ( + entity.kindString === KindString.Interface || + entity.kindString === KindString.Function || + entity.kindString === KindString.TypeAlias || + entity.kindString === KindString.Variable || + entity.kindString === KindString.Enumeration + ); }, isMethod(entity: TypeDocNode): boolean { return entity.kindString === KindString.Method; @@ -38,8 +40,10 @@ export const typeDocUtils = { isPrivateOrProtectedProperty(propertyName: string): boolean { return _.startsWith(propertyName, '_'); }, - getModuleDefinitionBySectionNameIfExists(versionDocObj: TypeDocNode, modulePaths: string[]): - TypeDocNode|undefined { + getModuleDefinitionBySectionNameIfExists( + versionDocObj: TypeDocNode, + modulePaths: string[], + ): TypeDocNode | undefined { const modules = versionDocObj.children; for (const mod of modules) { if (_.includes(modulePaths, mod.name)) { @@ -59,7 +63,8 @@ export const typeDocUtils = { return; // no-op } const packageDefinitionIfExists = typeDocUtils.getModuleDefinitionBySectionNameIfExists( - typeDocJson, modulePathsIfExists, + typeDocJson, + modulePathsIfExists, ); if (_.isUndefined(packageDefinitionIfExists)) { return; // no-op @@ -99,7 +104,11 @@ export const typeDocUtils = { case KindString.Constructor: isConstructor = true; const constructor = typeDocUtils._convertMethod( - entity, isConstructor, docsInfo.sections, sectionName, docsInfo.subPackageName, + entity, + isConstructor, + docsInfo.sections, + sectionName, + docsInfo.subPackageName, ); docSection.constructors.push(constructor); break; @@ -108,7 +117,11 @@ export const typeDocUtils = { if (entity.flags.isPublic) { isConstructor = false; const method = typeDocUtils._convertMethod( - entity, isConstructor, docsInfo.sections, sectionName, docsInfo.subPackageName, + entity, + isConstructor, + docsInfo.sections, + sectionName, + docsInfo.subPackageName, ); docSection.methods.push(method); } @@ -117,7 +130,11 @@ export const typeDocUtils = { case KindString.Property: if (!typeDocUtils.isPrivateOrProtectedProperty(entity.name)) { const property = typeDocUtils._convertProperty( - entity, docsInfo.sections, sectionName, docsInfo.subPackageName); + entity, + docsInfo.sections, + sectionName, + docsInfo.subPackageName, + ); docSection.properties.push(property); } break; @@ -129,7 +146,11 @@ export const typeDocUtils = { case KindString.TypeAlias: if (docsInfo.isPublicType(entity.name)) { const customType = typeDocUtils._convertCustomType( - entity, docsInfo.sections, sectionName, docsInfo.subPackageName); + entity, + docsInfo.sections, + sectionName, + docsInfo.subPackageName, + ); docSection.types.push(customType); } break; @@ -140,35 +161,40 @@ export const typeDocUtils = { }); return docSection; }, - _convertCustomType(entity: TypeDocNode, sections: SectionsMap, sectionName: string, - subPackageName: string): CustomType { - const typeIfExists = !_.isUndefined(entity.type) ? - typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName) : - undefined; + _convertCustomType( + entity: TypeDocNode, + sections: SectionsMap, + sectionName: string, + subPackageName: string, + ): CustomType { + const typeIfExists = !_.isUndefined(entity.type) + ? typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName) + : undefined; const isConstructor = false; - const methodIfExists = !_.isUndefined(entity.declaration) ? - typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, subPackageName) : - undefined; - const indexSignatureIfExists = !_.isUndefined(entity.indexSignature) ? - typeDocUtils._convertIndexSignature(entity.indexSignature[0], sections, sectionName, subPackageName) : - undefined; - const commentIfExists = !_.isUndefined(entity.comment) && !_.isUndefined(entity.comment.shortText) ? - entity.comment.shortText : - undefined; + const methodIfExists = !_.isUndefined(entity.declaration) + ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, subPackageName) + : undefined; + const indexSignatureIfExists = !_.isUndefined(entity.indexSignature) + ? typeDocUtils._convertIndexSignature(entity.indexSignature[0], sections, sectionName, subPackageName) + : undefined; + const commentIfExists = + !_.isUndefined(entity.comment) && !_.isUndefined(entity.comment.shortText) + ? entity.comment.shortText + : undefined; - const childrenIfExist = !_.isUndefined(entity.children) ? - _.map(entity.children, (child: TypeDocNode) => { - const childTypeIfExists = !_.isUndefined(child.type) ? - typeDocUtils._convertType(child.type, sections, sectionName, subPackageName) : - undefined; - const c: CustomTypeChild = { - name: child.name, - type: childTypeIfExists, - defaultValue: child.defaultValue, - }; - return c; - }) : - undefined; + const childrenIfExist = !_.isUndefined(entity.children) + ? _.map(entity.children, (child: TypeDocNode) => { + const childTypeIfExists = !_.isUndefined(child.type) + ? typeDocUtils._convertType(child.type, sections, sectionName, subPackageName) + : undefined; + const c: CustomTypeChild = { + name: child.name, + type: childTypeIfExists, + defaultValue: child.defaultValue, + }; + return c; + }) + : undefined; const customType = { name: entity.name, @@ -182,8 +208,12 @@ export const typeDocUtils = { }; return customType; }, - _convertIndexSignature(entity: TypeDocNode, sections: SectionsMap, sectionName: string, - subPackageName: string): IndexSignature { + _convertIndexSignature( + entity: TypeDocNode, + sections: SectionsMap, + sectionName: string, + subPackageName: string, + ): IndexSignature { const key = entity.parameters[0]; const indexSignature = { keyName: key.name, @@ -192,8 +222,12 @@ export const typeDocUtils = { }; return indexSignature; }, - _convertProperty(entity: TypeDocNode, sections: SectionsMap, sectionName: string, - subPackageName: string): Property { + _convertProperty( + entity: TypeDocNode, + sections: SectionsMap, + sectionName: string, + subPackageName: string, + ): Property { const source = entity.sources[0]; const commentIfExists = !_.isUndefined(entity.comment) ? entity.comment.shortText : undefined; const property = { @@ -208,7 +242,11 @@ export const typeDocUtils = { return property; }, _convertMethod( - entity: TypeDocNode, isConstructor: boolean, sections: SectionsMap, sectionName: string, subPackageName: string, + entity: TypeDocNode, + isConstructor: boolean, + sections: SectionsMap, + sectionName: string, + subPackageName: string, ): TypescriptMethod { const signature = entity.signatures[0]; const source = entity.sources[0]; @@ -222,9 +260,10 @@ export const typeDocUtils = { callPath = ''; } else if (subPackageName === '0x.js') { const topLevelInterface = isStatic ? 'ZeroEx.' : 'zeroEx.'; - callPath = (!_.isUndefined(sections.zeroEx) && sectionName !== sections.zeroEx) ? - `${topLevelInterface}${sectionName}.` : - topLevelInterface; + callPath = + !_.isUndefined(sections.zeroEx) && sectionName !== sections.zeroEx + ? `${topLevelInterface}${sectionName}.` + : topLevelInterface; } else { callPath = `${sectionName}.`; } @@ -233,10 +272,9 @@ export const typeDocUtils = { return typeDocUtils._convertParameter(param, sections, sectionName, subPackageName); }); const returnType = typeDocUtils._convertType(signature.type, sections, sectionName, subPackageName); - const typeParameter = _.isUndefined(signature.typeParameter) ? - undefined : - typeDocUtils._convertTypeParameter( - signature.typeParameter[0], sections, sectionName, subPackageName); + const typeParameter = _.isUndefined(signature.typeParameter) + ? undefined + : typeDocUtils._convertTypeParameter(signature.typeParameter[0], sections, sectionName, subPackageName); const method = { isConstructor, @@ -255,8 +293,12 @@ export const typeDocUtils = { }; return method; }, - _convertTypeParameter(entity: TypeDocNode, sections: SectionsMap, sectionName: string, - subPackageName: string): TypeParameter { + _convertTypeParameter( + entity: TypeDocNode, + sections: SectionsMap, + sectionName: string, + subPackageName: string, + ): TypeParameter { const type = typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName); const parameter = { name: entity.name, @@ -264,8 +306,12 @@ export const typeDocUtils = { }; return parameter; }, - _convertParameter(entity: TypeDocNode, sections: SectionsMap, sectionName: string, - subPackageName: string): Parameter { + _convertParameter( + entity: TypeDocNode, + sections: SectionsMap, + sectionName: string, + subPackageName: string, + ): Parameter { let comment = ''; if (entity.comment && entity.comment.shortText) { comment = entity.comment.shortText; @@ -273,9 +319,7 @@ export const typeDocUtils = { comment = entity.comment.text; } - const isOptional = !_.isUndefined(entity.flags.isOptional) ? - entity.flags.isOptional : - false; + const isOptional = !_.isUndefined(entity.flags.isOptional) ? entity.flags.isOptional : false; const type = typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName); @@ -296,16 +340,16 @@ export const typeDocUtils = { }); const isConstructor = false; - const methodIfExists = !_.isUndefined(entity.declaration) ? - typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, subPackageName) : - undefined; + const methodIfExists = !_.isUndefined(entity.declaration) + ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, subPackageName) + : undefined; - const elementTypeIfExists = !_.isUndefined(entity.elementType) ? - { - name: entity.elementType.name, - typeDocType: entity.elementType.type, - } : - undefined; + const elementTypeIfExists = !_.isUndefined(entity.elementType) + ? { + name: entity.elementType.name, + typeDocType: entity.elementType.type, + } + : undefined; const type = { name: entity.name, diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 36cc8f77b..1148ef1bb 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -1,4 +1,4 @@ -import {ExchangeContractErrs, ZeroExError} from '0x.js'; +import { ExchangeContractErrs, ZeroExError } from '0x.js'; import BigNumber from 'bignumber.js'; import deepEqual = require('deep-equal'); import isMobile = require('is-mobile'); @@ -15,8 +15,8 @@ import { Token, TokenByAddress, } from 'ts/types'; -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; +import { configs } from 'ts/utils/configs'; +import { constants } from 'ts/utils/constants'; import * as u2f from 'ts/vendor/u2f_api'; const LG_MIN_EM = 64; @@ -58,10 +58,20 @@ export const utils = { const formattedDate: string = m.format('h:MMa MMMM D YYYY'); return formattedDate; }, - generateOrder(networkId: number, exchangeContract: string, sideToAssetToken: SideToAssetToken, - orderExpiryTimestamp: BigNumber, orderTakerAddress: string, orderMakerAddress: string, - makerFee: BigNumber, takerFee: BigNumber, feeRecipient: string, - signatureData: SignatureData, tokenByAddress: TokenByAddress, orderSalt: BigNumber): Order { + generateOrder( + networkId: number, + exchangeContract: string, + sideToAssetToken: SideToAssetToken, + orderExpiryTimestamp: BigNumber, + orderTakerAddress: string, + orderMakerAddress: string, + makerFee: BigNumber, + takerFee: BigNumber, + feeRecipient: string, + signatureData: SignatureData, + tokenByAddress: TokenByAddress, + orderSalt: BigNumber, + ): Order { const makerToken = tokenByAddress[sideToAssetToken[Side.Deposit].address]; const takerToken = tokenByAddress[sideToAssetToken[Side.Receive].address]; const order = { @@ -104,7 +114,7 @@ export const utils = { async sleepAsync(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); }, - deepEqual(actual: any, expected: any, opts?: {strict: boolean}) { + deepEqual(actual: any, expected: any, opts?: { strict: boolean }) { return deepEqual(actual, expected, opts); }, getColSize(items: number) { @@ -148,7 +158,7 @@ export const utils = { window.location.hash = anchorId; }, async isU2FSupportedAsync(): Promise { - const w = (window as any); + const w = window as any; return new Promise((resolve: (isSupported: boolean) => void) => { if (w.u2f && !w.u2f.getApiVersion) { // u2f object was found (Firefox with extension) @@ -176,9 +186,10 @@ export const utils = { const metamaskDenialErrMsg = 'User denied message'; const paritySignerDenialErrMsg = 'Request has been rejected'; const ledgerDenialErrMsg = 'Invalid status 6985'; - const isUserDeniedErrMsg = _.includes(errMsg, metamaskDenialErrMsg) || - _.includes(errMsg, paritySignerDenialErrMsg) || - _.includes(errMsg, ledgerDenialErrMsg); + const isUserDeniedErrMsg = + _.includes(errMsg, metamaskDenialErrMsg) || + _.includes(errMsg, paritySignerDenialErrMsg) || + _.includes(errMsg, ledgerDenialErrMsg); return isUserDeniedErrMsg; }, getCurrentEnvironment() { @@ -206,14 +217,18 @@ export const utils = { return true; // Since it's registered, it is the canonical token } const registeredTokens = _.filter(tokens, t => t.isRegistered); - const tokenWithSameNameIfExists = _.find(registeredTokens, {name: token.name}); + const tokenWithSameNameIfExists = _.find(registeredTokens, { + name: token.name, + }); const isUniqueName = _.isUndefined(tokenWithSameNameIfExists); - const tokenWithSameSymbolIfExists = _.find(registeredTokens, {name: token.symbol}); + const tokenWithSameSymbolIfExists = _.find(registeredTokens, { + name: token.symbol, + }); const isUniqueSymbol = _.isUndefined(tokenWithSameSymbolIfExists); return isUniqueName && isUniqueSymbol; }, - zeroExErrToHumanReadableErrMsg(error: ZeroExError|ExchangeContractErrs, takerAddress: string): string { - const ZeroExErrorToHumanReadableError: {[error: string]: string} = { + zeroExErrToHumanReadableErrMsg(error: ZeroExError | ExchangeContractErrs, takerAddress: string): string { + const ZeroExErrorToHumanReadableError: { [error: string]: string } = { [ZeroExError.ExchangeContractDoesNotExist]: 'Exchange contract does not exist', [ZeroExError.EtherTokenContractDoesNotExist]: 'EtherToken contract does not exist', [ZeroExError.TokenTransferProxyContractDoesNotExist]: 'TokenTransferProxy contract does not exist', @@ -228,37 +243,37 @@ export const utils = { [ZeroExError.OutOfGas]: 'Transaction ran out of gas', [ZeroExError.NoNetworkId]: 'No network id detected', }; - const exchangeContractErrorToHumanReadableError: {[error: string]: string} = { + const exchangeContractErrorToHumanReadableError: { + [error: string]: string; + } = { [ExchangeContractErrs.OrderFillExpired]: 'This order has expired', [ExchangeContractErrs.OrderCancelExpired]: 'This order has expired', - [ExchangeContractErrs.OrderCancelAmountZero]: 'Order cancel amount can\'t be 0', + [ExchangeContractErrs.OrderCancelAmountZero]: "Order cancel amount can't be 0", [ExchangeContractErrs.OrderAlreadyCancelledOrFilled]: - 'This order has already been completely filled or cancelled', - [ExchangeContractErrs.OrderFillAmountZero]: 'Order fill amount can\'t be 0', + 'This order has already been completely filled or cancelled', + [ExchangeContractErrs.OrderFillAmountZero]: "Order fill amount can't be 0", [ExchangeContractErrs.OrderRemainingFillAmountZero]: - 'This order has already been completely filled or cancelled', + 'This order has already been completely filled or cancelled', [ExchangeContractErrs.OrderFillRoundingError]: 'Rounding error will occur when filling this order', [ExchangeContractErrs.InsufficientTakerBalance]: - 'Taker no longer has a sufficient balance to complete this order', + 'Taker no longer has a sufficient balance to complete this order', [ExchangeContractErrs.InsufficientTakerAllowance]: - 'Taker no longer has a sufficient allowance to complete this order', + 'Taker no longer has a sufficient allowance to complete this order', [ExchangeContractErrs.InsufficientMakerBalance]: - 'Maker no longer has a sufficient balance to complete this order', + 'Maker no longer has a sufficient balance to complete this order', [ExchangeContractErrs.InsufficientMakerAllowance]: - 'Maker no longer has a sufficient allowance to complete this order', + 'Maker no longer has a sufficient allowance to complete this order', [ExchangeContractErrs.InsufficientTakerFeeBalance]: 'Taker no longer has a sufficient balance to pay fees', [ExchangeContractErrs.InsufficientTakerFeeAllowance]: - 'Taker no longer has a sufficient allowance to pay fees', + 'Taker no longer has a sufficient allowance to pay fees', [ExchangeContractErrs.InsufficientMakerFeeBalance]: 'Maker no longer has a sufficient balance to pay fees', [ExchangeContractErrs.InsufficientMakerFeeAllowance]: - 'Maker no longer has a sufficient allowance to pay fees', - [ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker]: - `This order can only be filled by ${takerAddress}`, - [ExchangeContractErrs.InsufficientRemainingFillAmount]: - 'Insufficient remaining fill amount', + 'Maker no longer has a sufficient allowance to pay fees', + [ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker]: `This order can only be filled by ${takerAddress}`, + [ExchangeContractErrs.InsufficientRemainingFillAmount]: 'Insufficient remaining fill amount', }; - const humanReadableErrorMsg = exchangeContractErrorToHumanReadableError[error] || - ZeroExErrorToHumanReadableError[error]; + const humanReadableErrorMsg = + exchangeContractErrorToHumanReadableError[error] || ZeroExErrorToHumanReadableError[error]; return humanReadableErrorMsg; }, }; diff --git a/packages/website/ts/web3_wrapper.ts b/packages/website/ts/web3_wrapper.ts index 0dd24fde1..232f12138 100644 --- a/packages/website/ts/web3_wrapper.ts +++ b/packages/website/ts/web3_wrapper.ts @@ -1,7 +1,7 @@ -import {intervalUtils, promisify} from '@0xproject/utils'; +import { intervalUtils, promisify } from '@0xproject/utils'; import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; -import {Dispatcher} from 'ts/redux/dispatcher'; +import { Dispatcher } from 'ts/redux/dispatcher'; import * as Web3 from 'web3'; export class Web3Wrapper { @@ -12,8 +12,12 @@ export class Web3Wrapper { private _watchNetworkAndBalanceIntervalId: NodeJS.Timer; private _prevUserEtherBalanceInEth: BigNumber; private _prevUserAddress: string; - constructor(dispatcher: Dispatcher, provider: Web3.Provider, networkIdIfExists: number, - shouldPollUserAddress: boolean) { + constructor( + dispatcher: Dispatcher, + provider: Web3.Provider, + networkIdIfExists: number, + shouldPollUserAddress: boolean, + ) { this._dispatcher = dispatcher; this._prevNetworkId = networkIdIfExists; this._shouldPollUserAddress = shouldPollUserAddress; @@ -36,7 +40,7 @@ export class Web3Wrapper { if (_.isEmpty(addresses)) { return ''; } - return (addresses)[0]; + return addresses[0]; } public async getNodeVersionAsync(): Promise { const nodeVersion = await promisify(this._web3.version.getNode)(); @@ -71,7 +75,7 @@ export class Web3Wrapper { return signData; } public async getBlockTimestampAsync(blockHash: string): Promise { - const {timestamp} = await promisify(this._web3.eth.getBlock)(blockHash); + const { timestamp } = await promisify(this._web3.eth.getBlock)(blockHash); return timestamp; } public destroy() { -- cgit v1.2.3