Skip to content

Commit

Permalink
enrich emulated events with intentions
Browse files Browse the repository at this point in the history
  • Loading branch information
erokhinav committed Nov 14, 2024
1 parent 12cad02 commit df484c6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/api/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit df484c6

Please sign in to comment.