Skip to content

Commit 142b64a

Browse files
committed
Integrate getTxInfo reports server API
1 parent f020a96 commit 142b64a

File tree

10 files changed

+392
-20
lines changed

10 files changed

+392
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased (develop)
44

55
- added: `ReturnKeyTypeButton` to `FlipInputModal2`
6+
- added: Integrated reports server order status to transaction details.
67

78
## 4.32.0 (staging)
89

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"@react-navigation/native": "^6.1.3",
8181
"@react-navigation/stack": "^6.3.12",
8282
"@sentry/react-native": "^6.14.0",
83+
"@tanstack/react-query": "^5.83.0",
8384
"@types/jsrsasign": "^10.5.13",
8485
"@unstoppabledomains/resolution": "^9.3.0",
8586
"@walletconnect/react-native-compat": "^2.11.0",

src/__tests__/scenes/__snapshots__/TransactionDetailsScene.test.tsx.snap

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,170 @@ exports[`TransactionDetailsScene should render 1`] = `
17381738
</View>
17391739
</View>
17401740
</View>
1741+
<View
1742+
entering={BaseAnimationMock {}}
1743+
layout={BaseAnimationMock {}}
1744+
>
1745+
<View
1746+
style={
1747+
[
1748+
{
1749+
"alignSelf": "stretch",
1750+
"borderRadius": 16,
1751+
},
1752+
{
1753+
"marginBottom": 11,
1754+
"marginLeft": 11,
1755+
"marginRight": 11,
1756+
"marginTop": 11,
1757+
},
1758+
{
1759+
"paddingBottom": 11,
1760+
"paddingLeft": 11,
1761+
"paddingRight": 11,
1762+
"paddingTop": 11,
1763+
},
1764+
undefined,
1765+
]
1766+
}
1767+
>
1768+
<View
1769+
style={
1770+
{
1771+
"backgroundColor": "rgba(255, 255, 255, .1)",
1772+
"borderRadius": 16,
1773+
"bottom": 0,
1774+
"left": 0,
1775+
"overflow": "hidden",
1776+
"position": "absolute",
1777+
"right": 0,
1778+
"top": 0,
1779+
}
1780+
}
1781+
/>
1782+
<View
1783+
style={
1784+
[
1785+
{
1786+
"flexDirection": "column",
1787+
"flexGrow": 1,
1788+
"flexShrink": 1,
1789+
},
1790+
{
1791+
"marginVertical": 0,
1792+
},
1793+
]
1794+
}
1795+
>
1796+
<View
1797+
style={
1798+
{
1799+
"height": 135,
1800+
"position": "relative",
1801+
}
1802+
}
1803+
>
1804+
<View
1805+
onLayout={[Function]}
1806+
style={
1807+
{
1808+
"backgroundColor": "rgba(255, 255, 255, .05)",
1809+
"borderRadius": 16,
1810+
"bottom": 0,
1811+
"left": 0,
1812+
"overflow": "hidden",
1813+
"position": "absolute",
1814+
"right": 0,
1815+
"top": 0,
1816+
}
1817+
}
1818+
>
1819+
<View
1820+
style={
1821+
[
1822+
{
1823+
"bottom": 0,
1824+
"display": "flex",
1825+
"flexDirection": "row",
1826+
"left": 0,
1827+
"position": "absolute",
1828+
"top": 0,
1829+
},
1830+
{
1831+
"width": 0,
1832+
},
1833+
{
1834+
"transform": [
1835+
{
1836+
"translateX": 0,
1837+
},
1838+
],
1839+
},
1840+
]
1841+
}
1842+
>
1843+
<BVLinearGradient
1844+
colors={
1845+
[
1846+
0,
1847+
452984831,
1848+
]
1849+
}
1850+
endPoint={
1851+
{
1852+
"x": 1,
1853+
"y": 1,
1854+
}
1855+
}
1856+
locations={null}
1857+
startPoint={
1858+
{
1859+
"x": 0,
1860+
"y": 0,
1861+
}
1862+
}
1863+
style={
1864+
{
1865+
"flex": 1,
1866+
"height": "100%",
1867+
"width": "100%",
1868+
}
1869+
}
1870+
/>
1871+
<BVLinearGradient
1872+
colors={
1873+
[
1874+
0,
1875+
452984831,
1876+
]
1877+
}
1878+
endPoint={
1879+
{
1880+
"x": 0,
1881+
"y": 1,
1882+
}
1883+
}
1884+
locations={null}
1885+
startPoint={
1886+
{
1887+
"x": 1,
1888+
"y": 0,
1889+
}
1890+
}
1891+
style={
1892+
{
1893+
"flex": 1,
1894+
"height": "100%",
1895+
"width": "100%",
1896+
}
1897+
}
1898+
/>
1899+
</View>
1900+
</View>
1901+
</View>
1902+
</View>
1903+
</View>
1904+
</View>
17411905
<View
17421906
entering={BaseAnimationMock {}}
17431907
layout={BaseAnimationMock {}}

src/components/App.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import '@ethersproject/shims'
22

33
import { ErrorBoundary, Scope, wrap } from '@sentry/react-native'
4+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
45
import * as React from 'react'
56
import { StyleSheet } from 'react-native'
67
import { GestureHandlerRootView } from 'react-native-gesture-handler'
@@ -12,26 +13,30 @@ import { EdgeCoreManager } from './services/EdgeCoreManager'
1213
import { StatusBarManager } from './services/StatusBarManager'
1314
import { ThemeProvider } from './services/ThemeContext'
1415

16+
const queryClient = new QueryClient()
17+
1518
function MainApp() {
1619
const handleBeforeCapture = useHandler((scope: Scope) => {
1720
scope.setLevel('fatal')
1821
scope.setTag('handled', false)
1922
})
2023

2124
return (
22-
<SafeAreaProvider>
23-
<ThemeProvider>
24-
<GestureHandlerRootView style={StyleSheet.absoluteFill}>
25-
<ErrorBoundary
26-
beforeCapture={handleBeforeCapture}
27-
fallback={<CrashScene />}
28-
>
29-
<StatusBarManager />
30-
<EdgeCoreManager />
31-
</ErrorBoundary>
32-
</GestureHandlerRootView>
33-
</ThemeProvider>
34-
</SafeAreaProvider>
25+
<QueryClientProvider client={queryClient}>
26+
<SafeAreaProvider>
27+
<ThemeProvider>
28+
<GestureHandlerRootView style={StyleSheet.absoluteFill}>
29+
<ErrorBoundary
30+
beforeCapture={handleBeforeCapture}
31+
fallback={<CrashScene />}
32+
>
33+
<StatusBarManager />
34+
<EdgeCoreManager />
35+
</ErrorBoundary>
36+
</GestureHandlerRootView>
37+
</ThemeProvider>
38+
</SafeAreaProvider>
39+
</QueryClientProvider>
3540
)
3641
}
3742

src/components/scenes/TransactionDetailsScene.tsx

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useQuery } from '@tanstack/react-query'
12
import { abs } from 'biggystring'
23
import {
34
EdgeAccount,
@@ -36,6 +37,7 @@ import { EdgeAppSceneProps } from '../../types/routerTypes'
3637
import { getCurrencyCodeWithAccount } from '../../util/CurrencyInfoHelpers'
3738
import { matchJson } from '../../util/matchJson'
3839
import { getMemoTitle } from '../../util/memoUtils'
40+
import { fetchGetTxInfo } from '../../util/reportsServer'
3941
import {
4042
convertCurrencyFromExchangeRates,
4143
convertNativeToExchange,
@@ -44,6 +46,7 @@ import {
4446
} from '../../util/utils'
4547
import { ButtonsView } from '../buttons/ButtonsView'
4648
import { AdvancedDetailsCard } from '../cards/AdvancedDetailsCard'
49+
import { AlertCardUi4 } from '../cards/AlertCard'
4750
import { EdgeCard } from '../cards/EdgeCard'
4851
import { FiatExchangeDetailsCard } from '../cards/FiatExchangeDetailsCard'
4952
import { SwapDetailsCard } from '../cards/SwapDetailsCard'
@@ -58,6 +61,7 @@ import {
5861
ContactModalResult
5962
} from '../modals/ContactListModal'
6063
import { TextInputModal } from '../modals/TextInputModal'
64+
import { Shimmer } from '../progress-indicators/Shimmer'
6165
import { EdgeRow } from '../rows/EdgeRow'
6266
import { TxCryptoAmountRow } from '../rows/TxCryptoAmountRow'
6367
import { 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"

src/locales/en_US.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ const strings = {
857857
transaction_details_empty_note_placeholder: 'Tap to Add Note (Optional)',
858858
transaction_details_exchange_details: 'Exchange Details',
859859
transaction_details_exchange_service: 'Exchange Service',
860+
transaction_details_exchange_status: 'Exchange Status',
860861
transaction_details_exchange_order_id: 'Order ID',
861862
transaction_details_exchange_source_wallet: 'Source Wallet',
862863
transaction_details_exchange_destination_wallet: 'Destination Wallet',

src/locales/strings/enUS.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@
681681
"transaction_details_empty_note_placeholder": "Tap to Add Note (Optional)",
682682
"transaction_details_exchange_details": "Exchange Details",
683683
"transaction_details_exchange_service": "Exchange Service",
684+
"transaction_details_exchange_status": "Exchange Status",
684685
"transaction_details_exchange_order_id": "Order ID",
685686
"transaction_details_exchange_source_wallet": "Source Wallet",
686687
"transaction_details_exchange_destination_wallet": "Destination Wallet",

0 commit comments

Comments
 (0)