From 3a283de0402ea9d36a3b994f518386a3e9720f97 Mon Sep 17 00:00:00 2001 From: Simon Chow Date: Tue, 3 Oct 2023 14:31:59 -0400 Subject: [PATCH] Fix diagnostic event parsing bug --- internal/input/changes.go | 3 ++- internal/transform/diagnostic_events.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/input/changes.go b/internal/input/changes.go index af554c05..99472e62 100644 --- a/internal/input/changes.go +++ b/internal/input/changes.go @@ -89,7 +89,8 @@ func extractBatch( xdr.LedgerEntryTypeClaimableBalance, xdr.LedgerEntryTypeContractData, xdr.LedgerEntryTypeContractCode, - xdr.LedgerEntryTypeConfigSetting} + xdr.LedgerEntryTypeConfigSetting, + xdr.LedgerEntryTypeExpiration} changes := map[xdr.LedgerEntryType][]ingest.Change{} ctx := context.Background() diff --git a/internal/transform/diagnostic_events.go b/internal/transform/diagnostic_events.go index 9f4b74de..f7cb343f 100644 --- a/internal/transform/diagnostic_events.go +++ b/internal/transform/diagnostic_events.go @@ -34,11 +34,11 @@ func TransformDiagnosticEvent(transaction ingest.LedgerTransaction, lhe xdr.Ledg var transformedDiagnosticEvents []DiagnosticEventOutput for _, diagnoticEvent := range transactionMeta.SorobanMeta.DiagnosticEvents { + var outputContractId string + outputInSuccessfulContractCall := diagnoticEvent.InSuccessfulContractCall event := diagnoticEvent.Event outputExtV := event.Ext.V - contractIdByte, _ := event.ContractId.MarshalBinary() - outputContractId, _ := strkey.Encode(strkey.VersionByteContract, contractIdByte) outputType := event.Type.String() outputBodyV := event.Body.V body, ok := event.Body.GetV0() @@ -51,6 +51,12 @@ func TransformDiagnosticEvent(transaction ingest.LedgerTransaction, lhe xdr.Ledg continue } + if event.ContractId != nil { + contractId := *event.ContractId + contractIdByte, _ := contractId.MarshalBinary() + outputContractId, _ = strkey.Encode(strkey.VersionByteContract, contractIdByte) + } + transformedDiagnosticEvent := DiagnosticEventOutput{ TransactionHash: outputTransactionHash, LedgerSequence: outputLedgerSequence,