From c012bb773d3ed42ee3603d01160e165d14590f4f Mon Sep 17 00:00:00 2001 From: beer-1 Date: Mon, 7 Oct 2024 14:01:22 +0900 Subject: [PATCH] fix review comments --- x/move/keeper/handler.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/x/move/keeper/handler.go b/x/move/keeper/handler.go index a61a3c32..0871c702 100644 --- a/x/move/keeper/handler.go +++ b/x/move/keeper/handler.go @@ -430,6 +430,10 @@ func (k Keeper) dispatchMessage(parentCtx sdk.Context, message vmtypes.CosmosMes ctx, commit := parentCtx.CacheContext() defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("panic: %v", r) + } + success := err == nil // create submsg event @@ -446,7 +450,6 @@ func (k Keeper) dispatchMessage(parentCtx sdk.Context, message vmtypes.CosmosMes // emit failed reason event if failed and allowed to fail event.AppendAttributes(sdk.NewAttribute(types.AttributeKeyReason, err.Error())) - parentCtx.EventManager().EmitEvent(event) } else { // commit if success commit() @@ -477,6 +480,7 @@ func (k Keeper) dispatchMessage(parentCtx sdk.Context, message vmtypes.CosmosMes var msg proto.Message if stargateMsg, ok := message.(*vmtypes.CosmosMessage__Stargate); ok { + // validate basic & signer check is done in HandleVMStargateMsg msg, err = k.HandleVMStargateMsg(ctx, &stargateMsg.Value) if err != nil { return @@ -487,17 +491,18 @@ func (k Keeper) dispatchMessage(parentCtx sdk.Context, message vmtypes.CosmosMes callback = stargateMsg.Value.Callback callbackSender = stargateMsg.Value.Sender } else { + // signer check had been done in moveVM msg, err = types.ConvertToSDKMessage(ctx, NewMoveBankKeeper(&k), NewNftKeeper(&k), message, k.ac, k.vc) if err != nil { return } - } - // validate msg - if msg, ok := msg.(sdk.HasValidateBasic); ok { - err = msg.ValidateBasic() - if err != nil { - return + // conduct validate basic + if msg, ok := msg.(sdk.HasValidateBasic); ok { + err = msg.ValidateBasic() + if err != nil { + return + } } }