From 37a97016d9f90e26048b2109c0d33232e9399627 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Wed, 29 May 2024 11:12:13 -0400 Subject: [PATCH] fix: omit optional items from transaction event Signed-off-by: Chris Gianelloni --- input/chainsync/tx.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/input/chainsync/tx.go b/input/chainsync/tx.go index d5007b6..c436315 100644 --- a/input/chainsync/tx.go +++ b/input/chainsync/tx.go @@ -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"` @@ -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 }