-
Notifications
You must be signed in to change notification settings - Fork 16
/
reject_msgs.go
36 lines (30 loc) · 1.17 KB
/
reject_msgs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ante
import (
"strings"
errorsmod "cosmossdk.io/errors"
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 (RejectMessagesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
for _, msg := range tx.GetMsgs() {
// check if msgtypeurl starts with '/settlus.settlement'
if strings.HasPrefix(sdk.MsgTypeURL(msg), "/settlus.settlement") {
return ctx, errorsmod.Wrapf(
errortypes.ErrInvalidType,
"Settlment Msg can only be processed in the Settlement ante handler",
)
}
if sdk.MsgTypeURL(msg) == "/cosmos.staking.v1beta1.MsgCreateValidator" && ctx.BlockHeight() != 0 {
return ctx, errorsmod.Wrapf(
errortypes.ErrInvalidType,
"You can create validator only through governance or gentx",
)
}
}
return next(ctx, tx, simulate)
}