This commit is contained in:
i-norden 2022-03-01 08:20:49 -06:00
parent 47bafe4619
commit a031f9abca
4 changed files with 42 additions and 12 deletions

View File

@ -11,9 +11,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/types/tx/signing"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authante "github.com/tharsis/ethermint/x/auth/ante"
channelkeeper "github.com/cosmos/ibc-go/modules/core/04-channel/keeper" channelkeeper "github.com/cosmos/ibc-go/modules/core/04-channel/keeper"
ibcante "github.com/cosmos/ibc-go/modules/core/ante" ibcante "github.com/cosmos/ibc-go/modules/core/ante"

View File

@ -4,9 +4,10 @@ import (
"errors" "errors"
"math/big" "math/big"
authante "github.com/tharsis/ethermint/x/auth/ante"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/palantir/stacktrace" "github.com/palantir/stacktrace"
ethermint "github.com/tharsis/ethermint/types" ethermint "github.com/tharsis/ethermint/types"
@ -28,7 +29,7 @@ type EVMKeeper interface {
GetParams(ctx sdk.Context) evmtypes.Params GetParams(ctx sdk.Context) evmtypes.Params
WithContext(ctx sdk.Context) WithContext(ctx sdk.Context)
ResetRefundTransient(ctx sdk.Context) ResetRefundTransient(ctx sdk.Context)
NewEVM(msg core.Message, config *params.ChainConfig, params evmtypes.Params, coinbase common.Address, tracer vm.Tracer) *vm.EVM NewEVM(msg core.Message, config *params.ChainConfig, params evmtypes.Params, coinbase common.Address, tracer vm.EVMLogger) *vm.EVM
GetCodeHash(addr common.Address) common.Hash GetCodeHash(addr common.Address) common.Hash
} }

View File

@ -3,6 +3,8 @@ package app
import ( import (
"encoding/json" "encoding/json"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db"
types2 "github.com/cosmos/cosmos-sdk/store/types" types2 "github.com/cosmos/cosmos-sdk/store/types"
types3 "github.com/cosmos/cosmos-sdk/store/v2" types3 "github.com/cosmos/cosmos-sdk/store/v2"
@ -101,7 +103,6 @@ import (
// unnamed import of statik for swagger UI support // unnamed import of statik for swagger UI support
_ "github.com/tharsis/ethermint/client/docs/statik" _ "github.com/tharsis/ethermint/client/docs/statik"
"github.com/tharsis/ethermint/app/ante"
srvflags "github.com/tharsis/ethermint/server/flags" srvflags "github.com/tharsis/ethermint/server/flags"
ethermint "github.com/tharsis/ethermint/types" ethermint "github.com/tharsis/ethermint/types"
@ -614,13 +615,8 @@ func NewEthermintApp(
app.SetInitChainer(app.InitChainer) app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker) app.SetBeginBlocker(app.BeginBlocker)
// use Ethermint's custom AnteHandler // TODO: use Ethermint's custom AnteHandler
app.SetTxHandler( app.setTxHandler(encodingConfig.TxConfig, cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents)))
ante.NewAnteHandler(
app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.FeeGrantKeeper, app.IBCKeeper.ChannelKeeper,
encodingConfig.TxConfig.SignModeHandler(),
),
)
app.SetEndBlocker(app.EndBlocker) app.SetEndBlocker(app.EndBlocker)
@ -630,6 +626,39 @@ func NewEthermintApp(
return app return app
} }
func (app *EthermintApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []string) {
indexEvents := map[string]struct{}{}
for _, e := range indexEventsStr {
indexEvents[e] = struct{}{}
}
// need to sub in custom tx handler
/*
app.SetTxHandler(
ante.NewAnteHandler(
app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.FeeGrantKeeper, app.IBCKeeper.ChannelKeeper,
encodingConfig.TxConfig.SignModeHandler(),
),
)
*/
txHandler, err := middleware.NewDefaultTxHandler(middleware.TxHandlerOptions{
Debug: app.Trace(),
IndexEvents: indexEvents,
LegacyRouter: app.legacyRouter,
MsgServiceRouter: app.msgSvcRouter,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: middleware.DefaultSigVerificationGasConsumer,
TxDecoder: txConfig.TxDecoder(),
})
if err != nil {
panic(err)
}
app.SetTxHandler(txHandler)
}
// Name returns the name of the App // Name returns the name of the App
func (app *EthermintApp) Name() string { return app.BaseApp.Name() } func (app *EthermintApp) Name() string { return app.BaseApp.Name() }

View File

@ -3,8 +3,8 @@ package keeper
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/palantir/stacktrace" "github.com/palantir/stacktrace"
authante "github.com/tharsis/ethermint/x/auth/ante"
evmtypes "github.com/tharsis/ethermint/x/evm/types" evmtypes "github.com/tharsis/ethermint/x/evm/types"