-
Notifications
You must be signed in to change notification settings - Fork 367
/
vesting.go
48 lines (41 loc) · 1.19 KB
/
vesting.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
37
38
39
40
41
42
43
44
45
46
47
48
package ante
import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)
var _ sdk.AnteDecorator = VestingAccountDecorator{}
// VestingAccountDecorator blocks vesting messages from reaching the mempool
type VestingAccountDecorator struct {
disabledMsgTypeUrls []string
}
func NewVestingAccountDecorator() VestingAccountDecorator {
return VestingAccountDecorator{
disabledMsgTypeUrls: []string{
sdk.MsgTypeURL(&vesting.MsgCreateVestingAccount{}),
sdk.MsgTypeURL(&vesting.MsgCreatePermanentLockedAccount{}),
sdk.MsgTypeURL(&vesting.MsgCreatePeriodicVestingAccount{}),
},
}
}
func (vad VestingAccountDecorator) AnteHandle(
ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
for _, msg := range tx.GetMsgs() {
typeUrl := sdk.MsgTypeURL(msg)
for _, disabledTypeUrl := range vad.disabledMsgTypeUrls {
if typeUrl == disabledTypeUrl {
return ctx, errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
"MsgTypeURL %s not supported",
typeUrl,
)
}
}
}
return next(ctx, tx, simulate)
}