@ -12,6 +12,7 @@ import * as actions from '../../../ducks/gas/gas.duck'
import { useI18nContext } from '../../../hooks/useI18nContext'
import { useI18nContext } from '../../../hooks/useI18nContext'
import TransactionListItem from '../transaction-list-item'
import TransactionListItem from '../transaction-list-item'
import Button from '../../ui/button'
import Button from '../../ui/button'
import { TOKEN _CATEGORY _HASH } from '../../../helpers/constants/transactions'
const PAGE _INCREMENT = 10
const PAGE _INCREMENT = 10
@ -19,7 +20,23 @@ const getTransactionGroupRecipientAddressFilter = (recipientAddress) => {
return ( { initialTransaction : { txParams } } ) => txParams && txParams . to === recipientAddress
return ( { initialTransaction : { txParams } } ) => txParams && txParams . to === recipientAddress
}
}
export default function TransactionList ( { tokenAddress } ) {
const tokenTransactionFilter = ( {
initialTransaction : {
transactionCategory ,
} ,
} ) => ! TOKEN _CATEGORY _HASH [ transactionCategory ]
const getFilteredTransactionGroups = ( transactionGroups , hideTokenTransactions , tokenAddress ) => {
if ( hideTokenTransactions ) {
return transactionGroups . filter ( tokenTransactionFilter )
} else if ( tokenAddress ) {
return transactionGroups . filter ( getTransactionGroupRecipientAddressFilter ( tokenAddress ) )
}
return transactionGroups
}
export default function TransactionList ( { hideTokenTransactions , tokenAddress } ) {
const [ limit , setLimit ] = useState ( PAGE _INCREMENT )
const [ limit , setLimit ] = useState ( PAGE _INCREMENT )
const t = useI18nContext ( )
const t = useI18nContext ( )
@ -29,22 +46,12 @@ export default function TransactionList ({ tokenAddress }) {
const { transactionTime : transactionTimeFeatureActive } = useSelector ( getFeatureFlags )
const { transactionTime : transactionTimeFeatureActive } = useSelector ( getFeatureFlags )
const pendingTransactions = useMemo (
const pendingTransactions = useMemo (
( ) => (
( ) => getFilteredTransactionGroups ( unfilteredPendingTransactions , hideTokenTransactions , tokenAddress ) ,
tokenAddress && tokenAddress . startsWith ( '0x' )
[ hideTokenTransactions , tokenAddress , unfilteredPendingTransactions ]
? unfilteredPendingTransactions
. filter ( getTransactionGroupRecipientAddressFilter ( tokenAddress ) )
: unfilteredPendingTransactions
) ,
[ unfilteredPendingTransactions , tokenAddress ]
)
)
const completedTransactions = useMemo (
const completedTransactions = useMemo (
( ) => (
( ) => getFilteredTransactionGroups ( unfilteredCompletedTransactions , hideTokenTransactions , tokenAddress ) ,
tokenAddress && tokenAddress . startsWith ( '0x' )
[ hideTokenTransactions , tokenAddress , unfilteredCompletedTransactions ]
? unfilteredCompletedTransactions
. filter ( getTransactionGroupRecipientAddressFilter ( tokenAddress ) )
: unfilteredCompletedTransactions
) ,
[ unfilteredCompletedTransactions , tokenAddress ]
)
)
const { fetchGasEstimates , fetchBasicGasAndTimeEstimates } = useMemo ( ( ) => ( {
const { fetchGasEstimates , fetchBasicGasAndTimeEstimates } = useMemo ( ( ) => ( {
@ -122,9 +129,11 @@ export default function TransactionList ({ tokenAddress }) {
}
}
TransactionList . propTypes = {
TransactionList . propTypes = {
hideTokenTransactions : PropTypes . bool ,
tokenAddress : PropTypes . string ,
tokenAddress : PropTypes . string ,
}
}
TransactionList . defaultProps = {
TransactionList . defaultProps = {
hideTokenTransactions : false ,
tokenAddress : undefined ,
tokenAddress : undefined ,
}
}