1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-25 16:38:08 +00:00

added pending to SelectedAccountReducer

This commit is contained in:
Szymon Lesisz 2018-05-25 11:49:15 +02:00
parent c40432d2f2
commit 7b639fb223
3 changed files with 15 additions and 3 deletions

View File

@ -56,7 +56,8 @@ export const updateSelectedValues = (prevState: State, action: Action): AsyncAct
const account = stateUtils.getSelectedAccount(state);
const network = stateUtils.getSelectedNetwork(state);
const discovery = stateUtils.getDiscoveryProcess(state);
const tokens = stateUtils.getTokens(state, account);
const tokens = stateUtils.getAccountTokens(state, account);
const pending = stateUtils.getAccountPendingTx(state, account);
const web3 = stateUtils.getWeb3(state);
const payload: $ElementType<State, 'selectedAccount'> = {
@ -65,6 +66,7 @@ export const updateSelectedValues = (prevState: State, action: Action): AsyncAct
network,
discovery,
tokens,
pending,
web3
}

View File

@ -8,6 +8,7 @@ import type {
Account,
Coin,
Token,
PendingTx,
Discovery,
Web3Instance
} from '~/flowtype';
@ -18,6 +19,7 @@ export type State = {
account: ?Account;
network: ?Coin;
tokens: Array<Token>,
pending: Array<PendingTx>,
web3: ?Web3Instance,
discovery: ?Discovery
};
@ -27,6 +29,7 @@ export const initialState: State = {
account: null,
network: null,
tokens: [],
pending: [],
web3: null,
discovery: null
};

View File

@ -19,6 +19,7 @@ import type {
Coin,
Discovery,
Token,
PendingTx,
Web3Instance
} from '~/flowtype';
@ -83,9 +84,15 @@ export const getDiscoveryProcess = (state: State): ?Discovery => {
return state.discovery.find(d => d.deviceState === device.state && d.network === locationState.network);
}
export const getTokens = (state: State, account: ?Account): Array<Token> => {
export const getAccountPendingTx = (state: State, account: ?Account): Array<PendingTx> => {
const a = account;
if (!a) return state.selectedAccount.tokens;
if (!a) return state.selectedAccount.pending.length > 0 ? [] : state.selectedAccount.pending;
return state.pending.filter(p => p.network === a.network && p.address === a.address);
}
export const getAccountTokens = (state: State, account: ?Account): Array<Token> => {
const a = account;
if (!a) return state.selectedAccount.tokens.length > 0 ? [] : state.selectedAccount.tokens;
return state.tokens.filter(t => t.ethAddress === a.address && t.network === a.network && t.deviceState === a.deviceState);
}