From 6f8f26d392ae2942dc9fe95fdafe2bcdcde12a42 Mon Sep 17 00:00:00 2001 From: George Lima Date: Wed, 10 Apr 2019 20:17:14 -0300 Subject: [PATCH] feat(send): deny send transaction if node isn`t ready --- app/containers/send.js | 4 +++- app/redux/modules/app.js | 3 ++- app/views/send.js | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/containers/send.js b/app/containers/send.js index 9495854..0efd4e9 100644 --- a/app/containers/send.js +++ b/app/containers/send.js @@ -45,9 +45,10 @@ export type MapStateToProps = {| isSending: boolean, operationId: string | null, isToAddressValid: boolean, + nodeSyncType: string, |}; -const mapStateToProps = ({ sendStatus, receive }: AppState): MapStateToProps => ({ +const mapStateToProps = ({ sendStatus, receive, app }: AppState): MapStateToProps => ({ balance: sendStatus.addressBalance, zecPrice: sendStatus.zecPrice, addresses: receive.addresses, @@ -55,6 +56,7 @@ const mapStateToProps = ({ sendStatus, receive }: AppState): MapStateToProps => isSending: sendStatus.isSending, operationId: sendStatus.operationId, isToAddressValid: sendStatus.isToAddressValid, + nodeSyncType: app.nodeSyncType, }); export type MapDispatchToProps = {| diff --git a/app/redux/modules/app.js b/app/redux/modules/app.js index 7c7ad2f..c3124de 100644 --- a/app/redux/modules/app.js +++ b/app/redux/modules/app.js @@ -3,6 +3,7 @@ import electronStore from '../../../config/electron-store'; import { ZCASH_NETWORK, EMBEDDED_DAEMON } from '../../constants/zcash-network'; +import { NODE_SYNC_TYPES } from '../../constants/node-sync-types'; import type { Action } from '../../types/redux'; @@ -50,7 +51,7 @@ const initialState: State = { isErrorModalVisible: false, error: null, nodeSyncProgress: 0, - nodeSyncType: 'syncing', + nodeSyncType: NODE_SYNC_TYPES.SYNCING, zcashNetwork: electronStore.get(ZCASH_NETWORK), embeddedDaemon: electronStore.get(EMBEDDED_DAEMON), }; diff --git a/app/views/send.js b/app/views/send.js index 6325274..8e97c3c 100644 --- a/app/views/send.js +++ b/app/views/send.js @@ -8,6 +8,7 @@ import { type Match } from 'react-router-dom'; import { FEES } from '../constants/fees'; import { DARK } from '../constants/themes'; +import { NODE_SYNC_TYPES } from '../constants/node-sync-types'; import { InputLabelComponent } from '../components/input-label'; import { InputComponent } from '../components/input'; @@ -690,7 +691,7 @@ class Component extends PureComponent { }; shouldDisableSendButton = () => { - const { balance, isToAddressValid } = this.props; + const { balance, isToAddressValid, nodeSyncType } = this.props; const { from, amount, to, fee, } = this.state; @@ -703,6 +704,7 @@ class Component extends PureComponent { || !isToAddressValid || new BigNumber(amount).gt(balance) || !this.isMemoContentValid() + || nodeSyncType !== NODE_SYNC_TYPES.READY ); }; @@ -722,7 +724,14 @@ class Component extends PureComponent { render() { const { - addresses, balance, zecPrice, isSending, error, operationId, theme, + addresses, + balance, + zecPrice, + isSending, + error, + operationId, + theme, + nodeSyncType, } = this.props; const { showFee, @@ -925,6 +934,11 @@ class Component extends PureComponent { onClose={this.reset} renderTrigger={toggle => ( + {nodeSyncType === NODE_SYNC_TYPES.READY ? null : ( + + + + )} {!showBalanceTooltip ? null : (