From 43ddffb6e93766e4f1383a5cc6076d311d0c3233 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 25 May 2018 11:49:37 +0200 Subject: [PATCH] implementation on selectedAccount.pending --- src/js/actions/SendFormActions.js | 6 ++++-- .../account/send/PendingTransactions.js | 21 ++++++++----------- .../wallet/account/send/SendForm.js | 8 +++---- .../components/wallet/account/send/index.js | 4 ---- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/js/actions/SendFormActions.js b/src/js/actions/SendFormActions.js index acc625f1..db041763 100644 --- a/src/js/actions/SendFormActions.js +++ b/src/js/actions/SendFormActions.js @@ -151,6 +151,8 @@ export const calculate = (prevProps: Props, props: Props) => { const { account, + tokens, + pending, } = props.selectedAccount; if (!account) return; @@ -171,13 +173,13 @@ export const calculate = (prevProps: Props, props: Props) => { if (state.setMax) { - const pendingAmount = props.pending.reduce((value, p) => { + const pendingAmount = pending.reduce((value, p) => { //if (p.tx.amount) console.warn("PENDING AMOUNT!", p, value); }, 0); if (isToken) { - const token: ?Token = findToken(props.tokens, account.address, state.currency, account.deviceState); + const token: ?Token = findToken(tokens, account.address, state.currency, account.deviceState); if (token) { state.amount = token.balance; } diff --git a/src/js/components/wallet/account/send/PendingTransactions.js b/src/js/components/wallet/account/send/PendingTransactions.js index 968eb976..9449e9b1 100644 --- a/src/js/components/wallet/account/send/PendingTransactions.js +++ b/src/js/components/wallet/account/send/PendingTransactions.js @@ -8,15 +8,13 @@ import ScaleText from 'react-scale-text'; import { findAccountTokens } from '~/js/reducers/TokensReducer'; import type { Coin } from '~/js/reducers/LocalStorageReducer'; -import type { Account } from '~/js/reducers/AccountsReducer'; import type { Token } from '~/js/reducers/TokensReducer'; import type { Props as BaseProps } from './index'; type Props = { - pending: $ElementType, - tokens: $ElementType, - account: Account, - selectedCoin: Coin + pending: $PropertyType<$ElementType, 'pending'>, + tokens: $PropertyType<$ElementType, 'tokens'>, + network: Coin } type Style = { @@ -27,12 +25,11 @@ type Style = { const PendingTransactions = (props: Props) => { - const account = props.account; - const pending = props.pending.filter(p => p.network === account.network && p.address === account.address); + const pending = props.pending; if (pending.length < 1) return null; - const tokens: Array = findAccountTokens(props.tokens, account); + const tokens: Array = props.tokens; const bgColorFactory = new ColorHash({lightness: 0.7}); const textColorFactory = new ColorHash(); @@ -42,7 +39,7 @@ const PendingTransactions = (props: Props) => { let iconColor: Style; let symbol: string; let name: string; - const isSmartContractTx: boolean = tx.currency !== props.selectedCoin.symbol; + const isSmartContractTx: boolean = tx.currency !== props.network.symbol; if (isSmartContractTx) { const token: ?Token = tokens.find(t => t.symbol === tx.currency); if (!token) { @@ -69,8 +66,8 @@ const PendingTransactions = (props: Props) => { background: bgColorFactory.hex(tx.network), borderColor: bgColorFactory.hex(tx.network) } - symbol = props.selectedCoin.symbol; - name = props.selectedCoin.name; + symbol = props.network.symbol; + name = props.network.name; } return ( @@ -81,7 +78,7 @@ const PendingTransactions = (props: Props) => {
{ tx.amount } { symbol }
diff --git a/src/js/components/wallet/account/send/SendForm.js b/src/js/components/wallet/account/send/SendForm.js index bdb781d9..3fe7a7e7 100644 --- a/src/js/components/wallet/account/send/SendForm.js +++ b/src/js/components/wallet/account/send/SendForm.js @@ -45,7 +45,6 @@ const Send = (props: Props) => { if (!device || !account || !discovery || !network) return null; - const { address, amount, @@ -192,10 +191,9 @@ const Send = (props: Props) => { + pending={ props.selectedAccount.pending } + tokens={ props.selectedAccount.tokens } + network={ network } /> ); diff --git a/src/js/components/wallet/account/send/index.js b/src/js/components/wallet/account/send/index.js index b8415ff6..47a62394 100644 --- a/src/js/components/wallet/account/send/index.js +++ b/src/js/components/wallet/account/send/index.js @@ -15,8 +15,6 @@ import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } type OwnProps = { } export type StateProps = BaseStateProps & { - tokens: $ElementType, - pending: $ElementType, sendForm: $ElementType, fiat: $ElementType, localStorage: $ElementType, @@ -35,8 +33,6 @@ const mapStateToProps: MapStateToProps = (state: St selectedAccount: state.selectedAccount, wallet: state.wallet, - tokens: state.tokens, - pending: state.pending, sendForm: state.sendForm, fiat: state.fiat, localStorage: state.localStorage