github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/app/ante/validateMsg.go (about) 1 package ante 2 3 import sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 4 5 type ValidateMsgHandler func(ctx sdk.Context, msgs []sdk.Msg) error 6 7 type ValidateMsgHandlerDecorator struct { 8 validateMsgHandler ValidateMsgHandler 9 } 10 11 func NewValidateMsgHandlerDecorator(validateHandler ValidateMsgHandler) ValidateMsgHandlerDecorator { 12 return ValidateMsgHandlerDecorator{validateMsgHandler: validateHandler} 13 } 14 15 func (vmhd ValidateMsgHandlerDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { 16 // *ABORT* the tx in case of failing to validate it in checkTx mode 17 if ctx.IsCheckTx() && !simulate && vmhd.validateMsgHandler != nil { 18 err := vmhd.validateMsgHandler(ctx, tx.GetMsgs()) 19 if err != nil { 20 return ctx, err 21 } 22 } 23 24 return next(ctx, tx, simulate) 25 }