7
7
HealthStatus ,
8
8
useAvarageBlockTime ,
9
9
useAvarageFees ,
10
- useGetTxEffectsByBlockHeightRange ,
10
+ useGetLatestTxEffects ,
11
11
useLatestBlocks ,
12
12
usePendingTxs ,
13
13
useSubTitle ,
@@ -19,7 +19,7 @@ import {
19
19
} from "~/hooks" ;
20
20
import { formatDuration , formatFees } from "~/lib/utils" ;
21
21
import { routes } from "~/routes/__root" ;
22
- import { mapLatestBlocks , parseTxEffectsData } from "./util" ;
22
+ import { mapLatestBlocks , mapLatestTxEffects } from "./util" ;
23
23
24
24
export const Landing : FC = ( ) => {
25
25
const { systemHealth } = useSystemHealth ( ) ;
@@ -57,23 +57,24 @@ export const Landing: FC = () => {
57
57
58
58
useSubTitle ( latestBlocks ?. [ 0 ] ?. height . toString ( ) ?? routes . home . title ) ;
59
59
60
- const latestTxEffectsData = useGetTxEffectsByBlockHeightRange (
61
- latestBlocks ?. at ( 40 ) ?. height ?? latestBlocks ?. at ( - 1 ) ?. height ,
62
- latestBlocks ?. at ( 0 ) ?. height
63
- ) ;
60
+ const {
61
+ data : latestTxEffectsData ,
62
+ isLoading : isLoadingTxEffects ,
63
+ error : txEffectsError ,
64
+ } = useGetLatestTxEffects ( ) ;
64
65
65
66
const { data : pendingTxs } = usePendingTxs ( ) ;
66
67
67
- const {
68
- isLoadingTxEffects,
69
- txEffectsErrorMsg : txEffectsError ,
70
- latestTxEffects,
71
- } = parseTxEffectsData ( latestTxEffectsData , latestBlocks ) ;
72
-
73
68
const latestTxEffectsWithPending = useMemo ( ( ) => {
69
+ if ( ! latestTxEffectsData ) {
70
+ return [ ] ;
71
+ }
72
+ if ( ! latestBlocks ) {
73
+ return [ ] ;
74
+ }
74
75
const disguisedPendingTxs =
75
76
pendingTxs ?. reduce ( ( acc , tx ) => {
76
- if ( ! latestTxEffects . some ( ( effect ) => effect . txHash === tx . hash ) ) {
77
+ if ( ! latestTxEffectsData . some ( ( effect ) => effect . txHash === tx . hash ) ) {
77
78
acc . push ( {
78
79
txHash : tx . hash ,
79
80
transactionFee : - 1 ,
@@ -83,12 +84,15 @@ export const Landing: FC = () => {
83
84
}
84
85
return acc ;
85
86
} , [ ] as TxEffectTableSchema [ ] ) ?? [ ] ;
86
- return [ ...disguisedPendingTxs , ...latestTxEffects ] ;
87
- } , [ pendingTxs , latestTxEffects ] ) ;
87
+ return [
88
+ ...disguisedPendingTxs ,
89
+ ...mapLatestTxEffects ( latestTxEffectsData , latestBlocks ) ,
90
+ ] ;
91
+ } , [ pendingTxs , latestTxEffectsData , latestBlocks ] ) ;
88
92
89
93
const averageBlockTimeFormatted = formatDuration (
90
94
Number ( avarageBlockTime ) / 1000 ,
91
- true
95
+ true ,
92
96
) ;
93
97
94
98
const formattedFees = formatFees ( avarageFees ) ;
0 commit comments