@@ -13,6 +13,20 @@ import { explorerNavButton } from './style.module.scss'
1313
1414const MIN_CELL_WIDTH = 70
1515
16+ const CompactAddress = ( { address } : { address : string } ) => (
17+ < div
18+ title = { address }
19+ style = { {
20+ overflow : 'hidden' ,
21+ display : 'flex' ,
22+ } }
23+ className = "monospacedFont"
24+ >
25+ < span className = "textOverflow" > { address . slice ( 0 , - 6 ) } </ span >
26+ < span > { address . slice ( - 6 ) } </ span >
27+ </ div >
28+ )
29+
1630const Transaction = ( ) => {
1731 const [ t ] = useTranslation ( )
1832 const [ transaction , setTransaction ] = useState ( transactionState )
@@ -27,25 +41,42 @@ const Transaction = () => {
2741 name : t ( 'transaction.index' ) ,
2842 minWidth : 60 ,
2943 maxWidth : 60 ,
30- onRender : ( _item ?: any , index ?: number ) => {
44+ onRender : ( _input ?: State . DetailedInput , index ?: number ) => {
3145 if ( undefined !== index ) {
3246 return index
3347 }
3448 return null
3549 } ,
3650 } ,
3751 {
38- key : 'outPointCell' ,
39- name : 'OutPoint Cell' ,
40- minWidth : 150 ,
41- maxWidth : 600 ,
42- onRender : ( item : any ) => {
43- const text = item . previousOutput ? `${ item . previousOutput . txHash } [${ item . previousOutput . index } ]` : 'none'
44- return (
45- < span title = { text } className = "textOverflow" >
46- { text }
47- </ span >
48- )
52+ key : 'address' ,
53+ name : t ( 'transaction.address' ) ,
54+ minWidth : 200 ,
55+ maxWidth : 500 ,
56+ onRender : ( input ?: State . DetailedInput , _index ?: number , column ?: IColumn ) => {
57+ if ( ! input ) {
58+ return null
59+ }
60+ if ( ! input . lock ) {
61+ return t ( 'transaction.cell-from-cellbase' )
62+ }
63+ try {
64+ const address = ckbCore . utils . bech32Address ( input . lock . args , {
65+ prefix : addressPrefix ,
66+ type : ckbCore . utils . AddressType . HashIdx ,
67+ codeHashIndex : '0x00' ,
68+ } )
69+ if ( column && ( column . calculatedWidth || 0 ) < 450 ) {
70+ return < CompactAddress address = { address } />
71+ }
72+ return (
73+ < span title = { address } className = "monospacedFont" >
74+ { address }
75+ </ span >
76+ )
77+ } catch {
78+ return null
79+ }
4980 } ,
5081 } ,
5182 {
@@ -67,7 +98,7 @@ const Transaction = () => {
6798 ...col ,
6899 } )
69100 ) ,
70- [ t ]
101+ [ addressPrefix , t ]
71102 )
72103
73104 const outputColumns : IColumn [ ] = useMemo (
@@ -101,19 +132,7 @@ const Transaction = () => {
101132 codeHashIndex : '0x00' ,
102133 } )
103134 if ( column && ( column . calculatedWidth || 0 ) < 450 ) {
104- return (
105- < div
106- title = { address }
107- style = { {
108- overflow : 'hidden' ,
109- display : 'flex' ,
110- } }
111- className = "monospacedFont"
112- >
113- < span className = "textOverflow" > { address . slice ( 0 , - 6 ) } </ span >
114- < span > { address . slice ( - 6 ) } </ span >
115- </ div >
116- )
135+ return < CompactAddress address = { address } />
117136 }
118137 return (
119138 < span title = { address } className = "monospacedFont" >
0 commit comments