mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-09 06:32:41 +00:00
added blockchain connect Notification
This commit is contained in:
parent
1379a2e745
commit
67eadc332d
@ -1,6 +1,7 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Notification } from 'components/Notification';
|
import { Notification } from 'components/Notification';
|
||||||
|
import { reconnect } from 'actions/DiscoveryActions';
|
||||||
|
|
||||||
import type { State } from 'flowtype';
|
import type { State } from 'flowtype';
|
||||||
|
|
||||||
@ -8,11 +9,12 @@ export type StateProps = {
|
|||||||
className: string;
|
className: string;
|
||||||
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||||
wallet: $ElementType<State, 'wallet'>,
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
|
blockchain: $ElementType<State, 'blockchain'>,
|
||||||
children?: React.Node
|
children?: React.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DispatchProps = {
|
export type DispatchProps = {
|
||||||
|
blockchainReconnect: typeof reconnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
export type Props = StateProps & DispatchProps;
|
||||||
@ -28,8 +30,26 @@ const SelectedAccount = (props: Props) => {
|
|||||||
const {
|
const {
|
||||||
account,
|
account,
|
||||||
discovery,
|
discovery,
|
||||||
|
network
|
||||||
} = accountState;
|
} = accountState;
|
||||||
|
|
||||||
|
const blockchain = props.blockchain.find(b => b.name === network.network);
|
||||||
|
if (blockchain && !blockchain.connected) {
|
||||||
|
return (
|
||||||
|
<Notification
|
||||||
|
type="error"
|
||||||
|
title="Backend not connected"
|
||||||
|
actions={
|
||||||
|
[{
|
||||||
|
label: "Try again",
|
||||||
|
callback: async () => {
|
||||||
|
await props.blockchainReconnect(network.network);
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// account not found (yet). checking why...
|
// account not found (yet). checking why...
|
||||||
if (!account) {
|
if (!account) {
|
||||||
if (!discovery || discovery.waitingForDevice) {
|
if (!discovery || discovery.waitingForDevice) {
|
||||||
@ -57,10 +77,20 @@ const SelectedAccount = (props: Props) => {
|
|||||||
message="Connect device to load accounts"
|
message="Connect device to load accounts"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} if (discovery.waitingForBackend) {
|
} if (discovery.waitingForBlockchain) {
|
||||||
// case 4: backend is not working
|
// case 4: backend is not working
|
||||||
return (
|
return (
|
||||||
<Notification type="warning" title="Backend not working" />
|
<Notification
|
||||||
|
type="error"
|
||||||
|
title="Backend not connected"
|
||||||
|
actions={
|
||||||
|
[{
|
||||||
|
label: "Try again",
|
||||||
|
callback: async () => {
|
||||||
|
await props.blockchainReconnect(discovery.network);
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
} />
|
||||||
);
|
);
|
||||||
} if (discovery.completed) {
|
} if (discovery.completed) {
|
||||||
// case 5: account not found and discovery is completed
|
// case 5: account not found and discovery is completed
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import { reconnect } from 'actions/DiscoveryActions';
|
||||||
import { showAddress } from 'actions/ReceiveActions';
|
import { showAddress } from 'actions/ReceiveActions';
|
||||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
import type { State, Dispatch } from 'flowtype';
|
import type { State, Dispatch } from 'flowtype';
|
||||||
@ -28,12 +29,14 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
className: 'receive',
|
className: 'receive',
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
wallet: state.wallet,
|
wallet: state.wallet,
|
||||||
|
blockchain: state.blockchain,
|
||||||
|
|
||||||
receive: state.receive,
|
receive: state.receive,
|
||||||
modal: state.modal,
|
modal: state.modal,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
||||||
|
blockchainReconnect: bindActionCreators(reconnect, dispatch),
|
||||||
showAddress: bindActionCreators(showAddress, dispatch),
|
showAddress: bindActionCreators(showAddress, dispatch),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import * as React from 'react';
|
|||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import { reconnect } from 'actions/DiscoveryActions';
|
||||||
import SendFormActions from 'actions/SendFormActions';
|
import SendFormActions from 'actions/SendFormActions';
|
||||||
import * as SessionStorageActions from 'actions/SessionStorageActions';
|
import * as SessionStorageActions from 'actions/SessionStorageActions';
|
||||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
@ -12,7 +13,6 @@ import type { State, Dispatch } from 'flowtype';
|
|||||||
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from 'views/Wallet/components/SelectedAccount';
|
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from 'views/Wallet/components/SelectedAccount';
|
||||||
import AccountSend from './index';
|
import AccountSend from './index';
|
||||||
|
|
||||||
|
|
||||||
type OwnProps = { }
|
type OwnProps = { }
|
||||||
|
|
||||||
export type StateProps = BaseStateProps & {
|
export type StateProps = BaseStateProps & {
|
||||||
@ -33,6 +33,7 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
className: 'send-from',
|
className: 'send-from',
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
wallet: state.wallet,
|
wallet: state.wallet,
|
||||||
|
blockchain: state.blockchain,
|
||||||
|
|
||||||
sendForm: state.sendForm,
|
sendForm: state.sendForm,
|
||||||
fiat: state.fiat,
|
fiat: state.fiat,
|
||||||
@ -40,6 +41,7 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
||||||
|
blockchainReconnect: bindActionCreators(reconnect, dispatch),
|
||||||
sendFormActions: bindActionCreators(SendFormActions, dispatch),
|
sendFormActions: bindActionCreators(SendFormActions, dispatch),
|
||||||
saveSessionStorage: bindActionCreators(SessionStorageActions.save, dispatch),
|
saveSessionStorage: bindActionCreators(SessionStorageActions.save, dispatch),
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ import { bindActionCreators } from 'redux';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
|
import { reconnect } from 'actions/DiscoveryActions';
|
||||||
import * as TokenActions from 'actions/TokenActions';
|
import * as TokenActions from 'actions/TokenActions';
|
||||||
|
|
||||||
import type { State, Dispatch } from 'flowtype';
|
import type { State, Dispatch } from 'flowtype';
|
||||||
@ -30,6 +31,7 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
className: 'summary',
|
className: 'summary',
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
wallet: state.wallet,
|
wallet: state.wallet,
|
||||||
|
blockchain: state.blockchain,
|
||||||
|
|
||||||
tokens: state.tokens,
|
tokens: state.tokens,
|
||||||
summary: state.summary,
|
summary: state.summary,
|
||||||
@ -38,6 +40,7 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
||||||
|
blockchainReconnect: bindActionCreators(reconnect, dispatch),
|
||||||
addToken: bindActionCreators(TokenActions.add, dispatch),
|
addToken: bindActionCreators(TokenActions.add, dispatch),
|
||||||
loadTokens: bindActionCreators(TokenActions.load, dispatch),
|
loadTokens: bindActionCreators(TokenActions.load, dispatch),
|
||||||
removeToken: bindActionCreators(TokenActions.remove, dispatch),
|
removeToken: bindActionCreators(TokenActions.remove, dispatch),
|
||||||
|
Loading…
Reference in New Issue
Block a user