aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/wallet
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-11 23:38:51 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-05-14 16:35:13 +0800
commitb74957acdfc8d67d154bcb4698acd7575db7cc47 (patch)
tree3f33c2faac3b55e52098ab0b5b9883a9b62f5aee /packages/website/ts/components/wallet
parent6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b (diff)
downloaddexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.gz
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.bz2
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.lz
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.xz
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.zst
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.zip
Add missing type definitions
Diffstat (limited to 'packages/website/ts/components/wallet')
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx54
-rw-r--r--packages/website/ts/components/wallet/wrap_ether_item.tsx12
2 files changed, 33 insertions, 33 deletions
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<WalletProps, WalletState> {
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<WalletProps, WalletState> {
this._fetchBalancesAndAllowancesAsync(newTokenAddresses);
}
}
- public render() {
+ public render(): React.ReactNode {
const isReadyToRender = this.props.blockchainIsLoaded && this.props.blockchainErr === BlockchainErrs.NoError;
return <div style={styles.root}>{isReadyToRender && this._renderRows()}</div>;
}
- private _renderRows() {
+ private _renderRows(): React.ReactNode {
const isAddressAvailable = !_.isEmpty(this.props.userAddress);
return (
<List style={styles.list}>
@@ -210,7 +210,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
</List>
);
}
- 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<WalletProps, WalletState> {
/>
);
}
- private _renderDisconnectedRows() {
+ private _renderDisconnectedRows(): React.ReactElement<{}> {
return (
<WalletDisconnectedItem
key={DISCONNECTED_ITEM_KEY}
@@ -233,7 +233,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
/>
);
}
- 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<WalletProps, WalletState> {
/>
);
}
- 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<WalletProps, WalletState> {
</ListItem>
);
}
- private _onSidebarHover(event: React.FormEvent<HTMLInputElement>) {
+ private _onSidebarHover(event: React.FormEvent<HTMLInputElement>): void {
this.setState({
isHoveringSidebar: true,
});
}
- private _onSidebarHoverOff() {
+ private _onSidebarHoverOff(): void {
this.setState({
isHoveringSidebar: false,
});
}
- private _renderFooterRows() {
+ private _renderFooterRows(): React.ReactElement<{}> {
return (
<ListItem
key={FOOTER_ITEM_KEY}
@@ -302,7 +302,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
/>
);
}
- 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<WalletProps, WalletState> {
</div>
);
}
- 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<WalletProps, WalletState> {
);
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<WalletProps, WalletState> {
</div>
);
}
- 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<WalletProps, WalletState> {
</div>
);
}
- private _renderAllowanceToggle(config: AllowanceToggleConfig) {
+ private _renderAllowanceToggle(config: AllowanceToggleConfig): React.ReactNode {
return (
<AllowanceToggle
networkId={this.props.networkId}
@@ -446,13 +446,13 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
/>
);
}
- 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 <div style={styles.amountLabel}>{result}</div>;
}
- 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<WalletProps, WalletState> {
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 = <TokenIcon token={token} diameter={ICON_DIMENSION} />;
if (_.isUndefined(tokenLink)) {
@@ -475,7 +475,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
);
}
}
- 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<WalletProps, WalletState> {
/>
);
}
- 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<WalletProps, WalletState> {
});
return trackedTokenStateByAddress;
}
- private async _fetchBalancesAndAllowancesAsync(tokenAddresses: string[]) {
+ private async _fetchBalancesAndAllowancesAsync(tokenAddresses: string[]): Promise<void> {
const balanceAndAllowanceTupleByAddress: ItemByAddress<BigNumber[]> = {};
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<WalletProps, WalletState> {
});
}
}
- private async _refetchTokenStateAsync(tokenAddress: string) {
+ private async _refetchTokenStateAsync(tokenAddress: string): Promise<void> {
await this._fetchBalancesAndAllowancesAsync([tokenAddress]);
}
private async _getPriceByAddressAsync(tokenAddresses: string[]): Promise<ItemByAddress<BigNumber>> {
@@ -584,17 +584,17 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
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<WrapEtherItemProps, WrapEther
isEthConversionHappening: false,
};
}
- public render() {
+ public render(): React.ReactNode {
const etherBalanceInEth = ZeroEx.toUnitAmount(this.props.userEtherBalanceInWei, constants.DECIMAL_PLACES_ETH);
const isWrappingEth = this.props.direction === Side.Deposit;
const topLabelText = isWrappingEth ? 'Convert ETH into WETH 1:1' : 'Convert WETH into ETH 1:1';
@@ -116,20 +116,20 @@ export class WrapEtherItem extends React.Component<WrapEtherItemProps, WrapEther
/>
);
}
- 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 ? (
<div className="pl1" style={{ paddingTop: 10 }}>
<i className="zmdi zmdi-spinner zmdi-hc-spin" />
</div>
) : 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<WrapEtherItemProps, WrapEther
backgroundColor={colors.wrapEtherConfirmationButton}
label={labelText}
labelStyle={styles.wrapEtherConfirmationButtonLabel}
- onClick={this._wrapEtherConfirmationAction.bind(this)}
+ onClick={this._wrapEtherConfirmationActionAsync.bind(this)}
disabled={this.state.isEthConversionHappening}
/>
</div>
);
}
- private async _wrapEtherConfirmationAction() {
+ private async _wrapEtherConfirmationActionAsync(): Promise<void> {
this.setState({
isEthConversionHappening: true,
});