From 716e5c7890569e5f967af1ed6c840540bf40a556 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Mon, 6 Mar 2023 19:20:42 +0900 Subject: [PATCH] Propagate events in x/foundation through sdk.Results --- x/foundation/keeper/exec.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/foundation/keeper/exec.go b/x/foundation/keeper/exec.go index f0d5068094..cf317b2fe9 100644 --- a/x/foundation/keeper/exec.go +++ b/x/foundation/keeper/exec.go @@ -50,13 +50,18 @@ func (k Keeper) Exec(ctx sdk.Context, proposalID uint64) error { // Caching context so that we don't update the store in case of failure. ctx, flush := ctx.CacheContext() - if _, err = k.doExecuteMsgs(ctx, *proposal); err != nil { + if results, err := k.doExecuteMsgs(ctx, *proposal); err != nil { proposal.ExecutorResult = foundation.PROPOSAL_EXECUTOR_RESULT_FAILURE logs = fmt.Sprintf("proposal execution failed on proposal %d, because of error %s", proposalID, err.Error()) logger.Info("proposal execution failed", "cause", err, "proposalID", proposal.Id) } else { proposal.ExecutorResult = foundation.PROPOSAL_EXECUTOR_RESULT_SUCCESS flush() + + for _, res := range results { + // NOTE: The sdk msg handler creates a new EventManager, so events must be correctly propagated back to the current context + ctx.EventManager().EmitEvents(res.GetEvents()) + } } }