Skip to content

Commit

Permalink
Propagate events in x/foundation through sdk.Results
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Mar 14, 2023
1 parent d9428ec commit 716e5c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion x/foundation/keeper/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}

Expand Down

0 comments on commit 716e5c7

Please sign in to comment.