diff --git a/server/services/transactionEventsController.go b/server/services/transactionEventsController.go index e34c7ae5..a44ac860 100644 --- a/server/services/transactionEventsController.go +++ b/server/services/transactionEventsController.go @@ -45,61 +45,27 @@ func (controller *transactionEventsController) extractEventSCDeploy(tx *transact } func (controller *transactionEventsController) extractEventTransferValueOnly(tx *transaction.ApiTransactionResult) ([]*eventTransferValueOnly, error) { - isBeforeSirius := !controller.provider.IsReleaseSiriusActive(tx.Epoch) + if !controller.provider.IsReleaseSiriusActive(tx.Epoch) { + return make([]*eventTransferValueOnly, 0), nil + } + rawEvents := controller.findManyEventsByIdentifier(tx, transactionEventTransferValueOnly) typedEvents := make([]*eventTransferValueOnly, 0) for _, event := range rawEvents { - if isBeforeSirius { - typedEvent, err := controller.decideEffectiveEventTransferValueOnlyBeforeSirius(event) - if err != nil { - return nil, err - } - - if typedEvent != nil { - typedEvents = append(typedEvents, typedEvent) - } - } else { - typedEvent, err := controller.decideEffectiveEventTransferValueOnlyAfterSirius(event) - if err != nil { - return nil, err - } + typedEvent, err := controller.decideEffectiveEventTransferValueOnlyAfterSirius(event) + if err != nil { + return nil, err + } - if typedEvent != nil { - typedEvents = append(typedEvents, typedEvent) - } + if typedEvent != nil { + typedEvents = append(typedEvents, typedEvent) } } return typedEvents, nil } -func (controller *transactionEventsController) decideEffectiveEventTransferValueOnlyBeforeSirius(event *transaction.Events) (*eventTransferValueOnly, error) { - numTopics := len(event.Topics) - - if numTopics != numTopicsOfEventTransferValueOnlyBeforeSirius { - return nil, fmt.Errorf("%w: bad number of topics for 'transferValueOnly' = %d", errCannotRecognizeEvent, numTopics) - } - - senderPubKey := event.Topics[0] - receiverPubKey := event.Topics[1] - valueBytes := event.Topics[2] - - if len(valueBytes) == 0 { - return nil, nil - } - - sender := controller.provider.ConvertPubKeyToAddress(senderPubKey) - receiver := controller.provider.ConvertPubKeyToAddress(receiverPubKey) - value := big.NewInt(0).SetBytes(valueBytes) - - return &eventTransferValueOnly{ - sender: sender, - receiver: receiver, - value: value.String(), - }, nil -} - // See: https://github.com/multiversx/mx-specs/blob/main/releases/protocol/release-specs-v1.6.0-Sirius.md#17-logs--events-changes-5490 func (controller *transactionEventsController) decideEffectiveEventTransferValueOnlyAfterSirius(event *transaction.Events) (*eventTransferValueOnly, error) { numTopics := len(event.Topics) diff --git a/server/services/transactionEventsController_test.go b/server/services/transactionEventsController_test.go index 484717f5..b8851d09 100644 --- a/server/services/transactionEventsController_test.go +++ b/server/services/transactionEventsController_test.go @@ -206,7 +206,7 @@ func TestTransactionEventsController_ExtractEvents(t *testing.T) { require.Equal(t, "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6", events[0].deployerAddress) }) - t.Run("transferValueOnly, before Sirius", func(t *testing.T) { + t.Run("transferValueOnly, before Sirius (not handled at all)", func(t *testing.T) { topic0 := testscommon.TestContractFooShard0.PubKey topic1 := testscommon.TestContractBarShard0.PubKey topic2 := big.NewInt(100).Bytes() @@ -230,10 +230,7 @@ func TestTransactionEventsController_ExtractEvents(t *testing.T) { events, err := controller.extractEventTransferValueOnly(tx) require.NoError(t, err) - require.Len(t, events, 1) - require.Equal(t, testscommon.TestContractFooShard0.Address, events[0].sender) - require.Equal(t, testscommon.TestContractBarShard0.Address, events[0].receiver) - require.Equal(t, "100", events[0].value) + require.Len(t, events, 0) }) t.Run("transferValueOnly, after Sirius, effective (intra-shard ExecuteOnDestContext)", func(t *testing.T) {