Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Oct 7, 2024
1 parent a07984f commit c012bb7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions x/move/keeper/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
}

Expand Down

0 comments on commit c012bb7

Please sign in to comment.