Skip to content

Commit efb7f9c

Browse files
authored
fix: omit optional items from transaction event (#214)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 775f89c commit efb7f9c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

input/chainsync/tx.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type TransactionEvent struct {
3333
TransactionCbor byteSliceJsonHex `json:"transactionCbor,omitempty"`
3434
Inputs []ledger.TransactionInput `json:"inputs"`
3535
Outputs []ledger.TransactionOutput `json:"outputs"`
36-
Certificates []ledger.Certificate `json:"certificates"`
36+
Certificates []ledger.Certificate `json:"certificates,omitempty"`
3737
Metadata *cbor.LazyValue `json:"metadata,omitempty"`
3838
Fee uint64 `json:"fee"`
3939
TTL uint64 `json:"ttl,omitempty"`
@@ -65,15 +65,19 @@ func NewTransactionEvent(
6565
BlockHash: block.Hash(),
6666
Inputs: tx.Inputs(),
6767
Outputs: tx.Outputs(),
68-
Certificates: tx.Certificates(),
6968
Fee: tx.Fee(),
70-
TTL: tx.TTL(),
7169
}
7270
if includeCbor {
7371
evt.TransactionCbor = tx.Cbor()
7472
}
73+
if tx.Certificates() != nil {
74+
evt.Certificates = tx.Certificates()
75+
}
7576
if tx.Metadata() != nil {
7677
evt.Metadata = tx.Metadata()
7778
}
79+
if tx.TTL() != 0 {
80+
evt.TTL = tx.TTL()
81+
}
7882
return evt
7983
}

0 commit comments

Comments
 (0)