2022-01-02 22:44:46 +00:00
|
|
|
package ante
|
|
|
|
|
|
|
|
import (
|
2022-11-25 08:24:55 +00:00
|
|
|
errorsmod "cosmossdk.io/errors"
|
2022-01-02 22:44:46 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2022-11-25 08:24:55 +00:00
|
|
|
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
|
2022-06-19 09:43:41 +00:00
|
|
|
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
2022-01-02 22:44:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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 {
|
2022-11-25 08:24:55 +00:00
|
|
|
return ctx, errorsmod.Wrapf(
|
|
|
|
errortypes.ErrInvalidType,
|
2022-01-02 22:44:46 +00:00
|
|
|
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return next(ctx, tx, simulate)
|
|
|
|
}
|