refactor(baseapp,types)!: msg responses (#17348)
Co-authored-by: Julien Robert <julien@rbrt.fr> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
co-authored by
Julien Robert
Aleksandr Bezobchuk
parent
0dc32a0762
commit
30997f4227
+3
-5
@@ -959,7 +959,7 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res
|
||||
// Result is returned. The caller must not commit state if an error is returned.
|
||||
func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, msgsV2 []protov2.Message, mode execMode) (*sdk.Result, error) {
|
||||
events := sdk.EmptyEvents()
|
||||
var msgResponses []*codectypes.Any
|
||||
msgResponses := make([]*codectypes.Any, 0, len(msgs))
|
||||
|
||||
// NOTE: GasWanted is determined by the AnteHandler and GasUsed by the GasMeter.
|
||||
for i, msg := range msgs {
|
||||
@@ -997,9 +997,8 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, msgsV2 []protov2.Me
|
||||
|
||||
// Each individual sdk.Result that went through the MsgServiceRouter
|
||||
// (which should represent 99% of the Msgs now, since everyone should
|
||||
// be using protobuf Msgs) has exactly one Msg response, set inside
|
||||
// `WrapServiceResult`. We take that Msg response, and aggregate it
|
||||
// into an array.
|
||||
// be using protobuf Msgs) has exactly one Msg response.
|
||||
// We take that Msg response, and aggregate it into an array.
|
||||
if len(msgResult.MsgResponses) > 0 {
|
||||
msgResponse := msgResult.MsgResponses[0]
|
||||
if msgResponse == nil {
|
||||
@@ -1007,7 +1006,6 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, msgsV2 []protov2.Me
|
||||
}
|
||||
msgResponses = append(msgResponses, msgResponse)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data, err := makeABCIData(msgResponses)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
gogogrpc "github.com/cosmos/gogoproto/grpc"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/grpc"
|
||||
@@ -157,7 +158,20 @@ func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler inter
|
||||
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "Expecting proto.Message, got %T", resMsg)
|
||||
}
|
||||
|
||||
return sdk.WrapServiceResult(ctx, resMsg, err)
|
||||
anyResp, err := codectypes.NewAnyWithValue(resMsg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var events []abci.Event
|
||||
if evtMgr := ctx.EventManager(); evtMgr != nil {
|
||||
events = evtMgr.ABCIEvents()
|
||||
}
|
||||
|
||||
return &sdk.Result{
|
||||
Events: events,
|
||||
MsgResponses: []*codectypes.Any{anyResp},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user