Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean code #2868

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
RejectMessagesDecorator{},
NewRejectVestingDecorator(),
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
Expand Down
15 changes: 13 additions & 2 deletions ante/reject_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,33 @@ import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
)

// RejectMessagesDecorator prevents invalid msg types from being executed
type RejectMessagesDecorator struct{}

// AnteHandle rejects messages that requires ethereum-specific authentication.
// AnteHandle rejects the following messages:
// 1. Messages that requires ethereum-specific authentication.
// For example `MsgEthereumTx` requires fee to be deducted in the antehandler in
// order to perform the refund.
// 2. Messages that creates vesting accounts.
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 {
switch msg.(type) {
case *evmtypes.MsgEthereumTx:
return ctx, errorsmod.Wrapf(
errortypes.ErrInvalidType,
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
)

case *vestingtypes.MsgCreateVestingAccount,
*vestingtypes.MsgCreatePermanentLockedAccount,
*vestingtypes.MsgCreatePeriodicVestingAccount:
return ctx, errortypes.Wrap(
errortypes.ErrInvalidType,
"currently doesn't support creating vesting account")
}
}
return next(ctx, tx, simulate)
Expand Down
31 changes: 0 additions & 31 deletions ante/vesting.go

This file was deleted.

8 changes: 0 additions & 8 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/irisnet/irishub/v2/app/upgrades"
v110 "github.com/irisnet/irishub/v2/app/upgrades/v110"
v120 "github.com/irisnet/irishub/v2/app/upgrades/v120"
v130 "github.com/irisnet/irishub/v2/app/upgrades/v130"
v140 "github.com/irisnet/irishub/v2/app/upgrades/v140"
v200 "github.com/irisnet/irishub/v2/app/upgrades/v200"
v210 "github.com/irisnet/irishub/v2/app/upgrades/v210"
)

var (
router = upgrades.NewUpgradeRouter().
Register(v110.Upgrade).
Register(v120.Upgrade).
Register(v130.Upgrade).
Register(v140.Upgrade).
Register(v200.Upgrade).
Register(v210.Upgrade)
)
Expand Down
Loading