1+ import { useQuery } from '@tanstack/react-query'
12import { abs } from 'biggystring'
23import {
34 EdgeAccount ,
@@ -36,6 +37,7 @@ import { EdgeAppSceneProps } from '../../types/routerTypes'
3637import { getCurrencyCodeWithAccount } from '../../util/CurrencyInfoHelpers'
3738import { matchJson } from '../../util/matchJson'
3839import { getMemoTitle } from '../../util/memoUtils'
40+ import { fetchGetTxInfo } from '../../util/reportsServer'
3941import {
4042 convertCurrencyFromExchangeRates ,
4143 convertNativeToExchange ,
@@ -44,6 +46,7 @@ import {
4446} from '../../util/utils'
4547import { ButtonsView } from '../buttons/ButtonsView'
4648import { AdvancedDetailsCard } from '../cards/AdvancedDetailsCard'
49+ import { AlertCardUi4 } from '../cards/AlertCard'
4750import { EdgeCard } from '../cards/EdgeCard'
4851import { FiatExchangeDetailsCard } from '../cards/FiatExchangeDetailsCard'
4952import { SwapDetailsCard } from '../cards/SwapDetailsCard'
@@ -58,6 +61,7 @@ import {
5861 ContactModalResult
5962} from '../modals/ContactListModal'
6063import { TextInputModal } from '../modals/TextInputModal'
64+ import { Shimmer } from '../progress-indicators/Shimmer'
6165import { EdgeRow } from '../rows/EdgeRow'
6266import { TxCryptoAmountRow } from '../rows/TxCryptoAmountRow'
6367import { Airship , showError , showToast } from '../services/AirshipInstance'
@@ -86,6 +90,37 @@ const TransactionDetailsComponent = (props: Props) => {
8690 const styles = getStyles ( theme )
8791 const iconColor = useIconColor ( { pluginId : currencyInfo . pluginId , tokenId } )
8892
93+ // Query for transaction info from reports server
94+ const receiveAddress = transaction . ourReceiveAddresses ?. [ 0 ]
95+ const transactionDate = new Date ( date * 1000 )
96+
97+ const shouldShowTradeDetails = ! transaction . isSend && receiveAddress != null
98+ const {
99+ data : txInfo ,
100+ isLoading : isTxInfoLoading ,
101+ error : txInfoError
102+ } = useQuery ( {
103+ queryKey : [ 'txInfo' , receiveAddress , transactionDate . toISOString ( ) ] ,
104+ queryFn : async ( ) => {
105+ if ( ! shouldShowTradeDetails ) return null
106+
107+ // Set time range: 24 hours before and after transaction
108+ const startDate = new Date ( transactionDate )
109+ startDate . setHours ( startDate . getHours ( ) - 24 )
110+
111+ const endDate = new Date ( transactionDate )
112+ endDate . setHours ( endDate . getHours ( ) + 24 )
113+
114+ return await fetchGetTxInfo ( {
115+ address : receiveAddress ,
116+ startDate,
117+ endDate
118+ } )
119+ } ,
120+ enabled : shouldShowTradeDetails ,
121+ retry : false
122+ } )
123+
89124 // Choose a default category based on metadata or the txAction
90125 const {
91126 action,
@@ -580,6 +615,43 @@ const TransactionDetailsComponent = (props: Props) => {
580615 </ EdgeCard >
581616 </ EdgeAnim >
582617
618+ { /* Trade details */ }
619+ { shouldShowTradeDetails ? (
620+ < EdgeAnim enter = { { type : 'fadeInDown' , distance : 130 } } >
621+ < EdgeCard sections >
622+ { isTxInfoLoading ? (
623+ < View style = { { height : theme . rem ( 6 ) , position : 'relative' } } >
624+ < Shimmer />
625+ </ View >
626+ ) : txInfoError ? (
627+ < AlertCardUi4
628+ type = "error"
629+ title = { lstrings . error_unexpected_title }
630+ body = { txInfoError . message }
631+ />
632+ ) : txInfo != null ? (
633+ < >
634+ < EdgeRow
635+ rightButtonType = "none"
636+ title = { lstrings . transaction_details_exchange_order_id }
637+ body = { txInfo . orderId }
638+ />
639+ < EdgeRow
640+ rightButtonType = "none"
641+ title = { lstrings . transaction_details_exchange_service }
642+ body = { txInfo . providerId }
643+ />
644+ < EdgeRow
645+ rightButtonType = "none"
646+ title = { lstrings . transaction_details_exchange_status }
647+ body = { txInfo . status }
648+ />
649+ </ >
650+ ) : null }
651+ </ EdgeCard >
652+ </ EdgeAnim >
653+ ) : null }
654+
583655 < EdgeAnim enter = { { type : 'fadeInDown' , distance : 120 } } >
584656 < AdvancedDetailsCard
585657 transaction = { transaction }
@@ -591,6 +663,7 @@ const TransactionDetailsComponent = (props: Props) => {
591663 ) }
592664 />
593665 </ EdgeAnim >
666+
594667 < EdgeAnim enter = { { type : 'fadeInDown' , distance : 140 } } >
595668 < ButtonsView
596669 layout = "column"
0 commit comments