fix: propagate events in x/group through sdk.Results (#13808)

This commit is contained in:
Damian Nolan 2022-11-09 15:32:13 +01:00 committed by GitHub
parent bcdf81cbaf
commit 90fd3e9f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -754,13 +754,18 @@ func (k Keeper) Exec(goCtx context.Context, req *group.MsgExec) (*group.MsgExecR
return nil, err
}
if _, err := k.doExecuteMsgs(cacheCtx, k.router, proposal, addr); err != nil {
if results, err := k.doExecuteMsgs(cacheCtx, k.router, proposal, addr); err != nil {
proposal.ExecutorResult = group.PROPOSAL_EXECUTOR_RESULT_FAILURE
logs = fmt.Sprintf("proposal execution failed on proposal %d, because of error %s", id, err.Error())
k.Logger(ctx).Info("proposal execution failed", "cause", err, "proposalID", id)
} else {
proposal.ExecutorResult = group.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())
}
}
}