Skip to content

Commit

Permalink
fix: get last tx
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Nov 25, 2022
1 parent 07ef87e commit e3b3a3e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/web3/store/transactionsSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,27 @@ export const selectTXByHash = <T extends BaseTx>(
return state.transactionsPool[hash];
};

export const selectAllTransactionsByWallet = <T extends BaseTx>(
state: ITransactionsState<T>,
from: string
) => {
return selectAllTransactions(state).filter((tx) => tx.from == from);
};

export const selectPendingTransactionByWallet = <T extends BaseTx>(
state: ITransactionsState<T>,
from: string
) => {
return selectPendingTransactions(state).filter((tx) => tx.from == from);
};

export const selectLastTxByTypeAndPayload = <T extends BaseTx>(
state: ITransactionsState<T>,
from: string,
type: T['type'],
payload: T['payload']
) => {
const allTransactions = selectAllTransactions(state);
const allTransactions = selectAllTransactionsByWallet(state, from);
const filteredTransactions = allTransactions.filter(
(tx) => tx.type === type && isEqual(tx.payload, payload)
);
Expand All @@ -41,17 +56,3 @@ export const selectLastTxByTypeAndPayload = <T extends BaseTx>(
return undefined;
}
};

export const selectAllTransactionsByWallet = <T extends BaseTx>(
state: ITransactionsState<T>,
from: string
) => {
return selectAllTransactions(state).filter((tx) => tx.from == from);
};

export const selectPendingTransactionByWallet = <T extends BaseTx>(
state: ITransactionsState<T>,
from: string
) => {
return selectPendingTransactions(state).filter((tx) => tx.from == from);
};

0 comments on commit e3b3a3e

Please sign in to comment.