Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/google.golang.org/gr…
Browse files Browse the repository at this point in the history
…pc-1.57.1
  • Loading branch information
sydneynotthecity authored Oct 27, 2023
2 parents 1fc1321 + 9a0a4ad commit eab15f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/export_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var operationsCmd = &cobra.Command{
numFailures := 0
totalNumBytes := 0
for _, transformInput := range operations {
transformed, err := transform.TransformOperation(transformInput.Operation, transformInput.OperationIndex, transformInput.Transaction, transformInput.LedgerSeqNum, transformInput.LedgerCloseMeta)
transformed, err := transform.TransformOperation(transformInput.Operation, transformInput.OperationIndex, transformInput.Transaction, transformInput.LedgerSeqNum, transformInput.LedgerCloseMeta, env.NetworkPassphrase)
if err != nil {
txIndex := transformInput.Transaction.Index
cmdLogger.LogError(fmt.Errorf("could not transform operation %d in transaction %d in ledger %d: %v", transformInput.OperationIndex, txIndex, transformInput.LedgerSeqNum, err))
Expand Down
4 changes: 4 additions & 0 deletions internal/transform/diagnostic_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func TransformDiagnosticEvent(transaction ingest.LedgerTransaction, lhe xdr.Ledg
return []DiagnosticEventOutput{}, nil, false
}

if transactionMeta.SorobanMeta == nil {
return []DiagnosticEventOutput{}, nil, false
}

var transformedDiagnosticEvents []DiagnosticEventOutput

for _, diagnoticEvent := range transactionMeta.SorobanMeta.DiagnosticEvents {
Expand Down
12 changes: 6 additions & 6 deletions internal/transform/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type liquidityPoolDelta struct {
}

// TransformOperation converts an operation from the history archive ingestion system into a form suitable for BigQuery
func TransformOperation(operation xdr.Operation, operationIndex int32, transaction ingest.LedgerTransaction, ledgerSeq int32, ledgerCloseMeta xdr.LedgerCloseMeta) (OperationOutput, error) {
func TransformOperation(operation xdr.Operation, operationIndex int32, transaction ingest.LedgerTransaction, ledgerSeq int32, ledgerCloseMeta xdr.LedgerCloseMeta, network string) (OperationOutput, error) {
outputTransactionID := toid.New(ledgerSeq, int32(transaction.Index), 0).ToInt64()
outputOperationID := toid.New(ledgerSeq, int32(transaction.Index), operationIndex+1).ToInt64() //operationIndex needs +1 increment to stay in sync with ingest package

Expand All @@ -51,7 +51,7 @@ func TransformOperation(operation xdr.Operation, operationIndex int32, transacti
return OperationOutput{}, fmt.Errorf("The operation type (%d) is negative for operation %d (operation id=%d)", outputOperationType, operationIndex, outputOperationID)
}

outputDetails, err := extractOperationDetails(operation, transaction, operationIndex)
outputDetails, err := extractOperationDetails(operation, transaction, operationIndex, network)
if err != nil {
return OperationOutput{}, err
}
Expand Down Expand Up @@ -474,7 +474,7 @@ func addOperationFlagToOperationDetails(result map[string]interface{}, flag uint
result[prefix+"flags_s"] = stringFlags
}

func extractOperationDetails(operation xdr.Operation, transaction ingest.LedgerTransaction, operationIndex int32) (map[string]interface{}, error) {
func extractOperationDetails(operation xdr.Operation, transaction ingest.LedgerTransaction, operationIndex int32, network string) (map[string]interface{}, error) {
details := map[string]interface{}{}
sourceAccount := getOperationSourceAccount(operation, transaction)
operationType := operation.Body.Type
Expand Down Expand Up @@ -967,7 +967,7 @@ func extractOperationDetails(operation xdr.Operation, transaction ingest.LedgerT
}
details["parameters"] = params

if balanceChanges, err := parseAssetBalanceChangesFromContractEvents(transaction); err != nil {
if balanceChanges, err := parseAssetBalanceChangesFromContractEvents(transaction, network); err != nil {
return nil, err
} else {
details["asset_balance_changes"] = balanceChanges
Expand Down Expand Up @@ -1739,7 +1739,7 @@ func (operation *transactionOperationWrapper) parseAssetBalanceChangesFromContra
return balanceChanges, nil
}

func parseAssetBalanceChangesFromContractEvents(transaction ingest.LedgerTransaction) ([]map[string]interface{}, error) {
func parseAssetBalanceChangesFromContractEvents(transaction ingest.LedgerTransaction, network string) ([]map[string]interface{}, error) {
balanceChanges := []map[string]interface{}{}

diagnosticEvents, err := transaction.GetDiagnosticEvents()
Expand All @@ -1753,7 +1753,7 @@ func parseAssetBalanceChangesFromContractEvents(transaction ingest.LedgerTransac
// Parse the xdr contract event to contractevents.StellarAssetContractEvent model

// has some convenience like to/from attributes are expressed in strkey format for accounts(G...) and contracts(C...)
if sacEvent, err := contractevents.NewStellarAssetContractEvent(&contractEvent, "Test SDF Future Network ; October 2022"); err == nil {
if sacEvent, err := contractevents.NewStellarAssetContractEvent(&contractEvent, network); err == nil {
switch sacEvent.GetType() {
case contractevents.EventTypeTransfer:
transferEvt := sacEvent.(*contractevents.TransferEvent)
Expand Down
2 changes: 1 addition & 1 deletion internal/transform/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestTransformOperation(t *testing.T) {
}

for _, test := range tests {
actualOutput, actualError := TransformOperation(test.input.operation, test.input.index, test.input.transaction, 0, test.input.ledgerClosedMeta)
actualOutput, actualError := TransformOperation(test.input.operation, test.input.index, test.input.transaction, 0, test.input.ledgerClosedMeta, "")
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down

0 comments on commit eab15f2

Please sign in to comment.