feat(send): deny send transaction if node isn`t ready
This commit is contained in:
parent
777807d1b3
commit
6f8f26d392
|
@ -45,9 +45,10 @@ export type MapStateToProps = {|
|
||||||
isSending: boolean,
|
isSending: boolean,
|
||||||
operationId: string | null,
|
operationId: string | null,
|
||||||
isToAddressValid: boolean,
|
isToAddressValid: boolean,
|
||||||
|
nodeSyncType: string,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
const mapStateToProps = ({ sendStatus, receive }: AppState): MapStateToProps => ({
|
const mapStateToProps = ({ sendStatus, receive, app }: AppState): MapStateToProps => ({
|
||||||
balance: sendStatus.addressBalance,
|
balance: sendStatus.addressBalance,
|
||||||
zecPrice: sendStatus.zecPrice,
|
zecPrice: sendStatus.zecPrice,
|
||||||
addresses: receive.addresses,
|
addresses: receive.addresses,
|
||||||
|
@ -55,6 +56,7 @@ const mapStateToProps = ({ sendStatus, receive }: AppState): MapStateToProps =>
|
||||||
isSending: sendStatus.isSending,
|
isSending: sendStatus.isSending,
|
||||||
operationId: sendStatus.operationId,
|
operationId: sendStatus.operationId,
|
||||||
isToAddressValid: sendStatus.isToAddressValid,
|
isToAddressValid: sendStatus.isToAddressValid,
|
||||||
|
nodeSyncType: app.nodeSyncType,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type MapDispatchToProps = {|
|
export type MapDispatchToProps = {|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import electronStore from '../../../config/electron-store';
|
import electronStore from '../../../config/electron-store';
|
||||||
|
|
||||||
import { ZCASH_NETWORK, EMBEDDED_DAEMON } from '../../constants/zcash-network';
|
import { ZCASH_NETWORK, EMBEDDED_DAEMON } from '../../constants/zcash-network';
|
||||||
|
import { NODE_SYNC_TYPES } from '../../constants/node-sync-types';
|
||||||
|
|
||||||
import type { Action } from '../../types/redux';
|
import type { Action } from '../../types/redux';
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ const initialState: State = {
|
||||||
isErrorModalVisible: false,
|
isErrorModalVisible: false,
|
||||||
error: null,
|
error: null,
|
||||||
nodeSyncProgress: 0,
|
nodeSyncProgress: 0,
|
||||||
nodeSyncType: 'syncing',
|
nodeSyncType: NODE_SYNC_TYPES.SYNCING,
|
||||||
zcashNetwork: electronStore.get(ZCASH_NETWORK),
|
zcashNetwork: electronStore.get(ZCASH_NETWORK),
|
||||||
embeddedDaemon: electronStore.get(EMBEDDED_DAEMON),
|
embeddedDaemon: electronStore.get(EMBEDDED_DAEMON),
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { type Match } from 'react-router-dom';
|
||||||
|
|
||||||
import { FEES } from '../constants/fees';
|
import { FEES } from '../constants/fees';
|
||||||
import { DARK } from '../constants/themes';
|
import { DARK } from '../constants/themes';
|
||||||
|
import { NODE_SYNC_TYPES } from '../constants/node-sync-types';
|
||||||
|
|
||||||
import { InputLabelComponent } from '../components/input-label';
|
import { InputLabelComponent } from '../components/input-label';
|
||||||
import { InputComponent } from '../components/input';
|
import { InputComponent } from '../components/input';
|
||||||
|
@ -690,7 +691,7 @@ class Component extends PureComponent<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
shouldDisableSendButton = () => {
|
shouldDisableSendButton = () => {
|
||||||
const { balance, isToAddressValid } = this.props;
|
const { balance, isToAddressValid, nodeSyncType } = this.props;
|
||||||
const {
|
const {
|
||||||
from, amount, to, fee,
|
from, amount, to, fee,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
@ -703,6 +704,7 @@ class Component extends PureComponent<Props, State> {
|
||||||
|| !isToAddressValid
|
|| !isToAddressValid
|
||||||
|| new BigNumber(amount).gt(balance)
|
|| new BigNumber(amount).gt(balance)
|
||||||
|| !this.isMemoContentValid()
|
|| !this.isMemoContentValid()
|
||||||
|
|| nodeSyncType !== NODE_SYNC_TYPES.READY
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -722,7 +724,14 @@ class Component extends PureComponent<Props, State> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
addresses, balance, zecPrice, isSending, error, operationId, theme,
|
addresses,
|
||||||
|
balance,
|
||||||
|
zecPrice,
|
||||||
|
isSending,
|
||||||
|
error,
|
||||||
|
operationId,
|
||||||
|
theme,
|
||||||
|
nodeSyncType,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const {
|
const {
|
||||||
showFee,
|
showFee,
|
||||||
|
@ -925,6 +934,11 @@ class Component extends PureComponent<Props, State> {
|
||||||
onClose={this.reset}
|
onClose={this.reset}
|
||||||
renderTrigger={toggle => (
|
renderTrigger={toggle => (
|
||||||
<SendButtonWrapper>
|
<SendButtonWrapper>
|
||||||
|
{nodeSyncType === NODE_SYNC_TYPES.READY ? null : (
|
||||||
|
<SimpleTooltip>
|
||||||
|
<TooltipText value='Cannot send transaction until data is synced.' />
|
||||||
|
</SimpleTooltip>
|
||||||
|
)}
|
||||||
{!showBalanceTooltip ? null : (
|
{!showBalanceTooltip ? null : (
|
||||||
<SimpleTooltip>
|
<SimpleTooltip>
|
||||||
<TooltipText value='Not enough funds!' />
|
<TooltipText value='Not enough funds!' />
|
||||||
|
|
Loading…
Reference in New Issue