mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-28 03:08:30 +00:00
remove pendingTxs while switching between wallet types and forgeting device
This commit is contained in:
parent
0a77d0541e
commit
d6af3d6dfa
@ -3,12 +3,8 @@
|
|||||||
|
|
||||||
import * as PENDING from 'actions/constants/pendingTx';
|
import * as PENDING from 'actions/constants/pendingTx';
|
||||||
|
|
||||||
import type {
|
|
||||||
Action, ThunkAction, GetState, Dispatch,
|
|
||||||
} from 'flowtype';
|
|
||||||
import type { State, PendingTx } from 'reducers/PendingTxReducer';
|
import type { State, PendingTx } from 'reducers/PendingTxReducer';
|
||||||
|
|
||||||
|
|
||||||
export type PendingTxAction = {
|
export type PendingTxAction = {
|
||||||
type: typeof PENDING.FROM_STORAGE,
|
type: typeof PENDING.FROM_STORAGE,
|
||||||
payload: State
|
payload: State
|
||||||
@ -26,28 +22,3 @@ export type PendingTxAction = {
|
|||||||
type: typeof PENDING.TX_TOKEN_ERROR,
|
type: typeof PENDING.TX_TOKEN_ERROR,
|
||||||
tx: PendingTx,
|
tx: PendingTx,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const reject = (tx: PendingTx): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
|
||||||
/*
|
|
||||||
dispatch({
|
|
||||||
type: NOTIFICATION.ADD,
|
|
||||||
payload: {
|
|
||||||
type: 'warning',
|
|
||||||
title: 'Pending transaction rejected',
|
|
||||||
message: `Transaction with id: ${tx.id} not found.`,
|
|
||||||
cancelable: true,
|
|
||||||
actions: [
|
|
||||||
{
|
|
||||||
label: 'OK',
|
|
||||||
callback: () => {
|
|
||||||
dispatch({
|
|
||||||
type: PENDING.TX_RESOLVED,
|
|
||||||
tx,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
};
|
|
@ -1,20 +1,22 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
import * as CONNECT from 'actions/constants/TrezorConnect';
|
||||||
import * as PENDING from 'actions/constants/pendingTx';
|
import * as PENDING from 'actions/constants/pendingTx';
|
||||||
import * as SEND from 'actions/constants/send';
|
import * as SEND from 'actions/constants/send';
|
||||||
|
|
||||||
import type { Action } from 'flowtype';
|
import type { TrezorDevice, Action } from 'flowtype';
|
||||||
import type { SendTxAction } from 'actions/SendFormActions';
|
import type { SendTxAction } from 'actions/SendFormActions';
|
||||||
|
|
||||||
export type PendingTx = {
|
export type PendingTx = {
|
||||||
+type: 'send' | 'recv';
|
+type: 'send' | 'receive';
|
||||||
+id: string;
|
+id: string;
|
||||||
+network: string;
|
+network: string;
|
||||||
|
+address: string;
|
||||||
|
+deviceState: string;
|
||||||
+currency: string;
|
+currency: string;
|
||||||
+amount: string;
|
+amount: string;
|
||||||
+total: string;
|
+total: string;
|
||||||
+tx: any;
|
+tx: any;
|
||||||
+nonce: number;
|
+nonce: number;
|
||||||
+address: string;
|
|
||||||
rejected: boolean;
|
rejected: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,12 +30,14 @@ const add = (state: State, action: SendTxAction): State => {
|
|||||||
type: 'send',
|
type: 'send',
|
||||||
id: action.txid,
|
id: action.txid,
|
||||||
network: action.account.network,
|
network: action.account.network,
|
||||||
|
address: action.account.address,
|
||||||
|
deviceState: action.account.deviceState,
|
||||||
|
|
||||||
currency: action.selectedCurrency,
|
currency: action.selectedCurrency,
|
||||||
amount: action.amount,
|
amount: action.amount,
|
||||||
total: action.total,
|
total: action.total,
|
||||||
tx: action.tx,
|
tx: action.tx,
|
||||||
nonce: action.nonce,
|
nonce: action.nonce,
|
||||||
address: action.account.address,
|
|
||||||
rejected: false,
|
rejected: false,
|
||||||
});
|
});
|
||||||
return newState;
|
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 remove = (state: State, id: string): State => state.filter(tx => tx.id !== id);
|
||||||
|
|
||||||
const reject = (state: State, id: string): State => state.map((tx) => {
|
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:
|
case SEND.TX_COMPLETE:
|
||||||
return add(state, action);
|
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:
|
// case PENDING.ADD:
|
||||||
// return add(state, action.payload);
|
// return add(state, action.payload);
|
||||||
case PENDING.TX_RESOLVED:
|
case PENDING.TX_RESOLVED:
|
||||||
|
Loading…
Reference in New Issue
Block a user