Skip to content

Commit

Permalink
fix: bridge exit metadata hash
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Dec 6, 2024
1 parent 6531554 commit 9eec22f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 11 additions & 2 deletions agglayer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,29 @@ func (b *BridgeExit) Hash() common.Hash {

// MarshalJSON is the implementation of the json.Marshaler interface
func (b *BridgeExit) MarshalJSON() ([]byte, error) {
var metadataString interface{}
if b.IsMetadataHashed {
metadataString = common.Bytes2Hex(b.Metadata)
} else if len(b.Metadata) > 0 {
metadataString = bytesToUints(b.Metadata)
} else {
metadataString = nil
}

return json.Marshal(&struct {
LeafType string `json:"leaf_type"`
TokenInfo *TokenInfo `json:"token_info"`
DestinationNetwork uint32 `json:"dest_network"`
DestinationAddress common.Address `json:"dest_address"`
Amount string `json:"amount"`
Metadata []uint `json:"metadata"`
Metadata interface{} `json:"metadata"`
}{
LeafType: b.LeafType.String(),
TokenInfo: b.TokenInfo,
DestinationNetwork: b.DestinationNetwork,
DestinationAddress: b.DestinationAddress,
Amount: b.Amount.String(),
Metadata: bytesToUints(b.Metadata),
Metadata: metadataString,
})
}

Expand Down
Loading

0 comments on commit 9eec22f

Please sign in to comment.