2022-12-16 09:48:38 +00:00
|
|
|
// Copyright 2021 Evmos Foundation
|
|
|
|
// This file is part of Evmos' Ethermint library.
|
|
|
|
//
|
|
|
|
// The Ethermint library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The Ethermint library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
2018-11-28 22:19:22 +00:00
|
|
|
package evm
|
2019-08-14 23:52:45 +00:00
|
|
|
|
|
|
|
import (
|
2022-11-14 19:40:14 +00:00
|
|
|
errorsmod "cosmossdk.io/errors"
|
2020-07-02 15:19:48 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2022-11-14 19:40:14 +00:00
|
|
|
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
|
2021-04-18 15:54:18 +00:00
|
|
|
|
2022-06-19 09:43:41 +00:00
|
|
|
"github.com/evmos/ethermint/x/evm/types"
|
2019-08-14 23:52:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewHandler returns a handler for Ethermint type messages.
|
2021-06-08 17:10:29 +00:00
|
|
|
func NewHandler(server types.MsgServer) sdk.Handler {
|
2021-04-18 15:54:18 +00:00
|
|
|
return func(ctx sdk.Context, msg sdk.Msg) (result *sdk.Result, err error) {
|
2020-04-16 15:47:39 +00:00
|
|
|
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
2020-04-01 18:49:21 +00:00
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
switch msg := msg.(type) {
|
|
|
|
case *types.MsgEthereumTx:
|
|
|
|
// execute state transition
|
2021-06-08 17:10:29 +00:00
|
|
|
res, err := server.EthereumTx(sdk.WrapSDKContext(ctx), msg)
|
2021-06-08 11:11:37 +00:00
|
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
2020-04-30 03:36:30 +00:00
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
default:
|
2022-11-14 19:40:14 +00:00
|
|
|
err := errorsmod.Wrapf(errortypes.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
|
2021-04-18 15:54:18 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|