@@ -5,7 +5,6 @@ import { BlockWithTransactions } from 'alchemy-sdk';
55import { truncateAddress , truncateTransaction , getEtherValueFromWei } from '@/lib/utilities' ;
66import PopoverLink from '@/components/common/popover-link' ;
77import { DataState } from '@/lib/data-state' ;
8- import LoadingPulse from '@/components/common/indicators/loading-pulse' ;
98import LoadingPulseStatic from '@/components/common/indicators/loading-pulse-static' ;
109
1110
@@ -15,7 +14,12 @@ export default function Transaction(props: {
1514 blockWithTransactions : DataState < BlockWithTransactions > ,
1615} ) {
1716 // Use a callback because the transactions might still be loading:
18- const transaction = ( ) => props . blockWithTransactions . value ! . transactions [ props . id ] ;
17+ const transaction = props . blockWithTransactions . value ?. transactions [ props . id ] ;
18+
19+ const hash = transaction ?. hash ;
20+ const ethValue = transaction ?. value ;
21+ const from = transaction ?. from ;
22+ const to = transaction ?. to ;
1923
2024 return (
2125 < div className = 'md:min-h-[4.825rem] p-2 md:p-3 border-b border-(--border-color) last:border-0' >
@@ -26,25 +30,25 @@ export default function Transaction(props: {
2630 < span className = 'px-2 md:px-4' >
2731 < props . blockWithTransactions . Render
2832 value = { ( ) =>
29- < PopoverLink
30- href = { `/${ props . network } /transaction?hash=${ transaction ( ) . hash } ` }
31- content = { truncateTransaction ( transaction ( ) . hash , 18 ) }
32- popover = { transaction ( ) . hash }
33+ < PopoverLink // runtime error: transaction() undefined!?
34+ href = { `/${ props . network } /transaction?hash=${ hash } ` }
35+ content = { truncateTransaction ( hash ! , 18 ) }
36+ popover = { hash ! }
3337 className = '-left-full top-[-2.6rem] w-120 py-1.5 px-2.5'
3438 /> }
35- loadingFallback = { < LoadingPulse className = 'bg -(--link-color) w-[10rem]' /> }
39+ className = 'text -(--link-color) w-[10rem]'
3640 />
3741 </ span >
3842 < span className = 'px-2 md:pl-4' >
3943 < LoadingPulseStatic
4044 content = 'Amount:'
4145 dataState = { props . blockWithTransactions }
42- className = 'bg -(--grey-fg-color)'
46+ className = 'text -(--grey-fg-color)'
4347 />
4448
4549 < props . blockWithTransactions . Render
46- value = { ( ) => `Ξ${ getEtherValueFromWei ( transaction ( ) . value , 6 ) } ` }
47- loadingFallback = { < LoadingPulse className = 'bg -(--grey-fg-color) w-[3rem]' /> }
50+ value = { ( ) => `Ξ${ getEtherValueFromWei ( ethValue ! , 6 ) } ` }
51+ className = 'text -(--grey-fg-color) w-[3rem]'
4852 />
4953 </ span >
5054 </ div >
@@ -55,37 +59,37 @@ export default function Transaction(props: {
5559 < LoadingPulseStatic
5660 content = 'From:'
5761 dataState = { props . blockWithTransactions }
58- className = 'bg -(--grey-fg-color)'
62+ className = 'text -(--grey-fg-color)'
5963 />
6064
6165 < props . blockWithTransactions . Render
6266 value = { ( ) =>
6367 < PopoverLink
64- href = { `/${ props . network } /address?hash=${ transaction ( ) . from } ` }
65- content = { truncateAddress ( transaction ( ) . from , 21 ) }
66- popover = { transaction ( ) . from }
68+ href = { `/${ props . network } /address?hash=${ transaction ? .from } ` }
69+ content = { truncateAddress ( transaction ? .from ! , 21 ) }
70+ popover = { transaction ? .from ! }
6771 className = 'left-[-35%] top-[-2.6rem] w-78 py-1.5 px-2.5'
6872 /> }
69- loadingFallback = { < LoadingPulse className = 'bg -(--link-color) w-[11.5rem]' /> }
73+ className = 'text -(--link-color) w-[11.25rem]'
7074 />
7175 </ span >
7276 < span className = 'pl-7 md:pl-9' >
7377 < LoadingPulseStatic
7478 content = 'To:'
7579 dataState = { props . blockWithTransactions }
76- className = 'bg -(--grey-fg-color)'
80+ className = 'text -(--grey-fg-color)'
7781 />
7882
7983 < props . blockWithTransactions . Render
80- value = { ( ) => transaction ( ) . to ?
84+ value = { ( ) => transaction ? .to ?
8185 < PopoverLink
82- href = { `/${ props . network } /address?hash=${ transaction ( ) . to } ` }
83- content = { truncateAddress ( transaction ( ) . to ! , 21 ) }
84- popover = { transaction ( ) . to ! }
86+ href = { `/${ props . network } /address?hash=${ transaction ? .to } ` }
87+ content = { truncateAddress ( transaction ? .to ! , 21 ) }
88+ popover = { transaction ? .to ! }
8589 className = 'left-[-35%] top-[-2.6rem] w-78 py-1.5 px-2.5'
8690 />
8791 : < span > /</ span > }
88- loadingFallback = { < LoadingPulse className = 'bg -(--link-color) w-[11.5rem]' /> }
92+ className = 'text -(--link-color) w-[11.25rem]'
8993 />
9094 </ span >
9195 </ div >
0 commit comments