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 componentType = type === 'textarea' ? 'textarea' : 'input';
const isErrors = errors.hasOwnProperty(name) && errors[name] !== null; const isErrors = errors.hasOwnProperty(name) && errors[name] !== null;
const errorMessage = isErrors ? errors[name] : null; const errorMessage = isErrors ? errors[name] : null;
const wrapperProps = { width };
const inputProps = { name, type }; const inputProps = { name, type };
return ( return (

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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