Skip to content

Commit

Permalink
feat(cmd/paratime): Show block-level events
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Sep 13, 2023
1 parent e1e21ad commit 3e55842
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cmd/paratime/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/oasisprotocol/oasis-core/go/common/cbor"
"github.com/oasisprotocol/oasis-core/go/common/crypto/hash"
runtimeTx "github.com/oasisprotocol/oasis-core/go/runtime/transaction"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/client"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/connection"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/types"
Expand Down Expand Up @@ -121,6 +122,29 @@ var showCmd = &cobra.Command{

fmt.Printf("Transactions: %d\n", len(txs))

evs, err := rt.GetEventsRaw(ctx, blkNum)
cobra.CheckErr(err)
if len(evs) > 0 {
// Check if there were any block events emitted.
var blockEvs []*types.Event
for _, ev := range evs {
if ev.TxHash.Equal(&runtimeTx.TagBlockTxHash) {
blockEvs = append(blockEvs, ev)
}
}

if numEvents := len(blockEvs); numEvents > 0 {
fmt.Printf("=== Block events ===\n")
fmt.Printf("Events: %d\n", numEvents)
fmt.Println()

for evIndex, ev := range blockEvs {
prettyPrintEvent(" ", evIndex, ev, evDecoders)
fmt.Println()
}
}
}

if len(args) >= 2 {
fmt.Println()

Expand Down

0 comments on commit 3e55842

Please sign in to comment.