@@ -5,16 +5,12 @@ import { Checkout } from '@imtbl/checkout-sdk';
55import {
66 useCallback ,
77 useContext ,
8- useEffect ,
9- useState ,
108} from 'react' ;
119import { useTranslation } from 'react-i18next' ;
1210import { formatUnits } from 'ethers' ;
13- import { AXELAR_SCAN_URL } from '../../lib' ;
14- import { Transaction , TransactionStatus } from '../../lib/clients' ;
11+ import { Transaction } from '../../lib/clients' ;
1512import { CryptoFiatContext } from '../../context/crypto-fiat-context/CryptoFiatContext' ;
1613import { calculateCryptoToFiat , getTokenImageByAddress , isNativeToken } from '../../lib/utils' ;
17- import { TransactionItem } from './TransactionItem' ;
1814import { KnownNetworkMap } from './transactionsType' ;
1915import { containerStyles , transactionsListStyle } from './TransactionListStyles' ;
2016import { TransactionItemWithdrawPending } from './TransactionItemWithdrawPending' ;
@@ -40,23 +36,8 @@ export function TransactionList({
4036} : TransactionListProps ) {
4137 const { cryptoFiatState } = useContext ( CryptoFiatContext ) ;
4238 const { t } = useTranslation ( ) ;
43- const [ link , setLink ] = useState ( '' ) ;
4439 const { environment } = checkout . config ;
4540
46- useEffect ( ( ) => {
47- if ( ! checkout ) return ;
48- setLink ( AXELAR_SCAN_URL [ checkout . config . environment ] ) ;
49- } , [ checkout ] ) ;
50-
51- const sortWithdrawalPendingFirst = useCallback ( ( txnA , txnB ) => {
52- if (
53- txnA . details . current_status . status === TransactionStatus . WITHDRAWAL_PENDING
54- && txnB . details . current_status . status !== TransactionStatus . WITHDRAWAL_PENDING ) return - 1 ;
55- if ( txnA . details . current_status . status === txnB . details . current_status . status ) return 0 ;
56-
57- return 1 ;
58- } , [ ] ) ;
59-
6041 const getTransactionItemIcon = useCallback ( ( transaction ) => {
6142 if ( isNativeToken ( transaction . details . from_token_address ) ) {
6243 // Map transaction chain slug to native symbol icon asset
@@ -76,34 +57,16 @@ export function TransactionList({
7657 sx = { containerStyles }
7758 >
7859 { transactions
79- . sort ( sortWithdrawalPendingFirst )
8060 . map ( ( transaction ) => {
81- const hash = transaction . blockchain_metadata . transaction_hash ;
8261 const tokens = knownTokenMap [ transaction . details . from_chain ] ;
8362 const token = tokens [ transaction . details . from_token_address . toLowerCase ( ) ] ;
8463 const amount = formatUnits ( transaction . details . amount , token . decimals ) ;
8564 const fiat = calculateCryptoToFiat ( amount , token . symbol , cryptoFiatState . conversions ) ;
8665
87- if ( transaction . details . current_status . status === TransactionStatus . WITHDRAWAL_PENDING ) {
88- return (
89- < TransactionItemWithdrawPending
90- key = { hash }
91- label = { token . symbol }
92- transaction = { transaction }
93- fiatAmount = { `${ t ( 'views.TRANSACTIONS.fiatPricePrefix' ) } ${ fiat } ` }
94- amount = { amount }
95- icon = { getTransactionItemIcon ( transaction ) }
96- defaultTokenImage = { defaultTokenImage }
97- environment = { environment }
98- />
99- ) ;
100- }
101-
10266 return (
103- < TransactionItem
104- key = { hash }
67+ < TransactionItemWithdrawPending
68+ key = { transaction . details . current_status . index }
10569 label = { token . symbol }
106- details = { { text : t ( 'views.TRANSACTIONS.status.inProgress.stepInfo' ) , link, hash } }
10770 transaction = { transaction }
10871 fiatAmount = { `${ t ( 'views.TRANSACTIONS.fiatPricePrefix' ) } ${ fiat } ` }
10972 amount = { amount }
0 commit comments