Fix linting errors

This commit is contained in:
Fred Carlsen
2019-02-14 20:38:06 +01:00
committed by Jacob Evans
parent e5ea65da82
commit 6205d6c885
12 changed files with 38 additions and 129 deletions

View File

@@ -72,7 +72,6 @@ export const Input = React.forwardRef((props: InputProps, ref?: React.Ref<HTMLIn
const componentType = type === 'textarea' ? 'textarea' : 'input';
const isErrors = errors.hasOwnProperty(name) && errors[name] !== null;
const errorMessage = isErrors ? errors[name] : null;
const wrapperProps = { width };
const inputProps = { name, type };
return (

View File

@@ -6,6 +6,8 @@ import { colors } from 'ts/style/colors';
import { DialogContent, DialogOverlay } from '@reach/dialog';
import '@reach/dialog/styles.css';
// tslint:disable-next-line: no-duplicate-imports
import { FormEvent } from 'react';
import { Button } from 'ts/components/button';

View File

@@ -7,6 +7,7 @@ import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { constants } from 'ts/utils/constants';
// tslint:disable-next-line: no-duplicate-imports
import { ChangeEvent } from 'react';
import { AddressTableRow } from 'ts/pages/governance/address_table_row';
@@ -21,11 +22,6 @@ interface AddressTableState {
selectedAddressIndex?: number;
}
interface RowProps {
color: string;
width: number;
}
export class AddressTable extends React.Component<AddressTableProps, AddressTableState> {
constructor(props: AddressTableProps) {
super(props);

View File

@@ -2,6 +2,7 @@ import * as _ from 'lodash';
import * as React from 'react';
import styled from 'styled-components';
// tslint:disable-next-line: no-duplicate-imports
import { ChangeEvent } from 'react';
import { colors } from 'ts/style/colors';

View File

@@ -127,7 +127,6 @@ export class ConnectForm extends React.Component<Props, State> {
}
public render(): React.ReactNode {
const { errors } = this.state;
const { currentBalance } = this.props;
return (
<div style={{ textAlign: 'center' }}>
<Icon name="wallet" size={120} margin={[0, 0, 'default', 0]} />
@@ -167,7 +166,7 @@ export class ConnectForm extends React.Component<Props, State> {
);
}
public _renderChooseAddressContent(errors: ErrorProps): React.ReactNode {
const { userAddresses, addressBalances, preferredNetworkId, derivationPath } = this.state;
const { userAddresses, addressBalances, derivationPath } = this.state;
return (
<>
<Heading color={colors.textDarkPrimary} size={34} asElement="h2">
@@ -192,7 +191,7 @@ export class ConnectForm extends React.Component<Props, State> {
<Button type="button" onClick={this._onGoBack.bind(this, ConnectSteps.Connect)}>
Back
</Button>
<Button type="button" onClick={this._onSelectedLedgerAddress.bind(this)}>
<Button type="button" onClick={this._onSelectedLedgerAddressAsync.bind(this)}>
Next
</Button>
</ButtonRow>
@@ -200,11 +199,11 @@ export class ConnectForm extends React.Component<Props, State> {
);
}
public async _onChangeDerivationPathAsync(path: string): Promise<void> {
await this.setState({
this.setState({
derivationPath: path,
}, async () => {
await this._onFetchAddressesForDerivationPathAsync();
});
await this._onFetchAddressesForDerivationPathAsync();
}
public async getUserAccountsAsync(): Promise<string[]> {
utils.assert(!_.isUndefined(this._contractWrappers), 'ContractWrappers must be instantiated.');
@@ -252,21 +251,21 @@ export class ConnectForm extends React.Component<Props, State> {
return new BigNumber(0);
}
private async _onConnectWalletClickAsync(): Promise<boolean> {
const shouldPollUserAddress = true;
const shouldUseLedgerProvider = false;
const networkIdIfExists = await this._getInjectedProviderNetworkIdIfExistsAsync();
this.networkId = !_.isUndefined(networkIdIfExists) ? networkIdIfExists : constants.NETWORK_ID_MAINNET;
await this._resetOrInitializeAsync(this.networkId, shouldPollUserAddress, shouldUseLedgerProvider);
await this._resetOrInitializeAsync(this.networkId, shouldUseLedgerProvider);
const didSucceed = await this._fetchAddressesAndBalancesAsync();
if (didSucceed) {
await this.setState({
this.setState({
errors: {},
preferredNetworkId: this.networkId,
}, async () => {
// Always assume selected index is 0 for Metamask
await this._updateSelectedAddressAsync(0);
});
// Always assume selected index is 0 for Metamask
this._updateSelectedAddressAsync(0);
}
return didSucceed;
@@ -283,10 +282,6 @@ export class ConnectForm extends React.Component<Props, State> {
return false;
}
// const networkId = this.state.preferredNetworkId;
const shouldPollUserAddress = true;
const shouldUserLedgerProvider = false;
// We don't want to be out of sync with the network the injected provider declares.
const networkId = constants.NETWORK_ID_MAINNET;
await this._updateProviderToLedgerAsync(networkId);
@@ -305,8 +300,8 @@ export class ConnectForm extends React.Component<Props, State> {
selectedUserAddressIndex: index,
});
}
private _onSelectedLedgerAddress(): void {
this._updateSelectedAddressAsync(this.state.selectedUserAddressIndex);
private async _onSelectedLedgerAddressAsync(): Promise<void> {
await this._updateSelectedAddressAsync(this.state.selectedUserAddressIndex);
}
private async _onFetchAddressesForDerivationPathAsync(): Promise<boolean> {
const currentlySetPath = this.getLedgerDerivationPathIfExists();
@@ -372,17 +367,8 @@ export class ConnectForm extends React.Component<Props, State> {
}
}
private async _updateProviderToLedgerAsync(networkId: number): Promise<void> {
const shouldPollUserAddress = false;
const shouldUserLedgerProvider = true;
await this._resetOrInitializeAsync(networkId, shouldPollUserAddress, shouldUserLedgerProvider);
}
private async _updateProviderToInjectedAsync(): Promise<void> {
const shouldPollUserAddress = true;
const shouldUserLedgerProvider = false;
// this._dispatcher.updateBlockchainIsLoaded(false);
// We don't want to be out of sync with the network the injected provider declares.
const networkId = await this._getInjectedProviderNetworkIdIfExistsAsync();
await this._resetOrInitializeAsync(networkId, shouldPollUserAddress, shouldUserLedgerProvider);
await this._resetOrInitializeAsync(networkId, shouldUserLedgerProvider);
}
private _getNameGivenProvider(provider: Provider): string {
const providerType = utils.getProviderType(provider);
@@ -499,7 +485,6 @@ export class ConnectForm extends React.Component<Props, State> {
}
private async _resetOrInitializeAsync(
networkId: number,
shouldPollUserAddress: boolean = false,
shouldUserLedgerProvider: boolean = false,
): Promise<void> {
if (!shouldUserLedgerProvider) {
@@ -538,13 +523,6 @@ export class ConnectForm extends React.Component<Props, State> {
// await this.fetchTokenInformationAsync();
}
}
private _updateProviderName(injectedProviderIfExists?: InjectedProvider): void {
const doesInjectedProviderExist = !_.isUndefined(injectedProviderIfExists);
const providerName = doesInjectedProviderExist
? this._getNameGivenProvider(injectedProviderIfExists)
: constants.PROVIDER_NAME_PUBLIC;
// this._dispatcher.updateInjectedProviderName(providerName);
}
private async _getUserAddressesAsync(): Promise<string[]> {
let userAddresses: string[];
userAddresses = await this.getUserAccountsAsync();
@@ -554,11 +532,6 @@ export class ConnectForm extends React.Component<Props, State> {
}
return userAddresses;
}
private _onSelectedNetworkUpdated(_event: any, _index: number, networkId: number): void {
this.setState({
preferredNetworkId: networkId,
});
}
private _onGoBack(step: number): void {
switch (step) {
case ConnectSteps.SelectAddress:

View File

@@ -54,12 +54,6 @@ const riskLabels: LabelInterface = {
3: 'High Risk',
};
const complexityLabels: LabelInterface = {
1: 'Simple',
2: 'Medium',
3: 'Complex',
};
const proposalData = {
zeipId: 1,
title: 'MultiAssetProxy Approval',
@@ -124,21 +118,11 @@ export class Governance extends React.Component {
},
};
public componentDidMount(): void {
// tslint:disable:no-floating-promises
this._fetchVoteStatusAsync();
}
public render(): React.ReactNode {
const { isVoteReceived, isWalletConnected, providerName, tally } = this.state;
const buildAction = (
<Button
href="/docs"
isWithArrow={true}
isAccentColor={true}
isTransparent={true}
borderColor={colors.brandLight}
>
Build on 0x
</Button>
);
const { isVoteReceived, tally } = this.state;
return (
<SiteWrap theme="dark">
<DocumentTitle title="Governance Vote - 0x" />
@@ -232,27 +216,27 @@ export class Governance extends React.Component {
);
}
// private _renderSummarySection()
private _onOpenContactModal = (): void => {
private readonly _onOpenContactModal = (): void => {
this.setState({ ...this.state, isContactModalOpen: true });
};
private _onDismissContactModal = (): void => {
private readonly _onDismissContactModal = (): void => {
this.setState({ ...this.state, isContactModalOpen: false });
};
private _onOpenVoteModal = (): void => {
private readonly _onOpenVoteModal = (): void => {
this.setState({ ...this.state, isVoteModalOpen: true });
};
private _onDismissVoteModal = (): void => {
private readonly _onDismissVoteModal = (): void => {
this.setState({ ...this.state, isVoteModalOpen: false });
};
private _onWalletConnected = (providerName: string): void => {
private readonly _onWalletConnected = (providerName: string): void => {
this.setState({ ...this.state, isWalletConnected: true, providerName });
};
private _onVoteReceived = (): void => {
private readonly _onVoteReceived = (): void => {
this.setState({ ...this.state, isVoteReceived: true });
};
private async _fetchVoteStatusAsync(): Promise<void> {

View File

@@ -24,9 +24,6 @@ import {
LedgerSubprovider,
} from '@0x/subproviders';
import { Provider } from 'ethereum-types';
import {
InjectedProvider,
} from 'ts/types';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
@@ -66,16 +63,6 @@ interface FormProps {
isSubmitting?: boolean;
}
interface ErrorResponseProps {
param: string;
location: string;
msg: string;
}
interface ErrorResponse {
errors: ErrorResponseProps[];
}
interface ErrorProps {
[key: string]: string;
}
@@ -119,15 +106,12 @@ export class ModalVote extends React.Component<Props> {
// market maker lead fields
public countryRef: React.RefObject<HTMLInputElement> = React.createRef();
public fundSizeRef: React.RefObject<HTMLInputElement> = React.createRef();
// blockchain related
private _injectedProviderIfExists?: InjectedProvider;
private _web3Wrapper?: Web3Wrapper;
public constructor(props: Props) {
super(props);
}
public render(): React.ReactNode {
const { isOpen, onDismiss } = this.props;
const { isSuccessful, errors, selectedAddress, currentBalance } = this.state;
const { isSuccessful, selectedAddress, currentBalance } = this.state;
const formattedBalance = Web3Wrapper.toUnitAmount(currentBalance, constants.DECIMAL_PLACES_ETH).toFixed(configs.AMOUNT_DISPLAY_PRECSION);
return (
<>
@@ -137,7 +121,7 @@ export class ModalVote extends React.Component<Props> {
onDismiss={onDismiss}
>
<StyledDialogContent>
{this._renderFormContent(errors)}
{this._renderFormContent()}
<Confirmation isSuccessful={isSuccessful}>
<Icon name="voting" size="large" margin={[0, 0, 'default', 0]} />
<Heading color={colors.textDarkPrimary} size={34} asElement="h2">
@@ -163,17 +147,17 @@ export class ModalVote extends React.Component<Props> {
</>
);
}
public _renderFormContent(errors: ErrorProps): React.ReactNode {
public _renderFormContent(): React.ReactNode {
switch (this.state.isWalletConnected) {
case true:
return this._renderVoteFormContent(errors);
return this._renderVoteFormContent();
case false:
default:
return this._renderConnectWalletFormContent(errors);
return this._renderConnectWalletFormContent();
}
}
private _renderConnectWalletFormContent(errors: ErrorProps): React.ReactNode {
const { currentBalance, web3Wrapper } = this.state;
private _renderConnectWalletFormContent(): React.ReactNode {
const { web3Wrapper } = this.state;
return (
<>
<ConnectForm
@@ -184,7 +168,7 @@ export class ModalVote extends React.Component<Props> {
</>
);
}
private _renderVoteFormContent(errors: ErrorProps): React.ReactNode {
private _renderVoteFormContent(): React.ReactNode {
const {
currentBalance,
selectedAddress,

View File

@@ -2,6 +2,7 @@ import * as _ from 'lodash';
import * as React from 'react';
import styled from 'styled-components';
// tslint:disable-next-line: no-duplicate-imports
import { ChangeEvent } from 'react';
import { colors } from 'ts/style/colors';

View File

@@ -1,6 +1,5 @@
import * as _ from 'lodash';
import * as React from 'react';
import DocumentTitle from 'react-document-title';
import styled from 'styled-components';
import { Paragraph } from 'ts/components/text';

View File

@@ -1,10 +1,7 @@
import * as _ from 'lodash';
import * as React from 'react';
import DocumentTitle from 'react-document-title';
import styled from 'styled-components';
import { colors } from 'ts/style/colors';
interface VoteBarProps {
label: string;
color: string;

View File

@@ -1,17 +1,14 @@
import * as _ from 'lodash';
import * as moment from 'moment';
import * as React from 'react';
import styled from 'styled-components';
// tslint:disable-next-line: no-duplicate-imports
import { ChangeEvent, FormEvent } from 'react';
import { colors } from 'ts/style/colors';
import { DialogContent, DialogOverlay } from '@reach/dialog';
import '@reach/dialog/styles.css';
// import { LedgerSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
import { ContractWrappers } from '@0x/contract-wrappers';
import { BigNumber, signTypedDataUtils } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
@@ -32,19 +29,10 @@ import {
import { Provider } from 'ethereum-types';
import {
InjectedProvider,
Providers,
} from 'ts/types';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
const providerToName: { [provider: string]: string } = {
[Providers.Metamask]: constants.PROVIDER_NAME_METAMASK,
[Providers.Parity]: constants.PROVIDER_NAME_PARITY_SIGNER,
[Providers.Mist]: constants.PROVIDER_NAME_MIST,
[Providers.CoinbaseWallet]: constants.PROVIDER_NAME_COINBASE_WALLET,
[Providers.Cipher]: constants.PROVIDER_NAME_CIPHER,
};
export enum VoteValue {
Yes = 'Yes',
No = 'No',
@@ -85,16 +73,6 @@ interface FormProps {
isSubmitting?: boolean;
}
interface ErrorResponseProps {
param: string;
location: string;
msg: string;
}
interface ErrorResponse {
errors: ErrorResponseProps[];
}
interface ErrorProps {
[key: string]: string;
}
@@ -141,9 +119,6 @@ export class VoteForm extends React.Component<Props> {
// market maker lead fields
public countryRef: React.RefObject<HTMLInputElement> = React.createRef();
public fundSizeRef: React.RefObject<HTMLInputElement> = React.createRef();
// blockchain related
private _injectedProviderIfExists?: InjectedProvider;
private _web3Wrapper?: Web3Wrapper;
public constructor(props: Props) {
super(props);
}
@@ -210,11 +185,11 @@ export class VoteForm extends React.Component<Props> {
</Form>
);
}
private _createVoteAsync = async (e: FormEvent): Promise<any> => {
private readonly _createVoteAsync = async (e: FormEvent): Promise<any> => {
e.preventDefault();
const { zeip, votePreference } = this.state;
const { selectedAddress, web3Wrapper, isLedger, injectedProvider, providerEngine } = this.props;
const { selectedAddress, isLedger, providerEngine } = this.props;
// Query the available addresses
// const addresses = await web3Wrapper.getAvailableAddressesAsync();
// Use the first account as the maker
@@ -281,7 +256,7 @@ export class VoteForm extends React.Component<Props> {
return null as any;
}
};
private _eip712SignatureAsync = async (address: string, typedData: any): Promise<string> => {
private readonly _eip712SignatureAsync = async (address: string, typedData: any): Promise<string> => {
const signature = await this.props.web3Wrapper.signTypedDataAsync(address, typedData);
const ecSignatureRSV = this._parseSignatureHexAsRSV(signature);
const signatureBuffer = Buffer.concat([

View File

@@ -1,7 +1,5 @@
import * as _ from 'lodash';
import * as React from 'react';
import DocumentTitle from 'react-document-title';
import styled from 'styled-components';
import { TallyInterface } from 'ts/pages/governance/governance';