From df484c63e52ba8671e24b55f9038b07b8b74cfd9 Mon Sep 17 00:00:00 2001
From: Victoria Erokhina <viktoria.erokhina@gmail.com>
Date: Thu, 14 Nov 2024 17:40:52 +0000
Subject: [PATCH] enrich emulated events with intentions

---
 pkg/api/event_handlers.go | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pkg/api/event_handlers.go b/pkg/api/event_handlers.go
index b936df78..6c7bb6fe 100644
--- a/pkg/api/event_handlers.go
+++ b/pkg/api/event_handlers.go
@@ -310,10 +310,11 @@ func (h *Handler) GetAccountEvent(ctx context.Context, params oas.GetAccountEven
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
 	}
-	result, err := bath.FindActions(ctx, trace, bath.ForAccount(account.ID), bath.WithInformationSource(h.storage))
+	actions, err := bath.FindActions(ctx, trace, bath.ForAccount(account.ID), bath.WithInformationSource(h.storage))
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
 	}
+	result := bath.EnrichWithIntentions(trace, actions)
 	event, err := h.toAccountEvent(ctx, account.ID, trace, result, params.AcceptLanguage, params.SubjectOnly.Value)
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
@@ -374,10 +375,11 @@ func (h *Handler) EmulateMessageToAccountEvent(ctx context.Context, request *oas
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
 	}
-	result, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage))
+	actions, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage))
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
 	}
+	result := bath.EnrichWithIntentions(trace, actions)
 	event, err := h.toAccountEvent(ctx, account.ID, trace, result, params.AcceptLanguage, false)
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
@@ -425,10 +427,11 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat
 			return nil, toError(http.StatusInternalServerError, err)
 		}
 	}
-	result, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage))
+	actions, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage))
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
 	}
+	result := bath.EnrichWithIntentions(trace, actions)
 	event, err := h.toEvent(ctx, trace, result, params.AcceptLanguage)
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
@@ -601,10 +604,11 @@ func (h *Handler) EmulateMessageToWallet(ctx context.Context, request *oas.Emula
 		return nil, toError(http.StatusInternalServerError, err)
 	}
 	t := convertTrace(trace, h.addressBook)
-	result, err := bath.FindActions(ctx, trace, bath.ForAccount(*walletAddress), bath.WithInformationSource(h.storage))
+	actions, err := bath.FindActions(ctx, trace, bath.ForAccount(*walletAddress), bath.WithInformationSource(h.storage))
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)
 	}
+	result := bath.EnrichWithIntentions(trace, actions)
 	event, err := h.toAccountEvent(ctx, *walletAddress, trace, result, params.AcceptLanguage, true)
 	if err != nil {
 		return nil, toError(http.StatusInternalServerError, err)