052134aff6
* refactor (errors) refactor errors import to use cosmossdk.io instead of cosmos-sdk/types/errors * refactor (errors) refactor errors import in ethsecp256k1 file * refactor (errors) add changes to changelog
28 lines
798 B
Go
28 lines
798 B
Go
package evm
|
|
|
|
import (
|
|
errorsmod "cosmossdk.io/errors"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
|
|
|
|
"github.com/evmos/ethermint/x/evm/types"
|
|
)
|
|
|
|
// NewHandler returns a handler for Ethermint type messages.
|
|
func NewHandler(server types.MsgServer) sdk.Handler {
|
|
return func(ctx sdk.Context, msg sdk.Msg) (result *sdk.Result, err error) {
|
|
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
|
|
|
switch msg := msg.(type) {
|
|
case *types.MsgEthereumTx:
|
|
// execute state transition
|
|
res, err := server.EthereumTx(sdk.WrapSDKContext(ctx), msg)
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
|
|
|
default:
|
|
err := errorsmod.Wrapf(errortypes.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|