@@ -42,10 +42,11 @@ func init() {
4242}
4343
4444type blockResult struct {
45- block * flow.Block
46- events []flow.BlockEvents
47- collections []* flow.Collection
48- included []string
45+ block * flow.Block
46+ events []flow.BlockEvents
47+ transactions []* flow.Transaction
48+ results []* flow.TransactionResult
49+ included []string
4950}
5051
5152func (r * blockResult ) JSON () any {
@@ -56,23 +57,36 @@ func (r *blockResult) JSON() any {
5657 result ["totalSeals" ] = len (r .block .Seals )
5758 result ["totalCollections" ] = len (r .block .CollectionGuarantees )
5859
60+ // Keep collection info for backwards compatibility
5961 collections := make ([]any , 0 , len (r .block .CollectionGuarantees ))
60- for i , guarantee := range r .block .CollectionGuarantees {
62+ for _ , guarantee := range r .block .CollectionGuarantees {
6163 collection := make (map [string ]any )
6264 collection ["id" ] = guarantee .CollectionID .String ()
63-
64- if command .ContainsFlag (r .included , "transactions" ) {
65- txs := make ([]string , 0 )
66- for _ , tx := range r .collections [i ].TransactionIDs {
67- txs = append (txs , tx .String ())
65+ collections = append (collections , collection )
66+ }
67+ result ["collections" ] = collections
68+
69+ // Add transaction details if requested
70+ if command .ContainsFlag (r .included , "transactions" ) && len (r .transactions ) > 0 {
71+ txs := make ([]map [string ]any , 0 , len (r .transactions ))
72+ for i , tx := range r .transactions {
73+ txData := make (map [string ]any )
74+ txData ["id" ] = tx .ID ().String ()
75+ txData ["status" ] = r .results [i ].Status .String ()
76+
77+ // System transactions have empty collection ID
78+ if r .results [i ].CollectionID == flow .EmptyID {
79+ txData ["type" ] = "system"
80+ } else {
81+ txData ["type" ] = "user"
82+ txData ["collectionId" ] = r .results [i ].CollectionID .String ()
6883 }
69- collection ["transactions" ] = txs
70- }
7184
72- collections = append (collections , collection )
85+ txs = append (txs , txData )
86+ }
87+ result ["transactions" ] = txs
7388 }
7489
75- result ["collection" ] = collections
7690 return result
7791}
7892
@@ -99,17 +113,40 @@ func (r *blockResult) String() string {
99113 _ , _ = fmt .Fprintf (writer , "Status\t %s\n " , blockStatusToString (r .block .Status ))
100114
101115 _ , _ = fmt .Fprintf (writer , "Total Seals\t %v\n " , len (r .block .Seals ))
102-
103116 _ , _ = fmt .Fprintf (writer , "Total Collections\t %v\n " , len (r .block .CollectionGuarantees ))
104117
118+ // Show collections
105119 for i , guarantee := range r .block .CollectionGuarantees {
106120 _ , _ = fmt .Fprintf (writer , " Collection %d:\t %s\n " , i , guarantee .CollectionID )
121+ }
107122
108- if command .ContainsFlag (r .included , "transactions" ) {
109- for x , tx := range r .collections [i ].TransactionIDs {
110- _ , _ = fmt .Fprintf (writer , " Transaction %d: %s\n " , x , tx )
123+ // Show transactions if included
124+ if command .ContainsFlag (r .included , "transactions" ) && len (r .transactions ) > 0 {
125+ _ , _ = fmt .Fprintf (writer , "\n Transactions:\n " )
126+
127+ userCount := 0
128+ systemCount := 0
129+
130+ for i , tx := range r .transactions {
131+ var txType string
132+ if r .results [i ].CollectionID == flow .EmptyID {
133+ txType = "system"
134+ systemCount ++
135+ } else {
136+ txType = "user"
137+ userCount ++
111138 }
139+
140+ _ , _ = fmt .Fprintf (writer , " [%d] %s\t %s (%s)\n " ,
141+ i ,
142+ tx .ID ().String (),
143+ r .results [i ].Status .String (),
144+ txType ,
145+ )
112146 }
147+
148+ _ , _ = fmt .Fprintf (writer , "\n Total: %d transactions (%d user, %d system)\n " ,
149+ len (r .transactions ), userCount , systemCount )
113150 }
114151
115152 if len (r .events ) > 0 {
0 commit comments