|
|
@ -17,6 +17,7 @@ export type PendingTx = {
|
|
|
|
+tx: any;
|
|
|
|
+tx: any;
|
|
|
|
+nonce: number;
|
|
|
|
+nonce: number;
|
|
|
|
+address: string;
|
|
|
|
+address: string;
|
|
|
|
|
|
|
|
rejected: boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export type State = Array<PendingTx>;
|
|
|
|
export type State = Array<PendingTx>;
|
|
|
@ -34,6 +35,7 @@ const add = (state: State, action: SendTxAction): State => {
|
|
|
|
tx: action.tx,
|
|
|
|
tx: action.tx,
|
|
|
|
nonce: action.nonce,
|
|
|
|
nonce: action.nonce,
|
|
|
|
address: action.account.address,
|
|
|
|
address: action.account.address,
|
|
|
|
|
|
|
|
rejected: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return newState;
|
|
|
|
return newState;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -42,6 +44,15 @@ const remove = (state: State, id: string): State => {
|
|
|
|
return state.filter(tx => tx.id !== id);
|
|
|
|
return state.filter(tx => tx.id !== id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const reject = (state: State, id: string): State => {
|
|
|
|
|
|
|
|
return state.map(tx => {
|
|
|
|
|
|
|
|
if (tx.id === id && !tx.rejected) {
|
|
|
|
|
|
|
|
return { ...tx, rejected: true };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tx;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function pending(state: State = initialState, action: Action): State {
|
|
|
|
export default function pending(state: State = initialState, action: Action): State {
|
|
|
|
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
switch (action.type) {
|
|
|
@ -50,8 +61,9 @@ export default function pending(state: State = initialState, action: Action): St
|
|
|
|
return add(state, action);
|
|
|
|
return add(state, action);
|
|
|
|
|
|
|
|
|
|
|
|
case PENDING.TX_RESOLVED :
|
|
|
|
case PENDING.TX_RESOLVED :
|
|
|
|
case PENDING.TX_NOT_FOUND :
|
|
|
|
|
|
|
|
return remove(state, action.tx.id);
|
|
|
|
return remove(state, action.tx.id);
|
|
|
|
|
|
|
|
case PENDING.TX_NOT_FOUND :
|
|
|
|
|
|
|
|
return reject(state, action.tx.id);
|
|
|
|
|
|
|
|
|
|
|
|
case PENDING.FROM_STORAGE :
|
|
|
|
case PENDING.FROM_STORAGE :
|
|
|
|
return action.payload;
|
|
|
|
return action.payload;
|
|
|
|