Skip to content

Commit

Permalink
Include the block hash in evm.BlockExecuted event payload
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Jan 19, 2024
1 parent 2b49cb0 commit f79b1a2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fvm/evm/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ var blockExecutedEventCadenceType = &cadence.EventType{
QualifiedIdentifier: string(EventTypeBlockExecuted),
Fields: []cadence.Field{
cadence.NewField("height", cadence.UInt64Type{}),
cadence.NewField("hash", cadence.StringType{}),
cadence.NewField("totalSupply", cadence.UInt64Type{}),
cadence.NewField("parentHash", cadence.StringType{}),
cadence.NewField("receiptRoot", cadence.StringType{}),
Expand All @@ -121,8 +122,14 @@ func (p *BlockExecutedEventPayload) CadenceEvent() (cadence.Event, error) {
hashes[i] = cadence.String(hash.String())
}

blockHash, err := p.Block.Hash()
if err != nil {
return cadence.Event{}, err
}

fields := []cadence.Value{
cadence.NewUInt64(p.Block.Height),
cadence.String(blockHash.String()),
cadence.NewUInt64(p.Block.TotalSupply),
cadence.String(p.Block.ReceiptRoot.String()),
cadence.String(p.Block.ParentBlockHash.String()),
Expand Down

0 comments on commit f79b1a2

Please sign in to comment.