27 lines
950 B
Go
27 lines
950 B
Go
package ante
|
|
|
|
import (
|
|
errorsmod "cosmossdk.io/errors"
|
|
evmtypes "github.com/cerc-io/laconicd/x/evm/types"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
|
|
)
|
|
|
|
// RejectMessagesDecorator prevents invalid msg types from being executed
|
|
type RejectMessagesDecorator struct{}
|
|
|
|
// AnteHandle rejects messages that requires ethereum-specific authentication.
|
|
// For example `MsgEthereumTx` requires fee to be deducted in the antehandler in
|
|
// order to perform the refund.
|
|
func (rmd RejectMessagesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
|
|
for _, msg := range tx.GetMsgs() {
|
|
if _, ok := msg.(*evmtypes.MsgEthereumTx); ok {
|
|
return ctx, errorsmod.Wrapf(
|
|
errortypes.ErrInvalidType,
|
|
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
|
|
)
|
|
}
|
|
}
|
|
return next(ctx, tx, simulate)
|
|
}
|