diff options
Diffstat (limited to 'packages')
108 files changed, 826 insertions, 734 deletions
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index 8c21c1678..1ce111708 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -50,6 +50,8 @@ interface OrderStateByOrderHash { [orderHash: string]: OrderState; } +const DEFAULT_CLEANUP_JOB_INTERVAL_MS = 1000 * 60 * 60; // 1h + /** * This class includes all the functionality related to watching a set of orders * for potential changes in order validity/fillability. The orderWatcher notifies @@ -68,6 +70,8 @@ export class OrderStateWatcher { private _orderStateUtils: OrderStateUtils; private _orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore; private _balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore; + private _cleanupJobInterval: number; + private _cleanupJobIntervalIdIfExists?: NodeJS.Timer; constructor( web3Wrapper: Web3Wrapper, abiDecoder: AbiDecoder, token: TokenWrapper, exchange: ExchangeWrapper, config?: OrderStateWatcherConfig, @@ -92,6 +96,9 @@ export class OrderStateWatcher { this._expirationWatcher = new ExpirationWatcher( expirationMarginIfExistsMs, orderExpirationCheckingIntervalMsIfExists, ); + this._cleanupJobInterval = _.isUndefined(config) || _.isUndefined(config.cleanupJobIntervalMs) ? + DEFAULT_CLEANUP_JOB_INTERVAL_MS : + config.cleanupJobIntervalMs; } /** * Add an order to the orderStateWatcher. Before the order is added, it's @@ -139,12 +146,15 @@ export class OrderStateWatcher { this._callbackIfExists = callback; this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this)); this._expirationWatcher.subscribe(this._onOrderExpired.bind(this)); + this._cleanupJobIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval( + this._cleanupAsync.bind(this), this._cleanupJobInterval, + ); } /** * Ends an orderStateWatcher subscription. */ public unsubscribe(): void { - if (_.isUndefined(this._callbackIfExists)) { + if (_.isUndefined(this._callbackIfExists) || _.isUndefined(this._cleanupJobIntervalIdIfExists)) { throw new Error(ZeroExError.SubscriptionNotFound); } this._balanceAndProxyAllowanceLazyStore.deleteAll(); @@ -152,6 +162,34 @@ export class OrderStateWatcher { delete this._callbackIfExists; this._eventWatcher.unsubscribe(); this._expirationWatcher.unsubscribe(); + intervalUtils.clearAsyncExcludingInterval(this._cleanupJobIntervalIdIfExists); + } + private async _cleanupAsync(): Promise<void> { + for (const orderHash of _.keys(this._orderByOrderHash)) { + this._cleanupOrderRelatedState(orderHash); + await this._emitRevalidateOrdersAsync([orderHash]); + } + } + private _cleanupOrderRelatedState(orderHash: string): void { + const signedOrder = this._orderByOrderHash[orderHash]; + + this._orderFilledCancelledLazyStore.deleteFilledTakerAmount(orderHash); + this._orderFilledCancelledLazyStore.deleteCancelledTakerAmount(orderHash); + + this._balanceAndProxyAllowanceLazyStore.deleteBalance(signedOrder.makerTokenAddress, signedOrder.maker); + this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(signedOrder.makerTokenAddress, signedOrder.maker); + this._balanceAndProxyAllowanceLazyStore.deleteBalance(signedOrder.takerTokenAddress, signedOrder.taker); + this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(signedOrder.takerTokenAddress, signedOrder.taker); + + const zrxTokenAddress = this._getZRXTokenAddress(); + if (!signedOrder.makerFee.isZero()) { + this._balanceAndProxyAllowanceLazyStore.deleteBalance(zrxTokenAddress, signedOrder.maker); + this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(zrxTokenAddress, signedOrder.maker); + } + if (!signedOrder.takerFee.isZero()) { + this._balanceAndProxyAllowanceLazyStore.deleteBalance(zrxTokenAddress, signedOrder.taker); + this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(zrxTokenAddress, signedOrder.taker); + } } private _onOrderExpired(orderHash: string): void { const orderState: OrderState = { @@ -266,8 +304,7 @@ export class OrderStateWatcher { this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress] = new Set(); } this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress].add(orderHash); - const exchange = (this._orderFilledCancelledLazyStore as any).exchange as ExchangeWrapper; - const zrxTokenAddress = exchange.getZRXTokenAddress(); + const zrxTokenAddress = this._getZRXTokenAddress(); if (_.isUndefined(this._dependentOrderHashes[signedOrder.maker][zrxTokenAddress])) { this._dependentOrderHashes[signedOrder.maker][zrxTokenAddress] = new Set(); } @@ -282,4 +319,9 @@ export class OrderStateWatcher { delete this._dependentOrderHashes[makerAddress]; } } + private _getZRXTokenAddress(): string { + const exchange = (this._orderFilledCancelledLazyStore as any).exchange as ExchangeWrapper; + const zrxTokenAddress = exchange.getZRXTokenAddress(); + return zrxTokenAddress; + } } diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts index 3949c17c5..5363b02ff 100644 --- a/packages/0x.js/src/types.ts +++ b/packages/0x.js/src/types.ts @@ -407,11 +407,13 @@ export interface JSONRPCPayload { * eventPollingIntervalMs: How often to poll the Ethereum node for new events. Defaults: 200 * expirationMarginMs: Amount of time before order expiry that you'd like to be notified * of an orders expiration. Defaults: 0 + * cleanupJobIntervalMs: How often to run a cleanup job which revalidates all the orders. Defaults: 1h */ export interface OrderStateWatcherConfig { orderExpirationCheckingIntervalMs?: number; eventPollingIntervalMs?: number; expirationMarginMs?: number; + cleanupJobIntervalMs?: number; } /* diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index f6c823cc4..14559c706 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -680,7 +680,7 @@ describe('ExchangeWrapper', () => { await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelTakerAmountInBaseUnits); })().catch(done); }); - it('Outstanding subscriptions are cancelled when zeroEx.setProviderAsync called', (done: DoneCallback) => { + it('Outstanding subscriptions are cancelled when zeroEx.setProvider called', (done: DoneCallback) => { (async () => { const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent<LogFillContractEventArgs>) => { diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts index cc61c2324..c853fe0c2 100644 --- a/packages/0x.js/test/token_wrapper_test.ts +++ b/packages/0x.js/test/token_wrapper_test.ts @@ -398,7 +398,7 @@ describe('TokenWrapper', () => { await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount); })().catch(done); }); - it('Outstanding subscriptions are cancelled when zeroEx.setProviderAsync called', (done: DoneCallback) => { + it('Outstanding subscriptions are cancelled when zeroEx.setProvider called', (done: DoneCallback) => { (async () => { const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => { done(new Error('Expected this subscription to have been cancelled')); diff --git a/packages/website/package.json b/packages/website/package.json index f91b579bd..b8588a31f 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -5,6 +5,7 @@ "scripts": { "build": "NODE_ENV=production webpack; exit 0;", "clean": "shx rm -f public/bundle*", + "lint": "tslint --project . 'ts/**/*.ts' 'ts/**/*.tsx'", "dev": "webpack-dev-server --content-base public --https", "update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../website/contracts; done;", "deploy_staging": "npm run build; aws s3 sync ./public/. s3://staging-0xproject --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers", diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index b13c48a65..38a2ef532 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -1,59 +1,60 @@ -import * as _ from 'lodash'; -import * as React from 'react'; import { - ZeroEx, - ZeroExError, + BlockParam, + DecodedLogEvent, ExchangeContractErrs, ExchangeContractEventArgs, ExchangeEvents, - SubscriptionOpts, IndexedFilterValues, - DecodedLogEvent, - BlockParam, - LogFillContractEventArgs, LogCancelContractEventArgs, - Token as ZeroExToken, + LogFillContractEventArgs, LogWithDecodedArgs, - TransactionReceiptWithDecodedLogs, - SignedOrder, Order, + SignedOrder, + SubscriptionOpts, + Token as ZeroExToken, + TransactionReceiptWithDecodedLogs, + ZeroEx, + ZeroExError, } from '0x.js'; import BigNumber from 'bignumber.js'; -import Web3 = require('web3'); +import compareVersions = require('compare-versions'); import promisify = require('es6-promisify'); +import ethUtil = require('ethereumjs-util'); import findVersions = require('find-versions'); -import compareVersions = require('compare-versions'); +import * as _ from 'lodash'; +import * as React from 'react'; import contract = require('truffle-contract'); -import ethUtil = require('ethereumjs-util'); -import ProviderEngine = require('web3-provider-engine'); -import FilterSubprovider = require('web3-provider-engine/subproviders/filters'); -import { TransactionSubmitted } from 'ts/components/flash_messages/transaction_submitted'; import {TokenSendCompleted} from 'ts/components/flash_messages/token_send_completed'; -import {RedundantRPCSubprovider} from 'ts/subproviders/redundant_rpc_subprovider'; +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 {InjectedWeb3SubProvider} from 'ts/subproviders/injected_web3_subprovider'; import {ledgerWalletSubproviderFactory} from 'ts/subproviders/ledger_wallet_subprovider_factory'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; -import {configs} from 'ts/utils/configs'; +import {RedundantRPCSubprovider} from 'ts/subproviders/redundant_rpc_subprovider'; import { - BlockchainErrs, - Token, - SignatureData, - Side, - ContractResponse, BlockchainCallErrs, + BlockchainErrs, ContractInstance, - ProviderType, - LedgerWalletSubprovider, + ContractResponse, EtherscanLinkSuffixes, + LedgerWalletSubprovider, + ProviderType, + Side, + SignatureData, + Token, TokenByAddress, TokenStateByAddress, } from 'ts/types'; -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 {tradeHistoryStorage} from 'ts/local_storage/trade_history_storage'; -import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; +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'); + import * as MintableArtifacts from '../contracts/Mintable.json'; const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 45730; @@ -72,9 +73,68 @@ export class Blockchain { private cachedProvider: Web3.Provider; private ledgerSubProvider: LedgerWalletSubprovider; private zrxPollIntervalId: number; + private static async onPageLoadAsync() { + if (document.readyState === 'complete') { + return; // Already loaded + } + return new Promise((resolve, reject) => { + window.onload = resolve; + }); + } + private static getNameGivenProvider(provider: Web3.Provider): string { + if (!_.isUndefined((provider as any).isMetaMask)) { + return constants.METAMASK_PROVIDER_NAME; + } + + // HACK: We use the fact that Parity Signer's provider is an instance of their + // internal `Web3FrameProvider` class. + const isParitySigner = _.startsWith(provider.constructor.toString(), 'function Web3FrameProvider'); + if (isParitySigner) { + return constants.PARITY_SIGNER_PROVIDER_NAME; + } + + return constants.GENERIC_PROVIDER_NAME; + } + private static async getProviderAsync(injectedWeb3: Web3, networkIdIfExists: number) { + const doesInjectedWeb3Exist = !_.isUndefined(injectedWeb3); + const publicNodeUrlsIfExistsForNetworkId = constants.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkIdIfExists]; + const isPublicNodeAvailableForNetworkId = !_.isUndefined(publicNodeUrlsIfExistsForNetworkId); + + let provider; + if (doesInjectedWeb3Exist && isPublicNodeAvailableForNetworkId) { + // We catch all requests involving a users account and send it to the injectedWeb3 + // instance. All other requests go to the public hosted node. + provider = new ProviderEngine(); + provider.addProvider(new InjectedWeb3SubProvider(injectedWeb3)); + provider.addProvider(new FilterSubprovider()); + provider.addProvider(new RedundantRPCSubprovider( + publicNodeUrlsIfExistsForNetworkId, + )); + provider.start(); + } else if (doesInjectedWeb3Exist) { + // Since no public node for this network, all requests go to injectedWeb3 instance + provider = injectedWeb3.currentProvider; + } else { + // If no injectedWeb3 instance, all requests fallback to our public hosted mainnet/testnet node + // We do this so that users can still browse the 0x Portal DApp even if they do not have web3 + // injected into their browser. + provider = new ProviderEngine(); + provider.addProvider(new FilterSubprovider()); + const networkId = configs.isMainnetEnabled ? + constants.MAINNET_NETWORK_ID : + constants.TESTNET_NETWORK_ID; + provider.addProvider(new RedundantRPCSubprovider( + constants.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], + )); + provider.start(); + } + + return provider; + } constructor(dispatcher: Dispatcher, isSalePage: boolean = false) { this.dispatcher = dispatcher; this.userAddress = ''; + // tslint:disable-next-line:no-floating-promises this.onPageLoadInitFireAndForgetAsync(); } public async networkIdUpdatedFireAndForgetAsync(newNetworkId: number) { @@ -157,7 +217,7 @@ export class Blockchain { this.web3Wrapper.destroy(); const shouldPollUserAddress = false; this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, this.networkId, shouldPollUserAddress); - await this.zeroEx.setProviderAsync(provider); + this.zeroEx.setProvider(provider, networkId); await this.postInstantiationOrUpdatingProviderZeroExAsync(); break; } @@ -169,7 +229,7 @@ export class Blockchain { provider = this.cachedProvider; const shouldPollUserAddress = true; this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, this.networkId, shouldPollUserAddress); - await this.zeroEx.setProviderAsync(provider); + this.zeroEx.setProvider(provider, this.networkId); await this.postInstantiationOrUpdatingProviderZeroExAsync(); delete this.ledgerSubProvider; delete this.cachedProvider; @@ -216,7 +276,7 @@ export class Blockchain { signatureData: SignatureData, salt: BigNumber): SignedOrder { const ecSignature = signatureData; const exchangeContractAddress = this.getExchangeContractAddressIfExists(); - taker = _.isEmpty(taker) ? constants.NULL_ADDRESS : taker; + const takerOrNullAddress = _.isEmpty(taker) ? constants.NULL_ADDRESS : taker; const signedOrder = { ecSignature, exchangeContractAddress, @@ -227,7 +287,7 @@ export class Blockchain { makerTokenAddress, makerTokenAmount, salt, - taker, + taker: takerOrNullAddress, takerFee, takerTokenAddress, takerTokenAmount, @@ -273,51 +333,6 @@ export class Blockchain { public getExchangeContractAddressIfExists() { return this.exchangeAddress; } - public toHumanReadableErrorMsg(error: ZeroExError|ExchangeContractErrs, takerAddress: string): string { - const ZeroExErrorToHumanReadableError: {[error: string]: string} = { - [ZeroExError.ContractDoesNotExist]: 'Contract does not exist', - [ZeroExError.ExchangeContractDoesNotExist]: 'Exchange contract does not exist', - [ZeroExError.UnhandledError]: ' Unhandled error occured', - [ZeroExError.UserHasNoAssociatedAddress]: 'User has no addresses available', - [ZeroExError.InvalidSignature]: 'Order signature is not valid', - [ZeroExError.ContractNotDeployedOnNetwork]: 'Contract is not deployed on the detected network', - [ZeroExError.InvalidJump]: 'Invalid jump occured while executing the transaction', - [ZeroExError.OutOfGas]: 'Transaction ran out of gas', - [ZeroExError.NoNetworkId]: 'No network id detected', - }; - 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.OrderAlreadyCancelledOrFilled]: - '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', - [ExchangeContractErrs.OrderFillRoundingError]: 'Rounding error will occur when filling this order', - [ExchangeContractErrs.InsufficientTakerBalance]: - 'Taker no longer has a sufficient balance to complete this order', - [ExchangeContractErrs.InsufficientTakerAllowance]: - 'Taker no longer has a sufficient allowance to complete this order', - [ExchangeContractErrs.InsufficientMakerBalance]: - 'Maker no longer has a sufficient balance to complete this order', - [ExchangeContractErrs.InsufficientMakerAllowance]: - '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', - [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', - }; - const humanReadableErrorMsg = exchangeContractErrorToHumanReadableError[error] || - ZeroExErrorToHumanReadableError[error]; - return humanReadableErrorMsg; - } public async validateFillOrderThrowIfInvalidAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber, takerAddress: string): Promise<void> { @@ -446,6 +461,7 @@ export class Blockchain { public destroy() { clearInterval(this.zrxPollIntervalId); this.web3Wrapper.destroy(); + // tslint:disable-next-line:no-floating-promises this.stopWatchingExchangeLogFillEventsAsync(); // fire and forget } private async showEtherScanLinkAndAwaitTransactionMinedAsync( @@ -485,7 +501,7 @@ export class Blockchain { // Start a subscription for new logs const exchangeAddress = this.getExchangeContractAddressIfExists(); - const subscriptionId = await this.zeroEx.exchange.subscribeAsync( + const subscriptionId = this.zeroEx.exchange.subscribe( ExchangeEvents.LogFill, indexFilterValues, async (err: Error, decodedLogEvent: DecodedLogEvent<LogFillContractEventArgs>) => { const decodedLog = decodedLogEvent.log; @@ -493,7 +509,9 @@ export class Blockchain { // 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 + // tslint:disable-next-line:no-floating-promises this.stopWatchingExchangeLogFillEventsAsync(); // fire and forget return; } else { @@ -529,7 +547,7 @@ export class Blockchain { } } private async convertDecodedLogToFillAsync(decodedLog: LogWithDecodedArgs<LogFillContractEventArgs>) { - const args = decodedLog.args as LogFillContractEventArgs; + const args = decodedLog.args; const blockTimestamp = await this.web3Wrapper.getBlockTimestampAsync(decodedLog.blockHash); const fill = { filledTakerTokenAmount: args.filledTakerTokenAmount, @@ -548,7 +566,7 @@ export class Blockchain { return fill; } private doesLogEventInvolveUser(decodedLog: LogWithDecodedArgs<LogFillContractEventArgs>) { - const args = decodedLog.args as LogFillContractEventArgs; + const args = decodedLog.args; const isUserMakerOrTaker = args.maker === this.userAddress || args.taker === this.userAddress; return isUserMakerOrTaker; @@ -594,7 +612,7 @@ export class Blockchain { return tokenByAddress; } private async onPageLoadInitFireAndForgetAsync() { - await this.onPageLoadAsync(); // wait for page to load + await Blockchain.onPageLoadAsync(); // wait for page to load // Hack: We need to know the networkId the injectedWeb3 is connected to (if it is defined) in // order to properly instantiate the web3Wrapper. Since we must use the async call, we cannot @@ -612,9 +630,11 @@ export class Blockchain { } } - const provider = await this.getProviderAsync(injectedWeb3, networkId); - this.zeroEx = new ZeroEx(provider); - await this.updateProviderName(injectedWeb3); + const provider = await Blockchain.getProviderAsync(injectedWeb3, networkId); + this.zeroEx = new ZeroEx(provider, { + networkId, + }); + this.updateProviderName(injectedWeb3); const shouldPollUserAddress = true; this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, networkId, shouldPollUserAddress); await this.postInstantiationOrUpdatingProviderZeroExAsync(); @@ -623,12 +643,12 @@ export class Blockchain { // of the ZeroEx instance. private async postInstantiationOrUpdatingProviderZeroExAsync() { utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.'); - this.exchangeAddress = await this.zeroEx.exchange.getContractAddressAsync(); + this.exchangeAddress = await this.zeroEx.exchange.getContractAddress(); } private updateProviderName(injectedWeb3: Web3) { const doesInjectedWeb3Exist = !_.isUndefined(injectedWeb3); const providerName = doesInjectedWeb3Exist ? - this.getNameGivenProvider(injectedWeb3.currentProvider) : + Blockchain.getNameGivenProvider(injectedWeb3.currentProvider) : constants.PUBLIC_PROVIDER_NAME; this.dispatcher.updateInjectedProviderName(providerName); } @@ -637,56 +657,6 @@ export class Blockchain { private getBlockchainNetworkId() { return this.networkId; } - private async getProviderAsync(injectedWeb3: Web3, networkIdIfExists: number) { - const doesInjectedWeb3Exist = !_.isUndefined(injectedWeb3); - const publicNodeUrlsIfExistsForNetworkId = constants.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkIdIfExists]; - const isPublicNodeAvailableForNetworkId = !_.isUndefined(publicNodeUrlsIfExistsForNetworkId); - - let provider; - if (doesInjectedWeb3Exist && isPublicNodeAvailableForNetworkId) { - // We catch all requests involving a users account and send it to the injectedWeb3 - // instance. All other requests go to the public hosted node. - provider = new ProviderEngine(); - provider.addProvider(new InjectedWeb3SubProvider(injectedWeb3)); - provider.addProvider(new FilterSubprovider()); - provider.addProvider(new RedundantRPCSubprovider( - publicNodeUrlsIfExistsForNetworkId, - )); - provider.start(); - } else if (doesInjectedWeb3Exist) { - // Since no public node for this network, all requests go to injectedWeb3 instance - provider = injectedWeb3.currentProvider; - } else { - // If no injectedWeb3 instance, all requests fallback to our public hosted mainnet/testnet node - // We do this so that users can still browse the 0x Portal DApp even if they do not have web3 - // injected into their browser. - provider = new ProviderEngine(); - provider.addProvider(new FilterSubprovider()); - const networkId = configs.isMainnetEnabled ? - constants.MAINNET_NETWORK_ID : - constants.TESTNET_NETWORK_ID; - provider.addProvider(new RedundantRPCSubprovider( - constants.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], - )); - provider.start(); - } - - return provider; - } - private getNameGivenProvider(provider: Web3.Provider): string { - if (!_.isUndefined((provider as any).isMetaMask)) { - return constants.METAMASK_PROVIDER_NAME; - } - - // HACK: We use the fact that Parity Signer's provider is an instance of their - // internal `Web3FrameProvider` class. - const isParitySigner = _.startsWith(provider.constructor.toString(), 'function Web3FrameProvider'); - if (isParitySigner) { - return constants.PARITY_SIGNER_PROVIDER_NAME; - } - - return constants.GENERIC_PROVIDER_NAME; - } private async fetchTokenInformationAsync() { utils.assert(!_.isUndefined(this.networkId), 'Cannot call fetchTokenInformationAsync if disconnected from Ethereum node'); @@ -776,12 +746,4 @@ export class Blockchain { } } } - private async onPageLoadAsync() { - if (document.readyState === 'complete') { - return; // Already loaded - } - return new Promise((resolve, reject) => { - window.onload = resolve; - }); - } -} +} // tslint:disable:max-file-line-count diff --git a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx index 2e12fc889..963bd4388 100644 --- a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx +++ b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx @@ -1,12 +1,12 @@ import * as _ from 'lodash'; -import * as React from 'react'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import {colors} from 'material-ui/styles'; -import {constants} from 'ts/utils/constants'; -import {configs} from 'ts/utils/configs'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; import {BlockchainErrs} from 'ts/types'; +import {configs} from 'ts/utils/configs'; +import {constants} from 'ts/utils/constants'; interface BlockchainErrDialogProps { blockchain: Blockchain; @@ -21,6 +21,7 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp public render() { const dialogActions = [ <FlatButton + key="blockchainErrOk" label="Ok" primary={true} onTouchTap={this.props.toggleDialogFn.bind(this.props.toggleDialogFn, false)} 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 1db85e375..aba5b9faf 100644 --- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx +++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx @@ -1,12 +1,12 @@ -import * as React from 'react'; +import BigNumber from 'bignumber.js'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; -import RadioButtonGroup from 'material-ui/RadioButton/RadioButtonGroup'; import RadioButton from 'material-ui/RadioButton'; -import {Side, Token, TokenState} from 'ts/types'; -import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; +import RadioButtonGroup from 'material-ui/RadioButton/RadioButtonGroup'; +import * as React from 'react'; import {EthAmountInput} from 'ts/components/inputs/eth_amount_input'; -import BigNumber from 'bignumber.js'; +import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; +import {Side, Token, TokenState} from 'ts/types'; interface EthWethConversionDialogProps { onComplete: (direction: Side, value: BigNumber) => void; diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx index f89935500..d3c95a011 100644 --- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx +++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx @@ -1,24 +1,24 @@ -import * as _ from 'lodash'; -import * as React from 'react'; import BigNumber from 'bignumber.js'; -import {colors} from 'material-ui/styles'; +import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; -import TextField from 'material-ui/TextField'; +import {colors} from 'material-ui/styles'; import { Table, TableBody, TableHeader, - TableRow, TableHeaderColumn, + TableRow, TableRowColumn, } from 'material-ui/Table'; +import TextField from 'material-ui/TextField'; +import * as React from 'react'; import ReactTooltip = require('react-tooltip'); -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; import {Blockchain} from 'ts/blockchain'; -import {Dispatcher} from 'ts/redux/dispatcher'; import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {constants} from 'ts/utils/constants'; +import {utils} from 'ts/utils/utils'; const VALID_ETHEREUM_DERIVATION_PATH_PREFIX = `44'/60'`; @@ -59,6 +59,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, public render() { const dialogActions = [ <FlatButton + key="ledgerConnectCancel" label="Cancel" onTouchTap={this.onClose.bind(this)} />, diff --git a/packages/website/ts/components/dialogs/portal_disclaimer_dialog.tsx b/packages/website/ts/components/dialogs/portal_disclaimer_dialog.tsx index 8f870b42f..1d90624ee 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 * as React from 'react'; -import {colors} from 'material-ui/styles'; -import FlatButton from 'material-ui/FlatButton'; import Dialog from 'material-ui/Dialog'; +import FlatButton from 'material-ui/FlatButton'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {constants} from 'ts/utils/constants'; interface PortalDisclaimerDialogProps { @@ -16,6 +16,7 @@ export function PortalDisclaimerDialog(props: PortalDisclaimerDialogProps) { titleStyle={{fontWeight: 100}} actions={[ <FlatButton + key="portalAgree" label="I Agree" onTouchTap={props.onToggleDialog.bind(this)} />, diff --git a/packages/website/ts/components/dialogs/send_dialog.tsx b/packages/website/ts/components/dialogs/send_dialog.tsx index 10417a326..31afc3386 100644 --- a/packages/website/ts/components/dialogs/send_dialog.tsx +++ b/packages/website/ts/components/dialogs/send_dialog.tsx @@ -1,14 +1,14 @@ -import * as React from 'react'; +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; -import RadioButtonGroup from 'material-ui/RadioButton/RadioButtonGroup'; import RadioButton from 'material-ui/RadioButton'; -import {Side, Token, TokenState} from 'ts/types'; -import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; -import {EthAmountInput} from 'ts/components/inputs/eth_amount_input'; +import RadioButtonGroup from 'material-ui/RadioButton/RadioButtonGroup'; +import * as React from 'react'; import {AddressInput} from 'ts/components/inputs/address_input'; -import BigNumber from 'bignumber.js'; +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'; interface SendDialogProps { onComplete: (recipient: string, value: BigNumber) => void; diff --git a/packages/website/ts/components/dialogs/track_token_confirmation_dialog.tsx b/packages/website/ts/components/dialogs/track_token_confirmation_dialog.tsx index 97c654656..70c7d1ab6 100644 --- a/packages/website/ts/components/dialogs/track_token_confirmation_dialog.tsx +++ b/packages/website/ts/components/dialogs/track_token_confirmation_dialog.tsx @@ -1,14 +1,14 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import {colors} from 'material-ui/styles'; -import FlatButton from 'material-ui/FlatButton'; import Dialog from 'material-ui/Dialog'; -import {constants} from 'ts/utils/constants'; +import FlatButton from 'material-ui/FlatButton'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; -import {Dispatcher} from 'ts/redux/dispatcher'; import {TrackTokenConfirmation} from 'ts/components/track_token_confirmation'; import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; +import {Dispatcher} from 'ts/redux/dispatcher'; import {Token, TokenByAddress} from 'ts/types'; +import {constants} from 'ts/utils/constants'; interface TrackTokenConfirmationDialogProps { tokens: Token[]; @@ -41,10 +41,12 @@ export class TrackTokenConfirmationDialog extends titleStyle={{fontWeight: 100}} actions={[ <FlatButton + key="trackNo" label="No" onTouchTap={this.onTrackConfirmationRespondedAsync.bind(this, false)} />, <FlatButton + key="trackYes" label="Yes" onTouchTap={this.onTrackConfirmationRespondedAsync.bind(this, true)} />, diff --git a/packages/website/ts/components/dialogs/u2f_not_supported_dialog.tsx b/packages/website/ts/components/dialogs/u2f_not_supported_dialog.tsx index 28c24cdbe..09c32c997 100644 --- a/packages/website/ts/components/dialogs/u2f_not_supported_dialog.tsx +++ b/packages/website/ts/components/dialogs/u2f_not_supported_dialog.tsx @@ -1,7 +1,7 @@ -import * as React from 'react'; -import {colors} from 'material-ui/styles'; -import FlatButton from 'material-ui/FlatButton'; import Dialog from 'material-ui/Dialog'; +import FlatButton from 'material-ui/FlatButton'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {constants} from 'ts/utils/constants'; interface U2fNotSupportedDialogProps { @@ -16,6 +16,7 @@ export function U2fNotSupportedDialog(props: U2fNotSupportedDialogProps) { titleStyle={{fontWeight: 100}} actions={[ <FlatButton + key="u2fNo" label="Ok" onTouchTap={props.onToggleDialog.bind(this)} />, diff --git a/packages/website/ts/components/eth_weth_conversion_button.tsx b/packages/website/ts/components/eth_weth_conversion_button.tsx index fd8b713f4..a83b1543f 100644 --- a/packages/website/ts/components/eth_weth_conversion_button.tsx +++ b/packages/website/ts/components/eth_weth_conversion_button.tsx @@ -1,16 +1,15 @@ -import * as _ from 'lodash'; import {ZeroEx} from '0x.js'; -import * as React from 'react'; import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; import RaisedButton from 'material-ui/RaisedButton'; -import {BlockchainCallErrs, TokenState} from 'ts/types'; +import * as React from 'react'; +import {Blockchain} from 'ts/blockchain'; import {EthWethConversionDialog} from 'ts/components/dialogs/eth_weth_conversion_dialog'; -import {Side, Token} from 'ts/types'; -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; import {Dispatcher} from 'ts/redux/dispatcher'; +import {BlockchainCallErrs, Side, Token, TokenState} from 'ts/types'; +import {constants} from 'ts/utils/constants'; import {errorReporter} from 'ts/utils/error_reporter'; -import {Blockchain} from 'ts/blockchain'; +import {utils} from 'ts/utils/utils'; interface EthWethConversionButtonProps { ethToken: Token; diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx index dc965283e..388c72d8e 100644 --- a/packages/website/ts/components/fill_order.tsx +++ b/packages/website/ts/components/fill_order.tsx @@ -1,44 +1,44 @@ -import * as _ from 'lodash'; -import * as React from 'react'; +import {Order as ZeroExOrder, ZeroEx} from '0x.js'; import * as accounting from 'accounting'; -import {Link} from 'react-router-dom'; -import {ZeroEx, Order as ZeroExOrder} from '0x.js'; -import * as moment from 'moment'; import BigNumber from 'bignumber.js'; -import Paper from 'material-ui/Paper'; -import {Card, CardText, CardHeader} from 'material-ui/Card'; +import * as _ from 'lodash'; +import {Card, CardHeader, CardText} from 'material-ui/Card'; import Divider from 'material-ui/Divider'; -import TextField from 'material-ui/TextField'; +import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; +import TextField from 'material-ui/TextField'; +import * as moment from 'moment'; +import * as React from 'react'; +import {Link} from 'react-router-dom'; +import {Blockchain} from 'ts/blockchain'; +import {TrackTokenConfirmationDialog} from 'ts/components/dialogs/track_token_confirmation_dialog'; +import {FillOrderJSON} from 'ts/components/fill_order_json'; +import {FillWarningDialog} from 'ts/components/fill_warning_dialog'; +import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; +import {Alert} from 'ts/components/ui/alert'; +import {EthereumAddress} from 'ts/components/ui/ethereum_address'; +import {Identicon} from 'ts/components/ui/identicon'; +import {VisualOrder} from 'ts/components/visual_order'; +import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {orderSchema} from 'ts/schemas/order_schema'; +import {SchemaValidator} from 'ts/schemas/validator'; import { - Side, - TokenByAddress, - TokenStateByAddress, - Order, + AlertTypes, BlockchainErrs, + ContractResponse, + ExchangeContractErrs, + Order, OrderToken, + Side, Token, - ExchangeContractErrs, - AlertTypes, - ContractResponse, + TokenByAddress, + TokenStateByAddress, WebsitePaths, } from 'ts/types'; -import {Alert} from 'ts/components/ui/alert'; -import {Identicon} from 'ts/components/ui/identicon'; -import {EthereumAddress} from 'ts/components/ui/ethereum_address'; -import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; -import {FillWarningDialog} from 'ts/components/fill_warning_dialog'; -import {FillOrderJSON} from 'ts/components/fill_order_json'; -import {VisualOrder} from 'ts/components/visual_order'; -import {SchemaValidator} from 'ts/schemas/validator'; -import {orderSchema} from 'ts/schemas/order_schema'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {Blockchain} from 'ts/blockchain'; +import {constants} from 'ts/utils/constants'; import {errorReporter} from 'ts/utils/error_reporter'; -import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; -import {TrackTokenConfirmationDialog} from 'ts/components/dialogs/track_token_confirmation_dialog'; +import {utils} from 'ts/utils/utils'; const CUSTOM_LIGHT_GRAY = '#BBBBBB'; @@ -100,6 +100,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { } public componentWillMount() { if (!_.isEmpty(this.state.orderJSON)) { + // tslint:disable-next-line:no-floating-promises this.validateFillOrderFireAndForgetAsync(this.state.orderJSON); } } @@ -351,6 +352,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { isFillWarningDialogOpen: true, }); } else { + // tslint:disable-next-line:no-floating-promises this.onFillOrderClickFireAndForgetAsync(); } } @@ -359,6 +361,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { isFillWarningDialogOpen: false, }); if (!didUserCancel) { + // tslint:disable-next-line:no-floating-promises this.onFillOrderClickFireAndForgetAsync(); } } @@ -371,6 +374,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { didOrderValidationRun: _.isEmpty(orderJSON) && _.isEmpty(this.state.orderJSONErrMsg), didFillOrderSucceed: false, }); + // tslint:disable-next-line:no-floating-promises this.validateFillOrderFireAndForgetAsync(orderJSON); } private async checkForUntrackedTokensAndAskToAdd() { @@ -563,7 +567,9 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { await this.props.blockchain.validateFillOrderThrowIfInvalidAsync( signedOrder, takerFillAmount, this.props.userAddress); } catch (err) { - globalErrMsg = this.props.blockchain.toHumanReadableErrorMsg(err.message, parsedOrder.taker.address); + globalErrMsg = utils.zeroExErrToHumanReadableErrMsg( + err.message, parsedOrder.taker.address, + ); } } if (!_.isEmpty(globalErrMsg)) { @@ -652,7 +658,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { await this.props.blockchain.validateCancelOrderThrowIfInvalidAsync( signedOrder, availableTakerTokenAmount); } catch (err) { - globalErrMsg = this.props.blockchain.toHumanReadableErrorMsg(err.message, parsedOrder.taker.address); + globalErrMsg = utils.zeroExErrToHumanReadableErrMsg(err.message, parsedOrder.taker.address); } if (!_.isEmpty(globalErrMsg)) { this.setState({ @@ -711,4 +717,4 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { tokensToTrack: [], }); } -} +} // tslint:disable:max-file-line-count diff --git a/packages/website/ts/components/fill_order_json.tsx b/packages/website/ts/components/fill_order_json.tsx index b355d910b..f4db1f74e 100644 --- a/packages/website/ts/components/fill_order_json.tsx +++ b/packages/website/ts/components/fill_order_json.tsx @@ -1,13 +1,13 @@ -import * as _ from 'lodash'; -import * as React from 'react'; -import BigNumber from 'bignumber.js'; import {ZeroEx} from '0x.js'; +import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; import Paper from 'material-ui/Paper'; import TextField from 'material-ui/TextField'; -import {Side, TokenByAddress} from 'ts/types'; -import {utils} from 'ts/utils/utils'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; +import {Side, TokenByAddress} from 'ts/types'; import {constants} from 'ts/utils/constants'; +import {utils} from 'ts/utils/utils'; interface FillOrderJSONProps { blockchain: Blockchain; diff --git a/packages/website/ts/components/fill_warning_dialog.tsx b/packages/website/ts/components/fill_warning_dialog.tsx index 029fa8b0c..83e46cc8f 100644 --- a/packages/website/ts/components/fill_warning_dialog.tsx +++ b/packages/website/ts/components/fill_warning_dialog.tsx @@ -1,7 +1,7 @@ -import * as React from 'react'; -import {colors} from 'material-ui/styles'; -import FlatButton from 'material-ui/FlatButton'; import Dialog from 'material-ui/Dialog'; +import FlatButton from 'material-ui/FlatButton'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; interface FillWarningDialogProps { isOpen: boolean; @@ -16,10 +16,12 @@ export function FillWarningDialog(props: FillWarningDialogProps) { titleStyle={{fontWeight: 100, color: colors.red500}} actions={[ <FlatButton + key="fillWarningCancel" label="Cancel" onTouchTap={props.onToggleDialog.bind(this, didCancel)} />, <FlatButton + key="fillWarningContinue" label="Fill Order" onTouchTap={props.onToggleDialog.bind(this, !didCancel)} />, diff --git a/packages/website/ts/components/flash_messages/token_send_completed.tsx b/packages/website/ts/components/flash_messages/token_send_completed.tsx index c4977d70b..fef7520f6 100644 --- a/packages/website/ts/components/flash_messages/token_send_completed.tsx +++ b/packages/website/ts/components/flash_messages/token_send_completed.tsx @@ -1,7 +1,7 @@ -import * as React from 'react'; -import * as _ from 'lodash'; -import BigNumber from 'bignumber.js'; import {ZeroEx} from '0x.js'; +import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; +import * as React from 'react'; import {Token} from 'ts/types'; import {utils} from 'ts/utils/utils'; diff --git a/packages/website/ts/components/flash_messages/transaction_submitted.tsx b/packages/website/ts/components/flash_messages/transaction_submitted.tsx index 7a3cc6e86..cef3e2b1e 100644 --- a/packages/website/ts/components/flash_messages/transaction_submitted.tsx +++ b/packages/website/ts/components/flash_messages/transaction_submitted.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import * as _ from 'lodash'; +import * as React from 'react'; interface TransactionSubmittedProps { etherScanLinkIfExists?: string; diff --git a/packages/website/ts/components/footer.tsx b/packages/website/ts/components/footer.tsx index 99f97292e..f7070e0f8 100644 --- a/packages/website/ts/components/footer.tsx +++ b/packages/website/ts/components/footer.tsx @@ -1,13 +1,13 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {HashLink} from 'react-router-hash-link'; -import {Styles, WebsitePaths} from 'ts/types'; import { Link, } from 'react-router-dom'; +import {HashLink} from 'react-router-hash-link'; import { Link as ScrollLink, } from 'react-scroll'; +import {Styles, WebsitePaths} from 'ts/types'; import {constants} from 'ts/utils/constants'; interface MenuItemsBySection { diff --git a/packages/website/ts/components/generate_order/asset_picker.tsx b/packages/website/ts/components/generate_order/asset_picker.tsx index 410b0440a..633d6a017 100644 --- a/packages/website/ts/components/generate_order/asset_picker.tsx +++ b/packages/website/ts/components/generate_order/asset_picker.tsx @@ -1,26 +1,26 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import {colors} from 'material-ui/styles'; import Dialog from 'material-ui/Dialog'; +import FlatButton from 'material-ui/FlatButton'; import GridList from 'material-ui/GridList/GridList'; import GridTile from 'material-ui/GridList/GridTile'; -import FlatButton from 'material-ui/FlatButton'; -import {utils} from 'ts/utils/utils'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; +import {NewTokenForm} from 'ts/components/generate_order/new_token_form'; +import {TrackTokenConfirmation} from 'ts/components/track_token_confirmation'; +import {TokenIcon} from 'ts/components/ui/token_icon'; +import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; import {Dispatcher} from 'ts/redux/dispatcher'; import { - Token, AssetToken, - TokenByAddress, + DialogConfigs, Styles, + Token, + TokenByAddress, TokenState, - DialogConfigs, TokenVisibility, } from 'ts/types'; -import {NewTokenForm} from 'ts/components/generate_order/new_token_form'; -import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; -import {TrackTokenConfirmation} from 'ts/components/track_token_confirmation'; -import {TokenIcon} from 'ts/components/ui/token_icon'; +import {utils} from 'ts/utils/utils'; const TOKEN_ICON_DIMENSION = 100; const TILE_DIMENSION = 146; diff --git a/packages/website/ts/components/generate_order/generate_order_form.tsx b/packages/website/ts/components/generate_order/generate_order_form.tsx index e9026d9bc..72edf08cf 100644 --- a/packages/website/ts/components/generate_order/generate_order_form.tsx +++ b/packages/website/ts/components/generate_order/generate_order_form.tsx @@ -1,37 +1,37 @@ -import * as _ from 'lodash'; -import * as React from 'react'; -import {ZeroEx, Order} from '0x.js'; +import {Order, ZeroEx} from '0x.js'; import BigNumber from 'bignumber.js'; -import {Blockchain} from 'ts/blockchain'; -import Divider from 'material-ui/Divider'; +import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; +import Divider from 'material-ui/Divider'; import {colors} from 'material-ui/styles'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {utils} from 'ts/utils/utils'; -import {SchemaValidator} from 'ts/schemas/validator'; -import {orderSchema} from 'ts/schemas/order_schema'; -import {Alert} from 'ts/components/ui/alert'; -import {OrderJSON} from 'ts/components/order_json'; +import * as React from 'react'; +import {Blockchain} from 'ts/blockchain'; +import {ExpirationInput} from 'ts/components/inputs/expiration_input'; +import {HashInput} from 'ts/components/inputs/hash_input'; import {IdenticonAddressInput} from 'ts/components/inputs/identicon_address_input'; -import {TokenInput} from 'ts/components/inputs/token_input'; import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; -import {HashInput} from 'ts/components/inputs/hash_input'; -import {ExpirationInput} from 'ts/components/inputs/expiration_input'; -import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; -import {errorReporter} from 'ts/utils/error_reporter'; +import {TokenInput} from 'ts/components/inputs/token_input'; +import {OrderJSON} from 'ts/components/order_json'; +import {Alert} from 'ts/components/ui/alert'; import {HelpTooltip} from 'ts/components/ui/help_tooltip'; +import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; import {SwapIcon} from 'ts/components/ui/swap_icon'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {orderSchema} from 'ts/schemas/order_schema'; +import {SchemaValidator} from 'ts/schemas/validator'; import { + AlertTypes, + BlockchainErrs, + HashData, Side, SideToAssetToken, SignatureData, - HashData, + Token, TokenByAddress, TokenStateByAddress, - BlockchainErrs, - Token, - AlertTypes, } from 'ts/types'; +import {errorReporter} from 'ts/utils/error_reporter'; +import {utils} from 'ts/utils/utils'; enum SigningState { UNSIGNED, diff --git a/packages/website/ts/components/generate_order/new_token_form.tsx b/packages/website/ts/components/generate_order/new_token_form.tsx index 95c05f5bb..7e2c61ae8 100644 --- a/packages/website/ts/components/generate_order/new_token_form.tsx +++ b/packages/website/ts/components/generate_order/new_token_form.tsx @@ -1,15 +1,15 @@ +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; -import * as React from 'react'; import {colors} from 'material-ui/styles'; import TextField from 'material-ui/TextField'; -import {constants} from 'ts/utils/constants'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; -import {Token, TokenState, TokenByAddress, AlertTypes} from 'ts/types'; import {AddressInput} from 'ts/components/inputs/address_input'; import {Alert} from 'ts/components/ui/alert'; import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; import {RequiredLabel} from 'ts/components/ui/required_label'; -import BigNumber from 'bignumber.js'; +import {AlertTypes, Token, TokenByAddress, TokenState} from 'ts/types'; +import {constants} from 'ts/utils/constants'; interface NewTokenFormProps { blockchain: Blockchain; diff --git a/packages/website/ts/components/inputs/address_input.tsx b/packages/website/ts/components/inputs/address_input.tsx index 57ad7a5e2..8b03b8d12 100644 --- a/packages/website/ts/components/inputs/address_input.tsx +++ b/packages/website/ts/components/inputs/address_input.tsx @@ -1,8 +1,8 @@ -import * as _ from 'lodash'; -import * as React from 'react'; import {isAddress} from 'ethereum-address'; -import TextField from 'material-ui/TextField'; +import * as _ from 'lodash'; import {colors} from 'material-ui/styles'; +import TextField from 'material-ui/TextField'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; import {RequiredLabel} from 'ts/components/ui/required_label'; diff --git a/packages/website/ts/components/inputs/allowance_toggle.tsx b/packages/website/ts/components/inputs/allowance_toggle.tsx index f02112253..4c15ed4a0 100644 --- a/packages/website/ts/components/inputs/allowance_toggle.tsx +++ b/packages/website/ts/components/inputs/allowance_toggle.tsx @@ -1,12 +1,12 @@ -import * as _ from 'lodash'; -import * as React from 'react'; import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; import Toggle from 'material-ui/Toggle'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; import {Dispatcher} from 'ts/redux/dispatcher'; -import {Token, TokenState, BalanceErrs} from 'ts/types'; -import {utils} from 'ts/utils/utils'; +import {BalanceErrs, Token, TokenState} from 'ts/types'; import {errorReporter} from 'ts/utils/error_reporter'; +import {utils} from 'ts/utils/utils'; const DEFAULT_ALLOWANCE_AMOUNT_IN_BASE_UNITS = new BigNumber(2).pow(256).minus(1); diff --git a/packages/website/ts/components/inputs/balance_bounded_input.tsx b/packages/website/ts/components/inputs/balance_bounded_input.tsx index 1c8b410a4..7ddefc3b9 100644 --- a/packages/website/ts/components/inputs/balance_bounded_input.tsx +++ b/packages/website/ts/components/inputs/balance_bounded_input.tsx @@ -1,12 +1,12 @@ -import * as _ from 'lodash'; -import * as React from 'react'; import BigNumber from 'bignumber.js'; -import {ValidatedBigNumberCallback, InputErrMsg, WebsitePaths} from 'ts/types'; +import * as _ from 'lodash'; +import {colors} from 'material-ui/styles'; import TextField from 'material-ui/TextField'; +import * as React from 'react'; +import {Link} from 'react-router-dom'; import {RequiredLabel} from 'ts/components/ui/required_label'; -import {colors} from 'material-ui/styles'; +import {InputErrMsg, ValidatedBigNumberCallback, WebsitePaths} from 'ts/types'; import {utils} from 'ts/utils/utils'; -import {Link} from 'react-router-dom'; interface BalanceBoundedInputProps { label?: string; diff --git a/packages/website/ts/components/inputs/eth_amount_input.tsx b/packages/website/ts/components/inputs/eth_amount_input.tsx index ad551e125..5c5e23eef 100644 --- a/packages/website/ts/components/inputs/eth_amount_input.tsx +++ b/packages/website/ts/components/inputs/eth_amount_input.tsx @@ -1,9 +1,9 @@ +import {ZeroEx} from '0x.js'; import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as React from 'react'; -import {ZeroEx} from '0x.js'; -import {ValidatedBigNumberCallback} from 'ts/types'; import {BalanceBoundedInput} from 'ts/components/inputs/balance_bounded_input'; +import {ValidatedBigNumberCallback} from 'ts/types'; import {constants} from 'ts/utils/constants'; interface EthAmountInputProps { diff --git a/packages/website/ts/components/inputs/expiration_input.tsx b/packages/website/ts/components/inputs/expiration_input.tsx index 32dcad189..d3d3d258d 100644 --- a/packages/website/ts/components/inputs/expiration_input.tsx +++ b/packages/website/ts/components/inputs/expiration_input.tsx @@ -1,10 +1,10 @@ -import * as React from 'react'; +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import DatePicker from 'material-ui/DatePicker'; import TimePicker from 'material-ui/TimePicker'; -import {utils} from 'ts/utils/utils'; -import BigNumber from 'bignumber.js'; import * as moment from 'moment'; +import * as React from 'react'; +import {utils} from 'ts/utils/utils'; interface ExpirationInputProps { orderExpiryTimestamp: BigNumber; diff --git a/packages/website/ts/components/inputs/hash_input.tsx b/packages/website/ts/components/inputs/hash_input.tsx index 3e42f1d5f..7fadc3c15 100644 --- a/packages/website/ts/components/inputs/hash_input.tsx +++ b/packages/website/ts/components/inputs/hash_input.tsx @@ -1,8 +1,8 @@ +import {Order, ZeroEx} from '0x.js'; import * as React from 'react'; +import ReactTooltip = require('react-tooltip'); import {Blockchain} from 'ts/blockchain'; -import {ZeroEx, Order} from '0x.js'; import {FakeTextField} from 'ts/components/ui/fake_text_field'; -import ReactTooltip = require('react-tooltip'); import {HashData, Styles} from 'ts/types'; import {constants} from 'ts/utils/constants'; diff --git a/packages/website/ts/components/inputs/identicon_address_input.tsx b/packages/website/ts/components/inputs/identicon_address_input.tsx index 6452f5fe9..692a092d9 100644 --- a/packages/website/ts/components/inputs/identicon_address_input.tsx +++ b/packages/website/ts/components/inputs/identicon_address_input.tsx @@ -1,11 +1,11 @@ import * as _ from 'lodash'; -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; -import {Identicon} from 'ts/components/ui/identicon'; -import {RequiredLabel} from 'ts/components/ui/required_label'; import {AddressInput} from 'ts/components/inputs/address_input'; +import {Identicon} from 'ts/components/ui/identicon'; import {InputLabel} from 'ts/components/ui/input_label'; +import {RequiredLabel} from 'ts/components/ui/required_label'; interface IdenticonAddressInputProps { initialAddress: string; diff --git a/packages/website/ts/components/inputs/token_amount_input.tsx b/packages/website/ts/components/inputs/token_amount_input.tsx index e19af8984..f39341a4f 100644 --- a/packages/website/ts/components/inputs/token_amount_input.tsx +++ b/packages/website/ts/components/inputs/token_amount_input.tsx @@ -1,11 +1,11 @@ -import * as React from 'react'; -import * as _ from 'lodash'; -import BigNumber from 'bignumber.js'; import {ZeroEx} from '0x.js'; -import {Link} from 'react-router-dom'; +import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; import {colors} from 'material-ui/styles'; -import {Token, TokenState, InputErrMsg, ValidatedBigNumberCallback, WebsitePaths} from 'ts/types'; +import * as React from 'react'; +import {Link} from 'react-router-dom'; import {BalanceBoundedInput} from 'ts/components/inputs/balance_bounded_input'; +import {InputErrMsg, Token, TokenState, ValidatedBigNumberCallback, WebsitePaths} from 'ts/types'; interface TokenAmountInputProps { label: string; diff --git a/packages/website/ts/components/inputs/token_input.tsx b/packages/website/ts/components/inputs/token_input.tsx index 2be74d4fd..8daa84650 100644 --- a/packages/website/ts/components/inputs/token_input.tsx +++ b/packages/website/ts/components/inputs/token_input.tsx @@ -1,13 +1,13 @@ import * as _ from 'lodash'; -import * as React from 'react'; import Paper from 'material-ui/Paper'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {AssetToken, Side, TokenByAddress, BlockchainErrs, Token, TokenState} from 'ts/types'; import {AssetPicker} from 'ts/components/generate_order/asset_picker'; import {InputLabel} from 'ts/components/ui/input_label'; import {TokenIcon} from 'ts/components/ui/token_icon'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {AssetToken, BlockchainErrs, Side, Token, TokenByAddress, TokenState} from 'ts/types'; const TOKEN_ICON_DIMENSION = 80; diff --git a/packages/website/ts/components/order_json.tsx b/packages/website/ts/components/order_json.tsx index 90e3543dd..073abe419 100644 --- a/packages/website/ts/components/order_json.tsx +++ b/packages/website/ts/components/order_json.tsx @@ -1,15 +1,15 @@ -import * as _ from 'lodash'; -import * as React from 'react'; import BigNumber from 'bignumber.js'; -import {utils} from 'ts/utils/utils'; +import * as _ from 'lodash'; +import Paper from 'material-ui/Paper'; import {colors} from 'material-ui/styles'; -import {constants} from 'ts/utils/constants'; -import {configs} from 'ts/utils/configs'; import TextField from 'material-ui/TextField'; -import Paper from 'material-ui/Paper'; +import * as React from 'react'; import {CopyIcon} from 'ts/components/ui/copy_icon'; -import {SideToAssetToken, SignatureData, Order, TokenByAddress, WebsitePaths} from 'ts/types'; +import {Order, SideToAssetToken, SignatureData, TokenByAddress, WebsitePaths} 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'; interface OrderJSONProps { exchangeContractIfExists: string; @@ -36,6 +36,7 @@ export class OrderJSON extends React.Component<OrderJSONProps, OrderJSONState> { this.state = { shareLink: '', }; + // tslint:disable-next-line:no-floating-promises this.setShareLinkAsync(); } public render() { @@ -149,7 +150,7 @@ You can see and fill it here: ${this.state.shareLink}`); await errorReporter.reportAsync(new Error(`Bitly returned non-200: ${JSON.stringify(response)}`)); return ''; } - return (bodyObj as any).data.url; + return (bodyObj).data.url; } private getOrderUrl() { const order = utils.generateOrder(this.props.networkId, this.props.exchangeContractIfExists, diff --git a/packages/website/ts/components/portal.tsx b/packages/website/ts/components/portal.tsx index 3591a347b..62a5d2eac 100644 --- a/packages/website/ts/components/portal.tsx +++ b/packages/website/ts/components/portal.tsx @@ -1,44 +1,44 @@ +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; -import * as React from 'react'; -import * as DocumentTitle from 'react-document-title'; -import {Switch, Route} from 'react-router-dom'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {State} from 'ts/redux/reducer'; -import {utils} from 'ts/utils/utils'; -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; import {colors} from 'material-ui/styles'; -import {GenerateOrderForm} from 'ts/containers/generate_order_form'; -import {TokenBalances} from 'ts/components/token_balances'; +import * as React from 'react'; +import * as DocumentTitle from 'react-document-title'; +import {Route, Switch} from 'react-router-dom'; +import {Blockchain} from 'ts/blockchain'; +import {BlockchainErrDialog} from 'ts/components/dialogs/blockchain_err_dialog'; import {PortalDisclaimerDialog} from 'ts/components/dialogs/portal_disclaimer_dialog'; import {FillOrder} from 'ts/components/fill_order'; -import {Blockchain} from 'ts/blockchain'; -import {SchemaValidator} from 'ts/schemas/validator'; -import {orderSchema} from 'ts/schemas/order_schema'; -import {localStorage} from 'ts/local_storage/local_storage'; +import {Footer} from 'ts/components/footer'; +import {PortalMenu} from 'ts/components/portal_menu'; +import {TokenBalances} from 'ts/components/token_balances'; +import {TopBar} from 'ts/components/top_bar'; import {TradeHistory} from 'ts/components/trade_history/trade_history'; +import {FlashMessage} from 'ts/components/ui/flash_message'; +import {Loading} from 'ts/components/ui/loading'; +import {GenerateOrderForm} from 'ts/containers/generate_order_form'; +import {localStorage} from 'ts/local_storage/local_storage'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {State} from 'ts/redux/reducer'; +import {orderSchema} from 'ts/schemas/order_schema'; +import {SchemaValidator} from 'ts/schemas/validator'; import { - HashData, - TokenByAddress, BlockchainErrs, - Order, Fill, + HashData, + Order, + ScreenWidths, Side, Styles, - ScreenWidths, Token, + TokenByAddress, TokenStateByAddress, WebsitePaths, } from 'ts/types'; -import {TopBar} from 'ts/components/top_bar'; -import {Footer} from 'ts/components/footer'; -import {Loading} from 'ts/components/ui/loading'; -import {PortalMenu} from 'ts/components/portal_menu'; -import {BlockchainErrDialog} from 'ts/components/dialogs/blockchain_err_dialog'; -import BigNumber from 'bignumber.js'; -import {FlashMessage} from 'ts/components/ui/flash_message'; +import {configs} from 'ts/utils/configs'; +import {constants} from 'ts/utils/constants'; +import {utils} from 'ts/utils/utils'; const THROTTLE_TIMEOUT = 100; @@ -131,16 +131,19 @@ export class Portal extends React.Component<PortalAllProps, PortalAllState> { } public componentWillReceiveProps(nextProps: PortalAllProps) { if (nextProps.networkId !== this.state.prevNetworkId) { + // tslint:disable-next-line:no-floating-promises this.blockchain.networkIdUpdatedFireAndForgetAsync(nextProps.networkId); this.setState({ prevNetworkId: nextProps.networkId, }); } if (nextProps.userAddress !== this.state.prevUserAddress) { + // tslint:disable-next-line:no-floating-promises this.blockchain.userAddressUpdatedFireAndForgetAsync(nextProps.userAddress); if (!_.isEmpty(nextProps.userAddress) && nextProps.blockchainIsLoaded) { const tokens = _.values(nextProps.tokenByAddress); + // tslint:disable-next-line:no-floating-promises this.updateBalanceAndAllowanceWithLoadingScreenAsync(tokens); } this.setState({ @@ -148,6 +151,7 @@ export class Portal extends React.Component<PortalAllProps, PortalAllState> { }); } if (nextProps.nodeVersion !== this.state.prevNodeVersion) { + // tslint:disable-next-line:no-floating-promises this.blockchain.nodeVersionUpdatedFireAndForgetAsync(nextProps.nodeVersion); } } diff --git a/packages/website/ts/components/portal_menu.tsx b/packages/website/ts/components/portal_menu.tsx index 3b3641729..869df3e71 100644 --- a/packages/website/ts/components/portal_menu.tsx +++ b/packages/website/ts/components/portal_menu.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {MenuItem} from 'ts/components/ui/menu_item'; import {Link} from 'react-router-dom'; +import {MenuItem} from 'ts/components/ui/menu_item'; import {WebsitePaths} from 'ts/types'; export interface PortalMenuProps { diff --git a/packages/website/ts/components/send_button.tsx b/packages/website/ts/components/send_button.tsx index 274ba96a7..da8dd2a9b 100644 --- a/packages/website/ts/components/send_button.tsx +++ b/packages/website/ts/components/send_button.tsx @@ -1,15 +1,15 @@ -import * as _ from 'lodash'; import {ZeroEx} from '0x.js'; -import * as React from 'react'; import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; import RaisedButton from 'material-ui/RaisedButton'; -import {BlockchainCallErrs, Token, TokenState} from 'ts/types'; +import * as React from 'react'; +import {Blockchain} from 'ts/blockchain'; import {SendDialog} from 'ts/components/dialogs/send_dialog'; -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; import {Dispatcher} from 'ts/redux/dispatcher'; +import {BlockchainCallErrs, Token, TokenState} from 'ts/types'; +import {constants} from 'ts/utils/constants'; import {errorReporter} from 'ts/utils/error_reporter'; -import {Blockchain} from 'ts/blockchain'; +import {utils} from 'ts/utils/utils'; interface SendButtonProps { token: Token; diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index 2d533a9f2..ae5ef9222 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -1,53 +1,53 @@ -import * as _ from 'lodash'; -import * as React from 'react'; import {ZeroEx} from '0x.js'; +import BigNumber from 'bignumber.js'; import DharmaLoanFrame from 'dharma-loan-frame'; -import {colors} from 'material-ui/styles'; +import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import Divider from 'material-ui/Divider'; import FlatButton from 'material-ui/FlatButton'; -import RaisedButton from 'material-ui/RaisedButton'; import FloatingActionButton from 'material-ui/FloatingActionButton'; +import RaisedButton from 'material-ui/RaisedButton'; +import {colors} from 'material-ui/styles'; import ContentAdd from 'material-ui/svg-icons/content/add'; import ContentRemove from 'material-ui/svg-icons/content/remove'; import { Table, TableBody, TableHeader, - TableRow, TableHeaderColumn, + TableRow, TableRowColumn, } from 'material-ui/Table'; +import QueryString = require('query-string'); +import * as React from 'react'; import ReactTooltip = require('react-tooltip'); -import BigNumber from 'bignumber.js'; import firstBy = require('thenby'); -import QueryString = require('query-string'); +import {Blockchain} from 'ts/blockchain'; +import {EthWethConversionButton} from 'ts/components/eth_weth_conversion_button'; +import {AssetPicker} from 'ts/components/generate_order/asset_picker'; +import {AllowanceToggle} from 'ts/components/inputs/allowance_toggle'; +import {SendButton} from 'ts/components/send_button'; +import {HelpTooltip} from 'ts/components/ui/help_tooltip'; +import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; +import {TokenIcon} from 'ts/components/ui/token_icon'; +import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; import {Dispatcher} from 'ts/redux/dispatcher'; import { - TokenByAddress, - TokenStateByAddress, - Token, - BlockchainErrs, BalanceErrs, - Styles, - ScreenWidths, - EtherscanLinkSuffixes, BlockchainCallErrs, + BlockchainErrs, + EtherscanLinkSuffixes, + ScreenWidths, + Styles, + Token, + TokenByAddress, + TokenStateByAddress, TokenVisibility, } from 'ts/types'; -import {Blockchain} from 'ts/blockchain'; -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; import {configs} from 'ts/utils/configs'; -import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; -import {HelpTooltip} from 'ts/components/ui/help_tooltip'; +import {constants} from 'ts/utils/constants'; import {errorReporter} from 'ts/utils/error_reporter'; -import {AllowanceToggle} from 'ts/components/inputs/allowance_toggle'; -import {EthWethConversionButton} from 'ts/components/eth_weth_conversion_button'; -import {SendButton} from 'ts/components/send_button'; -import {AssetPicker} from 'ts/components/generate_order/asset_picker'; -import {TokenIcon} from 'ts/components/ui/token_icon'; -import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; +import {utils} from 'ts/utils/utils'; const ETHER_ICON_PATH = '/images/ether.png'; const ETHER_TOKEN_SYMBOL = 'WETH'; @@ -665,6 +665,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala isZRXSpinnerVisible: true, currentZrxBalance: zrxTokenState.balance, }); + // tslint:disable-next-line:no-floating-promises this.props.blockchain.pollTokenBalanceAsync(zrxToken); } return true; @@ -696,4 +697,4 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala isAddingToken: false, }); } -} +} // tslint:disable:max-file-line-count diff --git a/packages/website/ts/components/top_bar.tsx b/packages/website/ts/components/top_bar.tsx index 6248095b3..a84f1324d 100644 --- a/packages/website/ts/components/top_bar.tsx +++ b/packages/website/ts/components/top_bar.tsx @@ -1,25 +1,25 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import { - Link as ScrollLink, - animateScroll, -} from 'react-scroll'; -import {Link} from 'react-router-dom'; -import {HashLink} from 'react-router-hash-link'; import AppBar from 'material-ui/AppBar'; import Drawer from 'material-ui/Drawer'; import MenuItem from 'material-ui/MenuItem'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; +import {Link} from 'react-router-dom'; +import {HashLink} from 'react-router-hash-link'; +import { + animateScroll, + Link as ScrollLink, +} from 'react-scroll'; import ReactTooltip = require('react-tooltip'); -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; -import {Identicon} from 'ts/components/ui/identicon'; -import {NestedSidebarMenu} from 'ts/pages/shared/nested_sidebar_menu'; -import {typeDocUtils} from 'ts/utils/typedoc_utils'; import {PortalMenu} from 'ts/components/portal_menu'; -import {Styles, TypeDocNode, MenuSubsectionsBySection, WebsitePaths, Docs} from 'ts/types'; import {TopBarMenuItem} from 'ts/components/top_bar_menu_item'; import {DropDownMenuItem} from 'ts/components/ui/drop_down_menu_item'; +import {Identicon} from 'ts/components/ui/identicon'; +import {NestedSidebarMenu} from 'ts/pages/shared/nested_sidebar_menu'; +import {Docs, MenuSubsectionsBySection, Styles, TypeDocNode, WebsitePaths} from 'ts/types'; +import {configs} from 'ts/utils/configs'; +import {constants} from 'ts/utils/constants'; +import {typeDocUtils} from 'ts/utils/typedoc_utils'; const CUSTOM_DARK_GRAY = '#231F20'; const SECTION_HEADER_COLOR = 'rgb(234, 234, 234)'; @@ -135,8 +135,15 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { </a>, ]; const bottomBorderStyle = this.shouldDisplayBottomBar() ? styles.bottomBar : {}; - const fullWithClassNames = isFullWidthPage ? 'pr4' : ''; + const fullWidthClasses = isFullWidthPage ? 'pr4' : ''; const logoUrl = isNightVersion ? '/images/protocol_logo_white.png' : '/images/protocol_logo_black.png'; + const menuClasses = `col col-${isFullWidthPage ? '4' : '5'} ${fullWidthClasses} lg-pr0 md-pr2 sm-hide xs-hide`; + const menuIconStyle = { + fontSize: 25, + color: isNightVersion ? 'white' : 'black', + cursor: 'pointer', + paddingTop: 16, + }; return ( <div style={{...styles.topBar, ...bottomBorderStyle, ...this.props.style}} className="pb1"> <div className={parentClassNames}> @@ -148,7 +155,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { <div className={`col col-${isFullWidthPage ? '8' : '9'} lg-hide md-hide`} /> <div className={`col col-${isFullWidthPage ? '6' : '5'} sm-hide xs-hide`} /> {!this.isViewingPortal() && - <div className={`col col-${isFullWidthPage ? '4' : '5'} ${fullWithClassNames} lg-pr0 md-pr2 sm-hide xs-hide`}> + <div + className={menuClasses} + > <div className="flex justify-between"> <DropDownMenuItem title="Developers" @@ -188,9 +197,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { <div className={`col ${isFullWidthPage ? 'col-2 pl2' : 'col-1'} md-hide lg-hide`} > - <div - style={{fontSize: 25, color: isNightVersion ? 'white' : 'black', cursor: 'pointer', paddingTop: 16}} - > + <div style={menuIconStyle}> <i className="zmdi zmdi-menu" onClick={this.onMenuButtonClick.bind(this)} diff --git a/packages/website/ts/components/track_token_confirmation.tsx b/packages/website/ts/components/track_token_confirmation.tsx index bc036eae3..b9b2ef18a 100644 --- a/packages/website/ts/components/track_token_confirmation.tsx +++ b/packages/website/ts/components/track_token_confirmation.tsx @@ -1,11 +1,11 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import {colors} from 'material-ui/styles'; -import FlatButton from 'material-ui/FlatButton'; import Dialog from 'material-ui/Dialog'; -import {utils} from 'ts/utils/utils'; +import FlatButton from 'material-ui/FlatButton'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {Party} from 'ts/components/ui/party'; import {Token, TokenByAddress} from 'ts/types'; +import {utils} from 'ts/utils/utils'; interface TrackTokenConfirmationProps { tokens: Token[]; diff --git a/packages/website/ts/components/trade_history/trade_history.tsx b/packages/website/ts/components/trade_history/trade_history.tsx index 9deaf8fd8..59f85a03d 100644 --- a/packages/website/ts/components/trade_history/trade_history.tsx +++ b/packages/website/ts/components/trade_history/trade_history.tsx @@ -1,11 +1,11 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; -import {utils} from 'ts/utils/utils'; -import {Fill, TokenByAddress} from 'ts/types'; +import Paper from 'material-ui/Paper'; +import * as React from 'react'; import {TradeHistoryItem} from 'ts/components/trade_history/trade_history_item'; import {tradeHistoryStorage} from 'ts/local_storage/trade_history_storage'; +import {Fill, TokenByAddress} from 'ts/types'; +import {utils} from 'ts/utils/utils'; const FILL_POLLING_INTERVAL = 1000; diff --git a/packages/website/ts/components/trade_history/trade_history_item.tsx b/packages/website/ts/components/trade_history/trade_history_item.tsx index 58bdf84ae..4dcceadb7 100644 --- a/packages/website/ts/components/trade_history/trade_history_item.tsx +++ b/packages/website/ts/components/trade_history/trade_history_item.tsx @@ -1,14 +1,14 @@ -import * as _ from 'lodash'; -import * as React from 'react'; +import {ZeroEx} from '0x.js'; import BigNumber from 'bignumber.js'; -import * as ReactTooltip from 'react-tooltip'; -import * as moment from 'moment'; +import * as _ from 'lodash'; import Paper from 'material-ui/Paper'; import {colors} from 'material-ui/styles'; -import {ZeroEx} from '0x.js'; -import {TokenByAddress, Fill, Token, EtherscanLinkSuffixes} from 'ts/types'; -import {Party} from 'ts/components/ui/party'; +import * as moment from 'moment'; +import * as React from 'react'; +import * as ReactTooltip from 'react-tooltip'; import {EtherScanIcon} from 'ts/components/ui/etherscan_icon'; +import {Party} from 'ts/components/ui/party'; +import {EtherscanLinkSuffixes, Fill, Token, TokenByAddress} from 'ts/types'; const PRECISION = 5; const IDENTICON_DIAMETER = 40; diff --git a/packages/website/ts/components/ui/alert.tsx b/packages/website/ts/components/ui/alert.tsx index bf2f0baf5..71d2388f2 100644 --- a/packages/website/ts/components/ui/alert.tsx +++ b/packages/website/ts/components/ui/alert.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {AlertTypes} from 'ts/types'; const CUSTOM_GREEN = 'rgb(137, 199, 116)'; diff --git a/packages/website/ts/components/ui/badge.tsx b/packages/website/ts/components/ui/badge.tsx index 1e3bbdb99..15d5ea227 100644 --- a/packages/website/ts/components/ui/badge.tsx +++ b/packages/website/ts/components/ui/badge.tsx @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {Styles} from 'ts/types'; const styles: Styles = { diff --git a/packages/website/ts/components/ui/copy_icon.tsx b/packages/website/ts/components/ui/copy_icon.tsx index f8abaa59e..5f8e6a060 100644 --- a/packages/website/ts/components/ui/copy_icon.tsx +++ b/packages/website/ts/components/ui/copy_icon.tsx @@ -1,8 +1,8 @@ import * as _ from 'lodash'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; -import * as ReactDOM from 'react-dom'; import * as CopyToClipboard from 'react-copy-to-clipboard'; -import {colors} from 'material-ui/styles'; +import * as ReactDOM from 'react-dom'; import ReactTooltip = require('react-tooltip'); interface CopyIconProps { diff --git a/packages/website/ts/components/ui/drop_down_menu_item.tsx b/packages/website/ts/components/ui/drop_down_menu_item.tsx index b8b7eb167..05b88f7ce 100644 --- a/packages/website/ts/components/ui/drop_down_menu_item.tsx +++ b/packages/website/ts/components/ui/drop_down_menu_item.tsx @@ -1,12 +1,12 @@ import * as _ from 'lodash'; +import Menu from 'material-ui/Menu'; +import MenuItem from 'material-ui/MenuItem'; +import Popover from 'material-ui/Popover'; import * as React from 'react'; +import {Link} from 'react-router-dom'; import { Link as ScrollLink, } from 'react-scroll'; -import {Link} from 'react-router-dom'; -import Popover from 'material-ui/Popover'; -import Menu from 'material-ui/Menu'; -import MenuItem from 'material-ui/MenuItem'; import {Styles, WebsitePaths} from 'ts/types'; const CHECK_CLOSE_POPOVER_INTERVAL_MS = 300; diff --git a/packages/website/ts/components/ui/ethereum_address.tsx b/packages/website/ts/components/ui/ethereum_address.tsx index c3d03b78c..b3bc0bc59 100644 --- a/packages/website/ts/components/ui/ethereum_address.tsx +++ b/packages/website/ts/components/ui/ethereum_address.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import {EtherScanIcon} from 'ts/components/ui/etherscan_icon'; import ReactTooltip = require('react-tooltip'); +import {EtherScanIcon} from 'ts/components/ui/etherscan_icon'; import {EtherscanLinkSuffixes} from 'ts/types'; import {utils} from 'ts/utils/utils'; diff --git a/packages/website/ts/components/ui/etherscan_icon.tsx b/packages/website/ts/components/ui/etherscan_icon.tsx index 12044f44b..9b4d172f1 100644 --- a/packages/website/ts/components/ui/etherscan_icon.tsx +++ b/packages/website/ts/components/ui/etherscan_icon.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import ReactTooltip = require('react-tooltip'); -import {colors} from 'material-ui/styles'; import {EtherscanLinkSuffixes} from 'ts/types'; import {utils} from 'ts/utils/utils'; diff --git a/packages/website/ts/components/ui/fake_text_field.tsx b/packages/website/ts/components/ui/fake_text_field.tsx index 372785c2f..90bc47f01 100644 --- a/packages/website/ts/components/ui/fake_text_field.tsx +++ b/packages/website/ts/components/ui/fake_text_field.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {InputLabel} from 'ts/components/ui/input_label'; import {Styles} from 'ts/types'; diff --git a/packages/website/ts/components/ui/flash_message.tsx b/packages/website/ts/components/ui/flash_message.tsx index 684aeef68..ab4edbbb0 100644 --- a/packages/website/ts/components/ui/flash_message.tsx +++ b/packages/website/ts/components/ui/flash_message.tsx @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import * as React from 'react'; import Snackbar from 'material-ui/Snackbar'; +import * as React from 'react'; import {Dispatcher} from 'ts/redux/dispatcher'; const SHOW_DURATION_MS = 4000; diff --git a/packages/website/ts/components/ui/identicon.tsx b/packages/website/ts/components/ui/identicon.tsx index 814548fb4..a741ae43b 100644 --- a/packages/website/ts/components/ui/identicon.tsx +++ b/packages/website/ts/components/ui/identicon.tsx @@ -1,7 +1,7 @@ +import blockies = require('blockies'); import * as _ from 'lodash'; import * as React from 'react'; import {constants} from 'ts/utils/constants'; -import blockies = require('blockies'); interface IdenticonProps { address: string; diff --git a/packages/website/ts/components/ui/input_label.tsx b/packages/website/ts/components/ui/input_label.tsx index 5866c70b6..852097519 100644 --- a/packages/website/ts/components/ui/input_label.tsx +++ b/packages/website/ts/components/ui/input_label.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; export interface InputLabelProps { text: string | Element | React.ReactNode; diff --git a/packages/website/ts/components/ui/labeled_switcher.tsx b/packages/website/ts/components/ui/labeled_switcher.tsx index 3ed8ba0a4..80a8fbe94 100644 --- a/packages/website/ts/components/ui/labeled_switcher.tsx +++ b/packages/website/ts/components/ui/labeled_switcher.tsx @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; const CUSTOM_BLUE = '#63A6F1'; @@ -61,12 +61,9 @@ export class LabeledSwitcher extends React.Component<LabeledSwitcherProps, Label this.setState({ isLeftSelected: isLeft, }); - let didSucceed; - if (isLeft) { - didSucceed = await this.props.onLeftLabelClickAsync(); - } else { - didSucceed = await this.props.onRightLabelClickAsync(); - } + const didSucceed = isLeft ? + await this.props.onLeftLabelClickAsync() : + await this.props.onRightLabelClickAsync(); if (!didSucceed) { this.setState({ isLeftSelected: !isLeft, diff --git a/packages/website/ts/components/ui/lifecycle_raised_button.tsx b/packages/website/ts/components/ui/lifecycle_raised_button.tsx index e93c80ba4..630f71545 100644 --- a/packages/website/ts/components/ui/lifecycle_raised_button.tsx +++ b/packages/website/ts/components/ui/lifecycle_raised_button.tsx @@ -1,9 +1,9 @@ import * as _ from 'lodash'; +import RaisedButton from 'material-ui/RaisedButton'; import * as React from 'react'; -import {utils} from 'ts/utils/utils'; -import {Token} from 'ts/types'; import {Blockchain} from 'ts/blockchain'; -import RaisedButton from 'material-ui/RaisedButton'; +import {Token} from 'ts/types'; +import {utils} from 'ts/utils/utils'; const COMPLETE_STATE_SHOW_LENGTH_MS = 2000; @@ -11,7 +11,7 @@ enum ButtonState { READY, LOADING, COMPLETE, -}; +} interface LifeCycleRaisedButtonProps { isHidden?: boolean; @@ -49,7 +49,7 @@ export class LifeCycleRaisedButton extends this.didUnmount = true; } public render() { - if (this.props.isHidden === true) { + if (this.props.isHidden) { return <span />; } @@ -83,7 +83,7 @@ export class LifeCycleRaisedButton extends this.setState({ buttonState: ButtonState.LOADING, }); - const didSucceed = await this.props.onClickAsyncFn(); + const didSucceed = this.props.onClickAsyncFn(); if (this.didUnmount) { return; // noop since unmount called before async callback returned. } diff --git a/packages/website/ts/components/ui/loading.tsx b/packages/website/ts/components/ui/loading.tsx index 39c119d8f..83636b5ff 100644 --- a/packages/website/ts/components/ui/loading.tsx +++ b/packages/website/ts/components/ui/loading.tsx @@ -1,9 +1,9 @@ import * as _ from 'lodash'; -import * as React from 'react'; import Paper from 'material-ui/Paper'; -import {utils} from 'ts/utils/utils'; +import * as React from 'react'; import {DefaultPlayer as Video} from 'react-html5video'; import 'react-html5video/dist/styles.css'; +import {utils} from 'ts/utils/utils'; interface LoadingProps {} diff --git a/packages/website/ts/components/ui/menu_item.tsx b/packages/website/ts/components/ui/menu_item.tsx index b9caa91fb..862f28457 100644 --- a/packages/website/ts/components/ui/menu_item.tsx +++ b/packages/website/ts/components/ui/menu_item.tsx @@ -1,9 +1,9 @@ import * as _ from 'lodash'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import {Link} from 'react-router-dom'; import {Styles} from 'ts/types'; import {constants} from 'ts/utils/constants'; -import {colors} from 'material-ui/styles'; interface MenuItemProps { to: string; diff --git a/packages/website/ts/components/ui/party.tsx b/packages/website/ts/components/ui/party.tsx index b72e75181..2927d9d3d 100644 --- a/packages/website/ts/components/ui/party.tsx +++ b/packages/website/ts/components/ui/party.tsx @@ -1,11 +1,11 @@ import * as _ from 'lodash'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import ReactTooltip = require('react-tooltip'); -import {colors} from 'material-ui/styles'; +import {EthereumAddress} from 'ts/components/ui/ethereum_address'; import {Identicon} from 'ts/components/ui/identicon'; import {EtherscanLinkSuffixes} from 'ts/types'; import {utils} from 'ts/utils/utils'; -import {EthereumAddress} from 'ts/components/ui/ethereum_address'; const MIN_ADDRESS_WIDTH = 60; const IMAGE_DIMENSION = 100; diff --git a/packages/website/ts/components/ui/required_label.tsx b/packages/website/ts/components/ui/required_label.tsx index f9c73157a..db69d7278 100644 --- a/packages/website/ts/components/ui/required_label.tsx +++ b/packages/website/ts/components/ui/required_label.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; export interface RequiredLabelProps { label: string|React.ReactNode; diff --git a/packages/website/ts/components/ui/simple_loading.tsx b/packages/website/ts/components/ui/simple_loading.tsx index 12d09ecc4..d55d7851d 100644 --- a/packages/website/ts/components/ui/simple_loading.tsx +++ b/packages/website/ts/components/ui/simple_loading.tsx @@ -1,6 +1,6 @@ -import * as React from 'react'; -import {colors} from 'material-ui/styles'; import CircularProgress from 'material-ui/CircularProgress'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; export interface SimpleLoadingProps { message: string; diff --git a/packages/website/ts/components/ui/swap_icon.tsx b/packages/website/ts/components/ui/swap_icon.tsx index 89bb33d55..2e6ae89bb 100644 --- a/packages/website/ts/components/ui/swap_icon.tsx +++ b/packages/website/ts/components/ui/swap_icon.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import {constants} from 'ts/utils/constants'; -import {colors} from 'material-ui/styles'; interface SwapIconProps { swapTokensFn: () => void; diff --git a/packages/website/ts/components/ui/token_icon.tsx b/packages/website/ts/components/ui/token_icon.tsx index 168c09bd4..d3a7c9a8c 100644 --- a/packages/website/ts/components/ui/token_icon.tsx +++ b/packages/website/ts/components/ui/token_icon.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {Token} from 'ts/types'; import {Identicon} from 'ts/components/ui/identicon'; +import {Token} from 'ts/types'; interface TokenIconProps { token: Token; diff --git a/packages/website/ts/components/visual_order.tsx b/packages/website/ts/components/visual_order.tsx index a7d6d1a9e..037a321ff 100644 --- a/packages/website/ts/components/visual_order.tsx +++ b/packages/website/ts/components/visual_order.tsx @@ -1,10 +1,10 @@ +import {ZeroEx} from '0x.js'; import * as _ from 'lodash'; import * as React from 'react'; -import {ZeroEx} from '0x.js'; -import {AssetToken, Token, TokenByAddress} from 'ts/types'; -import {utils} from 'ts/utils/utils'; import {Party} from 'ts/components/ui/party'; +import {AssetToken, Token, TokenByAddress} from 'ts/types'; import {constants} from 'ts/utils/constants'; +import {utils} from 'ts/utils/utils'; const PRECISION = 5; diff --git a/packages/website/ts/containers/generate_order_form.tsx b/packages/website/ts/containers/generate_order_form.tsx index 97b5172e7..864d2702e 100644 --- a/packages/website/ts/containers/generate_order_form.tsx +++ b/packages/website/ts/containers/generate_order_form.tsx @@ -1,20 +1,20 @@ +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as React from 'react'; import {connect} from 'react-redux'; -import {Store as ReduxStore, Dispatch} from 'redux'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {State} from 'ts/redux/reducer'; +import {Dispatch, Store as ReduxStore} from 'redux'; import {Blockchain} from 'ts/blockchain'; import {GenerateOrderForm as GenerateOrderFormComponent} from 'ts/components/generate_order/generate_order_form'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {State} from 'ts/redux/reducer'; import { + BlockchainErrs, + HashData, SideToAssetToken, SignatureData, - HashData, TokenByAddress, TokenStateByAddress, - BlockchainErrs, } from 'ts/types'; -import BigNumber from 'bignumber.js'; interface GenerateOrderFormProps { blockchain: Blockchain; diff --git a/packages/website/ts/containers/portal.tsx b/packages/website/ts/containers/portal.tsx index 805058aa3..2987764f4 100644 --- a/packages/website/ts/containers/portal.tsx +++ b/packages/website/ts/containers/portal.tsx @@ -1,26 +1,26 @@ +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as React from 'react'; import {connect} from 'react-redux'; -import {Store as ReduxStore, Dispatch} from 'redux'; -import {State} from 'ts/redux/reducer'; -import {constants} from 'ts/utils/constants'; +import {Dispatch, Store as ReduxStore} from 'redux'; +import { + Portal as PortalComponent, + PortalAllProps as PortalComponentAllProps, + PortalPassedProps as PortalComponentPassedProps, +} from 'ts/components/portal'; import {Dispatcher} from 'ts/redux/dispatcher'; +import {State} from 'ts/redux/reducer'; import { - Side, - HashData, - TokenByAddress, BlockchainErrs, Fill, + HashData, Order, ScreenWidths, + Side, + TokenByAddress, TokenStateByAddress, } from 'ts/types'; -import { - Portal as PortalComponent, - PortalAllProps as PortalComponentAllProps, - PortalPassedProps as PortalComponentPassedProps, -} from 'ts/components/portal'; -import BigNumber from 'bignumber.js'; +import {constants} from 'ts/utils/constants'; interface MapStateToProps { blockchainErr: BlockchainErrs; diff --git a/packages/website/ts/containers/smart_contracts_documentation.tsx b/packages/website/ts/containers/smart_contracts_documentation.tsx index 5d05bdd2f..ccf3c4a65 100644 --- a/packages/website/ts/containers/smart_contracts_documentation.tsx +++ b/packages/website/ts/containers/smart_contracts_documentation.tsx @@ -1,13 +1,13 @@ import * as _ from 'lodash'; import * as React from 'react'; import {connect} from 'react-redux'; -import {Store as ReduxStore, Dispatch} from 'redux'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {State} from 'ts/redux/reducer'; +import {Dispatch, Store as ReduxStore} from 'redux'; import { SmartContractsDocumentation as SmartContractsDocumentationComponent, SmartContractsDocumentationAllProps, } from 'ts/pages/documentation/smart_contracts_documentation'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {State} from 'ts/redux/reducer'; interface ConnectedState { docsVersion: string; diff --git a/packages/website/ts/containers/zero_ex_js_documentation.tsx b/packages/website/ts/containers/zero_ex_js_documentation.tsx index a5b8298b5..ecf0451c0 100644 --- a/packages/website/ts/containers/zero_ex_js_documentation.tsx +++ b/packages/website/ts/containers/zero_ex_js_documentation.tsx @@ -1,15 +1,15 @@ +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as React from 'react'; import {connect} from 'react-redux'; -import {Store as ReduxStore, Dispatch} from 'redux'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import {State} from 'ts/redux/reducer'; +import {Dispatch, Store as ReduxStore} from 'redux'; import {Blockchain} from 'ts/blockchain'; import { ZeroExJSDocumentation as ZeroExJSDocumentationComponent, ZeroExJSDocumentationAllProps, } from 'ts/pages/documentation/zero_ex_js_documentation'; -import BigNumber from 'bignumber.js'; +import {Dispatcher} from 'ts/redux/dispatcher'; +import {State} from 'ts/redux/reducer'; interface ConnectedState { docsVersion: string; diff --git a/packages/website/ts/globals.d.ts b/packages/website/ts/globals.d.ts index ee449ecfd..c5b94dc45 100644 --- a/packages/website/ts/globals.d.ts +++ b/packages/website/ts/globals.d.ts @@ -132,6 +132,8 @@ declare class Subprovider {} declare module 'web3-provider-engine/subproviders/subprovider' { export = Subprovider; } + +// tslint:disable-next-line:max-classes-per-file declare class RpcSubprovider { constructor(options: {rpcUrl: string}); public handleRequest(payload: any, next: any, end: (err?: Error, data?: any) => void): void; @@ -139,6 +141,7 @@ declare class RpcSubprovider { declare module 'web3-provider-engine/subproviders/rpc' { export = RpcSubprovider; } +// tslint:disable-next-line:max-classes-per-file declare class HookedWalletSubprovider { constructor(wallet: any); } @@ -148,7 +151,9 @@ declare module 'web3-provider-engine/subproviders/hooked-wallet' { declare interface Artifact { abi: any; - networks: {[networkId: number]: { - address: string; - }}; + networks: { + [networkId: number]: { + address: string; + }; + }; } diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index ed4d09956..67a4e0067 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -1,24 +1,24 @@ // Polyfills import 'whatwg-fetch'; +import BigNumber from 'bignumber.js'; +import {colors, getMuiTheme, MuiThemeProvider} from 'material-ui/styles'; import * as React from 'react'; import {render} from 'react-dom'; import {Provider} from 'react-redux'; +import {BrowserRouter as Router, Link, Redirect, Route, Switch} from 'react-router-dom'; +import * as injectTapEventPlugin from 'react-tap-event-plugin'; import {createStore, Store as ReduxStore} from 'redux'; -import BigNumber from 'bignumber.js'; -import {constants} from 'ts/utils/constants'; -import {Landing} from 'ts/pages/landing/landing'; -import {FAQ} from 'ts/pages/faq/faq'; -import {About} from 'ts/pages/about/about'; -import {Wiki} from 'ts/pages/wiki/wiki'; -import {NotFound} from 'ts/pages/not_found'; import {createLazyComponent} from 'ts/lazy_component'; -import {State, reducer} from 'ts/redux/reducer'; -import {colors, getMuiTheme, MuiThemeProvider} from 'material-ui/styles'; -import {Switch, BrowserRouter as Router, Route, Link, Redirect} from 'react-router-dom'; import {tradeHistoryStorage} from 'ts/local_storage/trade_history_storage'; -import * as injectTapEventPlugin from 'react-tap-event-plugin'; +import {About} from 'ts/pages/about/about'; +import {FAQ} from 'ts/pages/faq/faq'; +import {Landing} from 'ts/pages/landing/landing'; +import {NotFound} from 'ts/pages/not_found'; +import {Wiki} from 'ts/pages/wiki/wiki'; +import {reducer, State} from 'ts/redux/reducer'; import {WebsitePaths} from 'ts/types'; +import {constants} from 'ts/utils/constants'; injectTapEventPlugin(); // By default BigNumber's `toString` method converts to exponential notation if the value has @@ -75,15 +75,17 @@ const muiTheme = getMuiTheme({ // At the same time webpack statically parses for System.import() to determine bundle chunk split points // so each lazy import needs it's own `System.import()` declaration. const LazyPortal = createLazyComponent( - 'Portal', () => System.import<any>(/* webpackChunkName: "portal" */'ts/containers/portal'), + 'Portal', async () => System.import<any>(/* webpackChunkName: "portal" */'ts/containers/portal'), ); const LazyZeroExJSDocumentation = createLazyComponent( 'ZeroExJSDocumentation', - () => System.import<any>(/* webpackChunkName: "zeroExDocs" */'ts/containers/zero_ex_js_documentation'), + async () => System.import<any>(/* webpackChunkName: "zeroExDocs" */'ts/containers/zero_ex_js_documentation'), ); const LazySmartContractsDocumentation = createLazyComponent( 'SmartContractsDocumentation', - () => System.import<any>(/* webpackChunkName: "smartContractDocs" */'ts/containers/smart_contracts_documentation'), + async () => System.import<any>( + /* webpackChunkName: "smartContractDocs" */'ts/containers/smart_contracts_documentation', + ), ); const store: ReduxStore<State> = createStore(reducer); diff --git a/packages/website/ts/lazy_component.tsx b/packages/website/ts/lazy_component.tsx index 7052b7be6..1dfe4db95 100644 --- a/packages/website/ts/lazy_component.tsx +++ b/packages/website/ts/lazy_component.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import * as _ from 'lodash'; +import * as React from 'react'; interface LazyComponentProps { reactComponentPromise: Promise<React.ComponentClass<any>>; @@ -22,10 +22,12 @@ export class LazyComponent extends React.Component<LazyComponentProps, LazyCompo }; } public componentWillMount() { + // tslint:disable-next-line:no-floating-promises this.loadComponentFireAndForgetAsync(this.props); } public componentWillReceiveProps(nextProps: LazyComponentProps) { if (nextProps.reactComponentPromise !== this.props.reactComponentPromise) { + // tslint:disable-next-line:no-floating-promises this.loadComponentFireAndForgetAsync(nextProps); } } diff --git a/packages/website/ts/local_storage/tracked_token_storage.ts b/packages/website/ts/local_storage/tracked_token_storage.ts index 0b54a66e0..051a78ae1 100644 --- a/packages/website/ts/local_storage/tracked_token_storage.ts +++ b/packages/website/ts/local_storage/tracked_token_storage.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import {Token, TrackedTokensByNetworkId} from 'ts/types'; import {localStorage} from 'ts/local_storage/local_storage'; +import {Token, TrackedTokensByNetworkId} from 'ts/types'; const TRACKED_TOKENS_KEY = 'trackedTokens'; diff --git a/packages/website/ts/local_storage/trade_history_storage.tsx b/packages/website/ts/local_storage/trade_history_storage.tsx index dd5872609..0d627e000 100644 --- a/packages/website/ts/local_storage/trade_history_storage.tsx +++ b/packages/website/ts/local_storage/trade_history_storage.tsx @@ -1,10 +1,10 @@ +import BigNumber from 'bignumber.js'; +import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; +import {localStorage} from 'ts/local_storage/local_storage'; import {Fill} from 'ts/types'; import {configs} from 'ts/utils/configs'; import {constants} from 'ts/utils/constants'; -import {localStorage} from 'ts/local_storage/local_storage'; -import ethUtil = require('ethereumjs-util'); -import BigNumber from 'bignumber.js'; const FILLS_KEY = 'fills'; const FILLS_LATEST_BLOCK = 'fillsLatestBlock'; diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx index 8859fb00a..3af05e8a4 100644 --- a/packages/website/ts/pages/about/about.tsx +++ b/packages/website/ts/pages/about/about.tsx @@ -1,17 +1,17 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import * as DocumentTitle from 'react-document-title'; import RaisedButton from 'material-ui/RaisedButton'; import {colors} from 'material-ui/styles'; -import {Styles, ProfileInfo} from 'ts/types'; -import {utils} from 'ts/utils/utils'; +import * as React from 'react'; +import * as DocumentTitle from 'react-document-title'; import {Link} from 'react-router-dom'; import {Footer} from 'ts/components/footer'; import {TopBar} from 'ts/components/top_bar'; +import {Profile} from 'ts/pages/about/profile'; import {Question} from 'ts/pages/faq/question'; +import {ProfileInfo, Styles} from 'ts/types'; import {configs} from 'ts/utils/configs'; import {constants} from 'ts/utils/constants'; -import {Profile} from 'ts/pages/about/profile'; +import {utils} from 'ts/utils/utils'; const CUSTOM_BACKGROUND_COLOR = '#F0F0F0'; const CUSTOM_GRAY = '#4C4C4C'; diff --git a/packages/website/ts/pages/about/profile.tsx b/packages/website/ts/pages/about/profile.tsx index 6c48a8553..71dbd09b5 100644 --- a/packages/website/ts/pages/about/profile.tsx +++ b/packages/website/ts/pages/about/profile.tsx @@ -1,9 +1,9 @@ import * as _ from 'lodash'; -import * as React from 'react'; import {colors} from 'material-ui/styles'; -import {utils} from 'ts/utils/utils'; +import * as React from 'react'; import {Element as ScrollElement} from 'react-scroll'; -import {Styles, ProfileInfo} from 'ts/types'; +import {ProfileInfo, Styles} from 'ts/types'; +import {utils} from 'ts/utils/utils'; const IMAGE_DIMENSION = 149; const styles: Styles = { diff --git a/packages/website/ts/pages/documentation/custom_enum.tsx b/packages/website/ts/pages/documentation/custom_enum.tsx index aca8af832..7dced9b60 100644 --- a/packages/website/ts/pages/documentation/custom_enum.tsx +++ b/packages/website/ts/pages/documentation/custom_enum.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {utils} from 'ts/utils/utils'; import {CustomType} from 'ts/types'; +import {utils} from 'ts/utils/utils'; const STRING_ENUM_CODE_PREFIX = ' strEnum('; diff --git a/packages/website/ts/pages/documentation/enum.tsx b/packages/website/ts/pages/documentation/enum.tsx index 9364a5d31..8fcd2c252 100644 --- a/packages/website/ts/pages/documentation/enum.tsx +++ b/packages/website/ts/pages/documentation/enum.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import * as React from 'react'; +import {EnumValue, TypeDocNode} from 'ts/types'; import {utils} from 'ts/utils/utils'; -import {TypeDocNode, EnumValue} from 'ts/types'; const STRING_ENUM_CODE_PREFIX = ' strEnum('; diff --git a/packages/website/ts/pages/documentation/event_definition.tsx b/packages/website/ts/pages/documentation/event_definition.tsx index 58271e98f..ea75d78bc 100644 --- a/packages/website/ts/pages/documentation/event_definition.tsx +++ b/packages/website/ts/pages/documentation/event_definition.tsx @@ -1,10 +1,10 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; -import {Event, EventArg, HeaderSizes} from 'ts/types'; import {Type} from 'ts/pages/documentation/type'; import {AnchorTitle} from 'ts/pages/shared/anchor_title'; +import {Event, EventArg, HeaderSizes} from 'ts/types'; +import {constants} from 'ts/utils/constants'; +import {utils} from 'ts/utils/utils'; const KEYWORD_COLOR = '#a81ca6'; const CUSTOM_GREEN = 'rgb(77, 162, 75)'; diff --git a/packages/website/ts/pages/documentation/interface.tsx b/packages/website/ts/pages/documentation/interface.tsx index 9e40b8901..d8d4aec32 100644 --- a/packages/website/ts/pages/documentation/interface.tsx +++ b/packages/website/ts/pages/documentation/interface.tsx @@ -1,8 +1,8 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {CustomType, TypeDocTypes} from 'ts/types'; -import {Type} from 'ts/pages/documentation/type'; import {MethodSignature} from 'ts/pages/documentation/method_signature'; +import {Type} from 'ts/pages/documentation/type'; +import {CustomType, TypeDocTypes} from 'ts/types'; interface InterfaceProps { type: CustomType; diff --git a/packages/website/ts/pages/documentation/method_block.tsx b/packages/website/ts/pages/documentation/method_block.tsx index e31c75ffd..026c46918 100644 --- a/packages/website/ts/pages/documentation/method_block.tsx +++ b/packages/website/ts/pages/documentation/method_block.tsx @@ -1,23 +1,23 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import * as ReactMarkdown from 'react-markdown'; import {Chip} from 'material-ui/Chip'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; +import * as ReactMarkdown from 'react-markdown'; +import {Comment} from 'ts/pages/documentation/comment'; +import {MethodSignature} from 'ts/pages/documentation/method_signature'; +import {SourceLink} from 'ts/pages/documentation/source_link'; +import {AnchorTitle} from 'ts/pages/shared/anchor_title'; import { - TypeDocNode, + HeaderSizes, + Parameter, + SolidityMethod, Styles, TypeDefinitionByName, + TypeDocNode, TypescriptMethod, - SolidityMethod, - Parameter, - HeaderSizes, } from 'ts/types'; -import {utils} from 'ts/utils/utils'; -import {SourceLink} from 'ts/pages/documentation/source_link'; -import {MethodSignature} from 'ts/pages/documentation/method_signature'; -import {AnchorTitle} from 'ts/pages/shared/anchor_title'; -import {Comment} from 'ts/pages/documentation/comment'; import {typeDocUtils} from 'ts/utils/typedoc_utils'; +import {utils} from 'ts/utils/utils'; interface MethodBlockProps { method: SolidityMethod|TypescriptMethod; diff --git a/packages/website/ts/pages/documentation/method_signature.tsx b/packages/website/ts/pages/documentation/method_signature.tsx index 3b5d2ce78..e3806b2fa 100644 --- a/packages/website/ts/pages/documentation/method_signature.tsx +++ b/packages/website/ts/pages/documentation/method_signature.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {TypescriptMethod, SolidityMethod, TypeDefinitionByName, Parameter} from 'ts/types'; import {Type} from 'ts/pages/documentation/type'; +import {Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod} from 'ts/types'; interface MethodSignatureProps { method: TypescriptMethod|SolidityMethod; diff --git a/packages/website/ts/pages/documentation/smart_contracts_documentation.tsx b/packages/website/ts/pages/documentation/smart_contracts_documentation.tsx index 3e97829c4..0d5751ffb 100644 --- a/packages/website/ts/pages/documentation/smart_contracts_documentation.tsx +++ b/packages/website/ts/pages/documentation/smart_contracts_documentation.tsx @@ -1,46 +1,46 @@ +import findVersions = require('find-versions'); import * as _ from 'lodash'; +import CircularProgress from 'material-ui/CircularProgress'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import DocumentTitle = require('react-document-title'); -import findVersions = require('find-versions'); -import semverSort = require('semver-sort'); -import {colors} from 'material-ui/styles'; -import CircularProgress from 'material-ui/CircularProgress'; import { scroller, } from 'react-scroll'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import { - SmartContractsDocSections, - Styles, - DoxityDocObj, - TypeDefinitionByName, - DocAgnosticFormat, - SolidityMethod, - Property, - CustomType, - MenuSubsectionsBySection, - Event, - Docs, - AddressByContractName, - Networks, - EtherscanLinkSuffixes, -} from 'ts/types'; +import semverSort = require('semver-sort'); import {TopBar} from 'ts/components/top_bar'; -import {utils} from 'ts/utils/utils'; -import {docUtils} from 'ts/utils/doc_utils'; -import {constants} from 'ts/utils/constants'; +import {Badge} from 'ts/components/ui/badge'; +import {Comment} from 'ts/pages/documentation/comment'; +import {EventDefinition} from 'ts/pages/documentation/event_definition'; import {MethodBlock} from 'ts/pages/documentation/method_block'; import {SourceLink} from 'ts/pages/documentation/source_link'; import {Type} from 'ts/pages/documentation/type'; import {TypeDefinition} from 'ts/pages/documentation/type_definition'; -import {MarkdownSection} from 'ts/pages/shared/markdown_section'; -import {Comment} from 'ts/pages/documentation/comment'; -import {Badge} from 'ts/components/ui/badge'; -import {EventDefinition} from 'ts/pages/documentation/event_definition'; import {AnchorTitle} from 'ts/pages/shared/anchor_title'; -import {SectionHeader} from 'ts/pages/shared/section_header'; +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 {Dispatcher} from 'ts/redux/dispatcher'; +import { + AddressByContractName, + CustomType, + DocAgnosticFormat, + Docs, + DoxityDocObj, + EtherscanLinkSuffixes, + Event, + MenuSubsectionsBySection, + Networks, + Property, + SmartContractsDocSections, + SolidityMethod, + Styles, + TypeDefinitionByName, +} from 'ts/types'; +import {constants} from 'ts/utils/constants'; +import {docUtils} from 'ts/utils/doc_utils'; import {doxityUtils} from 'ts/utils/doxity_utils'; +import {utils} from 'ts/utils/utils'; /* tslint:disable:no-var-requires */ const IntroMarkdown = require('md/docs/smart_contracts/introduction'); /* tslint:enable:no-var-requires */ @@ -104,6 +104,7 @@ export class SmartContractsDocumentation extends const lastSegment = pathName.substr(pathName.lastIndexOf('/') + 1); const versions = findVersions(lastSegment); const preferredVersionIfExists = versions.length > 0 ? versions[0] : undefined; + // tslint:disable-next-line:no-floating-promises this.fetchJSONDocsFireAndForgetAsync(preferredVersionIfExists); } public render() { diff --git a/packages/website/ts/pages/documentation/source_link.tsx b/packages/website/ts/pages/documentation/source_link.tsx index 24009ce8a..0d40a4b7a 100644 --- a/packages/website/ts/pages/documentation/source_link.tsx +++ b/packages/website/ts/pages/documentation/source_link.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import {colors} from 'material-ui/styles'; +import * as React from 'react'; import {Source} from 'ts/types'; import {constants} from 'ts/utils/constants'; diff --git a/packages/website/ts/pages/documentation/type.tsx b/packages/website/ts/pages/documentation/type.tsx index 7d02d6804..b7d56f360 100644 --- a/packages/website/ts/pages/documentation/type.tsx +++ b/packages/website/ts/pages/documentation/type.tsx @@ -1,13 +1,13 @@ import * as _ from 'lodash'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import {Link as ScrollLink} from 'react-scroll'; import * as ReactTooltip from 'react-tooltip'; -import {colors} from 'material-ui/styles'; -import {typeDocUtils} from 'ts/utils/typedoc_utils'; +import {TypeDefinition} from 'ts/pages/documentation/type_definition'; +import {Type as TypeDef, TypeDefinitionByName, TypeDocTypes} from 'ts/types'; import {constants} from 'ts/utils/constants'; -import {Type as TypeDef, TypeDocTypes, TypeDefinitionByName} from 'ts/types'; +import {typeDocUtils} from 'ts/utils/typedoc_utils'; import {utils} from 'ts/utils/utils'; -import {TypeDefinition} from 'ts/pages/documentation/type_definition'; const BUILT_IN_TYPE_COLOR = '#e69d00'; const STRING_LITERAL_COLOR = '#4da24b'; diff --git a/packages/website/ts/pages/documentation/type_definition.tsx b/packages/website/ts/pages/documentation/type_definition.tsx index bcb07be8e..984c223b6 100644 --- a/packages/website/ts/pages/documentation/type_definition.tsx +++ b/packages/website/ts/pages/documentation/type_definition.tsx @@ -1,16 +1,16 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; -import {KindString, CustomType, TypeDocTypes, CustomTypeChild, HeaderSizes} from 'ts/types'; -import {Type} from 'ts/pages/documentation/type'; -import {Interface} from 'ts/pages/documentation/interface'; +import {Comment} from 'ts/pages/documentation/comment'; import {CustomEnum} from 'ts/pages/documentation/custom_enum'; import {Enum} from 'ts/pages/documentation/enum'; +import {Interface} from 'ts/pages/documentation/interface'; import {MethodSignature} from 'ts/pages/documentation/method_signature'; +import {Type} from 'ts/pages/documentation/type'; import {AnchorTitle} from 'ts/pages/shared/anchor_title'; -import {Comment} from 'ts/pages/documentation/comment'; +import {CustomType, CustomTypeChild, HeaderSizes, KindString, TypeDocTypes} from 'ts/types'; +import {constants} from 'ts/utils/constants'; import {typeDocUtils} from 'ts/utils/typedoc_utils'; +import {utils} from 'ts/utils/utils'; const KEYWORD_COLOR = '#a81ca6'; diff --git a/packages/website/ts/pages/documentation/zero_ex_js_documentation.tsx b/packages/website/ts/pages/documentation/zero_ex_js_documentation.tsx index c26fb7d0a..d64b196ed 100644 --- a/packages/website/ts/pages/documentation/zero_ex_js_documentation.tsx +++ b/packages/website/ts/pages/documentation/zero_ex_js_documentation.tsx @@ -1,47 +1,47 @@ -import * as _ from 'lodash'; -import * as React from 'react'; -import * as ReactMarkdown from 'react-markdown'; -import DocumentTitle = require('react-document-title'); import findVersions = require('find-versions'); -import semverSort = require('semver-sort'); -import {colors} from 'material-ui/styles'; -import MenuItem from 'material-ui/MenuItem'; +import * as _ from 'lodash'; import CircularProgress from 'material-ui/CircularProgress'; +import MenuItem from 'material-ui/MenuItem'; import Paper from 'material-ui/Paper'; +import {colors} from 'material-ui/styles'; +import * as React from 'react'; +import DocumentTitle = require('react-document-title'); +import * as ReactMarkdown from 'react-markdown'; import { - Link as ScrollLink, Element as ScrollElement, + Link as ScrollLink, scroller, } from 'react-scroll'; -import {Dispatcher} from 'ts/redux/dispatcher'; -import { - KindString, - TypeDocNode, - ZeroExJsDocSections, - Styles, - ScreenWidths, - TypeDefinitionByName, - DocAgnosticFormat, - TypescriptMethod, - Property, - CustomType, - Docs, -} from 'ts/types'; +import semverSort = require('semver-sort'); import {TopBar} from 'ts/components/top_bar'; -import {utils} from 'ts/utils/utils'; -import {docUtils} from 'ts/utils/doc_utils'; -import {constants} from 'ts/utils/constants'; import {Loading} from 'ts/components/ui/loading'; +import {Comment} from 'ts/pages/documentation/comment'; import {MethodBlock} from 'ts/pages/documentation/method_block'; import {SourceLink} from 'ts/pages/documentation/source_link'; import {Type} from 'ts/pages/documentation/type'; import {TypeDefinition} from 'ts/pages/documentation/type_definition'; -import {MarkdownSection} from 'ts/pages/shared/markdown_section'; -import {Comment} from 'ts/pages/documentation/comment'; import {AnchorTitle} from 'ts/pages/shared/anchor_title'; -import {SectionHeader} from 'ts/pages/shared/section_header'; +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 {Dispatcher} from 'ts/redux/dispatcher'; +import { + CustomType, + DocAgnosticFormat, + Docs, + KindString, + Property, + ScreenWidths, + Styles, + TypeDefinitionByName, + TypeDocNode, + TypescriptMethod, + ZeroExJsDocSections, +} from 'ts/types'; +import {constants} from 'ts/utils/constants'; +import {docUtils} from 'ts/utils/doc_utils'; import {typeDocUtils} from 'ts/utils/typedoc_utils'; +import {utils} from 'ts/utils/utils'; /* tslint:disable:no-var-requires */ const IntroMarkdown = require('md/docs/0xjs/introduction'); const InstallationMarkdown = require('md/docs/0xjs/installation'); @@ -109,6 +109,7 @@ export class ZeroExJSDocumentation extends React.Component<ZeroExJSDocumentation const lastSegment = pathName.substr(pathName.lastIndexOf('/') + 1); const versions = findVersions(lastSegment); const preferredVersionIfExists = versions.length > 0 ? versions[0] : undefined; + // tslint:disable-next-line:no-floating-promises this.fetchJSONDocsFireAndForgetAsync(preferredVersionIfExists); } public render() { diff --git a/packages/website/ts/pages/faq/faq.tsx b/packages/website/ts/pages/faq/faq.tsx index 3c65d1042..c53ed28b8 100644 --- a/packages/website/ts/pages/faq/faq.tsx +++ b/packages/website/ts/pages/faq/faq.tsx @@ -1,13 +1,13 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import * as DocumentTitle from 'react-document-title'; import RaisedButton from 'material-ui/RaisedButton'; import {colors} from 'material-ui/styles'; -import {Styles, FAQSection, FAQQuestion, WebsitePaths} from 'ts/types'; +import * as React from 'react'; +import * as DocumentTitle from 'react-document-title'; import {Link} from 'react-router-dom'; import {Footer} from 'ts/components/footer'; import {TopBar} from 'ts/components/top_bar'; import {Question} from 'ts/pages/faq/question'; +import {FAQQuestion, FAQSection, Styles, WebsitePaths} from 'ts/types'; import {configs} from 'ts/utils/configs'; import {constants} from 'ts/utils/constants'; diff --git a/packages/website/ts/pages/faq/question.tsx b/packages/website/ts/pages/faq/question.tsx index 4ed198b91..917863e4a 100644 --- a/packages/website/ts/pages/faq/question.tsx +++ b/packages/website/ts/pages/faq/question.tsx @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import * as React from 'react'; import {Card, CardHeader, CardText} from 'material-ui/Card'; +import * as React from 'react'; export interface QuestionProps { prompt: string; diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx index 32ea86736..f3c46b8c7 100644 --- a/packages/website/ts/pages/landing/landing.tsx +++ b/packages/website/ts/pages/landing/landing.tsx @@ -1,15 +1,15 @@ import * as _ from 'lodash'; +import RaisedButton from 'material-ui/RaisedButton'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import DocumentTitle = require('react-document-title'); import {Link} from 'react-router-dom'; -import RaisedButton from 'material-ui/RaisedButton'; -import {colors} from 'material-ui/styles'; +import {Footer} from 'ts/components/footer'; +import {TopBar} from 'ts/components/top_bar'; +import {ScreenWidths, Styles, WebsitePaths} from 'ts/types'; import {configs} from 'ts/utils/configs'; import {constants} from 'ts/utils/constants'; -import {Styles, WebsitePaths, ScreenWidths} from 'ts/types'; import {utils} from 'ts/utils/utils'; -import {TopBar} from 'ts/components/top_bar'; -import {Footer} from 'ts/components/footer'; interface BoxContent { title: string; @@ -840,4 +840,4 @@ export class Landing extends React.Component<LandingProps, LandingState> { }); } } -} +} // tslint:disable:max-file-line-count diff --git a/packages/website/ts/pages/not_found.tsx b/packages/website/ts/pages/not_found.tsx index ddd720c97..075bcf91e 100644 --- a/packages/website/ts/pages/not_found.tsx +++ b/packages/website/ts/pages/not_found.tsx @@ -1,9 +1,9 @@ import * as _ from 'lodash'; import * as React from 'react'; -import {Styles} from 'ts/types'; import {Link} from 'react-router-dom'; import {Footer} from 'ts/components/footer'; import {TopBar} from 'ts/components/top_bar'; +import {Styles} from 'ts/types'; export interface NotFoundProps { location: Location; diff --git a/packages/website/ts/pages/shared/anchor_title.tsx b/packages/website/ts/pages/shared/anchor_title.tsx index dfa9401ae..0a3674fd9 100644 --- a/packages/website/ts/pages/shared/anchor_title.tsx +++ b/packages/website/ts/pages/shared/anchor_title.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; -import {Styles, HeaderSizes} from 'ts/types'; -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; import {Link as ScrollLink} from 'react-scroll'; +import {HeaderSizes, Styles} from 'ts/types'; +import {constants} from 'ts/utils/constants'; +import {utils} from 'ts/utils/utils'; const headerSizeToScrollOffset: {[headerSize: string]: number} = { h2: -20, @@ -59,11 +59,7 @@ export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleSt public render() { let opacity = 0; if (this.props.shouldShowAnchor) { - if (this.state.isHovering) { - opacity = 0.6; - } else { - opacity = 1; - } + opacity = this.state.isHovering ? 0.6 : 1; } return ( <div className="relative flex" style={{...styles[this.props.headerSize], ...styles.headers}}> diff --git a/packages/website/ts/pages/shared/markdown_section.tsx b/packages/website/ts/pages/shared/markdown_section.tsx index 32b55abc8..8686e80b6 100644 --- a/packages/website/ts/pages/shared/markdown_section.tsx +++ b/packages/website/ts/pages/shared/markdown_section.tsx @@ -1,12 +1,12 @@ import * as _ from 'lodash'; +import RaisedButton from 'material-ui/RaisedButton'; import * as React from 'react'; import * as ReactMarkdown from 'react-markdown'; import {Element as ScrollElement} from 'react-scroll'; import {AnchorTitle} from 'ts/pages/shared/anchor_title'; -import {utils} from 'ts/utils/utils'; import {MarkdownCodeBlock} from 'ts/pages/shared/markdown_code_block'; -import RaisedButton from 'material-ui/RaisedButton'; import {HeaderSizes} from 'ts/types'; +import {utils} from 'ts/utils/utils'; interface MarkdownSectionProps { sectionName: string; diff --git a/packages/website/ts/pages/shared/nested_sidebar_menu.tsx b/packages/website/ts/pages/shared/nested_sidebar_menu.tsx index e69506bb8..69e32aecb 100644 --- a/packages/website/ts/pages/shared/nested_sidebar_menu.tsx +++ b/packages/website/ts/pages/shared/nested_sidebar_menu.tsx @@ -1,13 +1,13 @@ import * as _ from 'lodash'; -import * as React from 'react'; import MenuItem from 'material-ui/MenuItem'; import {colors} from 'material-ui/styles'; -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; +import * as React from 'react'; +import {Link as ScrollLink} from 'react-scroll'; import {VersionDropDown} from 'ts/pages/shared/version_drop_down'; -import {ZeroExJsDocSections, Styles, MenuSubsectionsBySection, Docs} from 'ts/types'; +import {Docs, MenuSubsectionsBySection, Styles, ZeroExJsDocSections} from 'ts/types'; +import {constants} from 'ts/utils/constants'; import {typeDocUtils} from 'ts/utils/typedoc_utils'; -import {Link as ScrollLink} from 'react-scroll'; +import {utils} from 'ts/utils/utils'; interface NestedSidebarMenuProps { topLevelMenu: {[topLevel: string]: string[]}; diff --git a/packages/website/ts/pages/shared/section_header.tsx b/packages/website/ts/pages/shared/section_header.tsx index 5937be13b..b5119b128 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 {utils} from 'ts/utils/utils'; import {HeaderSizes} from 'ts/types'; +import {utils} from 'ts/utils/utils'; interface SectionHeaderProps { sectionName: string; diff --git a/packages/website/ts/pages/shared/version_drop_down.tsx b/packages/website/ts/pages/shared/version_drop_down.tsx index f29547c9c..8f4f1a35b 100644 --- a/packages/website/ts/pages/shared/version_drop_down.tsx +++ b/packages/website/ts/pages/shared/version_drop_down.tsx @@ -1,9 +1,9 @@ import * as _ from 'lodash'; -import * as React from 'react'; -import MenuItem from 'material-ui/MenuItem'; import DropDownMenu from 'material-ui/DropDownMenu'; -import {constants} from 'ts/utils/constants'; +import MenuItem from 'material-ui/MenuItem'; +import * as React from 'react'; import {Docs} from 'ts/types'; +import {constants} from 'ts/utils/constants'; interface VersionDropDownProps { selectedVersion: string; diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx index 0e6fc98ab..2447a24a2 100644 --- a/packages/website/ts/pages/wiki/wiki.tsx +++ b/packages/website/ts/pages/wiki/wiki.tsx @@ -1,20 +1,19 @@ import * as _ from 'lodash'; +import CircularProgress from 'material-ui/CircularProgress'; +import {colors} from 'material-ui/styles'; import * as React from 'react'; import DocumentTitle = require('react-document-title'); -import {colors} from 'material-ui/styles'; -import CircularProgress from 'material-ui/CircularProgress'; import { scroller, } from 'react-scroll'; -import {Styles, Article, ArticlesBySection} from 'ts/types'; import {TopBar} from 'ts/components/top_bar'; -import {HeaderSizes, WebsitePaths} from 'ts/types'; -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; -import {configs} from 'ts/utils/configs'; +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 {MarkdownSection} from 'ts/pages/shared/markdown_section'; +import {Article, ArticlesBySection, HeaderSizes, Styles, WebsitePaths} from 'ts/types'; +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; @@ -55,6 +54,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> { }; } public componentWillMount() { + // tslint:disable-next-line:no-floating-promises this.fetchArticlesBySectionAsync(); } public componentWillUnmount() { @@ -180,6 +180,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> { if (response.status === constants.HTTP_NO_CONTENT_STATUS_CODE) { // We need to backoff and try fetching again later this.wikiBackoffTimeoutId = window.setTimeout(() => { + // tslint:disable-next-line:no-floating-promises this.fetchArticlesBySectionAsync(); }, WIKI_NOT_READY_BACKOUT_TIMEOUT_MS); return; diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts index 566ab8a01..a0a1da21b 100644 --- a/packages/website/ts/redux/dispatcher.ts +++ b/packages/website/ts/redux/dispatcher.ts @@ -1,20 +1,20 @@ +import BigNumber from 'bignumber.js'; import {Dispatch} from 'redux'; import {State} from 'ts/redux/reducer'; import { - Direction, - Side, + ActionTypes, AssetToken, BlockchainErrs, - Token, - SignatureData, + Direction, Fill, Order, - ActionTypes, - ScreenWidths, ProviderType, + ScreenWidths, + Side, + SignatureData, + Token, TokenStateByAddress, } from 'ts/types'; -import BigNumber from 'bignumber.js'; export class Dispatcher { private dispatch: Dispatch<State>; diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index 7723597cd..da69a9d00 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -1,23 +1,23 @@ -import * as _ from 'lodash'; import {ZeroEx} from '0x.js'; import BigNumber from 'bignumber.js'; -import {utils} from 'ts/utils/utils'; +import * as _ from 'lodash'; import { + Action, + ActionTypes, + BlockchainErrs, + Direction, GenerateOrderSteps, + Order, + ProviderType, + ScreenWidths, Side, SideToAssetToken, - Direction, - BlockchainErrs, SignatureData, TokenByAddress, - TokenStateByAddress, - Order, - Action, - ActionTypes, - ScreenWidths, - ProviderType, TokenState, + TokenStateByAddress, } from 'ts/types'; +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 @@ -54,7 +54,7 @@ export interface State { flashMessage: string|React.ReactNode; providerType: ProviderType; injectedProviderName: string; -}; +} const INITIAL_STATE: State = { // Portal diff --git a/packages/website/ts/schemas/validator.ts b/packages/website/ts/schemas/validator.ts index bf6ba4044..e8eb4aaf2 100644 --- a/packages/website/ts/schemas/validator.ts +++ b/packages/website/ts/schemas/validator.ts @@ -1,8 +1,8 @@ -import {Validator, Schema as JSONSchema} from 'jsonschema'; -import {signatureDataSchema} from 'ts/schemas/signature_data_schema'; +import {Schema as JSONSchema, Validator} from 'jsonschema'; import {orderSchema} from 'ts/schemas/order_schema'; -import {tokenSchema} from 'ts/schemas/token_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/subproviders/injected_web3_subprovider.ts b/packages/website/ts/subproviders/injected_web3_subprovider.ts index b9e5af3ef..910fe3cdf 100644 --- a/packages/website/ts/subproviders/injected_web3_subprovider.ts +++ b/packages/website/ts/subproviders/injected_web3_subprovider.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import Web3 = require('web3'); import {constants} from 'ts/utils/constants'; +import Web3 = require('web3'); /* * This class implements the web3-provider-engine subprovider interface and forwards @@ -38,6 +38,7 @@ export class InjectedWeb3SubProvider { } } // Required to implement this method despite not needing it for this subprovider + // tslint:disable-next-line:prefer-function-over-method public setEngine(engine: any) { // noop } diff --git a/packages/website/ts/subproviders/ledger_wallet_subprovider_factory.ts b/packages/website/ts/subproviders/ledger_wallet_subprovider_factory.ts index df0c5a4db..bfabc90ae 100644 --- a/packages/website/ts/subproviders/ledger_wallet_subprovider_factory.ts +++ b/packages/website/ts/subproviders/ledger_wallet_subprovider_factory.ts @@ -1,11 +1,11 @@ -import * as _ from 'lodash'; -import Web3 = require('web3'); import * as EthereumTx from 'ethereumjs-tx'; import ethUtil = require('ethereumjs-util'); import * as ledger from 'ledgerco'; -import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet'); -import {constants} from 'ts/utils/constants'; +import * as _ from 'lodash'; import {LedgerEthConnection, SignPersonalMessageParams, TxParams} from 'ts/types'; +import {constants} from 'ts/utils/constants'; +import Web3 = require('web3'); +import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet'); const NUM_ADDRESSES_TO_FETCH = 10; const ASK_FOR_ON_DEVICE_CONFIRMATION = false; diff --git a/packages/website/ts/subproviders/redundant_rpc_subprovider.ts b/packages/website/ts/subproviders/redundant_rpc_subprovider.ts index a6c53ebd1..8dffd4437 100644 --- a/packages/website/ts/subproviders/redundant_rpc_subprovider.ts +++ b/packages/website/ts/subproviders/redundant_rpc_subprovider.ts @@ -1,11 +1,26 @@ +import promisify = require('es6-promisify'); import * as _ from 'lodash'; import {JSONRPCPayload} from 'ts/types'; -import promisify = require('es6-promisify'); -import Subprovider = require('web3-provider-engine/subproviders/subprovider'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); +import Subprovider = require('web3-provider-engine/subproviders/subprovider'); export class RedundantRPCSubprovider extends Subprovider { private rpcs: RpcSubprovider[]; + private static async firstSuccessAsync( + rpcs: RpcSubprovider[], payload: JSONRPCPayload, next: () => void, + ): Promise<any> { + let lastErr; + for (const rpc of rpcs) { + try { + const data = await promisify(rpc.handleRequest.bind(rpc))(payload, next); + return data; + } catch (err) { + lastErr = err; + continue; + } + } + throw Error(lastErr); + } constructor(endpoints: string[]) { super(); this.rpcs = _.map(endpoints, endpoint => { @@ -18,24 +33,11 @@ export class RedundantRPCSubprovider extends Subprovider { end: (err?: Error, data?: any) => void): Promise<void> { const rpcsCopy = this.rpcs.slice(); try { - const data = await this.firstSuccessAsync(rpcsCopy, payload, next); + const data = await RedundantRPCSubprovider.firstSuccessAsync(rpcsCopy, payload, next); end(null, data); } catch (err) { end(err); } } - private async firstSuccessAsync(rpcs: RpcSubprovider[], payload: JSONRPCPayload, next: () => void): Promise<any> { - let lastErr; - for (const rpc of rpcs) { - try { - const data = await promisify(rpc.handleRequest.bind(rpc))(payload, next); - return data; - } catch (err) { - lastErr = err; - continue; - } - } - throw Error(lastErr); - } } diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 2d0103499..403af9e78 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -1,5 +1,5 @@ -import * as _ from 'lodash'; import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; // Utility function to create a K:V from a list of strings // Adapted from: https://basarat.gitbooks.io/typescript/content/docs/types/literal-types.html @@ -16,7 +16,7 @@ export enum GenerateOrderSteps { RemainingConfigs, SignTransaction, CopyAndShare, -}; +} export const Side = strEnum([ 'receive', @@ -45,11 +45,11 @@ export interface Token { decimals: number; isTracked: boolean; isRegistered: boolean; -}; +} export interface TokenByAddress { [address: string]: Token; -}; +} export interface TokenState { allowance: BigNumber; @@ -58,7 +58,7 @@ export interface TokenState { export interface TokenStateByAddress { [address: string]: TokenState; -}; +} export interface AssetToken { address?: string; @@ -67,14 +67,14 @@ export interface AssetToken { export interface SideToAssetToken { [side: string]: AssetToken; -}; +} export interface SignatureData { hash: string; r: string; s: string; v: number; -}; +} export interface HashData { depositAmount: BigNumber; @@ -138,7 +138,7 @@ export enum BalanceErrs { wethConversionFailed, sendFailed, allowanceSettingFailed, -}; +} export const ActionTypes = strEnum([ // Portal @@ -535,7 +535,7 @@ interface LedgerSignResult { s: string; } interface LedgerCommunication { - close_async: () => void; + close_async: () => Promise<void>; } export interface LedgerEthConnection { getAddress_async: (derivationPath: string, askForDeviceConfirmation: boolean, @@ -566,7 +566,7 @@ export interface TxParams { export interface PublicNodeUrlsByNetworkId { [networkId: number]: string[]; -}; +} export interface JSONRPCPayload { params: any[]; @@ -689,4 +689,4 @@ export enum WebsitePaths { About = '/about', Whitepaper = '/pdfs/0x_white_paper.pdf', SmartContracts = '/docs/contracts', -} +} // tslint:disable:max-file-line-count diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts index 7fc52b035..77a6e3e38 100644 --- a/packages/website/ts/utils/constants.ts +++ b/packages/website/ts/utils/constants.ts @@ -1,14 +1,14 @@ +import BigNumber from 'bignumber.js'; import { + ContractAddresses, + Docs, ExchangeContractErrs, + Networks, PublicNodeUrlsByNetworkId, - ZeroExJsDocSections, SmartContractsDocSections, - Docs, - ContractAddresses, - Networks, WebsitePaths, + ZeroExJsDocSections, } from 'ts/types'; -import BigNumber from 'bignumber.js'; const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs'; diff --git a/packages/website/ts/utils/doc_utils.ts b/packages/website/ts/utils/doc_utils.ts index ca6e0dc52..594e3bae6 100644 --- a/packages/website/ts/utils/doc_utils.ts +++ b/packages/website/ts/utils/doc_utils.ts @@ -1,9 +1,9 @@ -import * as _ from 'lodash'; import findVersions = require('find-versions'); -import convert = require('xml-js'); +import * as _ from 'lodash'; +import {DoxityDocObj, S3FileObject, TypeDocNode, VersionToFileName} from 'ts/types'; import {constants} from 'ts/utils/constants'; import {utils} from 'ts/utils/utils'; -import {VersionToFileName, S3FileObject, TypeDocNode, DoxityDocObj} from 'ts/types'; +import convert = require('xml-js'); export const docUtils = { async getVersionToFileNameAsync(s3DocJsonRoot: string): @@ -29,12 +29,10 @@ export const docUtils = { compact: true, }); const responseObj = JSON.parse(responseJSONString); - let fileObjs: S3FileObject[]; - if (_.isArray(responseObj.ListBucketResult.Contents)) { - fileObjs = responseObj.ListBucketResult.Contents as S3FileObject[]; - } else { - fileObjs = [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; }); diff --git a/packages/website/ts/utils/doxity_utils.ts b/packages/website/ts/utils/doxity_utils.ts index 3bab0a69d..26e555b16 100644 --- a/packages/website/ts/utils/doxity_utils.ts +++ b/packages/website/ts/utils/doxity_utils.ts @@ -1,18 +1,18 @@ import * as _ from 'lodash'; import { - DoxityDocObj, - DoxityContractObj, - DoxityAbiDoc, - DoxityInput, + AbiTypes, DocAgnosticFormat, DocSection, + DoxityAbiDoc, + DoxityContractObj, + DoxityDocObj, + DoxityInput, + EventArg, Parameter, Property, + SolidityMethod, Type, TypeDocTypes, - EventArg, - AbiTypes, - SolidityMethod, } from 'ts/types'; export const doxityUtils = { diff --git a/packages/website/ts/utils/error_reporter.ts b/packages/website/ts/utils/error_reporter.ts index a9731c4d4..40991afbf 100644 --- a/packages/website/ts/utils/error_reporter.ts +++ b/packages/website/ts/utils/error_reporter.ts @@ -1,7 +1,7 @@ -import {utils} from 'ts/utils/utils'; -import {constants} from 'ts/utils/constants'; -import {configs} from 'ts/utils/configs'; 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 @@ -32,7 +32,7 @@ import Rollbar = require('../../public/js/rollbar.umd.nojson.min.js'); const rollbar = Rollbar.init(rollbarConfig); export const errorReporter = { - reportAsync(err: Error): Promise<any> { + async reportAsync(err: Error): Promise<any> { if (configs.ENVIRONMENT === Environments.DEVELOPMENT) { return; // Let's not log development errors to rollbar } diff --git a/packages/website/ts/utils/typedoc_utils.ts b/packages/website/ts/utils/typedoc_utils.ts index b3d0f7d90..bb2f7745a 100644 --- a/packages/website/ts/utils/typedoc_utils.ts +++ b/packages/website/ts/utils/typedoc_utils.ts @@ -1,25 +1,25 @@ -import * as _ from 'lodash'; import compareVersions = require('compare-versions'); -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; +import * as _ from 'lodash'; import { - TypeDocNode, - KindString, - ZeroExJsDocSections, - MenuSubsectionsBySection, - TypeDocType, - Type, + CustomType, + CustomTypeChild, DocAgnosticFormat, DocSection, - TypescriptMethod, + IndexSignature, + KindString, + MenuSubsectionsBySection, Parameter, Property, - CustomType, - IndexSignature, - CustomTypeChild, - TypeParameter, + Type, + TypeDocNode, + TypeDocType, TypeDocTypes, + TypeParameter, + TypescriptMethod, + ZeroExJsDocSections, } from 'ts/types'; +import {constants} from 'ts/utils/constants'; +import {utils} from 'ts/utils/utils'; const TYPES_MODULE_PATH = '"src/types"'; diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index eb4c5be3a..8b23b6a40 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -1,23 +1,24 @@ +import {ExchangeContractErrs, ZeroExError} from '0x.js'; +import BigNumber from 'bignumber.js'; +import deepEqual = require('deep-equal'); +import ethUtil = require('ethereumjs-util'); +import isMobile = require('is-mobile'); import * as _ from 'lodash'; +import * as moment from 'moment'; import { - SideToAssetToken, - SignatureData, + EtherscanLinkSuffixes, + Networks, Order, - Side, - TokenByAddress, OrderParty, ScreenWidths, - EtherscanLinkSuffixes, + Side, + SideToAssetToken, + SignatureData, Token, - Networks, + TokenByAddress, } from 'ts/types'; -import * as moment from 'moment'; -import isMobile = require('is-mobile'); -import * as u2f from 'ts/vendor/u2f_api'; -import deepEqual = require('deep-equal'); -import ethUtil = require('ethereumjs-util'); -import BigNumber from 'bignumber.js'; import {constants} from 'ts/utils/constants'; +import * as u2f from 'ts/vendor/u2f_api'; const LG_MIN_EM = 64; const MD_MIN_EM = 52; @@ -101,7 +102,7 @@ export const utils = { console.log(message); /* tslint:enable */ }, - sleepAsync(ms: number) { + async sleepAsync(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); }, deepEqual(actual: any, expected: any, opts?: {strict: boolean}) { @@ -212,4 +213,53 @@ export const utils = { const isUniqueSymbol = _.isUndefined(tokenWithSameSymbolIfExists); return isUniqueName && isUniqueSymbol; }, + 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', + [ZeroExError.TokenRegistryContractDoesNotExist]: 'TokenRegistry contract does not exist', + [ZeroExError.TokenContractDoesNotExist]: 'Token contract does not exist', + [ZeroExError.ZRXContractDoesNotExist]: 'ZRX contract does not exist', + [ZeroExError.UnhandledError]: 'Unhandled error occured', + [ZeroExError.UserHasNoAssociatedAddress]: 'User has no addresses available', + [ZeroExError.InvalidSignature]: 'Order signature is not valid', + [ZeroExError.ContractNotDeployedOnNetwork]: 'Contract is not deployed on the detected network', + [ZeroExError.InvalidJump]: 'Invalid jump occured while executing the transaction', + [ZeroExError.OutOfGas]: 'Transaction ran out of gas', + [ZeroExError.NoNetworkId]: 'No network id detected', + }; + 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.OrderAlreadyCancelledOrFilled]: + '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', + [ExchangeContractErrs.OrderFillRoundingError]: 'Rounding error will occur when filling this order', + [ExchangeContractErrs.InsufficientTakerBalance]: + 'Taker no longer has a sufficient balance to complete this order', + [ExchangeContractErrs.InsufficientTakerAllowance]: + 'Taker no longer has a sufficient allowance to complete this order', + [ExchangeContractErrs.InsufficientMakerBalance]: + 'Maker no longer has a sufficient balance to complete this order', + [ExchangeContractErrs.InsufficientMakerAllowance]: + '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', + [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', + }; + 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 24279f5d2..c43436c7e 100644 --- a/packages/website/ts/web3_wrapper.ts +++ b/packages/website/ts/web3_wrapper.ts @@ -1,8 +1,8 @@ -import * as _ from 'lodash'; -import Web3 = require('web3'); import BigNumber from 'bignumber.js'; import promisify = require('es6-promisify'); +import * as _ from 'lodash'; import {Dispatcher} from 'ts/redux/dispatcher'; +import Web3 = require('web3'); export class Web3Wrapper { private dispatcher: Dispatcher; @@ -21,6 +21,7 @@ export class Web3Wrapper { this.web3 = new Web3(); this.web3.setProvider(provider); + // tslint:disable-next-line:no-floating-promises this.startEmittingNetworkConnectionAndUserBalanceStateAsync(); } public isAddress(address: string) { @@ -35,7 +36,7 @@ export class Web3Wrapper { if (_.isEmpty(addresses)) { return ''; } - return (addresses as string[])[0]; + return (addresses)[0]; } public async getNodeVersionAsync() { const nodeVersion = await promisify(this.web3.version.getNode)(); diff --git a/packages/website/tslint.json b/packages/website/tslint.json index 6ac3ed760..957c0e11d 100644 --- a/packages/website/tslint.json +++ b/packages/website/tslint.json @@ -4,6 +4,8 @@ ], "rules": { "no-implicit-dependencies": false, - "no-object-literal-type-assertion": false + "no-object-literal-type-assertion": false, + "completed-docs": false, + "prefer-function-over-method": false } } |