Add missing type definitions
This commit is contained in:
@@ -18,7 +18,7 @@ interface BlockchainErrDialogProps {
|
||||
}
|
||||
|
||||
export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProps, undefined> {
|
||||
public render() {
|
||||
public render(): React.ReactNode {
|
||||
const dialogActions = [
|
||||
<FlatButton
|
||||
key="blockchainErrOk"
|
||||
@@ -45,7 +45,7 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
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<BlockchainErrDialogProp
|
||||
return 'Unexpected error';
|
||||
}
|
||||
}
|
||||
private _renderExplanation(hasWalletAddress: boolean) {
|
||||
private _renderExplanation(hasWalletAddress: boolean): React.ReactNode {
|
||||
if (this.props.blockchainErr === BlockchainErrs.AContractNotDeployedOnNetwork) {
|
||||
return this._renderContractsNotDeployedExplanation();
|
||||
} else if (!hasWalletAddress) {
|
||||
@@ -71,7 +71,7 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
|
||||
return this._renderUnexpectedErrorExplanation();
|
||||
}
|
||||
}
|
||||
private _renderDisconnectedFromNode() {
|
||||
private _renderDisconnectedFromNode(): React.ReactNode {
|
||||
return (
|
||||
<div>
|
||||
You were disconnected from the backing Ethereum node. If using{' '}
|
||||
@@ -86,7 +86,7 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private _renderDefaultTokenNotInTokenRegistry() {
|
||||
private _renderDefaultTokenNotInTokenRegistry(): React.ReactNode {
|
||||
return (
|
||||
<div>
|
||||
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<BlockchainErrDialogProp
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private _renderUnexpectedErrorExplanation() {
|
||||
private _renderUnexpectedErrorExplanation(): React.ReactNode {
|
||||
return <div>We encountered an unexpected error. Please try refreshing the page.</div>;
|
||||
}
|
||||
private _renderNoWalletFoundExplanation() {
|
||||
private _renderNoWalletFoundExplanation(): React.ReactNode {
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
@@ -137,7 +137,7 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private _renderContractsNotDeployedExplanation() {
|
||||
private _renderContractsNotDeployedExplanation(): React.ReactNode {
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
|
@@ -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 = [
|
||||
<FlatButton key="cancel" label="Cancel" onTouchTap={this._onCancel.bind(this)} />,
|
||||
<FlatButton key="convert" label="Convert" primary={true} onTouchTap={this._onConvertClick.bind(this)} />,
|
||||
@@ -72,7 +72,7 @@ export class EthWethConversionDialog extends React.Component<
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
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<
|
||||
</div>
|
||||
);
|
||||
}
|
||||
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<
|
||||
</div>
|
||||
);
|
||||
}
|
||||
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<void> {
|
||||
const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress;
|
||||
const [balance] = await this.props.blockchain.getTokenBalanceAndAllowanceAsync(
|
||||
userAddressIfExists,
|
||||
|
@@ -59,7 +59,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
preferredNetworkId: props.networkId,
|
||||
};
|
||||
}
|
||||
public render() {
|
||||
public render(): React.ReactNode {
|
||||
const dialogActions = [
|
||||
<FlatButton key="ledgerConnectCancel" label="Cancel" onTouchTap={this._onClose.bind(this)} />,
|
||||
];
|
||||
@@ -82,7 +82,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
private _renderConnectStep() {
|
||||
private _renderConnectStep(): React.ReactNode {
|
||||
const networkIds = _.values(sharedConstants.NETWORK_ID_BY_NAME);
|
||||
return (
|
||||
<div>
|
||||
@@ -122,7 +122,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private _renderSelectAddressStep() {
|
||||
private _renderSelectAddressStep(): React.ReactNode {
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
@@ -159,7 +159,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
</div>
|
||||
);
|
||||
}
|
||||
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<LedgerConfigDialogProps,
|
||||
});
|
||||
return rows;
|
||||
}
|
||||
private _onClose() {
|
||||
private _onClose(): void {
|
||||
this.setState({
|
||||
connectionErrMsg: '',
|
||||
stepIndex: LedgerSteps.CONNECT,
|
||||
@@ -197,7 +197,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
const isOpen = false;
|
||||
this.props.toggleDialogFn(isOpen);
|
||||
}
|
||||
private _onAddressSelected(selectedRowIndexes: number[]) {
|
||||
private _onAddressSelected(selectedRowIndexes: number[]): void {
|
||||
const selectedRowIndex = selectedRowIndexes[0];
|
||||
const selectedAddress = this.state.userAddresses[selectedRowIndex];
|
||||
const selectAddressBalance = this.state.addressBalances[selectedRowIndex];
|
||||
@@ -228,7 +228,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
}
|
||||
return didSucceed;
|
||||
}
|
||||
private async _fetchAddressesAndBalancesAsync() {
|
||||
private async _fetchAddressesAndBalancesAsync(): Promise<boolean> {
|
||||
let userAddresses: string[];
|
||||
const addressBalances: BigNumber[] = [];
|
||||
try {
|
||||
@@ -250,7 +250,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
private _onDerivationPathChanged(e: any, derivationPath: string) {
|
||||
private _onDerivationPathChanged(e: any, derivationPath: string): void {
|
||||
let derivationErrMsg = '';
|
||||
if (!_.startsWith(derivationPath, VALID_ETHEREUM_DERIVATION_PATH_PREFIX)) {
|
||||
derivationErrMsg = 'Must be valid Ethereum path.';
|
||||
@@ -261,7 +261,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
||||
derivationErrMsg,
|
||||
});
|
||||
}
|
||||
private async _onConnectLedgerClickAsync() {
|
||||
private async _onConnectLedgerClickAsync(): Promise<boolean> {
|
||||
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<LedgerConfigDialogProps,
|
||||
}
|
||||
return userAddresses;
|
||||
}
|
||||
private _onSelectedNetworkUpdated(e: any, index: number, networkId: number) {
|
||||
private _onSelectedNetworkUpdated(e: any, index: number, networkId: number): void {
|
||||
this.setState({
|
||||
preferredNetworkId: networkId,
|
||||
});
|
||||
|
@@ -8,7 +8,7 @@ interface PortalDisclaimerDialogProps {
|
||||
onToggleDialog: () => void;
|
||||
}
|
||||
|
||||
export function PortalDisclaimerDialog(props: PortalDisclaimerDialogProps) {
|
||||
export const PortalDisclaimerDialog = (props: PortalDisclaimerDialogProps) => {
|
||||
return (
|
||||
<Dialog
|
||||
title="0x Portal Disclaimer"
|
||||
@@ -33,4 +33,4 @@ export function PortalDisclaimerDialog(props: PortalDisclaimerDialogProps) {
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@@ -35,7 +35,7 @@ export class SendDialog extends React.Component<SendDialogProps, SendDialogState
|
||||
isAmountValid: false,
|
||||
};
|
||||
}
|
||||
public render() {
|
||||
public render(): React.ReactNode {
|
||||
const transferDialogActions = [
|
||||
<FlatButton key="cancelTransfer" label="Cancel" onTouchTap={this._onCancel.bind(this)} />,
|
||||
<FlatButton
|
||||
@@ -57,7 +57,7 @@ export class SendDialog extends React.Component<SendDialogProps, SendDialogState
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
private _renderSendDialogBody() {
|
||||
private _renderSendDialogBody(): React.ReactNode {
|
||||
return (
|
||||
<div className="mx-auto" style={{ maxWidth: 300 }}>
|
||||
<div style={{ height: 80 }}>
|
||||
@@ -86,19 +86,19 @@ export class SendDialog extends React.Component<SendDialogProps, SendDialogState
|
||||
</div>
|
||||
);
|
||||
}
|
||||
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<SendDialogProps, SendDialogState
|
||||
this.props.onComplete(this.state.recipient, value);
|
||||
}
|
||||
}
|
||||
private _onCancel() {
|
||||
private _onCancel(): void {
|
||||
this.setState({
|
||||
value: undefined,
|
||||
});
|
||||
this.props.onCancelled();
|
||||
}
|
||||
private _hasErrors() {
|
||||
private _hasErrors(): boolean {
|
||||
return _.isUndefined(this.state.recipient) || _.isUndefined(this.state.value) || !this.state.isAmountValid;
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ export class TrackTokenConfirmationDialog extends React.Component<
|
||||
isAddingTokenToTracked: false,
|
||||
};
|
||||
}
|
||||
public render() {
|
||||
public render(): React.ReactNode {
|
||||
const tokens = this.props.tokens;
|
||||
return (
|
||||
<Dialog
|
||||
@@ -66,7 +66,7 @@ export class TrackTokenConfirmationDialog extends React.Component<
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
private async _onTrackConfirmationRespondedAsync(didUserAcceptTracking: boolean) {
|
||||
private async _onTrackConfirmationRespondedAsync(didUserAcceptTracking: boolean): Promise<void> {
|
||||
if (!didUserAcceptTracking) {
|
||||
this.props.onToggleDialog(didUserAcceptTracking);
|
||||
return;
|
||||
|
@@ -9,7 +9,7 @@ interface U2fNotSupportedDialogProps {
|
||||
onToggleDialog: () => void;
|
||||
}
|
||||
|
||||
export function U2fNotSupportedDialog(props: U2fNotSupportedDialogProps) {
|
||||
export const U2fNotSupportedDialog = (props: U2fNotSupportedDialogProps) => {
|
||||
return (
|
||||
<Dialog
|
||||
title="U2F Not Supported"
|
||||
@@ -43,4 +43,4 @@ export function U2fNotSupportedDialog(props: U2fNotSupportedDialogProps) {
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@@ -8,7 +8,7 @@ interface WrappedEthSectionNoticeDialogProps {
|
||||
onToggleDialog: () => void;
|
||||
}
|
||||
|
||||
export function WrappedEthSectionNoticeDialog(props: WrappedEthSectionNoticeDialogProps) {
|
||||
export const WrappedEthSectionNoticeDialog = (props: WrappedEthSectionNoticeDialogProps) => {
|
||||
return (
|
||||
<Dialog
|
||||
title="Dedicated Wrapped Ether Section"
|
||||
@@ -30,4 +30,4 @@ export function WrappedEthSectionNoticeDialog(props: WrappedEthSectionNoticeDial
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user