From b74957acdfc8d67d154bcb4698acd7575db7cc47 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 11 May 2018 17:38:51 +0200 Subject: Add missing type definitions --- packages/website/ts/blockchain.ts | 57 ++++++++++---------- packages/website/ts/blockchain_watcher.ts | 14 ++--- .../components/dialogs/blockchain_err_dialog.tsx | 16 +++--- .../dialogs/eth_weth_conversion_dialog.tsx | 20 ++++---- .../ts/components/dialogs/ledger_config_dialog.tsx | 20 ++++---- .../dialogs/portal_disclaimer_dialog.tsx | 4 +- .../website/ts/components/dialogs/send_dialog.tsx | 14 ++--- .../dialogs/track_token_confirmation_dialog.tsx | 4 +- .../dialogs/u2f_not_supported_dialog.tsx | 4 +- .../dialogs/wrapped_eth_section_notice_dialog.tsx | 4 +- .../ts/components/dropdowns/network_drop_down.tsx | 4 +- .../ts/components/eth_weth_conversion_button.tsx | 6 +-- packages/website/ts/components/eth_wrappers.tsx | 24 ++++----- packages/website/ts/components/fill_order.tsx | 32 ++++++------ packages/website/ts/components/fill_order_json.tsx | 2 +- .../website/ts/components/fill_warning_dialog.tsx | 4 +- .../flash_messages/token_send_completed.tsx | 2 +- .../flash_messages/transaction_submitted.tsx | 2 +- packages/website/ts/components/footer.tsx | 10 ++-- .../ts/components/generate_order/asset_picker.tsx | 20 ++++---- .../generate_order/generate_order_form.tsx | 8 +-- .../components/generate_order/new_token_form.tsx | 18 +++---- .../website/ts/components/inputs/address_input.tsx | 6 +-- .../ts/components/inputs/allowance_toggle.tsx | 6 +-- .../ts/components/inputs/balance_bounded_input.tsx | 8 +-- .../ts/components/inputs/eth_amount_input.tsx | 4 +- .../ts/components/inputs/expiration_input.tsx | 8 +-- .../website/ts/components/inputs/hash_input.tsx | 4 +- .../components/inputs/identicon_address_input.tsx | 2 +- .../ts/components/inputs/token_amount_input.tsx | 12 ++--- .../website/ts/components/inputs/token_input.tsx | 8 +-- .../ts/components/legacy_portal/legacy_portal.tsx | 30 +++++------ .../legacy_portal/legacy_portal_menu.tsx | 4 +- packages/website/ts/components/order_json.tsx | 12 ++--- packages/website/ts/components/portal/portal.tsx | 22 ++++---- packages/website/ts/components/redirecter.tsx | 2 +- .../components/relayer_index/relayer_grid_tile.tsx | 4 +- .../ts/components/relayer_index/relayer_index.tsx | 6 +-- .../relayer_index/relayer_top_tokens.tsx | 2 +- packages/website/ts/components/send_button.tsx | 6 +-- packages/website/ts/components/sidebar_header.tsx | 2 +- packages/website/ts/components/token_balances.tsx | 40 +++++++-------- .../ts/components/top_bar/provider_display.tsx | 4 +- .../ts/components/top_bar/provider_picker.tsx | 8 +-- packages/website/ts/components/top_bar/top_bar.tsx | 32 ++++++------ .../ts/components/top_bar/top_bar_menu_item.tsx | 2 +- .../ts/components/track_token_confirmation.tsx | 2 +- .../ts/components/trade_history/trade_history.tsx | 20 ++++---- .../trade_history/trade_history_item.tsx | 8 +-- packages/website/ts/components/ui/alert.tsx | 4 +- packages/website/ts/components/ui/copy_icon.tsx | 12 ++--- packages/website/ts/components/ui/drop_down.tsx | 18 +++---- .../website/ts/components/ui/etherscan_icon.tsx | 2 +- .../website/ts/components/ui/fake_text_field.tsx | 4 +- .../website/ts/components/ui/flash_message.tsx | 4 +- packages/website/ts/components/ui/identicon.tsx | 2 +- .../ts/components/ui/lifecycle_raised_button.tsx | 6 +-- packages/website/ts/components/ui/menu_item.tsx | 4 +- packages/website/ts/components/ui/party.tsx | 2 +- packages/website/ts/components/ui/swap_icon.tsx | 4 +- packages/website/ts/components/ui/token_icon.tsx | 2 +- packages/website/ts/components/visual_order.tsx | 4 +- packages/website/ts/components/wallet/wallet.tsx | 54 +++++++++---------- .../ts/components/wallet/wrap_ether_item.tsx | 12 ++--- packages/website/ts/lazy_component.tsx | 8 +-- packages/website/ts/local_storage/local_storage.ts | 6 +-- .../ts/local_storage/trade_history_storage.tsx | 12 ++--- packages/website/ts/pages/about/about.tsx | 6 +-- packages/website/ts/pages/about/profile.tsx | 8 +-- .../website/ts/pages/documentation/doc_page.tsx | 10 ++-- packages/website/ts/pages/faq/faq.tsx | 8 +-- packages/website/ts/pages/faq/question.tsx | 4 +- packages/website/ts/pages/landing/landing.tsx | 39 ++++++++------ packages/website/ts/pages/not_found.tsx | 2 +- packages/website/ts/pages/wiki/wiki.tsx | 18 +++---- packages/website/ts/redux/dispatcher.ts | 60 +++++++++++----------- packages/website/ts/redux/reducer.ts | 2 +- packages/website/ts/utils/analytics.ts | 6 +-- packages/website/ts/utils/translate.ts | 8 +-- packages/website/ts/utils/utils.ts | 28 +++++----- 80 files changed, 460 insertions(+), 452 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index e90dfa747..d7f7ebc8f 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -39,6 +39,7 @@ import { BlockchainCallErrs, BlockchainErrs, ContractInstance, + Fill, Order as PortalOrder, Providers, ProviderType, @@ -88,7 +89,7 @@ export class Blockchain { } return providerNameIfExists; } - private static async _getProviderAsync(injectedWeb3: Web3, networkIdIfExists: number) { + private static async _getProviderAsync(injectedWeb3: Web3, networkIdIfExists: number): Promise { const doesInjectedWeb3Exist = !_.isUndefined(injectedWeb3); const publicNodeUrlsIfExistsForNetworkId = configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkIdIfExists]; const isPublicNodeAvailableForNetworkId = !_.isUndefined(publicNodeUrlsIfExistsForNetworkId); @@ -137,7 +138,7 @@ export class Blockchain { // tslint:disable-next-line:no-floating-promises this._onPageLoadInitFireAndForgetAsync(); } - public async networkIdUpdatedFireAndForgetAsync(newNetworkId: number) { + public async networkIdUpdatedFireAndForgetAsync(newNetworkId: number): Promise { const isConnected = !_.isUndefined(newNetworkId); if (!isConnected) { this.networkId = newNetworkId; @@ -147,17 +148,17 @@ export class Blockchain { this.networkId = newNetworkId; this._dispatcher.encounteredBlockchainError(BlockchainErrs.NoError); await this.fetchTokenInformationAsync(); - await this._rehydrateStoreWithContractEvents(); + await this._rehydrateStoreWithContractEventsAsync(); } } - public async userAddressUpdatedFireAndForgetAsync(newUserAddress: string) { + public async userAddressUpdatedFireAndForgetAsync(newUserAddress: string): Promise { if (this._userAddressIfExists !== newUserAddress) { this._userAddressIfExists = newUserAddress; await this.fetchTokenInformationAsync(); - await this._rehydrateStoreWithContractEvents(); + await this._rehydrateStoreWithContractEventsAsync(); } } - public async nodeVersionUpdatedFireAndForgetAsync(nodeVersion: string) { + public async nodeVersionUpdatedFireAndForgetAsync(nodeVersion: string): Promise { if (this.nodeVersion !== nodeVersion) { this.nodeVersion = nodeVersion; } @@ -174,13 +175,13 @@ export class Blockchain { const path = this._ledgerSubprovider.getPath(); return path; } - public updateLedgerDerivationPathIfExists(path: string) { + public updateLedgerDerivationPathIfExists(path: string): void { if (_.isUndefined(this._ledgerSubprovider)) { return; // noop } this._ledgerSubprovider.setPath(path); } - public async updateProviderToLedgerAsync(networkId: number) { + public async updateProviderToLedgerAsync(networkId: number): Promise { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); const isU2FSupported = await utils.isU2FSupportedAsync(); @@ -228,7 +229,7 @@ export class Blockchain { this._blockchainWatcher.startEmittingNetworkConnectionAndUserBalanceState(); this._dispatcher.updateProviderType(ProviderType.Ledger); } - public async updateProviderToInjectedAsync() { + public async updateProviderToInjectedAsync(): Promise { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); if (_.isUndefined(this._cachedProvider)) { @@ -367,7 +368,7 @@ export class Blockchain { const unavailableTakerAmount = await this._zeroEx.exchange.getUnavailableTakerAmountAsync(orderHash); return unavailableTakerAmount; } - public getExchangeContractAddressIfExists() { + public getExchangeContractAddressIfExists(): string | undefined { return this._zeroEx.exchange.getContractAddress(); } public async validateFillOrderThrowIfInvalidAsync( @@ -391,7 +392,7 @@ export class Blockchain { const lowercaseAddress = address.toLowerCase(); return Web3Wrapper.isAddress(lowercaseAddress); } - public async pollTokenBalanceAsync(token: Token) { + public async pollTokenBalanceAsync(token: Token): Promise { utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); const [currBalance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddressIfExists, token.address); @@ -445,7 +446,7 @@ export class Blockchain { this._dispatcher.updateECSignature(ecSignature); return ecSignature; } - public async mintTestTokensAsync(token: Token) { + public async mintTestTokensAsync(token: Token): Promise { utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); const mintableContract = await this._instantiateContractIfExistsAsync(MintableArtifacts, token.address); @@ -489,7 +490,7 @@ export class Blockchain { ); await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); } - public async doesContractExistAtAddressAsync(address: string) { + public async doesContractExistAtAddressAsync(address: string): Promise { const doesContractExist = await this._web3Wrapper.doesContractExistAtAddressAsync(address); return doesContractExist; } @@ -520,7 +521,7 @@ export class Blockchain { } return [balance, allowance]; } - public async getUserAccountsAsync() { + public async getUserAccountsAsync(): Promise { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); const userAccountsIfExists = await this._zeroEx.getAvailableAddressesAsync(); return userAccountsIfExists; @@ -528,14 +529,14 @@ export class Blockchain { // HACK: When a user is using a Ledger, we simply dispatch the selected userAddress, which // by-passes the web3Wrapper logic for updating the prevUserAddress. We therefore need to // manually update it. This should only be called by the LedgerConfigDialog. - public updateWeb3WrapperPrevUserAddress(newUserAddress: string) { + public updateWeb3WrapperPrevUserAddress(newUserAddress: string): void { this._blockchainWatcher.updatePrevUserAddress(newUserAddress); } - public destroy() { + public destroy(): void { this._blockchainWatcher.destroy(); this._stopWatchingExchangeLogFillEvents(); } - public async fetchTokenInformationAsync() { + public async fetchTokenInformationAsync(): Promise { utils.assert( !_.isUndefined(this.networkId), 'Cannot call fetchTokenInformationAsync if disconnected from Ethereum node', @@ -624,7 +625,7 @@ export class Blockchain { private _doesUserAddressExist(): boolean { return !_.isUndefined(this._userAddressIfExists); } - private async _rehydrateStoreWithContractEvents() { + private async _rehydrateStoreWithContractEventsAsync(): Promise { // Ensure we are only ever listening to one set of events this._stopWatchingExchangeLogFillEvents(); @@ -675,7 +676,7 @@ export class Blockchain { }, ); } - private async _fetchHistoricalExchangeLogFillEventsAsync(indexFilterValues: IndexedFilterValues) { + private async _fetchHistoricalExchangeLogFillEventsAsync(indexFilterValues: IndexedFilterValues): Promise { utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); const fromBlock = tradeHistoryStorage.getFillsLatestBlock(this._userAddressIfExists, this.networkId); @@ -697,7 +698,9 @@ export class Blockchain { tradeHistoryStorage.addFillToUser(this._userAddressIfExists, this.networkId, fill); } } - private async _convertDecodedLogToFillAsync(decodedLog: LogWithDecodedArgs) { + private async _convertDecodedLogToFillAsync( + decodedLog: LogWithDecodedArgs, + ): Promise { const args = decodedLog.args; const blockTimestamp = await this._web3Wrapper.getBlockTimestampAsync(decodedLog.blockHash); const fill = { @@ -716,12 +719,12 @@ export class Blockchain { }; return fill; } - private _doesLogEventInvolveUser(decodedLog: LogWithDecodedArgs) { + private _doesLogEventInvolveUser(decodedLog: LogWithDecodedArgs): boolean { const args = decodedLog.args; const isUserMakerOrTaker = args.maker === this._userAddressIfExists || args.taker === this._userAddressIfExists; return isUserMakerOrTaker; } - private _updateLatestFillsBlockIfNeeded(blockNumber: number) { + private _updateLatestFillsBlockIfNeeded(blockNumber: number): void { utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); const isBlockPending = _.isNull(blockNumber); @@ -762,7 +765,7 @@ export class Blockchain { }); return tokenByAddress; } - private async _onPageLoadInitFireAndForgetAsync() { + private async _onPageLoadInitFireAndForgetAsync(): Promise { await utils.onPageLoadAsync(); // wait for page to load // Hack: We need to know the networkId the injectedWeb3 is connected to (if it is defined) in @@ -805,9 +808,9 @@ export class Blockchain { this._dispatcher.updateUserAddress(this._userAddressIfExists); await this.fetchTokenInformationAsync(); this._blockchainWatcher.startEmittingNetworkConnectionAndUserBalanceState(); - await this._rehydrateStoreWithContractEvents(); + await this._rehydrateStoreWithContractEventsAsync(); } - private _updateProviderName(injectedWeb3: Web3) { + private _updateProviderName(injectedWeb3: Web3): void { const doesInjectedWeb3Exist = !_.isUndefined(injectedWeb3); const providerName = doesInjectedWeb3Exist ? Blockchain._getNameGivenProvider(injectedWeb3.currentProvider) @@ -849,12 +852,12 @@ export class Blockchain { } } } - private _showFlashMessageIfLedger() { + private _showFlashMessageIfLedger(): void { if (!_.isUndefined(this._ledgerSubprovider)) { this._dispatcher.showFlashMessage('Confirm the transaction on your Ledger Nano S'); } } - private async _updateDefaultGasPriceAsync() { + private async _updateDefaultGasPriceAsync(): Promise { try { const gasInfo = await backendClient.getGasInfoAsync(); const gasPriceInGwei = new BigNumber(gasInfo.average / 10); diff --git a/packages/website/ts/blockchain_watcher.ts b/packages/website/ts/blockchain_watcher.ts index 2712b2c04..c420a98a4 100644 --- a/packages/website/ts/blockchain_watcher.ts +++ b/packages/website/ts/blockchain_watcher.ts @@ -23,8 +23,8 @@ export class BlockchainWatcher { this._shouldPollUserAddress = shouldPollUserAddress; this._web3Wrapper = web3Wrapper; } - public destroy() { - this._stopEmittingNetworkConnectionAndUserBalanceStateAsync(); + public destroy(): void { + this._stopEmittingNetworkConnectionAndUserBalanceState(); // HACK: stop() is only available on providerEngine instances const provider = this._web3Wrapper.getProvider(); if (!_.isUndefined((provider as any).stop)) { @@ -32,10 +32,10 @@ export class BlockchainWatcher { } } // This should only be called from the LedgerConfigDialog - public updatePrevUserAddress(userAddress: string) { + public updatePrevUserAddress(userAddress: string): void { this._prevUserAddressIfExists = userAddress; } - public startEmittingNetworkConnectionAndUserBalanceState() { + public startEmittingNetworkConnectionAndUserBalanceState(): void { if (!_.isUndefined(this._watchNetworkAndBalanceIntervalId)) { return; // we are already emitting the state } @@ -88,18 +88,18 @@ export class BlockchainWatcher { 5000, (err: Error) => { logUtils.log(`Watching network and balances failed: ${err.stack}`); - this._stopEmittingNetworkConnectionAndUserBalanceStateAsync(); + this._stopEmittingNetworkConnectionAndUserBalanceState(); }, ); } - private async _updateUserWeiBalanceAsync(userAddress: string) { + private async _updateUserWeiBalanceAsync(userAddress: string): Promise { const balanceInWei = await this._web3Wrapper.getBalanceInWeiAsync(userAddress); if (!balanceInWei.eq(this._prevUserEtherBalanceInWei)) { this._prevUserEtherBalanceInWei = balanceInWei; this._dispatcher.updateUserWeiBalance(balanceInWei); } } - private _stopEmittingNetworkConnectionAndUserBalanceStateAsync() { + private _stopEmittingNetworkConnectionAndUserBalanceState(): void { if (!_.isUndefined(this._watchNetworkAndBalanceIntervalId)) { intervalUtils.clearAsyncExcludingInterval(this._watchNetworkAndBalanceIntervalId); } diff --git a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx index 1c3b7458d..7156e700b 100644 --- a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx +++ b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx @@ -18,7 +18,7 @@ interface BlockchainErrDialogProps { } export class BlockchainErrDialog extends React.Component { - public render() { + public render(): React.ReactNode { const dialogActions = [ ); } - private _getTitle(hasWalletAddress: boolean) { + private _getTitle(hasWalletAddress: boolean): string { if (this.props.blockchainErr === BlockchainErrs.AContractNotDeployedOnNetwork) { return '0x smart contracts not found'; } else if (!hasWalletAddress) { @@ -58,7 +58,7 @@ export class BlockchainErrDialog extends React.Component You were disconnected from the backing Ethereum node. If using{' '} @@ -86,7 +86,7 @@ export class BlockchainErrDialog extends React.Component ); } - private _renderDefaultTokenNotInTokenRegistry() { + private _renderDefaultTokenNotInTokenRegistry(): React.ReactNode { return (
The TokenRegistry deployed on your network does not contain the needed default tokens for 0x Portal to @@ -96,10 +96,10 @@ export class BlockchainErrDialog extends React.Component ); } - private _renderUnexpectedErrorExplanation() { + private _renderUnexpectedErrorExplanation(): React.ReactNode { return
We encountered an unexpected error. Please try refreshing the page.
; } - private _renderNoWalletFoundExplanation() { + private _renderNoWalletFoundExplanation(): React.ReactNode { return (
@@ -137,7 +137,7 @@ export class BlockchainErrDialog extends React.Component ); } - private _renderContractsNotDeployedExplanation() { + private _renderContractsNotDeployedExplanation(): React.ReactNode { return (
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 42ca1713d..069a75560 100644 --- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx +++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx @@ -47,14 +47,14 @@ export class EthWethConversionDialog extends React.Component< ethTokenBalance: new BigNumber(0), }; } - public componentWillMount() { + public componentWillMount(): void { // tslint:disable-next-line:no-floating-promises this._fetchEthTokenBalanceAsync(); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._isUnmounted = true; } - public render() { + public render(): React.ReactNode { const convertDialogActions = [ , , @@ -72,7 +72,7 @@ export class EthWethConversionDialog extends React.Component< ); } - private _renderConversionDialogBody() { + private _renderConversionDialogBody(): React.ReactNode { const explanation = this.props.direction === Side.Deposit ? 'Convert your Ether into a tokenized, tradable form.' @@ -137,7 +137,7 @@ export class EthWethConversionDialog extends React.Component<
); } - private _renderCurrency(isWrappedVersion: boolean) { + private _renderCurrency(isWrappedVersion: boolean): React.ReactNode { const name = isWrappedVersion ? 'Wrapped Ether' : 'Ether'; const iconUrl = isWrappedVersion ? '/images/token_icons/ether_erc20.png' : '/images/ether.png'; const symbol = isWrappedVersion ? 'WETH' : 'ETH'; @@ -155,18 +155,18 @@ export class EthWethConversionDialog extends React.Component<
); } - private _onMaxClick() { + private _onMaxClick(): void { this.setState({ value: this.state.ethTokenBalance, }); } - private _onValueChange(isValid: boolean, amount?: BigNumber) { + private _onValueChange(isValid: boolean, amount?: BigNumber): void { this.setState({ value: amount, hasErrors: !isValid, }); } - private _onConvertClick() { + private _onConvertClick(): void { if (this.state.hasErrors) { this.setState({ shouldShowIncompleteErrs: true, @@ -179,13 +179,13 @@ export class EthWethConversionDialog extends React.Component< this.props.onComplete(this.props.direction, value); } } - private _onCancel() { + private _onCancel(): void { this.setState({ value: undefined, }); this.props.onCancelled(); } - private async _fetchEthTokenBalanceAsync() { + private async _fetchEthTokenBalanceAsync(): Promise { const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; const [balance] = await this.props.blockchain.getTokenBalanceAndAllowanceAsync( userAddressIfExists, diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx index a72d33183..3c839d6f5 100644 --- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx +++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx @@ -59,7 +59,7 @@ export class LedgerConfigDialog extends React.Component, ]; @@ -82,7 +82,7 @@ export class LedgerConfigDialog extends React.Component ); } - private _renderConnectStep() { + private _renderConnectStep(): React.ReactNode { const networkIds = _.values(sharedConstants.NETWORK_ID_BY_NAME); return (
@@ -122,7 +122,7 @@ export class LedgerConfigDialog extends React.Component ); } - private _renderSelectAddressStep() { + private _renderSelectAddressStep(): React.ReactNode { return (
@@ -159,7 +159,7 @@ export class LedgerConfigDialog extends React.Component ); } - private _renderAddressTableRows() { + private _renderAddressTableRows(): React.ReactNode { const rows = _.map(this.state.userAddresses, (userAddress: string, i: number) => { const balanceInWei = this.state.addressBalances[i]; const addressTooltipId = `address-${userAddress}`; @@ -189,7 +189,7 @@ export class LedgerConfigDialog extends React.Component { let userAddresses: string[]; const addressBalances: BigNumber[] = []; try { @@ -250,7 +250,7 @@ export class LedgerConfigDialog extends React.Component { const isU2FSupported = await utils.isU2FSupportedAsync(); if (!isU2FSupported) { logUtils.log(`U2F not supported in this browser`); @@ -295,7 +295,7 @@ export class LedgerConfigDialog extends React.Component void; } -export function PortalDisclaimerDialog(props: PortalDisclaimerDialogProps) { +export const PortalDisclaimerDialog = (props: PortalDisclaimerDialogProps) => { return ( ); -} +}; diff --git a/packages/website/ts/components/dialogs/send_dialog.tsx b/packages/website/ts/components/dialogs/send_dialog.tsx index 2af7fd7ac..421f18b4f 100644 --- a/packages/website/ts/components/dialogs/send_dialog.tsx +++ b/packages/website/ts/components/dialogs/send_dialog.tsx @@ -35,7 +35,7 @@ export class SendDialog extends React.Component, ); } - private _renderSendDialogBody() { + private _renderSendDialogBody(): React.ReactNode { return (
@@ -86,19 +86,19 @@ export class SendDialog extends React.Component ); } - private _onRecipientChange(recipient?: string) { + private _onRecipientChange(recipient?: string): void { this.setState({ shouldShowIncompleteErrs: false, recipient, }); } - private _onValueChange(isValid: boolean, amount?: BigNumber) { + private _onValueChange(isValid: boolean, amount?: BigNumber): void { this.setState({ isAmountValid: isValid, value: amount, }); } - private _onSendClick() { + private _onSendClick(): void { if (this._hasErrors()) { this.setState({ shouldShowIncompleteErrs: true, @@ -112,13 +112,13 @@ export class SendDialog extends React.Component ); } - private async _onTrackConfirmationRespondedAsync(didUserAcceptTracking: boolean) { + private async _onTrackConfirmationRespondedAsync(didUserAcceptTracking: boolean): Promise { if (!didUserAcceptTracking) { this.props.onToggleDialog(didUserAcceptTracking); return; 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 6ac9cf917..ce86df856 100644 --- a/packages/website/ts/components/dialogs/u2f_not_supported_dialog.tsx +++ b/packages/website/ts/components/dialogs/u2f_not_supported_dialog.tsx @@ -9,7 +9,7 @@ interface U2fNotSupportedDialogProps { onToggleDialog: () => void; } -export function U2fNotSupportedDialog(props: U2fNotSupportedDialogProps) { +export const U2fNotSupportedDialog = (props: U2fNotSupportedDialogProps) => { return ( ); -} +}; diff --git a/packages/website/ts/components/dialogs/wrapped_eth_section_notice_dialog.tsx b/packages/website/ts/components/dialogs/wrapped_eth_section_notice_dialog.tsx index 9e91ff12d..78b270c1e 100644 --- a/packages/website/ts/components/dialogs/wrapped_eth_section_notice_dialog.tsx +++ b/packages/website/ts/components/dialogs/wrapped_eth_section_notice_dialog.tsx @@ -8,7 +8,7 @@ interface WrappedEthSectionNoticeDialogProps { onToggleDialog: () => void; } -export function WrappedEthSectionNoticeDialog(props: WrappedEthSectionNoticeDialogProps) { +export const WrappedEthSectionNoticeDialog = (props: WrappedEthSectionNoticeDialogProps) => { return ( ); -} +}; diff --git a/packages/website/ts/components/dropdowns/network_drop_down.tsx b/packages/website/ts/components/dropdowns/network_drop_down.tsx index b569807dd..2fd2785d1 100644 --- a/packages/website/ts/components/dropdowns/network_drop_down.tsx +++ b/packages/website/ts/components/dropdowns/network_drop_down.tsx @@ -13,7 +13,7 @@ interface NetworkDropDownProps { interface NetworkDropDownState {} export class NetworkDropDown extends React.Component { - public render() { + public render(): React.ReactNode { return (
@@ -22,7 +22,7 @@ export class NetworkDropDown extends React.Component ); } - private _renderDropDownItems() { + private _renderDropDownItems(): React.ReactNode { const items = _.map(this.props.avialableNetworkIds, networkId => { const networkName = sharedConstants.NETWORK_NAME_BY_ID[networkId]; const primaryText = ( diff --git a/packages/website/ts/components/eth_weth_conversion_button.tsx b/packages/website/ts/components/eth_weth_conversion_button.tsx index 586d260fb..e8db42a7a 100644 --- a/packages/website/ts/components/eth_weth_conversion_button.tsx +++ b/packages/website/ts/components/eth_weth_conversion_button.tsx @@ -46,7 +46,7 @@ export class EthWethConversionButton extends React.Component< isEthConversionHappening: false, }; } - public render() { + public render(): React.ReactNode { const labelStyle = this.state.isEthConversionHappening ? { fontSize: 10 } : {}; let callToActionLabel; let inProgressLabel; @@ -81,12 +81,12 @@ export class EthWethConversionButton extends React.Component<
); } - private _toggleConversionDialog() { + private _toggleConversionDialog(): void { this.setState({ isEthConversionDialogVisible: !this.state.isEthConversionDialogVisible, }); } - private async _onConversionAmountSelectedAsync(direction: Side, value: BigNumber) { + private async _onConversionAmountSelectedAsync(direction: Side, value: BigNumber): Promise { this.setState({ isEthConversionHappening: true, }); diff --git a/packages/website/ts/components/eth_wrappers.tsx b/packages/website/ts/components/eth_wrappers.tsx index 59afeb50b..f19b05861 100644 --- a/packages/website/ts/components/eth_wrappers.tsx +++ b/packages/website/ts/components/eth_wrappers.tsx @@ -65,7 +65,7 @@ export class EthWrappers extends React.Component ); } - private _renderActionColumnTitle(isBidirectional: boolean) { + private _renderActionColumnTitle(isBidirectional: boolean): React.ReactNode { let iconClass = 'zmdi-long-arrow-right'; let leftSymbol = 'WETH'; let rightSymbol = 'ETH'; @@ -241,7 +241,7 @@ export class EthWrappers extends React.Component ); } - private _renderOutdatedWeths(etherToken: Token, etherTokenState: TokenState) { + private _renderOutdatedWeths(etherToken: Token, etherTokenState: TokenState): React.ReactNode { const rows = _.map( configs.OUTDATED_WRAPPED_ETHERS, (outdatedWETHByNetworkId: OutdatedWrappedEtherByNetworkId) => { @@ -313,7 +313,7 @@ export class EthWrappers extends React.Component {_.isUndefined(etherscanUrl) ? ( @@ -326,7 +326,7 @@ export class EthWrappers extends React.Component ); } - private _renderToken(name: string, address: string, imgPath: string) { + private _renderToken(name: string, address: string, imgPath: string): React.ReactNode { const tooltipId = `tooltip-${address}`; return (
@@ -340,7 +340,7 @@ export class EthWrappers extends React.Component ); } - private async _onOutdatedConversionSuccessfulAsync(outdatedWETHAddress: string) { + private async _onOutdatedConversionSuccessfulAsync(outdatedWETHAddress: string): Promise { const currentOutdatedWETHState = this.state.outdatedWETHStateByAddress[outdatedWETHAddress]; this.setState({ outdatedWETHStateByAddress: { @@ -368,7 +368,7 @@ export class EthWrappers extends React.Component { const tokens = _.values(this.props.tokenByAddress); const wethToken = _.find(tokens, token => token.symbol === 'WETH'); const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; @@ -414,12 +414,12 @@ export class EthWrappers extends React.Component { const etherToken = this._getEthToken(); const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; const [balance, allowance] = await this.props.blockchain.getTokenBalanceAndAllowanceAsync( diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx index ea94e0987..59c32cebc 100644 --- a/packages/website/ts/components/fill_order.tsx +++ b/packages/website/ts/components/fill_order.tsx @@ -82,19 +82,19 @@ export class FillOrder extends React.Component { tokensToTrack: [], }; } - public componentWillMount() { + public componentWillMount(): void { if (!_.isEmpty(this.state.orderJSON)) { // tslint:disable-next-line:no-floating-promises this._validateFillOrderFireAndForgetAsync(this.state.orderJSON); } } - public componentDidMount() { + public componentDidMount(): void { window.scrollTo(0, 0); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._isUnmounted = true; } - public render() { + public render(): React.ReactNode { return (

Fill an order

@@ -159,7 +159,7 @@ export class FillOrder extends React.Component {
); } - private _renderOrderJsonNotices() { + private _renderOrderJsonNotices(): React.ReactNode { return (
{!_.isUndefined(this.props.initialOrder) && @@ -177,7 +177,7 @@ export class FillOrder extends React.Component {
); } - private _renderVisualOrder() { + private _renderVisualOrder(): React.ReactNode { const takerTokenAddress = this.state.parsedOrder.signedOrder.takerTokenAddress; const takerToken = this.props.tokenByAddress[takerTokenAddress]; const orderTakerAmount = new BigNumber(this.state.parsedOrder.signedOrder.takerTokenAmount); @@ -306,7 +306,7 @@ export class FillOrder extends React.Component {
); } - private _renderFillSuccessMsg() { + private _renderFillSuccessMsg(): React.ReactNode { return (
Order successfully filled. See the trade details in your{' '} @@ -316,10 +316,10 @@ export class FillOrder extends React.Component {
); } - private _renderCancelSuccessMsg() { + private _renderCancelSuccessMsg(): React.ReactNode { return
Order successfully cancelled.
; } - private _onFillOrderClick() { + private _onFillOrderClick(): void { if (!this.state.isMakerTokenAddressInRegistry || !this.state.isTakerTokenAddressInRegistry) { this.setState({ isFillWarningDialogOpen: true, @@ -329,7 +329,7 @@ export class FillOrder extends React.Component { this._onFillOrderClickFireAndForgetAsync(); } } - private _onFillWarningClosed(didUserCancel: boolean) { + private _onFillWarningClosed(didUserCancel: boolean): void { this.setState({ isFillWarningDialogOpen: false, }); @@ -338,10 +338,10 @@ export class FillOrder extends React.Component { this._onFillOrderClickFireAndForgetAsync(); } } - private _onFillAmountChange(isValid: boolean, amount?: BigNumber) { + private _onFillAmountChange(isValid: boolean, amount?: BigNumber): void { this.props.dispatcher.updateOrderFillAmount(amount); } - private _onFillOrderJSONChanged(event: any) { + private _onFillOrderJSONChanged(event: any): void { const orderJSON = event.target.value; this.setState({ didOrderValidationRun: _.isEmpty(orderJSON) && _.isEmpty(this.state.orderJSONErrMsg), @@ -350,7 +350,7 @@ export class FillOrder extends React.Component { // tslint:disable-next-line:no-floating-promises this._validateFillOrderFireAndForgetAsync(orderJSON); } - private async _checkForUntrackedTokensAndAskToAdd() { + private async _checkForUntrackedTokensAndAskToAddAsync(): Promise { if (!_.isEmpty(this.state.orderJSONErrMsg)) { return; } @@ -396,7 +396,7 @@ export class FillOrder extends React.Component { }); } } - private async _validateFillOrderFireAndForgetAsync(orderJSON: string) { + private async _validateFillOrderFireAndForgetAsync(orderJSON: string): Promise { let orderJSONErrMsg = ''; let parsedOrder: Order; let orderHash: string; @@ -491,7 +491,7 @@ export class FillOrder extends React.Component { unavailableTakerAmount, }); - await this._checkForUntrackedTokensAndAskToAdd(); + await this._checkForUntrackedTokensAndAskToAddAsync(); } private async _onFillOrderClickFireAndForgetAsync(): Promise { if (this.props.blockchainErr !== BlockchainErrs.NoError || _.isEmpty(this.props.userAddress)) { @@ -650,7 +650,7 @@ export class FillOrder extends React.Component { const roundedUnitAmount = Math.round(unitAmount.toNumber() * 100000) / 100000; return roundedUnitAmount; } - private _onToggleTrackConfirmDialog(didConfirmTokenTracking: boolean) { + private _onToggleTrackConfirmDialog(didConfirmTokenTracking: boolean): void { if (!didConfirmTokenTracking) { this.setState({ orderJSON: '', diff --git a/packages/website/ts/components/fill_order_json.tsx b/packages/website/ts/components/fill_order_json.tsx index 7d5351ec4..97297d5a1 100644 --- a/packages/website/ts/components/fill_order_json.tsx +++ b/packages/website/ts/components/fill_order_json.tsx @@ -19,7 +19,7 @@ interface FillOrderJSONProps { interface FillOrderJSONState {} export class FillOrderJSON extends React.Component { - public render() { + public render(): React.ReactNode { const tokenAddresses = _.keys(this.props.tokenByAddress); const exchangeContract = this.props.blockchain.getExchangeContractAddressIfExists(); const hintSideToAssetToken = { diff --git a/packages/website/ts/components/fill_warning_dialog.tsx b/packages/website/ts/components/fill_warning_dialog.tsx index d3215a6c1..83095b1d3 100644 --- a/packages/website/ts/components/fill_warning_dialog.tsx +++ b/packages/website/ts/components/fill_warning_dialog.tsx @@ -8,7 +8,7 @@ interface FillWarningDialogProps { onToggleDialog: (didUserCancel: boolean) => void; } -export function FillWarningDialog(props: FillWarningDialogProps) { +export const FillWarningDialog = (props: FillWarningDialogProps) => { const didCancel = true; return ( ); -} +}; 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 a3b056758..bb5adfa4e 100644 --- a/packages/website/ts/components/flash_messages/token_send_completed.tsx +++ b/packages/website/ts/components/flash_messages/token_send_completed.tsx @@ -16,7 +16,7 @@ interface TokenSendCompletedProps { interface TokenSendCompletedState {} export class TokenSendCompleted extends React.Component { - public render() { + public render(): React.ReactNode { const etherScanLink = !_.isUndefined(this.props.etherScanLinkIfExists) && ( Verify on Etherscan diff --git a/packages/website/ts/components/flash_messages/transaction_submitted.tsx b/packages/website/ts/components/flash_messages/transaction_submitted.tsx index 188f1f9a6..2a6d2a64b 100644 --- a/packages/website/ts/components/flash_messages/transaction_submitted.tsx +++ b/packages/website/ts/components/flash_messages/transaction_submitted.tsx @@ -9,7 +9,7 @@ interface TransactionSubmittedProps { interface TransactionSubmittedState {} export class TransactionSubmitted extends React.Component { - public render() { + public render(): React.ReactNode { if (_.isUndefined(this.props.etherScanLinkIfExists)) { return
Transaction submitted to the network
; } else { diff --git a/packages/website/ts/components/footer.tsx b/packages/website/ts/components/footer.tsx index 487b039b2..c44e41084 100644 --- a/packages/website/ts/components/footer.tsx +++ b/packages/website/ts/components/footer.tsx @@ -50,7 +50,7 @@ export class Footer extends React.Component { selectedLanguage: props.translate.getLanguage(), }; } - public render() { + public render(): React.ReactNode { const menuItemsBySection: MenuItemsBySection = { [Key.Documentation]: [ { @@ -180,14 +180,14 @@ export class Footer extends React.Component {
); } - private _renderIcon(fileName: string) { + private _renderIcon(fileName: string): React.ReactNode { return (
); } - private _renderMenuItem(item: FooterMenuItem) { + private _renderMenuItem(item: FooterMenuItem): React.ReactNode { const titleToIcon: { [title: string]: string } = { [this.props.translate.get(Key.RocketChat, Deco.Cap)]: 'rocketchat.png', [this.props.translate.get(Key.Blog, Deco.Cap)]: 'medium.png', @@ -222,7 +222,7 @@ export class Footer extends React.Component {
); } - private _renderHeader(key: Key) { + private _renderHeader(key: Key): React.ReactNode { const headerStyle = { color: colors.grey400, letterSpacing: 2, @@ -235,7 +235,7 @@ export class Footer extends React.Component {
); } - private _updateLanguage(e: any, index: number, value: Language) { + private _updateLanguage(e: any, index: number, value: Language): void { this.setState({ selectedLanguage: value, }); diff --git a/packages/website/ts/components/generate_order/asset_picker.tsx b/packages/website/ts/components/generate_order/asset_picker.tsx index 69fb32a21..d7cc554c4 100644 --- a/packages/website/ts/components/generate_order/asset_picker.tsx +++ b/packages/website/ts/components/generate_order/asset_picker.tsx @@ -79,7 +79,7 @@ export class AssetPicker extends React.Component ); } - private _renderConfirmTrackToken() { + private _renderConfirmTrackToken(): React.ReactNode { const token = this.props.tokenByAddress[this.state.chosenTrackTokenAddress]; return ( ); } - private _renderAssetPicker() { + private _renderAssetPicker(): React.ReactNode { return (
); } - private _renderGridTiles() { + private _renderGridTiles(): React.ReactNode { let isHovered; let tileStyles; const gridTiles = _.map(this.props.tokenByAddress, (token: Token, address: string) => { @@ -195,19 +195,19 @@ export class AssetPicker extends React.Component { if (!didUserAcceptTracking) { this.setState({ isAddingTokenToTracked: false, 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 eb76cb529..d46c29058 100644 --- a/packages/website/ts/components/generate_order/generate_order_form.tsx +++ b/packages/website/ts/components/generate_order/generate_order_form.tsx @@ -63,10 +63,10 @@ export class GenerateOrderForm extends React.Component ); } - private _onTokenAmountChange(token: Token, side: Side, isValid: boolean, amount?: BigNumber) { + private _onTokenAmountChange(token: Token, side: Side, isValid: boolean, amount?: BigNumber): void { this.props.dispatcher.updateChosenAssetToken(side, { address: token.address, amount, }); } - private _onCloseOrderJSONDialog() { + private _onCloseOrderJSONDialog(): void { // Upon closing the order JSON dialog, we update the orderSalt stored in the Redux store // with a new value so that if a user signs the identical order again, the newly signed // orderHash will not collide with the previously generated orderHash. 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 e7f3b93c6..10f71b430 100644 --- a/packages/website/ts/components/generate_order/new_token_form.tsx +++ b/packages/website/ts/components/generate_order/new_token_form.tsx @@ -42,7 +42,7 @@ export class NewTokenForm extends React.Component
@@ -96,7 +96,7 @@ export class NewTokenForm extends React.Component ); } - private async _onAddNewTokenClickAsync() { + private async _onAddNewTokenClickAsync(): Promise { // Trigger validation of name and symbol this._onTokenNameChanged(undefined, this.state.name); this._onTokenSymbolChanged(undefined, this.state.symbol); @@ -152,7 +152,7 @@ export class NewTokenForm extends React.Component : this.props.label; const labelDisplay = this.props.shouldHideLabel ? 'hidden' : 'block'; const hintText = this.props.hintText ? this.props.hintText : ''; @@ -57,7 +57,7 @@ export class AddressInput extends React.Component ); } - private _onOrderTakerAddressUpdated(e: any) { + private _onOrderTakerAddressUpdated(e: any): void { const address = e.target.value.toLowerCase(); const isValidAddress = addressUtils.isAddress(address) || address === ''; const errMsg = isValidAddress ? '' : 'Invalid ethereum address'; diff --git a/packages/website/ts/components/inputs/allowance_toggle.tsx b/packages/website/ts/components/inputs/allowance_toggle.tsx index cfe75b751..48c7f9f57 100644 --- a/packages/website/ts/components/inputs/allowance_toggle.tsx +++ b/packages/website/ts/components/inputs/allowance_toggle.tsx @@ -63,7 +63,7 @@ export class AllowanceToggle extends React.Component
@@ -128,7 +128,7 @@ export class AllowanceToggle extends React.Component ); } - private _onValueChange(e: any, amountString: string) { + private _onValueChange(e: any, amountString: string): void { const errMsg = this._validate(amountString, this.props.balance); this.setState( { @@ -135,7 +135,7 @@ export class BalanceBoundedInput extends React.Component ); } - private _onChange(isValid: boolean, amount?: BigNumber) { + private _onChange(isValid: boolean, amount?: BigNumber): void { const baseUnitAmountIfExists = _.isUndefined(amount) ? undefined : ZeroEx.toBaseUnitAmount(amount, constants.DECIMAL_PLACES_ETH); diff --git a/packages/website/ts/components/inputs/expiration_input.tsx b/packages/website/ts/components/inputs/expiration_input.tsx index e473648d2..5c68080fe 100644 --- a/packages/website/ts/components/inputs/expiration_input.tsx +++ b/packages/website/ts/components/inputs/expiration_input.tsx @@ -30,7 +30,7 @@ export class ExpirationInput extends React.Component { - public render() { + public render(): React.ReactNode { const msgHashHex = this.props.blockchainIsLoaded ? this._generateMessageHashHex() : ''; return (
@@ -40,7 +40,7 @@ export class HashInput extends React.Component {
); } - private _generateMessageHashHex() { + private _generateMessageHashHex(): string { const exchangeContractAddress = this.props.blockchain.getExchangeContractAddressIfExists(); const hashData = this.props.hashData; const order: Order = { diff --git a/packages/website/ts/components/inputs/identicon_address_input.tsx b/packages/website/ts/components/inputs/identicon_address_input.tsx index 4cf9af64d..a4dc01ba8 100644 --- a/packages/website/ts/components/inputs/identicon_address_input.tsx +++ b/packages/website/ts/components/inputs/identicon_address_input.tsx @@ -23,7 +23,7 @@ export class IdenticonAddressInput extends React.Component : this.props.label; return (
diff --git a/packages/website/ts/components/inputs/token_amount_input.tsx b/packages/website/ts/components/inputs/token_amount_input.tsx index 9e638b67b..9a74bdd51 100644 --- a/packages/website/ts/components/inputs/token_amount_input.tsx +++ b/packages/website/ts/components/inputs/token_amount_input.tsx @@ -52,14 +52,14 @@ export class TokenAmountInput extends React.Component ); } - private _onChange(isValid: boolean, amount?: BigNumber) { + private _onChange(isValid: boolean, amount?: BigNumber): void { let baseUnitAmount; if (!_.isUndefined(amount)) { baseUnitAmount = ZeroEx.toBaseUnitAmount(amount, this.props.token.decimals); @@ -122,7 +122,7 @@ export class TokenAmountInput extends React.Component { this.setState({ isBalanceAndAllowanceLoaded: false, }); diff --git a/packages/website/ts/components/inputs/token_input.tsx b/packages/website/ts/components/inputs/token_input.tsx index 545e9a095..c2c4dd63b 100644 --- a/packages/website/ts/components/inputs/token_input.tsx +++ b/packages/website/ts/components/inputs/token_input.tsx @@ -38,7 +38,7 @@ export class TokenInput extends React.Component ); } - private _onTokenChosen(tokenAddress: string) { + private _onTokenChosen(tokenAddress: string): void { const assetToken: AssetToken = { address: tokenAddress, amount: this.props.assetToken.amount, @@ -86,12 +86,12 @@ export class TokenInput extends React.Component void; - public static hasAlreadyDismissedWethNotice() { + public static hasAlreadyDismissedWethNotice(): boolean { const didDismissWethNotice = localStorage.getItemIfExists(constants.LOCAL_STORAGE_KEY_DISMISS_WETH_NOTICE); const hasAlreadyDismissedWethNotice = !_.isUndefined(didDismissWethNotice) && !_.isEmpty(didDismissWethNotice); return hasAlreadyDismissedWethNotice; @@ -105,14 +105,14 @@ export class LegacyPortal extends React.Component ); } - public onToggleLedgerDialog() { + public onToggleLedgerDialog(): void { this.setState({ isLedgerDialogOpen: !this.state.isLedgerDialogOpen, }); } - private _renderEthWrapper() { + private _renderEthWrapper(): React.ReactNode { return ( ); } - private _renderTradeHistory() { + private _renderTradeHistory(): React.ReactNode { return ( ); } - private _renderTokenBalances() { + private _renderTokenBalances(): React.ReactNode { const allTokens = _.values(this.props.tokenByAddress); const trackedTokens = _.filter(allTokens, t => t.isTracked); return ( @@ -322,7 +322,7 @@ export class LegacyPortal extends React.Component ); } - private _renderFillOrder(match: any, location: Location, history: History) { + private _renderFillOrder(match: any, location: Location, history: History): React.ReactNode { const initialFillOrder = !_.isUndefined(this.props.userSuppliedOrderCache) ? this.props.userSuppliedOrderCache : this._sharedOrderIfExists; @@ -341,7 +341,7 @@ export class LegacyPortal extends React.Component ); } - private _renderGenerateOrderForm(match: any, location: Location, history: History) { + private _renderGenerateOrderForm(match: any, location: Location, history: History): React.ReactNode { return ( ); } - private _onPortalDisclaimerAccepted() { + private _onPortalDisclaimerAccepted(): void { localStorage.setItem(constants.LOCAL_STORAGE_KEY_ACCEPT_DISCLAIMER, 'set'); this.setState({ isDisclaimerDialogOpen: false, }); } - private _onWethNoticeAccepted() { + private _onWethNoticeAccepted(): void { localStorage.setItem(constants.LOCAL_STORAGE_KEY_DISMISS_WETH_NOTICE, 'set'); this.setState({ isWethNoticeDialogOpen: false, @@ -388,7 +388,7 @@ export class LegacyPortal extends React.Component = { onClick: _.noop, }; - public render() { + public render(): React.ReactNode { return (
); } - private _renderMenuItemWithIcon(title: string, iconName: string) { + private _renderMenuItemWithIcon(title: string, iconName: string): React.ReactNode { return (
diff --git a/packages/website/ts/components/order_json.tsx b/packages/website/ts/components/order_json.tsx index 02b88b888..6feefea50 100644 --- a/packages/website/ts/components/order_json.tsx +++ b/packages/website/ts/components/order_json.tsx @@ -38,7 +38,7 @@ export class OrderJSON extends React.Component { // tslint:disable-next-line:no-floating-promises this._setShareLinkAsync(); } - public render() { + public render(): React.ReactNode { const order = utils.generateOrder( this.props.exchangeContractIfExists, this.props.sideToAssetToken, @@ -116,11 +116,11 @@ export class OrderJSON extends React.Component {
); } - private async _shareViaTwitterAsync() { + private _shareViaTwitterAsync(): void { const tweetText = encodeURIComponent(`Fill my order using the 0x protocol: ${this.state.shareLink}`); window.open(`https://twitter.com/intent/tweet?text=${tweetText}`, 'Share your order', 'width=500,height=400'); } - private async _shareViaFacebook() { + private _shareViaFacebook(): void { (window as any).FB.ui( { display: 'popup', @@ -130,14 +130,14 @@ export class OrderJSON extends React.Component { _.noop, ); } - private async _shareViaEmailAsync() { + private _shareViaEmailAsync(): void { const encodedSubject = encodeURIComponent("Let's trade using the 0x protocol"); const encodedBody = encodeURIComponent(`I generated an order with the 0x protocol. You can see and fill it here: ${this.state.shareLink}`); const mailToLink = `mailto:mail@example.org?subject=${encodedSubject}&body=${encodedBody}`; window.open(mailToLink, '_blank'); } - private async _setShareLinkAsync() { + private async _setShareLinkAsync(): Promise { const shareLink = await this._generateShareLinkAsync(); this.setState({ shareLink, @@ -159,7 +159,7 @@ You can see and fill it here: ${this.state.shareLink}`); } return bodyObj.data.url; } - private _getOrderUrl() { + private _getOrderUrl(): string { const order = utils.generateOrder( this.props.exchangeContractIfExists, this.props.sideToAssetToken, diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index 4cbc65ce4..e572b7911 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -102,14 +102,14 @@ export class Portal extends React.Component { isLedgerDialogOpen: false, }; } - public componentDidMount() { + public componentDidMount(): void { window.addEventListener('resize', this._throttledScreenWidthUpdate); window.scrollTo(0, 0); } - public componentWillMount() { + public componentWillMount(): void { this._blockchain = new Blockchain(this.props.dispatcher); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._blockchain.destroy(); window.removeEventListener('resize', this._throttledScreenWidthUpdate); // We re-set the entire redux state when the portal is unmounted so that when it is re-rendered @@ -118,7 +118,7 @@ export class Portal extends React.Component { // become disconnected from their backing Ethereum node, changed user accounts, etc...) this.props.dispatcher.resetState(); } - public componentWillReceiveProps(nextProps: PortalProps) { + public componentWillReceiveProps(nextProps: PortalProps): void { if (nextProps.networkId !== this.state.prevNetworkId) { // tslint:disable-next-line:no-floating-promises this._blockchain.networkIdUpdatedFireAndForgetAsync(nextProps.networkId); @@ -144,7 +144,7 @@ export class Portal extends React.Component { }); } } - public render() { + public render(): React.ReactNode { const updateShouldBlockchainErrDialogBeOpen = this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen.bind( this.props.dispatcher, ); @@ -241,7 +241,7 @@ export class Portal extends React.Component {
); } - private _onTokenChosen(tokenAddress: string) { + private _onTokenChosen(tokenAddress: string): void { if (_.isEmpty(tokenAddress)) { this.setState({ tokenManagementState: TokenManagementState.None, @@ -269,28 +269,28 @@ export class Portal extends React.Component { tokenManagementState: TokenManagementState.None, }); } - private _onToggleLedgerDialog() { + private _onToggleLedgerDialog(): void { this.setState({ isLedgerDialogOpen: !this.state.isLedgerDialogOpen, }); } - private _onAddToken() { + private _onAddToken(): void { this.setState({ tokenManagementState: TokenManagementState.Add, }); } - private _onRemoveToken() { + private _onRemoveToken(): void { this.setState({ tokenManagementState: TokenManagementState.Remove, }); } - private _onPortalDisclaimerAccepted() { + private _onPortalDisclaimerAccepted(): void { localStorage.setItem(constants.LOCAL_STORAGE_KEY_ACCEPT_DISCLAIMER, 'set'); this.setState({ isDisclaimerDialogOpen: false, }); } - private _updateScreenWidth() { + private _updateScreenWidth(): void { const newScreenWidth = utils.getScreenWidth(); this.props.dispatcher.updateScreenWidth(newScreenWidth); } diff --git a/packages/website/ts/components/redirecter.tsx b/packages/website/ts/components/redirecter.tsx index 2e705af58..629522bbb 100644 --- a/packages/website/ts/components/redirecter.tsx +++ b/packages/website/ts/components/redirecter.tsx @@ -5,6 +5,6 @@ interface RedirecterProps { location: string; } -export function Redirecter(props: RedirecterProps) { +export function Redirecter(props: RedirecterProps): void { window.location.href = constants.URL_ANGELLIST; } diff --git a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx index d88a59d15..592bff29f 100644 --- a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx +++ b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx @@ -109,14 +109,14 @@ class ImgWithFallback extends React.Component; } else { return ; } } - private _onError() { + private _onError(): void { this.setState({ imageLoadFailed: true, }); diff --git a/packages/website/ts/components/relayer_index/relayer_index.tsx b/packages/website/ts/components/relayer_index/relayer_index.tsx index dffd0f83f..d4fd6aeaf 100644 --- a/packages/website/ts/components/relayer_index/relayer_index.tsx +++ b/packages/website/ts/components/relayer_index/relayer_index.tsx @@ -48,14 +48,14 @@ export class RelayerIndex extends React.Component = (props: TopTo ); }; -function tokenLinkFromToken(tokenInfo: WebsiteBackendTokenInfo, networkId: number) { +function tokenLinkFromToken(tokenInfo: WebsiteBackendTokenInfo, networkId: number): string { return sharedUtils.getEtherScanLinkIfExists(tokenInfo.address, networkId, EtherscanLinkSuffixes.Address); } diff --git a/packages/website/ts/components/send_button.tsx b/packages/website/ts/components/send_button.tsx index 79c103e05..8486dbd8b 100644 --- a/packages/website/ts/components/send_button.tsx +++ b/packages/website/ts/components/send_button.tsx @@ -33,7 +33,7 @@ export class SendButton extends React.Component @@ -57,12 +57,12 @@ export class SendButton extends React.Component ); } - private _toggleSendDialog() { + private _toggleSendDialog(): void { this.setState({ isSendDialogVisible: !this.state.isSendDialogVisible, }); } - private async _onSendAmountSelectedAsync(recipient: string, value: BigNumber) { + private async _onSendAmountSelectedAsync(recipient: string, value: BigNumber): Promise { this.setState({ isSending: true, }); diff --git a/packages/website/ts/components/sidebar_header.tsx b/packages/website/ts/components/sidebar_header.tsx index a0ea869fb..bf46caad9 100644 --- a/packages/website/ts/components/sidebar_header.tsx +++ b/packages/website/ts/components/sidebar_header.tsx @@ -12,7 +12,7 @@ interface SidebarHeaderProps { interface SidebarHeaderState {} export class SidebarHeader extends React.Component { - public render() { + public render(): React.ReactNode { return (
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index 618b5fe8f..83948e5c2 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -99,15 +99,15 @@ export class TokenBalances extends React.Component ); } - private _renderTokenTableRows() { + private _renderTokenTableRows(): React.ReactNode { if (!this.props.blockchainIsLoaded || this.props.blockchainErr !== BlockchainErrs.NoError) { return ''; } @@ -313,7 +313,7 @@ export class TokenBalances extends React.Component ); } - private _onAssetTokenPicked(tokenAddress: string) { + private _onAssetTokenPicked(tokenAddress: string): void { if (_.isEmpty(tokenAddress)) { this.setState({ isTokenPickerOpen: false, @@ -439,16 +439,16 @@ export class TokenBalances extends React.Component @@ -460,7 +460,7 @@ export class TokenBalances extends React.Component ); } - private _renderErrorDialogBody() { + private _renderErrorDialogBody(): React.ReactNode { switch (this.state.errorType) { case BalanceErrs.incorrectNetworkForFaucet: return ( @@ -499,7 +499,7 @@ export class TokenBalances extends React.Component { const tokens = _.values(this.props.tokenByAddress); const zrxToken = _.find(tokens, t => t.symbol === ZRX_TOKEN_SYMBOL); @@ -609,7 +609,7 @@ export class TokenBalances extends React.Component { const trackedTokenStateByAddress = this.state.trackedTokenStateByAddress; const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; for (const tokenAddress of tokenAddresses) { @@ -629,7 +629,7 @@ export class TokenBalances extends React.Component { trackedTokenStateByAddress[token.address] = { @@ -640,7 +640,7 @@ export class TokenBalances extends React.Component { const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; const [balance, allowance] = await this.props.blockchain.getTokenBalanceAndAllowanceAsync( userAddressIfExists, diff --git a/packages/website/ts/components/top_bar/provider_display.tsx b/packages/website/ts/components/top_bar/provider_display.tsx index 4cd50dba9..9d8bd6913 100644 --- a/packages/website/ts/components/top_bar/provider_display.tsx +++ b/packages/website/ts/components/top_bar/provider_display.tsx @@ -35,7 +35,7 @@ const styles: Styles = { }; export class ProviderDisplay extends React.Component { - public render() { + public render(): React.ReactNode { const isAddressAvailable = !_.isEmpty(this.props.userAddress); const isExternallyInjectedProvider = this.props.providerType === ProviderType.Injected && this.props.injectedProviderName !== '0x Public'; @@ -81,7 +81,7 @@ export class ProviderDisplay extends React.Component ); } - public renderPopoverContent(hasInjectedProvider: boolean, hasLedgerProvider: boolean) { + public renderPopoverContent(hasInjectedProvider: boolean, hasLedgerProvider: boolean): React.ReactNode { if (hasInjectedProvider || hasLedgerProvider) { return ( { - public render() { + public render(): React.ReactNode { const isLedgerSelected = this.props.providerType === ProviderType.Ledger; const menuStyle = { padding: 10, @@ -46,7 +46,7 @@ export class ProviderPicker extends React.Component ); } - private _renderLabel(title: string, shouldShowNetwork: boolean) { + private _renderLabel(title: string, shouldShowNetwork: boolean): React.ReactNode { const label = (
{title}
@@ -55,7 +55,7 @@ export class ProviderPicker extends React.Component @@ -70,7 +70,7 @@ export class ProviderPicker extends React.Component ); } - private _onProviderRadioChanged(value: string) { + private _onProviderRadioChanged(value: string): void { if (value === ProviderType.Ledger) { this.props.onToggleLedgerDialog(); } else { diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 5a1b50310..5fde007d6 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -83,7 +83,7 @@ export class TopBar extends React.Component { style: {}, isNightVersion: false, }; - public static heightForDisplayType(displayType: TopBarDisplayType) { + public static heightForDisplayType(displayType: TopBarDisplayType): number { const result = displayType === TopBarDisplayType.Expanded ? EXPANDED_HEIGHT : DEFAULT_HEIGHT; return result + 1; } @@ -93,7 +93,7 @@ export class TopBar extends React.Component { isDrawerOpen: false, }; } - public render() { + public render(): React.ReactNode { const isNightVersion = this.props.isNightVersion; const isExpandedDisplayType = this.props.displayType === TopBarDisplayType.Expanded; const parentClassNames = `flex mx-auto ${isExpandedDisplayType ? 'pl3 py1' : 'max-width-4'}`; @@ -278,7 +278,7 @@ export class TopBar extends React.Component {
); } - private _renderDrawer() { + private _renderDrawer(): React.ReactNode { return ( {
); } - private _onMenuButtonClick() { + private _onMenuButtonClick(): void { this.setState({ isDrawerOpen: !this.state.isDrawerOpen, }); } - private _isViewingPortal() { + private _isViewingPortal(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.Portal); } - private _isViewingFAQ() { + private _isViewingFAQ(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.FAQ); } - private _isViewing0xjsDocs() { + private _isViewing0xjsDocs(): boolean { return ( _.includes(this.props.location.pathname, WebsitePaths.ZeroExJs) || _.includes(this.props.location.pathname, WebsiteLegacyPaths.ZeroExJs) ); } - private _isViewingConnectDocs() { + private _isViewingConnectDocs(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.Connect); } - private _isViewingSmartContractsDocs() { + private _isViewingSmartContractsDocs(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.SmartContracts); } - private _isViewingWeb3WrapperDocs() { + private _isViewingWeb3WrapperDocs(): boolean { return ( _.includes(this.props.location.pathname, WebsitePaths.Web3Wrapper) || _.includes(this.props.location.pathname, WebsiteLegacyPaths.Web3Wrapper) ); } - private _isViewingSolCompilerDocs() { + private _isViewingSolCompilerDocs(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.SolCompiler); } - private _isViewingJsonSchemasDocs() { + private _isViewingJsonSchemasDocs(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.JSONSchemas); } - private _isViewingSolCovDocs() { + private _isViewingSolCovDocs(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.SolCov); } - private _isViewingSubprovidersDocs() { + private _isViewingSubprovidersDocs(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.Subproviders); } - private _isViewingWiki() { + private _isViewingWiki(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.Wiki); } - private _shouldDisplayBottomBar() { + private _shouldDisplayBottomBar(): boolean { return ( this._isViewingWiki() || this._isViewing0xjsDocs() || diff --git a/packages/website/ts/components/top_bar/top_bar_menu_item.tsx b/packages/website/ts/components/top_bar/top_bar_menu_item.tsx index c0e674b17..2e4254cfa 100644 --- a/packages/website/ts/components/top_bar/top_bar_menu_item.tsx +++ b/packages/website/ts/components/top_bar/top_bar_menu_item.tsx @@ -26,7 +26,7 @@ export class TopBarMenuItem extends React.Component { - public render() { + public render(): React.ReactNode { const isMultipleTokens = this.props.tokens.length > 1; const allTokens = _.values(this.props.tokenByAddress); return ( diff --git a/packages/website/ts/components/trade_history/trade_history.tsx b/packages/website/ts/components/trade_history/trade_history.tsx index 635358627..1ca9d866f 100644 --- a/packages/website/ts/components/trade_history/trade_history.tsx +++ b/packages/website/ts/components/trade_history/trade_history.tsx @@ -28,16 +28,16 @@ export class TradeHistory extends React.Component

Trade history

@@ -48,7 +48,7 @@ export class TradeHistory extends React.Component ); } - private _renderTrades() { + private _renderTrades(): React.ReactNode { const numNonCustomFills = this._numFillsWithoutCustomERC20Tokens(); if (numNonCustomFills === 0) { return this._renderEmptyNotice(); @@ -66,14 +66,14 @@ export class TradeHistory extends React.Component No filled orders yet. ); } - private _numFillsWithoutCustomERC20Tokens() { + private _numFillsWithoutCustomERC20Tokens(): number { let numNonCustomFills = 0; const tokens = _.values(this.props.tokenByAddress); _.each(this.state.sortedFills, fill => { @@ -93,7 +93,7 @@ export class TradeHistory extends React.Component { const sortedFills = this._getSortedFills(); if (!utils.deepEqual(sortedFills, this.state.sortedFills)) { @@ -103,10 +103,10 @@ export class TradeHistory extends React.Component fill.blockTimestamp * -1]); 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 dbe72259b..adca4d58c 100644 --- a/packages/website/ts/components/trade_history/trade_history_item.tsx +++ b/packages/website/ts/components/trade_history/trade_history_item.tsx @@ -23,7 +23,7 @@ interface TradeHistoryItemProps { interface TradeHistoryItemState {} export class TradeHistoryItem extends React.Component { - public render() { + public render(): React.ReactNode { const fill = this.props.fill; const tokens = _.values(this.props.tokenByAddress); const takerToken = _.find(tokens, token => { @@ -88,7 +88,7 @@ export class TradeHistoryItem extends React.Component ); } - private _renderAmounts(makerToken: Token, takerToken: Token) { + private _renderAmounts(makerToken: Token, takerToken: Token): React.ReactNode { const fill = this.props.fill; const filledTakerTokenAmountInUnits = ZeroEx.toUnitAmount(fill.filledTakerTokenAmount, takerToken.decimals); const filledMakerTokenAmountInUnits = ZeroEx.toUnitAmount(fill.filledMakerTokenAmount, takerToken.decimals); @@ -136,7 +136,7 @@ export class TradeHistoryItem extends React.Component ); } - private _renderDate() { + private _renderDate(): React.ReactNode { const blockMoment = moment.unix(this.props.fill.blockTimestamp); if (!blockMoment.isValid()) { return null; @@ -159,7 +159,7 @@ export class TradeHistoryItem extends React.Component ); } - private _renderAmount(amount: BigNumber, symbol: string, decimals: number) { + private _renderAmount(amount: BigNumber, symbol: string, decimals: number): React.ReactNode { const unitAmount = ZeroEx.toUnitAmount(amount, decimals); return ( diff --git a/packages/website/ts/components/ui/alert.tsx b/packages/website/ts/components/ui/alert.tsx index f81939255..b571d8c1c 100644 --- a/packages/website/ts/components/ui/alert.tsx +++ b/packages/website/ts/components/ui/alert.tsx @@ -7,7 +7,7 @@ interface AlertProps { message: string | React.ReactNode; } -export function Alert(props: AlertProps) { +export const Alert = (props: AlertProps) => { const isAlert = props.type === AlertTypes.ERROR; const errMsgStyles = { background: isAlert ? colors.red200 : colors.lightestGreen, @@ -22,4 +22,4 @@ export function Alert(props: AlertProps) { {props.message}
); -} +}; diff --git a/packages/website/ts/components/ui/copy_icon.tsx b/packages/website/ts/components/ui/copy_icon.tsx index d58e50815..2c2941067 100644 --- a/packages/website/ts/components/ui/copy_icon.tsx +++ b/packages/website/ts/components/ui/copy_icon.tsx @@ -23,14 +23,14 @@ export class CopyIcon extends React.Component { isHovering: false, }; } - public componentDidUpdate() { + public componentDidUpdate(): void { // Remove tooltip if hover away if (!this.state.isHovering && this._copyTooltipTimeoutId) { clearInterval(this._copyTooltipTimeoutId); this._hideTooltip(); } } - public render() { + public render(): React.ReactNode { return (
@@ -55,15 +55,15 @@ export class CopyIcon extends React.Component {
); } - private _setRefToProperty(el: HTMLInputElement) { + private _setRefToProperty(el: HTMLInputElement): void { this._copyable = el; } - private _setHoverState(isHovering: boolean) { + private _setHoverState(isHovering: boolean): void { this.setState({ isHovering, }); } - private _onCopy() { + private _onCopy(): void { if (this._copyTooltipTimeoutId) { clearInterval(this._copyTooltipTimeoutId); } @@ -73,7 +73,7 @@ export class CopyIcon extends React.Component { this._hideTooltip(); }, tooltipLifespanMs); } - private _hideTooltip() { + private _hideTooltip(): void { ReactTooltip.hide(ReactDOM.findDOMNode(this._copyable)); } } diff --git a/packages/website/ts/components/ui/drop_down.tsx b/packages/website/ts/components/ui/drop_down.tsx index 63b9eec0b..98a495581 100644 --- a/packages/website/ts/components/ui/drop_down.tsx +++ b/packages/website/ts/components/ui/drop_down.tsx @@ -35,15 +35,15 @@ export class DropDown extends React.Component { isDropDownOpen: false, }; } - public componentDidMount() { + public componentDidMount(): void { this._popoverCloseCheckIntervalId = window.setInterval(() => { this._checkIfShouldClosePopover(); }, CHECK_CLOSE_POPOVER_INTERVAL_MS); } - public componentWillUnmount() { + public componentWillUnmount(): void { window.clearInterval(this._popoverCloseCheckIntervalId); } - public componentWillReceiveProps(nextProps: DropDownProps) { + public componentWillReceiveProps(nextProps: DropDownProps): void { // HACK: If the popoverContent is updated to a different dimension and the users // mouse is no longer above it, the dropdown can enter an inconsistent state where // it believes the user is still hovering over it. In order to remedy this, we @@ -52,7 +52,7 @@ export class DropDown extends React.Component { // dropdowns from having dynamic content. this._onHoverOff(); } - public render() { + public render(): React.ReactNode { return (
{
); } - private _onHover(event: React.FormEvent) { + private _onHover(event: React.FormEvent): void { this._isHovering = true; this._checkIfShouldOpenPopover(event); } - private _checkIfShouldOpenPopover(event: React.FormEvent) { + private _checkIfShouldOpenPopover(event: React.FormEvent): void { if (this.state.isDropDownOpen) { return; // noop } @@ -91,16 +91,16 @@ export class DropDown extends React.Component { anchorEl: event.currentTarget, }); } - private _onHoverOff() { + private _onHoverOff(): void { this._isHovering = false; } - private _checkIfShouldClosePopover() { + private _checkIfShouldClosePopover(): void { if (!this.state.isDropDownOpen || this._isHovering) { return; // noop } this._closePopover(); } - private _closePopover() { + private _closePopover(): void { this.setState({ isDropDownOpen: false, }); diff --git a/packages/website/ts/components/ui/etherscan_icon.tsx b/packages/website/ts/components/ui/etherscan_icon.tsx index c1154d3d6..1b032c112 100644 --- a/packages/website/ts/components/ui/etherscan_icon.tsx +++ b/packages/website/ts/components/ui/etherscan_icon.tsx @@ -35,6 +35,6 @@ export const EtherScanIcon = (props: EtherScanIconProps) => { ); }; -function renderIcon() { +function renderIcon(): React.ReactNode { return ; } diff --git a/packages/website/ts/components/ui/fake_text_field.tsx b/packages/website/ts/components/ui/fake_text_field.tsx index 646ae98f6..ac3c30fec 100644 --- a/packages/website/ts/components/ui/fake_text_field.tsx +++ b/packages/website/ts/components/ui/fake_text_field.tsx @@ -21,7 +21,7 @@ interface FakeTextFieldProps { children?: any; } -export function FakeTextField(props: FakeTextFieldProps) { +export const FakeTextField = (props: FakeTextFieldProps) => { return (
{props.label !== '' && } @@ -31,4 +31,4 @@ export function FakeTextField(props: FakeTextFieldProps) {
); -} +}; diff --git a/packages/website/ts/components/ui/flash_message.tsx b/packages/website/ts/components/ui/flash_message.tsx index 2cb1fc764..2b866676d 100644 --- a/packages/website/ts/components/ui/flash_message.tsx +++ b/packages/website/ts/components/ui/flash_message.tsx @@ -19,7 +19,7 @@ export class FlashMessage extends React.Component { public static defaultProps: Partial = { style: {}, }; - public render() { + public render(): React.ReactNode { let address = this.props.address; if (_.isEmpty(address)) { address = constants.NULL_ADDRESS; diff --git a/packages/website/ts/components/ui/lifecycle_raised_button.tsx b/packages/website/ts/components/ui/lifecycle_raised_button.tsx index c85e11884..b06978f16 100644 --- a/packages/website/ts/components/ui/lifecycle_raised_button.tsx +++ b/packages/website/ts/components/ui/lifecycle_raised_button.tsx @@ -42,11 +42,11 @@ export class LifeCycleRaisedButton extends React.Component; } @@ -77,7 +77,7 @@ export class LifeCycleRaisedButton extends React.Component ); } - public async onClickAsync() { + public async onClickAsync(): Promise { this.setState({ buttonState: ButtonState.LOADING, }); diff --git a/packages/website/ts/components/ui/menu_item.tsx b/packages/website/ts/components/ui/menu_item.tsx index 3482f436c..64c0dc49d 100644 --- a/packages/website/ts/components/ui/menu_item.tsx +++ b/packages/website/ts/components/ui/menu_item.tsx @@ -24,7 +24,7 @@ export class MenuItem extends React.Component { isHovering: false, }; } - public render() { + public render(): React.ReactNode { const menuItemStyles = { cursor: 'pointer', opacity: this.state.isHovering ? 0.5 : 1, @@ -43,7 +43,7 @@ export class MenuItem extends React.Component { ); } - private _onToggleHover(isHovering: boolean) { + private _onToggleHover(isHovering: boolean): void { this.setState({ isHovering, }); diff --git a/packages/website/ts/components/ui/party.tsx b/packages/website/ts/components/ui/party.tsx index 3d94903d1..0d86a6db5 100644 --- a/packages/website/ts/components/ui/party.tsx +++ b/packages/website/ts/components/ui/party.tsx @@ -27,7 +27,7 @@ export class Party extends React.Component { identiconStyle: {}, identiconDiameter: IDENTICON_DIAMETER, }; - public render() { + public render(): React.ReactNode { const label = this.props.label; const address = this.props.address; const identiconDiameter = this.props.identiconDiameter; diff --git a/packages/website/ts/components/ui/swap_icon.tsx b/packages/website/ts/components/ui/swap_icon.tsx index e465a8074..4a6000d1b 100644 --- a/packages/website/ts/components/ui/swap_icon.tsx +++ b/packages/website/ts/components/ui/swap_icon.tsx @@ -17,7 +17,7 @@ export class SwapIcon extends React.Component { isHovering: false, }; } - public render() { + public render(): React.ReactNode { const swapStyles = { color: this.state.isHovering ? colors.amber600 : colors.amber800, fontSize: 50, @@ -34,7 +34,7 @@ export class SwapIcon extends React.Component {
); } - private _onToggleHover(isHovering: boolean) { + private _onToggleHover(isHovering: boolean): void { this.setState({ isHovering, }); diff --git a/packages/website/ts/components/ui/token_icon.tsx b/packages/website/ts/components/ui/token_icon.tsx index ff57a96de..a9ad567ef 100644 --- a/packages/website/ts/components/ui/token_icon.tsx +++ b/packages/website/ts/components/ui/token_icon.tsx @@ -11,7 +11,7 @@ interface TokenIconProps { interface TokenIconState {} export class TokenIcon extends React.Component { - public render() { + public render(): React.ReactNode { const token = this.props.token; const diameter = this.props.diameter; return ( diff --git a/packages/website/ts/components/visual_order.tsx b/packages/website/ts/components/visual_order.tsx index 3bf464e92..76a283547 100644 --- a/packages/website/ts/components/visual_order.tsx +++ b/packages/website/ts/components/visual_order.tsx @@ -20,7 +20,7 @@ interface VisualOrderProps { interface VisualOrderState {} export class VisualOrder extends React.Component { - public render() { + public render(): React.ReactNode { const allTokens = _.values(this.props.tokenByAddress); const makerImage = this.props.makerToken.iconUrl; const takerImage = this.props.takerToken.iconUrl; @@ -62,7 +62,7 @@ export class VisualOrder extends React.Component ); } - private _renderAmount(assetToken: AssetToken, token: Token) { + private _renderAmount(assetToken: AssetToken, token: Token): React.ReactNode { const unitAmount = ZeroEx.toUnitAmount(assetToken.amount, token.decimals); return (
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx index 079c0e3b3..95f31582e 100644 --- a/packages/website/ts/components/wallet/wallet.tsx +++ b/packages/website/ts/components/wallet/wallet.tsx @@ -162,15 +162,15 @@ export class Wallet extends React.Component { isHoveringSidebar: false, }; } - public componentWillMount() { + public componentWillMount(): void { const trackedTokenAddresses = _.keys(this.state.trackedTokenStateByAddress); // tslint:disable-next-line:no-floating-promises this._fetchBalancesAndAllowancesAsync(trackedTokenAddresses); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._isUnmounted = true; } - public componentWillReceiveProps(nextProps: WalletProps) { + public componentWillReceiveProps(nextProps: WalletProps): void { if ( nextProps.userAddress !== this.props.userAddress || nextProps.networkId !== this.props.networkId || @@ -196,11 +196,11 @@ export class Wallet extends React.Component { this._fetchBalancesAndAllowancesAsync(newTokenAddresses); } } - public render() { + public render(): React.ReactNode { const isReadyToRender = this.props.blockchainIsLoaded && this.props.blockchainErr === BlockchainErrs.NoError; return
{isReadyToRender && this._renderRows()}
; } - private _renderRows() { + private _renderRows(): React.ReactNode { const isAddressAvailable = !_.isEmpty(this.props.userAddress); return ( @@ -210,7 +210,7 @@ export class Wallet extends React.Component { ); } - private _renderDisconnectedHeaderRows() { + private _renderDisconnectedHeaderRows(): React.ReactElement<{}> { const userAddress = this.props.userAddress; const primaryText = 'wallet'; return ( @@ -223,7 +223,7 @@ export class Wallet extends React.Component { /> ); } - private _renderDisconnectedRows() { + private _renderDisconnectedRows(): React.ReactElement<{}> { return ( { /> ); } - private _renderConnectedHeaderRows() { + private _renderConnectedHeaderRows(): React.ReactElement<{}> { const userAddress = this.props.userAddress; const primaryText = utils.getAddressBeginAndEnd(userAddress); return ( @@ -246,7 +246,7 @@ export class Wallet extends React.Component { /> ); } - private _renderBody() { + private _renderBody(): React.ReactElement<{}> { const bodyStyle: React.CSSProperties = { ...styles.bodyInnerDiv, overflow: this.state.isHoveringSidebar ? 'auto' : 'hidden', @@ -263,17 +263,17 @@ export class Wallet extends React.Component { ); } - private _onSidebarHover(event: React.FormEvent) { + private _onSidebarHover(event: React.FormEvent): void { this.setState({ isHoveringSidebar: true, }); } - private _onSidebarHoverOff() { + private _onSidebarHoverOff(): void { this.setState({ isHoveringSidebar: false, }); } - private _renderFooterRows() { + private _renderFooterRows(): React.ReactElement<{}> { return ( { /> ); } - private _renderEthRows() { + private _renderEthRows(): React.ReactNode { const primaryText = this._renderAmount( this.props.userEtherBalanceInWei, constants.DECIMAL_PLACES_ETH, @@ -352,7 +352,7 @@ export class Wallet extends React.Component {
); } - private _renderTokenRows() { + private _renderTokenRows(): React.ReactNode { const trackedTokens = this.props.trackedTokens; const trackedTokensStartingWithEtherToken = trackedTokens.sort( firstBy((t: Token) => t.symbol !== ETHER_TOKEN_SYMBOL) @@ -361,7 +361,7 @@ export class Wallet extends React.Component { ); return _.map(trackedTokensStartingWithEtherToken, this._renderTokenRow.bind(this)); } - private _renderTokenRow(token: Token, index: number) { + private _renderTokenRow(token: Token, index: number): React.ReactNode { const tokenState = this.state.trackedTokenStateByAddress[token.address]; const tokenLink = sharedUtils.getEtherScanLinkIfExists( token.address, @@ -415,7 +415,7 @@ export class Wallet extends React.Component {
); } - private _renderAccessoryItems(config: AccessoryItemConfig) { + private _renderAccessoryItems(config: AccessoryItemConfig): React.ReactElement<{}> { const shouldShowWrappedEtherAction = !_.isUndefined(config.wrappedEtherDirection); const shouldShowToggle = !_.isUndefined(config.allowanceToggleConfig); return ( @@ -431,7 +431,7 @@ export class Wallet extends React.Component {
); } - private _renderAllowanceToggle(config: AllowanceToggleConfig) { + private _renderAllowanceToggle(config: AllowanceToggleConfig): React.ReactNode { return ( { /> ); } - private _renderAmount(amount: BigNumber, decimals: number, symbol: string) { + private _renderAmount(amount: BigNumber, decimals: number, symbol: string): React.ReactNode { const unitAmount = ZeroEx.toUnitAmount(amount, decimals); const formattedAmount = unitAmount.toPrecision(TOKEN_AMOUNT_DISPLAY_PRECISION); const result = `${formattedAmount} ${symbol}`; return
{result}
; } - private _renderValue(amount: BigNumber, decimals: number, price?: BigNumber) { + private _renderValue(amount: BigNumber, decimals: number, price?: BigNumber): React.ReactNode { if (_.isUndefined(price)) { return null; } @@ -462,7 +462,7 @@ export class Wallet extends React.Component { const result = `$${formattedAmount}`; return result; } - private _renderTokenIcon(token: Token, tokenLink?: string) { + private _renderTokenIcon(token: Token, tokenLink?: string): React.ReactElement<{}> { const tooltipId = `tooltip-${token.address}`; const tokenIcon = ; if (_.isUndefined(tokenLink)) { @@ -475,7 +475,7 @@ export class Wallet extends React.Component { ); } } - private _renderWrappedEtherButton(wrappedEtherDirection: Side) { + private _renderWrappedEtherButton(wrappedEtherDirection: Side): React.ReactNode { const isWrappedEtherDirectionOpen = this.state.wrappedEtherDirection === wrappedEtherDirection; let buttonLabel; let buttonIcon; @@ -510,7 +510,7 @@ export class Wallet extends React.Component { /> ); } - private _getInitialTrackedTokenStateByAddress(tokenAddresses: string[]) { + private _getInitialTrackedTokenStateByAddress(tokenAddresses: string[]): TokenStateByAddress { const trackedTokenStateByAddress: TokenStateByAddress = {}; _.each(tokenAddresses, tokenAddress => { trackedTokenStateByAddress[tokenAddress] = { @@ -521,7 +521,7 @@ export class Wallet extends React.Component { }); return trackedTokenStateByAddress; } - private async _fetchBalancesAndAllowancesAsync(tokenAddresses: string[]) { + private async _fetchBalancesAndAllowancesAsync(tokenAddresses: string[]): Promise { const balanceAndAllowanceTupleByAddress: ItemByAddress = {}; const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; for (const tokenAddress of tokenAddresses) { @@ -554,7 +554,7 @@ export class Wallet extends React.Component { }); } } - private async _refetchTokenStateAsync(tokenAddress: string) { + private async _refetchTokenStateAsync(tokenAddress: string): Promise { await this._fetchBalancesAndAllowancesAsync([tokenAddress]); } private async _getPriceByAddressAsync(tokenAddresses: string[]): Promise> { @@ -584,17 +584,17 @@ export class Wallet extends React.Component { return {}; } } - private _openWrappedEtherActionRow(wrappedEtherDirection: Side) { + private _openWrappedEtherActionRow(wrappedEtherDirection: Side): void { this.setState({ wrappedEtherDirection, }); } - private _closeWrappedEtherActionRow() { + private _closeWrappedEtherActionRow(): void { this.setState({ wrappedEtherDirection: undefined, }); } - private _getEthToken() { + private _getEthToken(): Token { const tokens = _.values(this.props.tokenByAddress); const etherToken = _.find(tokens, { symbol: ETHER_TOKEN_SYMBOL }); return etherToken; diff --git a/packages/website/ts/components/wallet/wrap_ether_item.tsx b/packages/website/ts/components/wallet/wrap_ether_item.tsx index a38163770..2ed924bcd 100644 --- a/packages/website/ts/components/wallet/wrap_ether_item.tsx +++ b/packages/website/ts/components/wallet/wrap_ether_item.tsx @@ -64,7 +64,7 @@ export class WrapEtherItem extends React.Component ); } - private _onValueChange(isValid: boolean, amount?: BigNumber) { + private _onValueChange(isValid: boolean, amount?: BigNumber): void { this.setState({ currentInputAmount: amount, currentInputHasErrors: !isValid, }); } - private _renderIsEthConversionHappeningSpinner() { + private _renderIsEthConversionHappeningSpinner(): React.ReactElement<{}> { return this.state.isEthConversionHappening ? (
) : null; } - private _renderWrapEtherConfirmationButton() { + private _renderWrapEtherConfirmationButton(): React.ReactElement<{}> { const isWrappingEth = this.props.direction === Side.Deposit; const labelText = isWrappingEth ? 'wrap' : 'unwrap'; return ( @@ -138,13 +138,13 @@ export class WrapEtherItem extends React.Component
); } - private async _wrapEtherConfirmationAction() { + private async _wrapEtherConfirmationActionAsync(): Promise { this.setState({ isEthConversionHappening: true, }); diff --git a/packages/website/ts/lazy_component.tsx b/packages/website/ts/lazy_component.tsx index 48800c2dd..dce06ed8d 100644 --- a/packages/website/ts/lazy_component.tsx +++ b/packages/website/ts/lazy_component.tsx @@ -21,22 +21,22 @@ export class LazyComponent extends React.Component { const component = await props.reactComponentPromise; this.setState({ component, diff --git a/packages/website/ts/local_storage/local_storage.ts b/packages/website/ts/local_storage/local_storage.ts index d94e6877b..20a533a91 100644 --- a/packages/website/ts/local_storage/local_storage.ts +++ b/packages/website/ts/local_storage/local_storage.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; export const localStorage = { - doesExist() { + doesExist(): boolean { return !!window.localStorage; }, getItemIfExists(key: string): string { @@ -14,13 +14,13 @@ export const localStorage = { } return item; }, - setItem(key: string, value: string) { + setItem(key: string, value: string): void { if (!this.doesExist || _.isUndefined(value)) { return; } window.localStorage.setItem(key, value); }, - removeItem(key: string) { + removeItem(key: string): void { if (!this.doesExist) { return; } diff --git a/packages/website/ts/local_storage/trade_history_storage.tsx b/packages/website/ts/local_storage/trade_history_storage.tsx index df731236e..cc764d98e 100644 --- a/packages/website/ts/local_storage/trade_history_storage.tsx +++ b/packages/website/ts/local_storage/trade_history_storage.tsx @@ -14,7 +14,7 @@ export const tradeHistoryStorage = { // Clear all fill related localStorage if we've updated the config variable in an update // that introduced a backward incompatible change requiring the user to re-fetch the fills from // the blockchain - clearIfRequired() { + clearIfRequired(): void { const lastClearFillDate = localStorage.getItemIfExists(FILL_CLEAR_KEY); if (lastClearFillDate !== configs.LAST_LOCAL_STORAGE_FILL_CLEARANCE_DATE) { const localStorageKeys = localStorage.getAllKeys(); @@ -26,7 +26,7 @@ export const tradeHistoryStorage = { } localStorage.setItem(FILL_CLEAR_KEY, configs.LAST_LOCAL_STORAGE_FILL_CLEARANCE_DATE); }, - addFillToUser(userAddress: string, networkId: number, fill: Fill) { + addFillToUser(userAddress: string, networkId: number, fill: Fill): void { const fillsByHash = this.getUserFillsByHash(userAddress, networkId); const fillHash = this._getFillHash(fill); const doesFillExist = !_.isUndefined(fillsByHash[fillHash]); @@ -38,7 +38,7 @@ export const tradeHistoryStorage = { const userFillsKey = this._getUserFillsKey(userAddress, networkId); localStorage.setItem(userFillsKey, userFillsJSONString); }, - removeFillFromUser(userAddress: string, networkId: number, fill: Fill) { + removeFillFromUser(userAddress: string, networkId: number, fill: Fill): void { const fillsByHash = this.getUserFillsByHash(userAddress, networkId); const fillHash = this._getFillHash(fill); const doesFillExist = !_.isUndefined(fillsByHash[fillHash]); @@ -74,15 +74,15 @@ export const tradeHistoryStorage = { const blockNumber = _.parseInt(blockNumberStr); return blockNumber; }, - setFillsLatestBlock(userAddress: string, networkId: number, blockNumber: number) { + setFillsLatestBlock(userAddress: string, networkId: number, blockNumber: number): void { const userFillsLatestBlockKey = this._getFillsLatestBlockKey(userAddress, networkId); localStorage.setItem(userFillsLatestBlockKey, `${blockNumber}`); }, - _getUserFillsKey(userAddress: string, networkId: number) { + _getUserFillsKey(userAddress: string, networkId: number): string { const userFillsKey = `${FILLS_KEY}-${userAddress}-${networkId}`; return userFillsKey; }, - _getFillsLatestBlockKey(userAddress: string, networkId: number) { + _getFillsLatestBlockKey(userAddress: string, networkId: number): string { const userFillsLatestBlockKey = `${FILLS_LATEST_BLOCK}-${userAddress}-${networkId}`; return userFillsLatestBlockKey; }, diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx index d78cca703..673022329 100644 --- a/packages/website/ts/pages/about/about.tsx +++ b/packages/website/ts/pages/about/about.tsx @@ -210,10 +210,10 @@ const styles: Styles = { }; export class About extends React.Component { - public componentDidMount() { + public componentDidMount(): void { window.scrollTo(0, 0); } - public render() { + public render(): React.ReactNode { return (
@@ -284,7 +284,7 @@ export class About extends React.Component {
); } - private _renderProfiles(profiles: ProfileInfo[]) { + private _renderProfiles(profiles: ProfileInfo[]): React.ReactNode { const numIndiv = profiles.length; const colSize = utils.getColSize(numIndiv); return _.map(profiles, profile => { diff --git a/packages/website/ts/pages/about/profile.tsx b/packages/website/ts/pages/about/profile.tsx index 4361da103..dd046a8cb 100644 --- a/packages/website/ts/pages/about/profile.tsx +++ b/packages/website/ts/pages/about/profile.tsx @@ -22,7 +22,7 @@ interface ProfileProps { profileInfo: ProfileInfo; } -export function Profile(props: ProfileProps) { +export const Profile = (props: ProfileProps) => { return (
@@ -53,9 +53,9 @@ export function Profile(props: ProfileProps) {
); -} +}; -function renderSocialMediaIcons(profileInfo: ProfileInfo) { +function renderSocialMediaIcons(profileInfo: ProfileInfo): React.ReactNode { const icons = [ renderSocialMediaIcon('zmdi-github-box', profileInfo.github), renderSocialMediaIcon('zmdi-linkedin-box', profileInfo.linkedIn), @@ -64,7 +64,7 @@ function renderSocialMediaIcons(profileInfo: ProfileInfo) { return icons; } -function renderSocialMediaIcon(iconName: string, url: string) { +function renderSocialMediaIcon(iconName: string, url: string): React.ReactNode { if (_.isEmpty(url)) { return null; } diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx index be8ae02f4..17efc56ed 100644 --- a/packages/website/ts/pages/documentation/doc_page.tsx +++ b/packages/website/ts/pages/documentation/doc_page.tsx @@ -59,7 +59,7 @@ export class DocPage extends React.Component { docAgnosticFormat: undefined, }; } - public componentWillMount() { + public componentWillMount(): void { const pathName = this.props.location.pathname; const lastSegment = pathName.substr(pathName.lastIndexOf('/') + 1); const versions = findVersions(lastSegment); @@ -67,10 +67,10 @@ export class DocPage extends React.Component { // tslint:disable-next-line:no-floating-promises this._fetchJSONDocsFireAndForgetAsync(preferredVersionIfExists); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._isUnmounted = true; } - public render() { + public render(): React.ReactNode { const menuSubsectionsBySection = _.isUndefined(this.state.docAgnosticFormat) ? {} : this.props.docsInfo.getMenuSubsectionsBySection(this.state.docAgnosticFormat); @@ -135,7 +135,7 @@ export class DocPage extends React.Component { }); } } - private _getSourceUrl() { + private _getSourceUrl(): string { const url = this.props.docsInfo.packageUrl; let pkg = docIdToSubpackageName[this.props.docsInfo.id]; let tagPrefix = pkg; @@ -155,7 +155,7 @@ export class DocPage extends React.Component { const sourceUrl = `${url}/blob/${tagPrefix}%40${this.props.docsVersion}/packages${pkg}`; return sourceUrl; } - private _onVersionSelected(semver: string) { + private _onVersionSelected(semver: string): void { let path = window.location.pathname; const lastChar = path[path.length - 1]; if (_.isFinite(_.parseInt(lastChar))) { diff --git a/packages/website/ts/pages/faq/faq.tsx b/packages/website/ts/pages/faq/faq.tsx index 701031d44..c9295d806 100644 --- a/packages/website/ts/pages/faq/faq.tsx +++ b/packages/website/ts/pages/faq/faq.tsx @@ -404,10 +404,10 @@ const sections: FAQSection[] = [ ]; export class FAQ extends React.Component { - public componentDidMount() { + public componentDidMount(): void { window.scrollTo(0, 0); } - public render() { + public render(): React.ReactNode { return (
@@ -422,7 +422,7 @@ export class FAQ extends React.Component {
); } - private _renderSections() { + private _renderSections(): React.ReactNode { const renderedSections = _.map(sections, (section: FAQSection, i: number) => { const isFirstSection = i === 0; return ( @@ -434,7 +434,7 @@ export class FAQ extends React.Component { }); return renderedSections; } - private _renderQuestions(questions: FAQQuestion[], isFirstSection: boolean) { + private _renderQuestions(questions: FAQQuestion[], isFirstSection: boolean): React.ReactNode { const renderedQuestions = _.map(questions, (question: FAQQuestion, i: number) => { const isFirstQuestion = i === 0; return ( diff --git a/packages/website/ts/pages/faq/question.tsx b/packages/website/ts/pages/faq/question.tsx index 240dae910..28ea6881a 100644 --- a/packages/website/ts/pages/faq/question.tsx +++ b/packages/website/ts/pages/faq/question.tsx @@ -20,7 +20,7 @@ export class Question extends React.Component { isExpanded: props.shouldDisplayExpanded, }; } - public render() { + public render(): React.ReactNode { return (
{
); } - private _onExchangeChange() { + private _onExchangeChange(): void { this.setState({ isExpanded: !this.state.isExpanded, }); diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx index a63c24fb7..02ecfa117 100644 --- a/packages/website/ts/pages/landing/landing.tsx +++ b/packages/website/ts/pages/landing/landing.tsx @@ -177,14 +177,14 @@ export class Landing extends React.Component { }; this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT); } - public componentDidMount() { + public componentDidMount(): void { window.addEventListener('resize', this._throttledScreenWidthUpdate); window.scrollTo(0, 0); } - public componentWillUnmount() { + public componentWillUnmount(): void { window.removeEventListener('resize', this._throttledScreenWidthUpdate); } - public render() { + public render(): React.ReactNode { return (
@@ -218,7 +218,7 @@ export class Landing extends React.Component {
); } - private _renderHero() { + private _renderHero(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const buttonLabelStyle: React.CSSProperties = { textTransform: 'none', @@ -305,7 +305,7 @@ export class Landing extends React.Component {
); } - private _renderWhatsNew() { + private _renderWhatsNew(): React.ReactNode { return (
); } - private _renderProjects(projects: Project[], title: string, backgroundColor: string, isTitleCenter: boolean) { + private _renderProjects( + projects: Project[], + title: string, + backgroundColor: string, + isTitleCenter: boolean, + ): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const projectList = _.map(projects, (project: Project, i: number) => { const isRelayersOnly = projects.length === 12; @@ -393,7 +398,7 @@ export class Landing extends React.Component {
); } - private _renderTokenizationSection() { + private _renderTokenizationSection(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -424,7 +429,7 @@ export class Landing extends React.Component {
); } - private _renderProtocolSection() { + private _renderProtocolSection(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -469,7 +474,7 @@ export class Landing extends React.Component {
); } - private _renderBuildingBlocksSection() { + private _renderBuildingBlocksSection(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const descriptionStyle: React.CSSProperties = { fontFamily: 'Roboto Mono', @@ -526,7 +531,7 @@ export class Landing extends React.Component {
); } - private _renderBlockChipImage() { + private _renderBlockChipImage(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -534,7 +539,7 @@ export class Landing extends React.Component {
); } - private _renderTokenCloud() { + private _renderTokenCloud(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -542,7 +547,7 @@ export class Landing extends React.Component {
); } - private _renderAssetTypes() { + private _renderAssetTypes(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const assetTypes: AssetType[] = [ { @@ -585,7 +590,7 @@ export class Landing extends React.Component { }); return assets; } - private _renderInfoBoxes() { + private _renderInfoBoxes(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const boxStyle: React.CSSProperties = { maxWidth: 253, @@ -648,7 +653,7 @@ export class Landing extends React.Component {
); } - private _renderUseCases() { + private _renderUseCases(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const useCases: UseCase[] = [ @@ -746,7 +751,7 @@ export class Landing extends React.Component {
); } - private _renderCallToAction() { + private _renderCallToAction(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const buttonLabelStyle: React.CSSProperties = { textTransform: 'none', @@ -793,7 +798,7 @@ export class Landing extends React.Component {
); } - private _updateScreenWidth() { + private _updateScreenWidth(): void { const newScreenWidth = utils.getScreenWidth(); if (newScreenWidth !== this.state.screenWidth) { this.setState({ @@ -801,7 +806,7 @@ export class Landing extends React.Component { }); } } - private _onLanguageSelected(language: Language) { + private _onLanguageSelected(language: Language): void { this.props.dispatcher.updateSelectedLanguage(language); } } // 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 ff25a35e9..96c73d4ec 100644 --- a/packages/website/ts/pages/not_found.tsx +++ b/packages/website/ts/pages/not_found.tsx @@ -21,7 +21,7 @@ const styles: Styles = { }; export class NotFound extends React.Component { - public render() { + public render(): React.ReactNode { return (
diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx index edca5834d..720c1cc37 100644 --- a/packages/website/ts/pages/wiki/wiki.tsx +++ b/packages/website/ts/pages/wiki/wiki.tsx @@ -69,19 +69,19 @@ export class Wiki extends React.Component { isHoveringSidebar: false, }; } - public componentDidMount() { + public componentDidMount(): void { window.addEventListener('hashchange', this._onHashChanged.bind(this), false); } - public componentWillMount() { + public componentWillMount(): void { // tslint:disable-next-line:no-floating-promises this._fetchArticlesBySectionAsync(); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._isUnmounted = true; clearTimeout(this._wikiBackoffTimeoutId); window.removeEventListener('hashchange', this._onHashChanged.bind(this), false); } - public render() { + public render(): React.ReactNode { const menuSubsectionsBySection = _.isUndefined(this.state.articlesBySection) ? {} : this._getMenuSubsectionsBySection(this.state.articlesBySection); @@ -171,7 +171,7 @@ export class Wiki extends React.Component { const sections = _.map(sectionNames, sectionName => this._renderSection(sectionName)); return sections; } - private _renderSection(sectionName: string) { + private _renderSection(sectionName: string): React.ReactNode { const articles = this.state.articlesBySection[sectionName]; const renderedArticles = _.map(articles, (article: Article) => { const githubLink = `${constants.URL_GITHUB_WIKI}/edit/master/${sectionName}/${article.fileName}`; @@ -227,7 +227,7 @@ export class Wiki extends React.Component { } } } - private _getMenuSubsectionsBySection(articlesBySection: ArticlesBySection) { + private _getMenuSubsectionsBySection(articlesBySection: ArticlesBySection): { [section: string]: string[] } { const sectionNames = _.keys(articlesBySection); const menuSubsectionsBySection: { [section: string]: string[] } = {}; for (const sectionName of sectionNames) { @@ -237,17 +237,17 @@ export class Wiki extends React.Component { } return menuSubsectionsBySection; } - private _onSidebarHover(event: React.FormEvent) { + private _onSidebarHover(event: React.FormEvent): void { this.setState({ isHoveringSidebar: true, }); } - private _onSidebarHoverOff() { + private _onSidebarHoverOff(): void { this.setState({ isHoveringSidebar: false, }); } - private _onHashChanged(event: any) { + private _onHashChanged(event: any): void { const hash = window.location.hash.slice(1); sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID); } diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts index 13e9a10cc..981522360 100644 --- a/packages/website/ts/redux/dispatcher.ts +++ b/packages/website/ts/redux/dispatcher.ts @@ -22,47 +22,47 @@ export class Dispatcher { this._dispatch = dispatch; } // Portal - public resetState() { + public resetState(): void { this._dispatch({ type: ActionTypes.ResetState, }); } - public updateNodeVersion(nodeVersion: string) { + public updateNodeVersion(nodeVersion: string): void { this._dispatch({ data: nodeVersion, type: ActionTypes.UpdateNodeVersion, }); } - public updateScreenWidth(screenWidth: ScreenWidths) { + public updateScreenWidth(screenWidth: ScreenWidths): void { this._dispatch({ data: screenWidth, type: ActionTypes.UpdateScreenWidth, }); } - public swapAssetTokenSymbols() { + public swapAssetTokenSymbols(): void { this._dispatch({ type: ActionTypes.SwapAssetTokens, }); } - public updateOrderSalt(salt: BigNumber) { + public updateOrderSalt(salt: BigNumber): void { this._dispatch({ data: salt, type: ActionTypes.UpdateOrderSalt, }); } - public updateUserSuppliedOrderCache(order: Order) { + public updateUserSuppliedOrderCache(order: Order): void { this._dispatch({ data: order, type: ActionTypes.UpdateUserSuppliedOrderCache, }); } - public updateShouldBlockchainErrDialogBeOpen(shouldBeOpen: boolean) { + public updateShouldBlockchainErrDialogBeOpen(shouldBeOpen: boolean): void { this._dispatch({ data: shouldBeOpen, type: ActionTypes.UpdateShouldBlockchainErrDialogBeOpen, }); } - public updateChosenAssetToken(side: Side, token: AssetToken) { + public updateChosenAssetToken(side: Side, token: AssetToken): void { this._dispatch({ data: { side, @@ -71,7 +71,7 @@ export class Dispatcher { type: ActionTypes.UpdateChosenAssetToken, }); } - public updateChosenAssetTokenAddress(side: Side, address: string) { + public updateChosenAssetTokenAddress(side: Side, address: string): void { this._dispatch({ data: { address, @@ -80,43 +80,43 @@ export class Dispatcher { type: ActionTypes.UpdateChosenAssetTokenAddress, }); } - public updateOrderTakerAddress(address: string) { + public updateOrderTakerAddress(address: string): void { this._dispatch({ data: address, type: ActionTypes.UpdateOrderTakerAddress, }); } - public updateUserAddress(address?: string) { + public updateUserAddress(address?: string): void { this._dispatch({ data: address, type: ActionTypes.UpdateUserAddress, }); } - public updateOrderExpiry(unixTimestampSec: BigNumber) { + public updateOrderExpiry(unixTimestampSec: BigNumber): void { this._dispatch({ data: unixTimestampSec, type: ActionTypes.UpdateOrderExpiry, }); } - public encounteredBlockchainError(err: BlockchainErrs) { + public encounteredBlockchainError(err: BlockchainErrs): void { this._dispatch({ data: err, type: ActionTypes.BlockchainErrEncountered, }); } - public updateBlockchainIsLoaded(isLoaded: boolean) { + public updateBlockchainIsLoaded(isLoaded: boolean): void { this._dispatch({ data: isLoaded, type: ActionTypes.UpdateBlockchainIsLoaded, }); } - public addTokenToTokenByAddress(token: Token) { + public addTokenToTokenByAddress(token: Token): void { this._dispatch({ data: token, type: ActionTypes.AddTokenToTokenByAddress, }); } - public removeTokenToTokenByAddress(token: Token) { + public removeTokenToTokenByAddress(token: Token): void { this._dispatch({ data: token, type: ActionTypes.RemoveTokenFromTokenByAddress, @@ -127,7 +127,7 @@ export class Dispatcher { networkId: number, userAddressIfExists: string | undefined, sideToAssetToken: SideToAssetToken, - ) { + ): void { this._dispatch({ data: { tokenByAddress, @@ -138,36 +138,36 @@ export class Dispatcher { type: ActionTypes.BatchDispatch, }); } - public updateTokenByAddress(tokens: Token[]) { + public updateTokenByAddress(tokens: Token[]): void { this._dispatch({ data: tokens, type: ActionTypes.UpdateTokenByAddress, }); } - public forceTokenStateRefetch() { + public forceTokenStateRefetch(): void { this._dispatch({ type: ActionTypes.ForceTokenStateRefetch, }); } - public updateECSignature(ecSignature: ECSignature) { + public updateECSignature(ecSignature: ECSignature): void { this._dispatch({ data: ecSignature, type: ActionTypes.UpdateOrderECSignature, }); } - public updateUserWeiBalance(balance: BigNumber) { + public updateUserWeiBalance(balance: BigNumber): void { this._dispatch({ data: balance, type: ActionTypes.UpdateUserEtherBalance, }); } - public updateNetworkId(networkId: number) { + public updateNetworkId(networkId: number): void { this._dispatch({ data: networkId, type: ActionTypes.UpdateNetworkId, }); } - public updateOrderFillAmount(amount: BigNumber) { + public updateOrderFillAmount(amount: BigNumber): void { this._dispatch({ data: amount, type: ActionTypes.UpdateOrderFillAmount, @@ -175,13 +175,13 @@ export class Dispatcher { } // Docs - public updateCurrentDocsVersion(version: string) { + public updateCurrentDocsVersion(version: string): void { this._dispatch({ data: version, type: ActionTypes.UpdateLibraryVersion, }); } - public updateAvailableDocVersions(versions: string[]) { + public updateAvailableDocVersions(versions: string[]): void { this._dispatch({ data: versions, type: ActionTypes.UpdateAvailableLibraryVersions, @@ -189,30 +189,30 @@ export class Dispatcher { } // Shared - public showFlashMessage(msg: string | React.ReactNode) { + public showFlashMessage(msg: string | React.ReactNode): void { this._dispatch({ data: msg, type: ActionTypes.ShowFlashMessage, }); } - public hideFlashMessage() { + public hideFlashMessage(): void { this._dispatch({ type: ActionTypes.HideFlashMessage, }); } - public updateProviderType(providerType: ProviderType) { + public updateProviderType(providerType: ProviderType): void { this._dispatch({ type: ActionTypes.UpdateProviderType, data: providerType, }); } - public updateInjectedProviderName(injectedProviderName: string) { + public updateInjectedProviderName(injectedProviderName: string): void { this._dispatch({ type: ActionTypes.UpdateInjectedProviderName, data: injectedProviderName, }); } - public updateSelectedLanguage(language: Language) { + public updateSelectedLanguage(language: Language): void { this._dispatch({ type: ActionTypes.UpdateSelectedLanguage, data: language, diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index a628f65c2..bb8f1472b 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -91,7 +91,7 @@ const INITIAL_STATE: State = { translate: new Translate(), }; -export function reducer(state: State = INITIAL_STATE, action: Action) { +export function reducer(state: State = INITIAL_STATE, action: Action): State { switch (action.type) { // Portal case ActionTypes.ResetState: diff --git a/packages/website/ts/utils/analytics.ts b/packages/website/ts/utils/analytics.ts index 37c47c7b0..928e45bc3 100644 --- a/packages/website/ts/utils/analytics.ts +++ b/packages/website/ts/utils/analytics.ts @@ -5,10 +5,10 @@ import { utils } from 'ts/utils/utils'; import * as Web3 from 'web3'; export const analytics = { - init() { + init(): void { ReactGA.initialize(configs.GOOGLE_ANALYTICS_ID); }, - logEvent(category: string, action: string, label: string, value?: any) { + logEvent(category: string, action: string, label: string, value?: any): void { ReactGA.event({ category, action, @@ -16,7 +16,7 @@ export const analytics = { value, }); }, - async logProviderAsync(web3IfExists: Web3) { + async logProviderAsync(web3IfExists: Web3): Promise { await utils.onPageLoadAsync(); const providerType = !_.isUndefined(web3IfExists) ? utils.getProviderType(web3IfExists.currentProvider) diff --git a/packages/website/ts/utils/translate.ts b/packages/website/ts/utils/translate.ts index 5148e48ad..39924b6f7 100644 --- a/packages/website/ts/utils/translate.ts +++ b/packages/website/ts/utils/translate.ts @@ -42,10 +42,10 @@ export class Translate { } this.setLanguage(language); } - public getLanguage() { + public getLanguage(): Language { return this._selectedLanguage; } - public setLanguage(language: Language) { + public setLanguage(language: Language): void { const isLanguageSupported = !_.isUndefined(languageToTranslations[language]); if (!isLanguageSupported) { throw new Error(`${language} not supported`); @@ -53,7 +53,7 @@ export class Translate { this._selectedLanguage = language; this._translation = languageToTranslations[language]; } - public get(key: Key, decoration?: Deco) { + public get(key: Key, decoration?: Deco): string { let text = this._translation[key]; if (!_.isUndefined(decoration) && !_.includes(languagesWithoutCaps, this._selectedLanguage)) { switch (decoration) { @@ -77,7 +77,7 @@ export class Translate { } return text; } - private _capitalize(text: string) { + private _capitalize(text: string): string { return `${text.charAt(0).toUpperCase()}${text.slice(1)}`; } } diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 472870f31..bf30f4e04 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -25,15 +25,15 @@ const LG_MIN_EM = 64; const MD_MIN_EM = 52; export const utils = { - assert(condition: boolean, message: string) { + assert(condition: boolean, message: string): void { if (!condition) { throw new Error(message); } }, - spawnSwitchErr(name: string, value: any) { + spawnSwitchErr(name: string, value: any): Error { return new Error(`Unexpected switch value: ${value} encountered for ${name}`); }, - isNumeric(n: string) { + isNumeric(n: string): boolean { return !isNaN(parseFloat(n)) && isFinite(Number(n)); }, // This default unix timestamp is used for orders where the user does not specify an expiry date. @@ -106,13 +106,13 @@ export const utils = { }; return order; }, - async sleepAsync(ms: number) { - return new Promise(resolve => setTimeout(resolve, ms)); + async sleepAsync(ms: number): Promise { + return new Promise(resolve => setTimeout(resolve, ms)); }, - deepEqual(actual: any, expected: any, opts?: { strict: boolean }) { + deepEqual(actual: any, expected: any, opts?: { strict: boolean }): boolean { return deepEqual(actual, expected, opts); }, - getColSize(items: number) { + getColSize(items: number): number { const bassCssGridSize = 12; // Source: http://basscss.com/#basscss-grid const colSize = bassCssGridSize / items; if (!_.isInteger(colSize)) { @@ -120,7 +120,7 @@ export const utils = { } return colSize; }, - getScreenWidth() { + getScreenWidth(): ScreenWidths { const documentEl = document.documentElement; const body = document.getElementsByTagName('body')[0]; const widthInPx = window.innerWidth || documentEl.clientWidth || body.clientWidth; @@ -162,7 +162,7 @@ export const utils = { // This checks the error message returned from an injected Web3 instance on the page // after a user was prompted to sign a message or send a transaction and decided to // reject the request. - didUserDenyWeb3Request(errMsg: string) { + didUserDenyWeb3Request(errMsg: string): boolean { const metamaskDenialErrMsg = 'User denied'; const paritySignerDenialErrMsg = 'Request has been rejected'; const ledgerDenialErrMsg = 'Invalid status 6985'; @@ -172,7 +172,7 @@ export const utils = { _.includes(errMsg, ledgerDenialErrMsg); return isUserDeniedErrMsg; }, - getCurrentEnvironment() { + getCurrentEnvironment(): string { switch (location.host) { case configs.DOMAIN_DEVELOPMENT: return 'development'; @@ -188,7 +188,7 @@ export const utils = { const truncatedAddress = `${address.substring(0, 6)}...${address.substr(-4)}`; // 0x3d5a...b287 return truncatedAddress; }, - hasUniqueNameAndSymbol(tokens: Token[], token: Token) { + hasUniqueNameAndSymbol(tokens: Token[], token: Token): boolean { if (token.isRegistered) { return true; // Since it's registered, it is the canonical token } @@ -269,7 +269,7 @@ export const utils = { ); return isTestNetwork; }, - getCurrentBaseUrl() { + getCurrentBaseUrl(): string { const port = window.location.port; const hasPort = !_.isUndefined(port); const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`; @@ -302,10 +302,10 @@ export const utils = { } return parsedProviderName; }, - isDevelopment() { + isDevelopment(): boolean { return configs.ENVIRONMENT === Environments.DEVELOPMENT; }, - isStaging() { + isStaging(): boolean { return _.includes(window.location.href, configs.DOMAIN_STAGING); }, }; -- cgit From 478f6ed011185b66ac87323c6d9ad1f598060760 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 14 May 2018 19:23:50 +0200 Subject: Move from using lerna multi-package commands to wsrun, update README's accordingly --- packages/website/README.md | 8 +++----- packages/website/package.json | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'packages/website') diff --git a/packages/website/README.md b/packages/website/README.md index d93d18935..7115a3b5c 100644 --- a/packages/website/README.md +++ b/packages/website/README.md @@ -30,18 +30,16 @@ yarn install ### Initial setup -The **first** time you work with this package, you must build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory: +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -yarn lerna:rebuild +PKG=@0xproject/website yarn build ``` ### Run dev server -The the `website` root directory, run: - ```bash -yarn dev +PKG=@0xproject/website yarn watch ``` Visit [0xproject.localhost:3572](http://0xproject.localhost:3572) in your browser. diff --git a/packages/website/package.json b/packages/website/package.json index ad84a3eb9..286ceaca8 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -7,7 +7,7 @@ "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", + "watch": "webpack-dev-server --content-base public --https", "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", "deploy_live": "npm run build; aws s3 sync ./public/. s3://0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers" }, -- cgit From f86cc0dc7a5d75792b8ef7a38cbf9bba04cb6ab4 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 9 May 2018 13:29:43 -0700 Subject: Document Node.js version requirement and add it to package.json --- packages/website/package.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages/website') diff --git a/packages/website/package.json b/packages/website/package.json index ad84a3eb9..9ec2b0ae5 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,9 @@ { "name": "@0xproject/website", "version": "0.0.32", + "engines": { + "node" : ">=8.0.0" + }, "private": true, "description": "Website and 0x portal dapp", "scripts": { -- cgit From fdeab0475c956c48ab79bb5238ae60e732b14e11 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 10 May 2018 11:46:02 -0700 Subject: Change minimum Node version to 6.12 --- packages/website/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/website') diff --git a/packages/website/package.json b/packages/website/package.json index 9ec2b0ae5..707fea108 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -2,7 +2,7 @@ "name": "@0xproject/website", "version": "0.0.32", "engines": { - "node" : ">=8.0.0" + "node" : ">=6.12" }, "private": true, "description": "Website and 0x portal dapp", -- cgit From b3e53b609b997921aa11063f7ccb513682d1c621 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 14 May 2018 22:49:08 -0700 Subject: Change to weekly txn volume --- packages/website/ts/components/relayer_index/relayer_grid_tile.tsx | 6 +++--- packages/website/ts/types.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx index 592bff29f..5964dcd56 100644 --- a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx +++ b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx @@ -47,7 +47,7 @@ const styles: Styles = { width: '100%', boxSizing: 'border-box', }, - dailyTradeVolumeLabel: { + weeklyTradeVolumeLabel: { fontSize: 14, color: colors.mediumBlue, }, @@ -80,9 +80,9 @@ export const RelayerGridTile: React.StatelessComponent = (
{props.relayerInfo.name}
-
{props.relayerInfo.dailyTxnVolume}
+
{props.relayerInfo.weeklyTxnVolume}
- Daily Trade Volume + Weekly Trade Volume
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 58929a0c6..5caf5e73c 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -506,7 +506,7 @@ export interface TokenState { export interface WebsiteBackendRelayerInfo { name: string; - dailyTxnVolume: string; + weeklyTxnVolume: string; url: string; appUrl?: string; headerImgUrl?: string; -- cgit From ca08dd9705c2aefb092b10926af359ed8fabac79 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 15 May 2018 00:52:51 -0700 Subject: Add hover state to top tokens --- .../relayer_index/relayer_top_tokens.tsx | 53 ++++++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx b/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx index 468a350e4..03c70c9dd 100644 --- a/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx +++ b/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx @@ -26,21 +26,54 @@ export const TopTokens: React.StatelessComponent = (props: TopTo {_.map(props.tokens, (tokenInfo: WebsiteBackendTokenInfo, index: number) => { const firstItemStyle = { ...styles.tokenLabel, ...styles.followingTokenLabel }; const style = index !== 0 ? firstItemStyle : styles.tokenLabel; - return ( - - {tokenInfo.symbol} - - ); + return ; })}
); }; +interface TokenLinkProps { + tokenInfo: WebsiteBackendTokenInfo; + style: React.CSSProperties; + networkId: number; +} +interface TokenLinkState { + isHovering: boolean; +} + +class TokenLink extends React.Component { + constructor(props: TokenLinkProps) { + super(props); + this.state = { + isHovering: false, + }; + } + public render(): React.ReactNode { + const style = { + ...this.props.style, + cursor: 'pointer', + opacity: this.state.isHovering ? 0.5 : 1, + }; + return ( + + {this.props.tokenInfo.symbol} + + ); + } + private _onToggleHover(isHovering: boolean): void { + this.setState({ + isHovering, + }); + } +} + function tokenLinkFromToken(tokenInfo: WebsiteBackendTokenInfo, networkId: number): string { return sharedUtils.getEtherScanLinkIfExists(tokenInfo.address, networkId, EtherscanLinkSuffixes.Address); } -- cgit From 184232ba4fe304bb00a3dbbee21972b1ff29736b Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 15 May 2018 13:51:43 -0700 Subject: Add dogfood configs to website --- packages/website/package.json | 1 + packages/website/ts/index.tsx | 2 +- packages/website/ts/utils/configs.ts | 6 +++++- packages/website/ts/utils/utils.ts | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'packages/website') diff --git a/packages/website/package.json b/packages/website/package.json index 538aa91a7..f1b2a1750 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -11,6 +11,7 @@ "clean": "shx rm -f public/bundle*", "lint": "tslint --project . 'ts/**/*.ts' 'ts/**/*.tsx'", "watch": "webpack-dev-server --content-base public --https", + "deploy_dogfood": "npm run build; aws s3 sync ./public/. s3://dogfood-0xproject --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers", "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", "deploy_live": "npm run build; aws s3 sync ./public/. s3://0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers" }, diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index 49bcdeaac..f255f81e7 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -35,7 +35,7 @@ import 'less/all.less'; // 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 = - utils.isDevelopment() || utils.isStaging() + utils.isDevelopment() || utils.isStaging() || utils.isDogfood() ? createLazyComponent('Portal', async () => System.import(/* webpackChunkName: "portal" */ 'ts/containers/portal'), ) diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts index a54fc56a8..bea9c4ee2 100644 --- a/packages/website/ts/utils/configs.ts +++ b/packages/website/ts/utils/configs.ts @@ -1,5 +1,6 @@ import * as _ from 'lodash'; import { Environments, OutdatedWrappedEtherByNetworkId, PublicNodeUrlsByNetworkId } from 'ts/types'; +import { utils } from 'ts/utils/utils'; const BASE_URL = window.location.origin; const isDevelopment = _.includes( @@ -10,13 +11,16 @@ const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs'; export const configs = { AMOUNT_DISPLAY_PRECSION: 5, - BACKEND_BASE_URL: 'https://website-api.0xproject.com', + BACKEND_BASE_URL: utils.isDogfood() + ? 'http://ec2-52-91-181-85.compute-1.amazonaws.com' + : 'https://website-api.0xproject.com', BASE_URL, BITLY_ACCESS_TOKEN: 'ffc4c1a31e5143848fb7c523b39f91b9b213d208', DEFAULT_DERIVATION_PATH: `44'/60'/0'`, // WARNING: ZRX & WETH MUST always be default trackedTokens DEFAULT_TRACKED_TOKEN_SYMBOLS: ['WETH', 'ZRX'], DOMAIN_STAGING: 'staging-0xproject.s3-website-us-east-1.amazonaws.com', + DOMAIN_DOGFOOD: 'dogfood-0xproject.s3-website-us-east-1.amazonaws.com', DOMAIN_DEVELOPMENT: '0xproject.localhost:3572', DOMAIN_PRODUCTION: '0xproject.com', ENVIRONMENT: isDevelopment ? Environments.DEVELOPMENT : Environments.PRODUCTION, diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index bf30f4e04..c3e261ddb 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -308,4 +308,7 @@ export const utils = { isStaging(): boolean { return _.includes(window.location.href, configs.DOMAIN_STAGING); }, + isDogfood(): boolean { + return _.includes(window.location.href, configs.DOMAIN_DOGFOOD); + }, }; -- cgit From 509a81a572937e1a7376d59c0ebb66fdb9e99960 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 15 May 2018 14:44:57 -0700 Subject: Add myself to about page --- packages/website/ts/pages/about/about.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx index 673022329..360cbb136 100644 --- a/packages/website/ts/pages/about/about.tsx +++ b/packages/website/ts/pages/about/about.tsx @@ -128,9 +128,6 @@ const teamRow4: ProfileInfo[] = [ github: '', medium: '', }, -]; - -const teamRow5: ProfileInfo[] = [ { name: 'Greg Hysen', title: 'Blockchain Engineer', @@ -140,6 +137,9 @@ const teamRow5: ProfileInfo[] = [ github: 'https://github.com/hysz', medium: '', }, +]; + +const teamRow5: ProfileInfo[] = [ { name: 'Remco Bloemen', title: 'Technical Fellow', @@ -149,6 +149,14 @@ const teamRow5: ProfileInfo[] = [ github: 'http://github.com/recmo', medium: '', }, + { + name: 'Francesco Agosti', + title: 'Senior Frontend Engineer', + description: `Full-stack engineer. Previously senior software engineer at Yelp. Computer science Duke.`, + image: 'images/team/fragosti.png', + linkedIn: 'https://www.linkedin.com/in/fragosti/', + github: 'http://github.com/fragosti', + }, ]; const advisors: ProfileInfo[] = [ -- cgit From f43b275f16b46a72409962bb61fe1eb66f700c62 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 15 May 2018 14:50:33 -0700 Subject: Add my profile image to images --- packages/website/public/images/team/fragosti.png | Bin 0 -> 26209 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 packages/website/public/images/team/fragosti.png (limited to 'packages/website') diff --git a/packages/website/public/images/team/fragosti.png b/packages/website/public/images/team/fragosti.png new file mode 100644 index 000000000..60c168514 Binary files /dev/null and b/packages/website/public/images/team/fragosti.png differ -- cgit From 2ba78eb740d4eb04ecc1147f52dce236047f6816 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 15 May 2018 15:27:27 -0700 Subject: Fix circular dependency --- packages/website/ts/utils/backend_client.ts | 10 +++++----- packages/website/ts/utils/configs.ts | 5 ++--- packages/website/ts/utils/utils.ts | 9 ++++++--- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/utils/backend_client.ts b/packages/website/ts/utils/backend_client.ts index 63e06fda7..cc238325a 100644 --- a/packages/website/ts/utils/backend_client.ts +++ b/packages/website/ts/utils/backend_client.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import { ArticlesBySection, WebsiteBackendGasInfo, WebsiteBackendPriceInfo, WebsiteBackendRelayerInfo } from 'ts/types'; -import { configs } from 'ts/utils/configs'; +import { utils } from 'ts/utils/utils'; import { fetchUtils } from 'ts/utils/fetch_utils'; const ETH_GAS_STATION_ENDPOINT = '/eth_gas_station'; @@ -11,7 +11,7 @@ const WIKI_ENDPOINT = '/wiki'; export const backendClient = { async getGasInfoAsync(): Promise { - const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, ETH_GAS_STATION_ENDPOINT); + const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), ETH_GAS_STATION_ENDPOINT); return result; }, async getPriceInfoAsync(tokenSymbols: string[]): Promise { @@ -22,15 +22,15 @@ export const backendClient = { const queryParams = { tokens: joinedTokenSymbols, }; - const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, PRICES_ENDPOINT, queryParams); + const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), PRICES_ENDPOINT, queryParams); return result; }, async getRelayerInfosAsync(): Promise { - const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, RELAYERS_ENDPOINT); + const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), RELAYERS_ENDPOINT); return result; }, async getWikiArticlesBySectionAsync(): Promise { - const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, WIKI_ENDPOINT); + const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), WIKI_ENDPOINT); return result; }, }; diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts index bea9c4ee2..9fec814b7 100644 --- a/packages/website/ts/utils/configs.ts +++ b/packages/website/ts/utils/configs.ts @@ -11,9 +11,8 @@ const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs'; export const configs = { AMOUNT_DISPLAY_PRECSION: 5, - BACKEND_BASE_URL: utils.isDogfood() - ? 'http://ec2-52-91-181-85.compute-1.amazonaws.com' - : 'https://website-api.0xproject.com', + BACKEND_BASE_PROD_URL: 'https://website-api.0xproject.com', + BACKEND_BASE_STAGING_URL: 'http://ec2-52-91-181-85.compute-1.amazonaws.com', BASE_URL, BITLY_ACCESS_TOKEN: 'ffc4c1a31e5143848fb7c523b39f91b9b213d208', DEFAULT_DERIVATION_PATH: `44'/60'/0'`, diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index c3e261ddb..cb01fec24 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -24,6 +24,8 @@ import * as u2f from 'ts/vendor/u2f_api'; const LG_MIN_EM = 64; const MD_MIN_EM = 52; +const isDogfood = (): boolean => _.includes(window.location.href, configs.DOMAIN_DOGFOOD); + export const utils = { assert(condition: boolean, message: string): void { if (!condition) { @@ -302,13 +304,14 @@ export const utils = { } return parsedProviderName; }, + getBackendBaseUrl(): string { + return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL; + }, isDevelopment(): boolean { return configs.ENVIRONMENT === Environments.DEVELOPMENT; }, isStaging(): boolean { return _.includes(window.location.href, configs.DOMAIN_STAGING); }, - isDogfood(): boolean { - return _.includes(window.location.href, configs.DOMAIN_DOGFOOD); - }, + isDogfood, }; -- cgit From dc58d539c2ec0561974323aced0841d17117927d Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 15 May 2018 15:54:17 -0700 Subject: fix style errors --- packages/website/ts/utils/backend_client.ts | 2 +- packages/website/ts/utils/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/utils/backend_client.ts b/packages/website/ts/utils/backend_client.ts index cc238325a..c440b1604 100644 --- a/packages/website/ts/utils/backend_client.ts +++ b/packages/website/ts/utils/backend_client.ts @@ -1,8 +1,8 @@ import * as _ from 'lodash'; import { ArticlesBySection, WebsiteBackendGasInfo, WebsiteBackendPriceInfo, WebsiteBackendRelayerInfo } from 'ts/types'; -import { utils } from 'ts/utils/utils'; import { fetchUtils } from 'ts/utils/fetch_utils'; +import { utils } from 'ts/utils/utils'; const ETH_GAS_STATION_ENDPOINT = '/eth_gas_station'; const PRICES_ENDPOINT = '/prices'; diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index cb01fec24..3c99bd2fe 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -305,7 +305,7 @@ export const utils = { return parsedProviderName; }, getBackendBaseUrl(): string { - return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL; + return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL; }, isDevelopment(): boolean { return configs.ENVIRONMENT === Environments.DEVELOPMENT; -- cgit