|
|
|
@ -1,20 +1,22 @@
|
|
|
|
|
/* @flow */
|
|
|
|
|
import * as CONNECT from 'actions/constants/TrezorConnect';
|
|
|
|
|
import * as PENDING from 'actions/constants/pendingTx';
|
|
|
|
|
import * as SEND from 'actions/constants/send';
|
|
|
|
|
|
|
|
|
|
import type { Action } from 'flowtype';
|
|
|
|
|
import type { TrezorDevice, Action } from 'flowtype';
|
|
|
|
|
import type { SendTxAction } from 'actions/SendFormActions';
|
|
|
|
|
|
|
|
|
|
export type PendingTx = {
|
|
|
|
|
+type: 'send' | 'recv';
|
|
|
|
|
+type: 'send' | 'receive';
|
|
|
|
|
+id: string;
|
|
|
|
|
+network: string;
|
|
|
|
|
+address: string;
|
|
|
|
|
+deviceState: string;
|
|
|
|
|
+currency: string;
|
|
|
|
|
+amount: string;
|
|
|
|
|
+total: string;
|
|
|
|
|
+tx: any;
|
|
|
|
|
+nonce: number;
|
|
|
|
|
+address: string;
|
|
|
|
|
rejected: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -28,12 +30,14 @@ const add = (state: State, action: SendTxAction): State => {
|
|
|
|
|
type: 'send',
|
|
|
|
|
id: action.txid,
|
|
|
|
|
network: action.account.network,
|
|
|
|
|
address: action.account.address,
|
|
|
|
|
deviceState: action.account.deviceState,
|
|
|
|
|
|
|
|
|
|
currency: action.selectedCurrency,
|
|
|
|
|
amount: action.amount,
|
|
|
|
|
total: action.total,
|
|
|
|
|
tx: action.tx,
|
|
|
|
|
nonce: action.nonce,
|
|
|
|
|
address: action.account.address,
|
|
|
|
|
rejected: false,
|
|
|
|
|
});
|
|
|
|
|
return newState;
|
|
|
|
@ -47,6 +51,8 @@ const addFromBloockbokNotifiaction = (state: State, payload: any): State => {
|
|
|
|
|
};
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const clear = (state: State, device: TrezorDevice): State => state.filter(tx => tx.deviceState !== device.state);
|
|
|
|
|
|
|
|
|
|
const remove = (state: State, id: string): State => state.filter(tx => tx.id !== id);
|
|
|
|
|
|
|
|
|
|
const reject = (state: State, id: string): State => state.map((tx) => {
|
|
|
|
@ -61,6 +67,12 @@ export default function pending(state: State = initialState, action: Action): St
|
|
|
|
|
case SEND.TX_COMPLETE:
|
|
|
|
|
return add(state, action);
|
|
|
|
|
|
|
|
|
|
case CONNECT.FORGET:
|
|
|
|
|
case CONNECT.FORGET_SINGLE:
|
|
|
|
|
case CONNECT.FORGET_SILENT:
|
|
|
|
|
case CONNECT.RECEIVE_WALLET_TYPE:
|
|
|
|
|
return clear(state, action.device);
|
|
|
|
|
|
|
|
|
|
// case PENDING.ADD:
|
|
|
|
|
// return add(state, action.payload);
|
|
|
|
|
case PENDING.TX_RESOLVED:
|
|
|
|
|