From eb4fd1cce8fd0f2dad61726a88ef16f6abb70b24 Mon Sep 17 00:00:00 2001 From: Eddie Wang Date: Mon, 15 Jan 2018 01:51:35 -0500 Subject: [PATCH] Stricter balance checks during swap (#793) * check currentBalance before showing Amount Field and GenerateTx button * add token balance check * check wallet balance * comments * simplify wallet balance check --- .../GenerateTransaction.tsx | 16 +++-- .../Tabs/Swap/components/LiteSend/Fields.tsx | 67 ++++++++++++------- common/libs/wallet/balance.ts | 2 +- common/reducers/wallet.ts | 2 +- common/selectors/transaction/current.ts | 25 ++++++- 5 files changed, 80 insertions(+), 32 deletions(-) diff --git a/common/components/GenerateTransaction/GenerateTransaction.tsx b/common/components/GenerateTransaction/GenerateTransaction.tsx index 151ce558..f6ea3eb9 100644 --- a/common/components/GenerateTransaction/GenerateTransaction.tsx +++ b/common/components/GenerateTransaction/GenerateTransaction.tsx @@ -4,7 +4,7 @@ import EthTx from 'ethereumjs-tx'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { AppState } from 'reducers'; -import { getTransaction, isNetworkRequestPending } from 'selectors/transaction'; +import { getTransaction, isNetworkRequestPending, isValidAmount } from 'selectors/transaction'; import { getWalletType } from 'selectors/wallet'; interface StateProps { @@ -12,17 +12,24 @@ interface StateProps { networkRequestPending: boolean; isFullTransaction: boolean; isWeb3Wallet: boolean; + validAmount: boolean; } class GenerateTransactionClass extends Component { public render() { - const { isFullTransaction, isWeb3Wallet, transaction, networkRequestPending } = this.props; + const { + isFullTransaction, + isWeb3Wallet, + transaction, + networkRequestPending, + validAmount + } = this.props; return ( (