@@ -16,8 +16,14 @@ import { StateDispatch } from 'states/stateProvider/reducer'
1616import { contextMenu , showTransactionDetails } from 'services/remote'
1717
1818import { useLocalDescription } from 'utils/hooks'
19- import { shannonToCKBFormatter , uniformTimeFormatter as timeFormatter , uniformTimeFormatter } from 'utils/formatters'
19+ import {
20+ shannonToCKBFormatter ,
21+ uniformTimeFormatter as timeFormatter ,
22+ uniformTimeFormatter ,
23+ localNumberFormatter ,
24+ } from 'utils/formatters'
2025import { onRenderRow } from 'utils/fabricUIRender'
26+ import { CONFIRMATION_THRESHOLD } from 'utils/const'
2127
2228const theme = getTheme ( )
2329
@@ -50,12 +56,14 @@ const TransactionList = ({
5056 isUpdatingDescription = false ,
5157 items = [ ] ,
5258 walletID,
59+ tipBlockNumber,
5360 dispatch,
5461} : {
5562 isLoading ?: boolean
5663 isUpdatingDescription ?: boolean
5764 walletID : string
5865 items : State . Transaction [ ]
66+ tipBlockNumber : string
5967 dispatch : StateDispatch
6068} ) => {
6169 const [ t ] = useTranslation ( )
@@ -71,35 +79,95 @@ const TransactionList = ({
7179 const transactionColumns : IColumn [ ] = useMemo (
7280 ( ) : IColumn [ ] =>
7381 [
74- { name : t ( 'history.type' ) , key : 'type' , fieldName : 'type' , minWidth : MIN_CELL_WIDTH , maxWidth : 50 } ,
82+ {
83+ name : t ( 'history.type' ) ,
84+ key : 'type' ,
85+ fieldName : 'type' ,
86+ minWidth : MIN_CELL_WIDTH ,
87+ maxWidth : 50 ,
88+ onRender : ( item ?: FormatTransaction ) => {
89+ if ( ! item ) {
90+ return null
91+ }
92+ const type = t ( `history.${ item . type } ` )
93+ return < span title = { type } > { type } </ span >
94+ } ,
95+ } ,
7596 {
7697 name : t ( 'history.timestamp' ) ,
7798 key : 'timestamp' ,
7899 fieldName : 'timestamp' ,
79100 minWidth : 80 ,
80101 maxWidth : 80 ,
81102 onRender : ( item ?: FormatTransaction ) => {
82- return item ? < span > { uniformTimeFormatter ( item . timestamp || item . createdAt ) . split ( ' ' ) [ 1 ] } </ span > : null
103+ if ( ! item ) {
104+ return null
105+ }
106+ const time = uniformTimeFormatter ( item . timestamp || item . createdAt ) . split ( ' ' ) [ 1 ]
107+ return < span title = { time } > { time } </ span >
83108 } ,
84109 } ,
85110 {
86111 name : t ( 'history.transaction-hash' ) ,
87112 key : 'hash' ,
88113 fieldName : 'hash' ,
114+ minWidth : 150 ,
115+ maxWidth : 150 ,
116+ onRender : ( item ?: FormatTransaction ) => {
117+ if ( ! item ) {
118+ return '-'
119+ }
120+ return (
121+ < span className = "text-overflow monospacedFont" title = { item . hash } >
122+ { `${ item . hash . slice ( 0 , 8 ) } ...${ item . hash . slice ( - 6 ) } ` }
123+ </ span >
124+ )
125+ } ,
126+ } ,
127+ {
128+ name : t ( 'history.confirmations' ) ,
129+ key : 'confirmation' ,
89130 minWidth : 100 ,
90- maxWidth : 600 ,
131+ maxWidth : + tipBlockNumber > 1e12 ? undefined : 150 ,
91132 onRender : ( item ?: FormatTransaction ) => {
92- if ( item ) {
93- return (
94- < span className = "text-overflow monospacedFont" title = { item . hash } >
95- { item . hash }
96- </ span >
97- )
133+ if ( ! item || item . status !== 'success' ) {
134+ return null
98135 }
99- return '-'
136+ const confirmationCount = 1 + + tipBlockNumber - + item . blockNumber
137+ if ( confirmationCount < CONFIRMATION_THRESHOLD ) {
138+ return t ( `history.confirming-with-count` , {
139+ confirmations : `${ confirmationCount } / ${ CONFIRMATION_THRESHOLD } ` ,
140+ } )
141+ }
142+ const confirmations = localNumberFormatter ( confirmationCount )
143+ return (
144+ < span title = { `${ confirmations } ` } className = "text-overflow" >
145+ { confirmations }
146+ </ span >
147+ )
148+ } ,
149+ } ,
150+ {
151+ name : t ( 'history.status' ) ,
152+ key : 'status' ,
153+ fieldName : 'status' ,
154+ minWidth : 80 ,
155+ maxWidth : 80 ,
156+ onRender : ( item ?: FormatTransaction ) => {
157+ if ( ! item ) {
158+ return null
159+ }
160+ if ( item . status !== 'success' ) {
161+ const status = t ( `history.${ item . status } ` )
162+ return < span title = { status } > { status } </ span >
163+ }
164+ const confirmationCount = 1 + + tipBlockNumber - + item . blockNumber
165+ if ( confirmationCount < CONFIRMATION_THRESHOLD ) {
166+ return t ( `history.confirming` )
167+ }
168+ return t ( `history.success` )
100169 } ,
101170 } ,
102- { name : t ( 'history.status' ) , key : 'status' , fieldName : 'status' , minWidth : 50 , maxWidth : 50 } ,
103171 {
104172 name : t ( 'history.description' ) ,
105173 key : 'description' ,
@@ -151,6 +219,7 @@ const TransactionList = ({
151219 } ,
152220 ] . map ( ( col ) : IColumn => ( { fieldName : col . key , ariaLabel : col . name , ...col } ) ) ,
153221 [
222+ tipBlockNumber ,
154223 localDescription ,
155224 onDescriptionChange ,
156225 onDescriptionFieldBlur ,
0 commit comments