mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-29 10:28:08 +00:00
abstractAccount > SelectedAccount
This commit is contained in:
parent
58d023fd46
commit
b7bed8ee4c
@ -15,7 +15,7 @@ import type {
|
|||||||
import type { Reducers, ReducersState } from '~/js/reducers';
|
import type { Reducers, ReducersState } from '~/js/reducers';
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
import type { AbstractAccountAction } from '~/js/actions/AbstractAccountActions';
|
import type { SelectedAccountAction } from '~/js/actions/SelectedAccountActions';
|
||||||
import type { AccountAction } from '~/js/actions/AccountsActions';
|
import type { AccountAction } from '~/js/actions/AccountsActions';
|
||||||
import type { DiscoveryAction } from '~/js/actions/DiscoveryActions';
|
import type { DiscoveryAction } from '~/js/actions/DiscoveryActions';
|
||||||
import type { StorageAction } from '~/js/actions/LocalStorageActions';
|
import type { StorageAction } from '~/js/actions/LocalStorageActions';
|
||||||
@ -94,7 +94,7 @@ export type Action =
|
|||||||
| DeviceEventAction
|
| DeviceEventAction
|
||||||
| UiEventAction
|
| UiEventAction
|
||||||
|
|
||||||
| AbstractAccountAction
|
| SelectedAccountAction
|
||||||
| AccountAction
|
| AccountAction
|
||||||
| DiscoveryAction
|
| DiscoveryAction
|
||||||
| StorageAction
|
| StorageAction
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
import * as ACCOUNT from './constants/account';
|
import * as ACCOUNT from './constants/account';
|
||||||
|
|
||||||
import { initialState } from '../reducers/AbstractAccountReducer';
|
import { initialState } from '../reducers/SelectedAccountReducer';
|
||||||
import { findSelectedDevice } from '../reducers/TrezorConnectReducer';
|
import { findSelectedDevice } from '../reducers/TrezorConnectReducer';
|
||||||
|
|
||||||
import type { AsyncAction, ThunkAction, Action, GetState, Dispatch, TrezorDevice } from '~/flowtype';
|
import type { AsyncAction, ThunkAction, Action, GetState, Dispatch, TrezorDevice } from '~/flowtype';
|
||||||
import type { State } from '../reducers/AbstractAccountReducer';
|
import type { State } from '../reducers/SelectedAccountReducer';
|
||||||
import type { Coin } from '../reducers/LocalStorageReducer';
|
import type { Coin } from '../reducers/LocalStorageReducer';
|
||||||
|
|
||||||
export type AbstractAccountAction = {
|
export type SelectedAccountAction = {
|
||||||
type: typeof ACCOUNT.INIT,
|
type: typeof ACCOUNT.INIT,
|
||||||
state: State
|
state: State
|
||||||
} | {
|
} | {
|
||||||
@ -52,15 +52,15 @@ export const init = (): ThunkAction => {
|
|||||||
export const update = (initAccountAction: () => ThunkAction): ThunkAction => {
|
export const update = (initAccountAction: () => ThunkAction): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const {
|
const {
|
||||||
abstractAccount,
|
selectedAccount,
|
||||||
router
|
router
|
||||||
} = getState();
|
} = getState();
|
||||||
|
|
||||||
const shouldReload: boolean = (!abstractAccount || router.location.pathname !== abstractAccount.location);
|
const shouldReload: boolean = (!selectedAccount || router.location.pathname !== selectedAccount.location);
|
||||||
if (shouldReload) {
|
if (shouldReload) {
|
||||||
dispatch( dispose() );
|
dispatch( dispose() );
|
||||||
dispatch( init() );
|
dispatch( init() );
|
||||||
if (abstractAccount !== null)
|
if (selectedAccount !== null)
|
||||||
initAccountAction();
|
initAccountAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ import type {
|
|||||||
RouterLocationState,
|
RouterLocationState,
|
||||||
TrezorDevice
|
TrezorDevice
|
||||||
} from '~/flowtype';
|
} from '~/flowtype';
|
||||||
import type { State as AccountState } from '../reducers/AbstractAccountReducer';
|
import type { State as AccountState } from '../reducers/SelectedAccountReducer';
|
||||||
import type { Web3Instance } from '../reducers/Web3Reducer';
|
import type { Web3Instance } from '../reducers/Web3Reducer';
|
||||||
import type { Config, Coin } from '../reducers/LocalStorageReducer';
|
import type { Config, Coin } from '../reducers/LocalStorageReducer';
|
||||||
import type { Token } from '../reducers/TokensReducer';
|
import type { Token } from '../reducers/TokensReducer';
|
||||||
@ -197,7 +197,7 @@ export const getFeeLevels = (symbol: string, gasPrice: BigNumber | string, gasLi
|
|||||||
export const init = (): ThunkAction => {
|
export const init = (): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
|
|
||||||
const { location } = getState().router;
|
const { location } = getState().router;
|
||||||
@ -257,7 +257,7 @@ export const toggleAdvanced = (address: string): Action => {
|
|||||||
export const validation = (): ThunkAction => {
|
export const validation = (): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
|
|
||||||
const state: State = getState().sendForm;
|
const state: State = getState().sendForm;
|
||||||
@ -438,7 +438,7 @@ export const onAddressChange = (address: string): ThunkAction => {
|
|||||||
export const onAmountChange = (amount: string): ThunkAction => {
|
export const onAmountChange = (amount: string): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
||||||
const touched = { ...currentState.touched };
|
const touched = { ...currentState.touched };
|
||||||
@ -464,7 +464,7 @@ export const onAmountChange = (amount: string): ThunkAction => {
|
|||||||
|
|
||||||
export const onCurrencyChange = (currency: { value: string, label: string }): ThunkAction => {
|
export const onCurrencyChange = (currency: { value: string, label: string }): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
const isToken: boolean = currency.value !== currentState.coinSymbol;
|
const isToken: boolean = currency.value !== currentState.coinSymbol;
|
||||||
@ -522,7 +522,7 @@ export const onCurrencyChange = (currency: { value: string, label: string }): Th
|
|||||||
|
|
||||||
export const onSetMax = (): ThunkAction => {
|
export const onSetMax = (): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
||||||
@ -568,7 +568,7 @@ export const onSetMax = (): ThunkAction => {
|
|||||||
|
|
||||||
export const onFeeLevelChange = (feeLevel: FeeLevel): ThunkAction => {
|
export const onFeeLevelChange = (feeLevel: FeeLevel): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
||||||
@ -620,7 +620,7 @@ export const onFeeLevelChange = (feeLevel: FeeLevel): ThunkAction => {
|
|||||||
|
|
||||||
export const updateFeeLevels = (): ThunkAction => {
|
export const updateFeeLevels = (): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
||||||
@ -661,7 +661,7 @@ export const updateFeeLevels = (): ThunkAction => {
|
|||||||
|
|
||||||
export const onGasPriceChange = (gasPrice: string): ThunkAction => {
|
export const onGasPriceChange = (gasPrice: string): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
||||||
@ -714,7 +714,7 @@ export const onGasPriceChange = (gasPrice: string): ThunkAction => {
|
|||||||
|
|
||||||
export const onGasLimitChange = (gasLimit: string): ThunkAction => {
|
export const onGasLimitChange = (gasLimit: string): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
const isToken: boolean = currentState.selectedCurrency !== currentState.coinSymbol;
|
||||||
@ -808,7 +808,7 @@ export const onDataChange = (data: string): AsyncAction => {
|
|||||||
const estimateGasPrice = (): AsyncAction => {
|
const estimateGasPrice = (): AsyncAction => {
|
||||||
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
|
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
const web3instance: ?Web3Instance = getState().web3.filter(w3 => w3.network === accountState.network)[0];
|
const web3instance: ?Web3Instance = getState().web3.filter(w3 => w3.network === accountState.network)[0];
|
||||||
if (!web3instance) return;
|
if (!web3instance) return;
|
||||||
@ -841,7 +841,7 @@ export const onSend = (): AsyncAction => {
|
|||||||
//return onSendERC20();
|
//return onSendERC20();
|
||||||
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
|
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
|
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
|
@ -9,9 +9,9 @@ import type { Props } from './index';
|
|||||||
|
|
||||||
const ConfirmAddress = (props: Props) => {
|
const ConfirmAddress = (props: Props) => {
|
||||||
|
|
||||||
const { accounts, abstractAccount } = props;
|
const { accounts, selectedAccount } = props;
|
||||||
if (!abstractAccount) return null;
|
if (!selectedAccount) return null;
|
||||||
const account = findAccount(accounts, abstractAccount.index, abstractAccount.deviceState, abstractAccount.network);
|
const account = findAccount(accounts, selectedAccount.index, selectedAccount.deviceState, selectedAccount.network);
|
||||||
if (!account) return null;
|
if (!account) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -22,7 +22,7 @@ const ConfirmAddress = (props: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="content">
|
<div className="content">
|
||||||
<p>{ account.address }</p>
|
<p>{ account.address }</p>
|
||||||
<label>{ abstractAccount.coin.symbol } account #{ (account.index + 1) }</label>
|
<label>{ selectedAccount.coin.symbol } account #{ (account.index + 1) }</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -54,11 +54,11 @@ export class ConfirmUnverifiedAddress extends Component<Props> {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
accounts,
|
accounts,
|
||||||
abstractAccount
|
selectedAccount
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
if(!abstractAccount) return null;
|
if(!selectedAccount) return null;
|
||||||
const account = findAccount(accounts, abstractAccount.index, abstractAccount.deviceState, abstractAccount.network);
|
const account = findAccount(accounts, selectedAccount.index, selectedAccount.deviceState, selectedAccount.network);
|
||||||
if (!account) return null;
|
if (!account) return null;
|
||||||
|
|
||||||
this.props.modalActions.onCancel();
|
this.props.modalActions.onCancel();
|
||||||
|
@ -36,7 +36,7 @@ type StateProps = {
|
|||||||
accounts: $ElementType<State, 'accounts'>,
|
accounts: $ElementType<State, 'accounts'>,
|
||||||
devices: $PropertyType<$ElementType<State, 'connect'>, 'devices'>,
|
devices: $PropertyType<$ElementType<State, 'connect'>, 'devices'>,
|
||||||
connect: $ElementType<State, 'connect'>,
|
connect: $ElementType<State, 'connect'>,
|
||||||
abstractAccount: $ElementType<State, 'abstractAccount'>,
|
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||||
sendForm: $ElementType<State, 'sendForm'>,
|
sendForm: $ElementType<State, 'sendForm'>,
|
||||||
receive: $ElementType<State, 'receive'>,
|
receive: $ElementType<State, 'receive'>,
|
||||||
localStorage: $ElementType<State, 'localStorage'>,
|
localStorage: $ElementType<State, 'localStorage'>,
|
||||||
@ -128,7 +128,7 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
devices: state.connect.devices,
|
devices: state.connect.devices,
|
||||||
connect: state.connect,
|
connect: state.connect,
|
||||||
abstractAccount: state.abstractAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
sendForm: state.sendForm,
|
sendForm: state.sendForm,
|
||||||
receive: state.receive,
|
receive: state.receive,
|
||||||
localStorage: state.localStorage
|
localStorage: state.localStorage
|
||||||
|
@ -5,22 +5,22 @@ import React, { Component } from 'react';
|
|||||||
import { Notification } from '~/js/components/common/Notification';
|
import { Notification } from '~/js/components/common/Notification';
|
||||||
import { findDevice } from '~/js/reducers/TrezorConnectReducer';
|
import { findDevice } from '~/js/reducers/TrezorConnectReducer';
|
||||||
|
|
||||||
// import * as AbstractAccountActions from '~/js/actions/AbstractAccountActions';
|
// import * as SelectedAccountActions from '~/js/actions/SelectedAccountActions';
|
||||||
import { default as AbstractAccountActions } from '~/js/actions/AbstractAccountActions';
|
import { default as SelectedAccountActions } from '~/js/actions/SelectedAccountActions';
|
||||||
|
|
||||||
import type { State, TrezorDevice, Action, ThunkAction } from '~/flowtype';
|
import type { State, TrezorDevice, Action, ThunkAction } from '~/flowtype';
|
||||||
import type { Account } from '~/js/reducers/AccountsReducer';
|
import type { Account } from '~/js/reducers/AccountsReducer';
|
||||||
import type { Discovery } from '~/js/reducers/DiscoveryReducer';
|
import type { Discovery } from '~/js/reducers/DiscoveryReducer';
|
||||||
|
|
||||||
export type StateProps = {
|
export type StateProps = {
|
||||||
abstractAccount: $ElementType<State, 'abstractAccount'>,
|
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||||
devices: $PropertyType<$ElementType<State, 'connect'>, 'devices'>,
|
devices: $PropertyType<$ElementType<State, 'connect'>, 'devices'>,
|
||||||
discovery: $ElementType<State, 'discovery'>,
|
discovery: $ElementType<State, 'discovery'>,
|
||||||
accounts: $ElementType<State, 'accounts'>,
|
accounts: $ElementType<State, 'accounts'>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DispatchProps = {
|
export type DispatchProps = {
|
||||||
abstractAccountActions: typeof AbstractAccountActions,
|
selectedAccountActions: typeof SelectedAccountActions,
|
||||||
initAccount: () => ThunkAction,
|
initAccount: () => ThunkAction,
|
||||||
disposeAccount: () => Action,
|
disposeAccount: () => Action,
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ export type AccountState = {
|
|||||||
deviceStatusNotification: ?React$Element<typeof Notification>;
|
deviceStatusNotification: ?React$Element<typeof Notification>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class AbstractAccount<P> extends Component<Props & P, AccountState> {
|
export default class SelectedAccount<P> extends Component<Props & P, AccountState> {
|
||||||
|
|
||||||
state: AccountState = {
|
state: AccountState = {
|
||||||
device: null,
|
device: null,
|
||||||
@ -44,15 +44,15 @@ export default class AbstractAccount<P> extends Component<Props & P, AccountStat
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.abstractAccountActions.init();
|
this.props.selectedAccountActions.init();
|
||||||
this.props.initAccount();
|
this.props.initAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(props: Props & P) {
|
componentWillReceiveProps(props: Props & P) {
|
||||||
|
|
||||||
this.props.abstractAccountActions.update( this.props.initAccount );
|
this.props.selectedAccountActions.update( this.props.initAccount );
|
||||||
|
|
||||||
const accountState = props.abstractAccount;
|
const accountState = props.selectedAccount;
|
||||||
if (!accountState) return;
|
if (!accountState) return;
|
||||||
|
|
||||||
const device = findDevice(props.devices, accountState.deviceId, accountState.deviceState, accountState.deviceInstance);
|
const device = findDevice(props.devices, accountState.deviceId, accountState.deviceState, accountState.deviceInstance);
|
||||||
@ -83,14 +83,14 @@ export default class AbstractAccount<P> extends Component<Props & P, AccountStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.abstractAccountActions.dispose();
|
this.props.selectedAccountActions.dispose();
|
||||||
this.props.disposeAccount();
|
this.props.disposeAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): ?React$Element<string> {
|
render(): ?React$Element<string> {
|
||||||
|
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
const accountState = props.abstractAccount;
|
const accountState = props.selectedAccount;
|
||||||
|
|
||||||
if (!accountState) {
|
if (!accountState) {
|
||||||
return (<section><Notification className="info" title="Loading device..." /></section>);
|
return (<section><Notification className="info" title="Loading device..." /></section>);
|
@ -6,13 +6,13 @@ import React, { Component } from 'react';
|
|||||||
import Tooltip from 'rc-tooltip';
|
import Tooltip from 'rc-tooltip';
|
||||||
import { QRCode } from 'react-qr-svg';
|
import { QRCode } from 'react-qr-svg';
|
||||||
|
|
||||||
import AbstractAccount from '../AbstractAccount';
|
import selectedAccount from '../SelectedAccount';
|
||||||
import { Notification } from '~/js/components/common/Notification';
|
import { Notification } from '~/js/components/common/Notification';
|
||||||
|
|
||||||
import type { AccountState } from '../AbstractAccount';
|
import type { AccountState } from '../SelectedAccount';
|
||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
|
|
||||||
export default class Receive extends AbstractAccount<Props> {
|
export default class Receive extends selectedAccount<Props> {
|
||||||
render() {
|
render() {
|
||||||
return super.render() || _render(this.props, this.state);
|
return super.render() || _render(this.props, this.state);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import { bindActionCreators } from 'redux';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { default as ReceiveActions } from '~/js/actions/ReceiveActions';
|
import { default as ReceiveActions } from '~/js/actions/ReceiveActions';
|
||||||
import { default as AbstractAccountActions } from '~/js/actions/AbstractAccountActions';
|
import { default as SelectedAccountActions } from '~/js/actions/SelectedAccountActions';
|
||||||
import * as TokenActions from '~/js/actions/TokenActions';
|
import * as TokenActions from '~/js/actions/TokenActions';
|
||||||
import Receive from './Receive';
|
import Receive from './Receive';
|
||||||
|
|
||||||
@ -15,9 +15,9 @@ import type { State, Dispatch } from '~/flowtype';
|
|||||||
import type {
|
import type {
|
||||||
StateProps as BaseStateProps,
|
StateProps as BaseStateProps,
|
||||||
DispatchProps as BaseDispatchProps
|
DispatchProps as BaseDispatchProps
|
||||||
} from '../AbstractAccount';
|
} from '../SelectedAccount';
|
||||||
|
|
||||||
import type { AccountState } from '../AbstractAccount';
|
import type { AccountState } from '../SelectedAccount';
|
||||||
|
|
||||||
type OwnProps = { }
|
type OwnProps = { }
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ export type Props = StateProps & DispatchProps;
|
|||||||
|
|
||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
||||||
return {
|
return {
|
||||||
abstractAccount: state.abstractAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
devices: state.connect.devices,
|
devices: state.connect.devices,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
@ -43,7 +43,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 => {
|
||||||
return {
|
return {
|
||||||
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
|
selectedAccountActions: bindActionCreators(SelectedAccountActions, dispatch),
|
||||||
|
|
||||||
initAccount: bindActionCreators(ReceiveActions.init, dispatch),
|
initAccount: bindActionCreators(ReceiveActions.init, dispatch),
|
||||||
disposeAccount: bindActionCreators(ReceiveActions.dispose, dispatch),
|
disposeAccount: bindActionCreators(ReceiveActions.dispose, dispatch),
|
||||||
|
@ -6,7 +6,7 @@ import Tooltip from 'rc-tooltip';
|
|||||||
import type { Props as BaseProps } from './index';
|
import type { Props as BaseProps } from './index';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
abstractAccount: $ElementType<BaseProps, 'abstractAccount'>,
|
selectedAccount: $ElementType<BaseProps, 'selectedAccount'>,
|
||||||
sendForm: $ElementType<BaseProps, 'sendForm'>,
|
sendForm: $ElementType<BaseProps, 'sendForm'>,
|
||||||
sendFormActions: $ElementType<BaseProps, 'sendFormActions'>,
|
sendFormActions: $ElementType<BaseProps, 'sendFormActions'>,
|
||||||
children?: $ElementType<BaseProps, 'children'>,
|
children?: $ElementType<BaseProps, 'children'>,
|
||||||
@ -14,10 +14,10 @@ type Props = {
|
|||||||
|
|
||||||
const AdvancedForm = (props: Props) => {
|
const AdvancedForm = (props: Props) => {
|
||||||
|
|
||||||
const abstractAccount = props.abstractAccount;
|
const selectedAccount = props.selectedAccount;
|
||||||
if (!abstractAccount) return null;
|
if (!selectedAccount) return null;
|
||||||
|
|
||||||
const { network } = abstractAccount;
|
const { network } = selectedAccount;
|
||||||
const {
|
const {
|
||||||
coinSymbol,
|
coinSymbol,
|
||||||
selectedCurrency,
|
selectedCurrency,
|
||||||
|
@ -7,13 +7,13 @@ import AdvancedForm from './AdvancedForm';
|
|||||||
import PendingTransactions from './PendingTransactions';
|
import PendingTransactions from './PendingTransactions';
|
||||||
import { FeeSelectValue, FeeSelectOption } from './FeeSelect';
|
import { FeeSelectValue, FeeSelectOption } from './FeeSelect';
|
||||||
import { Notification } from '~/js/components/common/Notification';
|
import { Notification } from '~/js/components/common/Notification';
|
||||||
import AbstractAccount from '../AbstractAccount';
|
import SelectedAccount from '../SelectedAccount';
|
||||||
import { findAccountTokens } from '~/js/reducers/TokensReducer';
|
import { findAccountTokens } from '~/js/reducers/TokensReducer';
|
||||||
|
|
||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
import type { AccountState } from '../AbstractAccount';
|
import type { AccountState } from '../SelectedAccount';
|
||||||
|
|
||||||
export default class Send extends AbstractAccount<Props> {
|
export default class Send extends SelectedAccount<Props> {
|
||||||
render() {
|
render() {
|
||||||
return super.render() || _render(this.props, this.state);
|
return super.render() || _render(this.props, this.state);
|
||||||
}
|
}
|
||||||
@ -27,12 +27,12 @@ const _render = (props: Props, state: AccountState): React$Element<string> => {
|
|||||||
discovery,
|
discovery,
|
||||||
deviceStatusNotification
|
deviceStatusNotification
|
||||||
} = state;
|
} = state;
|
||||||
const abstractAccount = props.abstractAccount;
|
const selectedAccount = props.selectedAccount;
|
||||||
|
|
||||||
if (!device || !account || !discovery || !abstractAccount) return <section></section>;
|
if (!device || !account || !discovery || !selectedAccount) return <section></section>;
|
||||||
|
|
||||||
const tokens = findAccountTokens(props.tokens, account);
|
const tokens = findAccountTokens(props.tokens, account);
|
||||||
const { network } = abstractAccount;
|
const { network } = selectedAccount;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
address,
|
address,
|
||||||
@ -61,7 +61,7 @@ const _render = (props: Props, state: AccountState): React$Element<string> => {
|
|||||||
onSend,
|
onSend,
|
||||||
} = props.sendFormActions;
|
} = props.sendFormActions;
|
||||||
|
|
||||||
const selectedCoin = abstractAccount.coin;
|
const selectedCoin = selectedAccount.coin;
|
||||||
const fiatRate = props.fiat.find(f => f.network === network);
|
const fiatRate = props.fiat.find(f => f.network === network);
|
||||||
|
|
||||||
const tokensSelectData = tokens.map(t => {
|
const tokensSelectData = tokens.map(t => {
|
||||||
@ -177,7 +177,7 @@ const _render = (props: Props, state: AccountState): React$Element<string> => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AdvancedForm
|
<AdvancedForm
|
||||||
abstractAccount={ props.abstractAccount }
|
selectedAccount={ props.selectedAccount }
|
||||||
sendForm={ props.sendForm }
|
sendForm={ props.sendForm }
|
||||||
sendFormActions={ props.sendFormActions }>
|
sendFormActions={ props.sendFormActions }>
|
||||||
<button disabled={ buttonDisabled } onClick={ event => onSend() }>{ buttonLabel }</button>
|
<button disabled={ buttonDisabled } onClick={ event => onSend() }>{ buttonLabel }</button>
|
||||||
|
@ -6,12 +6,12 @@ import { bindActionCreators } from 'redux';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { default as SendFormActions } from '~/js/actions/SendFormActions';
|
import { default as SendFormActions } from '~/js/actions/SendFormActions';
|
||||||
import { default as AbstractAccountActions } from '~/js/actions/AbstractAccountActions';
|
import { default as SelectedAccountActions } from '~/js/actions/SelectedAccountActions';
|
||||||
import SendForm from './SendForm';
|
import SendForm from './SendForm';
|
||||||
|
|
||||||
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';
|
||||||
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../AbstractAccount';
|
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount';
|
||||||
|
|
||||||
type OwnProps = { }
|
type OwnProps = { }
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ export type Props = StateProps & DispatchProps;
|
|||||||
|
|
||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
||||||
return {
|
return {
|
||||||
abstractAccount: state.abstractAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
devices: state.connect.devices,
|
devices: state.connect.devices,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
@ -46,7 +46,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 => {
|
||||||
return {
|
return {
|
||||||
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
|
selectedAccountActions: bindActionCreators(SelectedAccountActions, dispatch),
|
||||||
sendFormActions: bindActionCreators(SendFormActions, dispatch),
|
sendFormActions: bindActionCreators(SendFormActions, dispatch),
|
||||||
initAccount: bindActionCreators(SendFormActions.init, dispatch),
|
initAccount: bindActionCreators(SendFormActions.init, dispatch),
|
||||||
disposeAccount: bindActionCreators(SendFormActions.dispose, dispatch),
|
disposeAccount: bindActionCreators(SendFormActions.dispose, dispatch),
|
||||||
|
@ -7,13 +7,13 @@ import { Async } from 'react-select';
|
|||||||
import Tooltip from 'rc-tooltip';
|
import Tooltip from 'rc-tooltip';
|
||||||
|
|
||||||
import { resolveAfter } from '~/js/utils/promiseUtils';
|
import { resolveAfter } from '~/js/utils/promiseUtils';
|
||||||
import AbstractAccount from '../AbstractAccount';
|
import SelectedAccount from '../SelectedAccount';
|
||||||
import { Notification } from '~/js/components/common/Notification';
|
import { Notification } from '~/js/components/common/Notification';
|
||||||
import SummaryDetails from './SummaryDetails.js';
|
import SummaryDetails from './SummaryDetails.js';
|
||||||
import SummaryTokens from './SummaryTokens.js';
|
import SummaryTokens from './SummaryTokens.js';
|
||||||
|
|
||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
import type { AccountState } from '../AbstractAccount';
|
import type { AccountState } from '../SelectedAccount';
|
||||||
|
|
||||||
import type { TrezorDevice } from '~/flowtype';
|
import type { TrezorDevice } from '~/flowtype';
|
||||||
import type { NetworkToken } from '~/js/reducers/LocalStorageReducer';
|
import type { NetworkToken } from '~/js/reducers/LocalStorageReducer';
|
||||||
@ -21,7 +21,7 @@ import type { Account } from '~/js/reducers/AccountsReducer';
|
|||||||
import type { Discovery } from '~/js/reducers/DiscoveryReducer';
|
import type { Discovery } from '~/js/reducers/DiscoveryReducer';
|
||||||
import { findAccountTokens } from '~/js/reducers/TokensReducer';
|
import { findAccountTokens } from '~/js/reducers/TokensReducer';
|
||||||
|
|
||||||
export default class Summary extends AbstractAccount<Props> {
|
export default class Summary extends SelectedAccount<Props> {
|
||||||
render() {
|
render() {
|
||||||
return super.render() || _render(this.props, this.state);
|
return super.render() || _render(this.props, this.state);
|
||||||
}
|
}
|
||||||
@ -34,13 +34,13 @@ const _render = (props: Props, state: AccountState): React$Element<string> => {
|
|||||||
account,
|
account,
|
||||||
deviceStatusNotification
|
deviceStatusNotification
|
||||||
} = state;
|
} = state;
|
||||||
const abstractAccount = props.abstractAccount;
|
const selectedAccount = props.selectedAccount;
|
||||||
|
|
||||||
if (!device || !account || !abstractAccount) return <section></section>;
|
if (!device || !account || !selectedAccount) return <section></section>;
|
||||||
|
|
||||||
|
|
||||||
const tokens = findAccountTokens(props.tokens, account);
|
const tokens = findAccountTokens(props.tokens, account);
|
||||||
const explorerLink: string = `${abstractAccount.coin.explorer.address}${account.address}`;
|
const explorerLink: string = `${selectedAccount.coin.explorer.address}${account.address}`;
|
||||||
|
|
||||||
const tokensTooltip = (
|
const tokensTooltip = (
|
||||||
<div className="tooltip-wrapper">
|
<div className="tooltip-wrapper">
|
||||||
@ -53,16 +53,16 @@ const _render = (props: Props, state: AccountState): React$Element<string> => {
|
|||||||
<section className="summary">
|
<section className="summary">
|
||||||
{ deviceStatusNotification }
|
{ deviceStatusNotification }
|
||||||
|
|
||||||
<h2 className={ `summary-header ${abstractAccount.network}` }>
|
<h2 className={ `summary-header ${selectedAccount.network}` }>
|
||||||
Account #{ parseInt(abstractAccount.index) + 1 }
|
Account #{ parseInt(selectedAccount.index) + 1 }
|
||||||
<a href={ explorerLink } className="gray" target="_blank" rel="noreferrer noopener">See full transaction history</a>
|
<a href={ explorerLink } className="gray" target="_blank" rel="noreferrer noopener">See full transaction history</a>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<SummaryDetails
|
<SummaryDetails
|
||||||
coin={ abstractAccount.coin }
|
coin={ selectedAccount.coin }
|
||||||
summary={ props.summary }
|
summary={ props.summary }
|
||||||
balance={ account.balance }
|
balance={ account.balance }
|
||||||
network={ abstractAccount.network }
|
network={ selectedAccount.network }
|
||||||
fiat={ props.fiat }
|
fiat={ props.fiat }
|
||||||
localStorage={ props.localStorage }
|
localStorage={ props.localStorage }
|
||||||
onToggle={ props.onDetailsToggle } />
|
onToggle={ props.onDetailsToggle } />
|
||||||
|
@ -8,7 +8,7 @@ import type { Props as BaseProps } from './index';
|
|||||||
import type { Coin } from '~/js/reducers/LocalStorageReducer';
|
import type { Coin } from '~/js/reducers/LocalStorageReducer';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
// coin: $PropertyType<$ElementType<BaseProps, 'abstractAccount'>, 'coin'>,
|
// coin: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'coin'>,
|
||||||
coin: Coin,
|
coin: Coin,
|
||||||
summary: $ElementType<BaseProps, 'summary'>,
|
summary: $ElementType<BaseProps, 'summary'>,
|
||||||
balance: string,
|
balance: string,
|
||||||
|
@ -6,13 +6,13 @@ import { bindActionCreators } from 'redux';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import Summary from './Summary';
|
import Summary from './Summary';
|
||||||
import { default as AbstractAccountActions } from '~/js/actions/AbstractAccountActions';
|
import { default as SelectedAccountActions } from '~/js/actions/SelectedAccountActions';
|
||||||
import * as SummaryActions from '~/js/actions/SummaryActions';
|
import * as SummaryActions from '~/js/actions/SummaryActions';
|
||||||
import * as TokenActions from '~/js/actions/TokenActions';
|
import * as TokenActions from '~/js/actions/TokenActions';
|
||||||
|
|
||||||
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';
|
||||||
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../AbstractAccount';
|
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount';
|
||||||
|
|
||||||
type OwnProps = { }
|
type OwnProps = { }
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ export type Props = StateProps & DispatchProps;
|
|||||||
|
|
||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
||||||
return {
|
return {
|
||||||
abstractAccount: state.abstractAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
devices: state.connect.devices,
|
devices: state.connect.devices,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
@ -48,7 +48,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 => {
|
||||||
return {
|
return {
|
||||||
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
|
selectedAccountActions: bindActionCreators(SelectedAccountActions, dispatch),
|
||||||
|
|
||||||
initAccount: bindActionCreators(SummaryActions.init, dispatch),
|
initAccount: bindActionCreators(SummaryActions.init, dispatch),
|
||||||
disposeAccount: bindActionCreators(SummaryActions.dispose, dispatch),
|
disposeAccount: bindActionCreators(SummaryActions.dispose, dispatch),
|
||||||
|
@ -11,7 +11,7 @@ import notifications from './NotificationReducer.js';
|
|||||||
import modal from './ModalReducer.js';
|
import modal from './ModalReducer.js';
|
||||||
import web3 from './Web3Reducer.js';
|
import web3 from './Web3Reducer.js';
|
||||||
import accounts from './AccountsReducer.js';
|
import accounts from './AccountsReducer.js';
|
||||||
import abstractAccount from './AbstractAccountReducer.js';
|
import selectedAccount from './SelectedAccountReducer.js';
|
||||||
import sendForm from './SendFormReducer.js';
|
import sendForm from './SendFormReducer.js';
|
||||||
import receive from './ReceiveReducer.js';
|
import receive from './ReceiveReducer.js';
|
||||||
import summary from './SummaryReducer.js';
|
import summary from './SummaryReducer.js';
|
||||||
@ -30,7 +30,7 @@ const reducers = {
|
|||||||
modal,
|
modal,
|
||||||
web3,
|
web3,
|
||||||
accounts,
|
accounts,
|
||||||
abstractAccount,
|
selectedAccount,
|
||||||
sendForm,
|
sendForm,
|
||||||
receive,
|
receive,
|
||||||
summary,
|
summary,
|
||||||
|
@ -38,7 +38,7 @@ const save = (dispatch: Dispatch, getState: GetState): void => {
|
|||||||
|
|
||||||
if (typeof window.sessionStorage === 'undefined') return;
|
if (typeof window.sessionStorage === 'undefined') return;
|
||||||
|
|
||||||
const accountState = getState().abstractAccount;
|
const accountState = getState().selectedAccount;
|
||||||
const sendState = getState().sendForm;
|
const sendState = getState().sendForm;
|
||||||
if (accountState && !sendState.untouched) {
|
if (accountState && !sendState.untouched) {
|
||||||
const value = {
|
const value = {
|
||||||
@ -68,7 +68,7 @@ const load = (dispatch: Dispatch, getState: GetState): void => {
|
|||||||
|
|
||||||
if (typeof window.localStorage === 'undefined') return;
|
if (typeof window.localStorage === 'undefined') return;
|
||||||
|
|
||||||
const accountState = getState().abstractAccount;
|
const accountState = getState().selectedAccount;
|
||||||
const sendState = getState().sendForm;
|
const sendState = getState().sendForm;
|
||||||
|
|
||||||
if (accountState) {
|
if (accountState) {
|
||||||
@ -122,7 +122,7 @@ const load = (dispatch: Dispatch, getState: GetState): void => {
|
|||||||
const clear = (getState: GetState) => {
|
const clear = (getState: GetState) => {
|
||||||
if (typeof window.localStorage === 'undefined') return;
|
if (typeof window.localStorage === 'undefined') return;
|
||||||
|
|
||||||
const accountState = getState().abstractAccount;
|
const accountState = getState().selectedAccount;
|
||||||
if (accountState) {
|
if (accountState) {
|
||||||
const key: string = `SEND:${accountState.location}`;
|
const key: string = `SEND:${accountState.location}`;
|
||||||
window.sessionStorage.removeItem(key);
|
window.sessionStorage.removeItem(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user