@@ -8,8 +8,34 @@ import { Badge } from '@/components/ui/badge';
88import { ScrollArea } from '@/components/ui/scroll-area' ;
99import { Separator } from '@/components/ui/separator' ;
1010import { X , Copy , CheckCircle2 , FileText , Vote , Settings } from 'lucide-react' ;
11- import { useAppStore } from '@/lib/store' ;
11+ import { useAppStore , type BuilderTxBodyElement } from '@/lib/store' ;
1212import { toast } from 'sonner' ;
13+ import { formatAda } from '@/lib/utils/ada' ;
14+
15+ function summarizeTxBodyElement ( el : BuilderTxBodyElement ) : string {
16+ if ( el . type === 'ProposalProcedures' ) {
17+ const kind = el . data ?. kind ;
18+ if ( kind === 'info' ) {
19+ const deposit = el . data ?. deposit ;
20+ try {
21+ return `Info · ${ formatAda ( BigInt ( String ( deposit ?? 0 ) ) ) } ada` ;
22+ } catch {
23+ return 'Info' ;
24+ }
25+ }
26+ if ( kind === 'parameter-change' ) {
27+ const cm = el . data ?. costModels as { PlutusV1 ?: number [ ] ; PlutusV2 ?: number [ ] ; PlutusV3 ?: number [ ] } | undefined ;
28+ const langs = cm
29+ ? Object . keys ( cm ) . filter ( ( k ) : k is 'PlutusV1' | 'PlutusV2' | 'PlutusV3' =>
30+ [ 'PlutusV1' , 'PlutusV2' , 'PlutusV3' ] . includes ( k ) )
31+ : [ ] ;
32+ return `Parameter Change${ langs . length ? ` · ${ langs . join ( ', ' ) } ` : '' } ` ;
33+ }
34+ // 'cbor' or missing — fall through to legacy hex-snippet behaviour.
35+ }
36+ const first = Object . values ( el . data ?? { } ) [ 0 ] ;
37+ return first ? String ( first ) . slice ( 0 , 20 ) : 'Element' ;
38+ }
1339
1440export function TransactionSummary ( ) {
1541 const { builderCertificates, builderTxBodyElements, builtTxHex, removeCertificate, removeTxBodyElement } = useAppStore ( ) ;
@@ -257,7 +283,7 @@ export function TransactionSummary() {
257283 </ div >
258284 </ div >
259285 ) }
260- { Object . entries ( groupedTxBodyElements ) . filter ( ( [ key , items ] ) =>
286+ { Object . entries ( groupedTxBodyElements ) . filter ( ( [ key , items ] ) =>
261287 ! [ 'inputs' , 'outputs' , 'fees' ] . includes ( key ) && items . length > 0
262288 ) . map ( ( [ key , items ] ) => (
263289 < div key = { key } >
@@ -272,7 +298,7 @@ export function TransactionSummary() {
272298 { getTxBodyElementLabel ( el . type ) }
273299 </ Badge >
274300 < span className = "text-xs text-muted-foreground truncate" >
275- { Object . values ( el . data ) [ 0 ] ? String ( Object . values ( el . data ) [ 0 ] ) . slice ( 0 , 20 ) : 'Element' }
301+ { summarizeTxBodyElement ( el ) }
276302 </ span >
277303 </ div >
278304 < Button variant = "ghost" size = "sm" onClick = { ( ) => removeTxBodyElement ( el . id ) } >
0 commit comments