Skip to content

Commit

Permalink
Merge pull request #199 from stellar/fix-diagnostic-event-bug
Browse files Browse the repository at this point in the history
Fix diagnostic event parsing bug
  • Loading branch information
chowbao authored Oct 3, 2023
2 parents 4053d24 + 3a283de commit 1132c44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/input/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions internal/transform/diagnostic_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down

0 comments on commit 1132c44

Please sign in to comment.