Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transactions - display medianTime for transactions #419

Merged
merged 5 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MaterialIcons } from '@expo/vector-icons'
import { NavigationProp, useNavigation } from '@react-navigation/native'
import dayjs from 'dayjs'
import * as React from 'react'
import { useEffect, useState } from 'react'
import { FlatList, RefreshControl, TouchableOpacity, View } from 'react-native'
Expand All @@ -14,6 +15,10 @@ import { EmptyTransaction } from './EmptyTransaction'
import { activitiesToViewModel, VMTransaction } from './screens/stateProcessor'
import { TransactionsParamList } from './TransactionsNavigator'

export function formatBlockTime (date: number): string {
return dayjs(date * 1000).format('MMM D, h:mm a')
}

export function TransactionsScreen (): JSX.Element {
const client = useWhaleApiClient()
const wallet = useWallet()
Expand Down Expand Up @@ -63,7 +68,7 @@ function TransactionRow (navigation: NavigationProp<TransactionsParamList>): (ro
iconName,
amount,
desc,
block,
medianTime,
token
} = row.item

Expand All @@ -85,7 +90,7 @@ function TransactionRow (navigation: NavigationProp<TransactionsParamList>): (ro
<Text style={tailwind('font-medium')}>{translate('screens/TransactionsScreen', desc)}</Text>
<Text
style={tailwind('text-xs text-gray-600')}
>{translate('screens/TransactionsScreen', 'Block')}: {block}
>{formatBlockTime(medianTime)}
</Text>
</View>
<View style={tailwind('flex-row ml-3 w-32 justify-end items-center')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDeFiScanContext } from '../../../../../contexts/DeFiScanContext'
import { tailwind } from '../../../../../tailwind'
import { translate } from '../../../../../translations'
import { TransactionsParamList } from '../TransactionsNavigator'
import { formatBlockTime } from '../TransactionsScreen'

type Props = StackScreenProps<TransactionsParamList, 'TransactionDetailScreen'>

Expand Down Expand Up @@ -43,6 +44,7 @@ export function TransactionDetailScreen (props: Props): JSX.Element {
{/* TODO(@ivan-zynesis): handle different transaction type other than sent/receive */}
{RenderRow('Amount', translate('screens/TransactionDetailScreen', tx.amount))}
{RenderRow('Block', translate('screens/TransactionDetailScreen', `${tx.block}`))}
{RenderRow('Date', translate('screens/TransactionDetailScreen', `${formatBlockTime(tx.medianTime)}`))}
{grayDivider}
<View
testID='transaction-detail-explorer-url'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface VMTransaction {
color: string
amount: string
block: number
medianTime: number
token: string
txid: string
}
Expand Down Expand Up @@ -57,6 +58,7 @@ export function activityToViewModel (activity: AddressActivity): VMTransaction {
color,
amount: amount.toFixed(),
block: activity.block.height,
medianTime: activity.block.medianTime,
token: tokenId,
txid: activity.txid
}
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@reduxjs/toolkit": "^1.6.1",
"bignumber.js": "^9.0.1",
"buffer": "^6.0.3",
"dayjs": "^1.10.6",
"expo": "^42.0.0",
"expo-asset": "~8.3.3",
"expo-barcode-scanner": "~10.2.2",
Expand Down