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