2022-01-08 00:39:27 +00:00
|
|
|
package ante
|
|
|
|
|
|
|
|
import (
|
2023-04-05 23:21:59 +00:00
|
|
|
errorsmod "cosmossdk.io/errors"
|
2022-01-08 00:39:27 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
|
|
)
|
|
|
|
|
2022-06-06 16:07:31 +00:00
|
|
|
var _ sdk.AnteDecorator = VestingAccountDecorator{}
|
|
|
|
|
2023-04-06 20:21:56 +00:00
|
|
|
// VestingAccountDecorator blocks vesting messages from reaching the mempool
|
|
|
|
type VestingAccountDecorator struct {
|
|
|
|
disabledMsgTypeUrls []string
|
|
|
|
}
|
2022-01-08 00:39:27 +00:00
|
|
|
|
|
|
|
func NewVestingAccountDecorator() VestingAccountDecorator {
|
2023-04-06 20:21:56 +00:00
|
|
|
return VestingAccountDecorator{
|
|
|
|
disabledMsgTypeUrls: []string{
|
2024-06-19 16:13:31 +00:00
|
|
|
// sdk.MsgTypeURL(&vesting.MsgCreateVestingAccount{}),
|
|
|
|
// sdk.MsgTypeURL(&vesting.MsgCreatePermanentLockedAccount{}),
|
|
|
|
// sdk.MsgTypeURL(&vesting.MsgCreatePeriodicVestingAccount{}),
|
2023-04-06 20:21:56 +00:00
|
|
|
},
|
|
|
|
}
|
2022-01-08 00:39:27 +00:00
|
|
|
}
|
|
|
|
|
2023-04-06 20:21:56 +00:00
|
|
|
func (vad VestingAccountDecorator) AnteHandle(
|
|
|
|
ctx sdk.Context,
|
|
|
|
tx sdk.Tx,
|
|
|
|
simulate bool,
|
|
|
|
next sdk.AnteHandler,
|
|
|
|
) (newCtx sdk.Context, err error) {
|
2022-01-08 00:39:27 +00:00
|
|
|
for _, msg := range tx.GetMsgs() {
|
2023-04-06 20:21:56 +00:00
|
|
|
typeUrl := sdk.MsgTypeURL(msg)
|
|
|
|
|
|
|
|
for _, disabledTypeUrl := range vad.disabledMsgTypeUrls {
|
|
|
|
if typeUrl == disabledTypeUrl {
|
|
|
|
return ctx, errorsmod.Wrapf(
|
|
|
|
sdkerrors.ErrUnauthorized,
|
|
|
|
"MsgTypeURL %s not supported",
|
|
|
|
typeUrl,
|
|
|
|
)
|
|
|
|
}
|
2022-01-08 00:39:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return next(ctx, tx, simulate)
|
|
|
|
}
|