Skip to content

Commit

Permalink
fix: omit optional items from transaction event
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
  • Loading branch information
wolf31o2 committed May 29, 2024
1 parent 775f89c commit 37a9701
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions input/chainsync/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type TransactionEvent struct {
TransactionCbor byteSliceJsonHex `json:"transactionCbor,omitempty"`
Inputs []ledger.TransactionInput `json:"inputs"`
Outputs []ledger.TransactionOutput `json:"outputs"`
Certificates []ledger.Certificate `json:"certificates"`
Certificates []ledger.Certificate `json:"certificates,omitempty"`
Metadata *cbor.LazyValue `json:"metadata,omitempty"`
Fee uint64 `json:"fee"`
TTL uint64 `json:"ttl,omitempty"`
Expand Down Expand Up @@ -65,15 +65,19 @@ func NewTransactionEvent(
BlockHash: block.Hash(),
Inputs: tx.Inputs(),
Outputs: tx.Outputs(),
Certificates: tx.Certificates(),
Fee: tx.Fee(),
TTL: tx.TTL(),
}
if includeCbor {
evt.TransactionCbor = tx.Cbor()
}
if tx.Certificates() != nil {
evt.Certificates = tx.Certificates()
}
if tx.Metadata() != nil {
evt.Metadata = tx.Metadata()
}
if tx.TTL() != 0 {
evt.TTL = tx.TTL()
}
return evt
}

0 comments on commit 37a9701

Please sign in to comment.