Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Mar 15, 2024
1 parent afdacb8 commit 457e857
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 55 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func NewEthermintApp(
app.EvmKeeper = evmkeeper.NewKeeper(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, nil, nil,
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
nil, geth.NewEVM, tracer, evmSs,
)

Expand Down
15 changes: 0 additions & 15 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ type Keeper struct {
// fetch EIP1559 base fee and parameters
feeMarketKeeper types.FeeMarketKeeper

ibcTransferKeeper statedb.IBCTransferKeeper
evmutilKeeper statedb.EvmutilKeeper

// chain ID number obtained from the context's chain id
eip155ChainID *big.Int

Expand Down Expand Up @@ -94,8 +91,6 @@ func NewKeeper(
bankKeeper types.BankKeeper,
sk types.StakingKeeper,
fmk types.FeeMarketKeeper,
ibcTransferKeeper statedb.IBCTransferKeeper,
evmutilKeeper statedb.EvmutilKeeper,
customPrecompiles evm.PrecompiledContracts,
evmConstructor evm.Constructor,
tracer string,
Expand Down Expand Up @@ -123,8 +118,6 @@ func NewKeeper(
bankKeeper: bankKeeper,
stakingKeeper: sk,
feeMarketKeeper: fmk,
ibcTransferKeeper: ibcTransferKeeper,
evmutilKeeper: evmutilKeeper,
storeKey: storeKey,
transientKey: transientKey,
customPrecompiles: customPrecompiles,
Expand Down Expand Up @@ -407,11 +400,3 @@ func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, er
k.SetTransientGasUsed(ctx, result)
return result, nil
}

func (k Keeper) IBCTransferKeeper() statedb.IBCTransferKeeper {
return k.ibcTransferKeeper
}

func (k Keeper) EvmutilKeeper() statedb.EvmutilKeeper {
return k.evmutilKeeper
}
19 changes: 0 additions & 19 deletions x/evm/statedb/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
package statedb

import (
"context"
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
)
Expand All @@ -35,20 +33,6 @@ type ExtStateDB interface {
AppendJournalEntry(JournalEntry)
}

type IBCTransferKeeper interface {
Transfer(goCtx context.Context, msg *ibctransfertypes.MsgTransfer) (*ibctransfertypes.MsgTransferResponse, error)
}

type EvmutilKeeper interface {
ConvertERC20ToCoin(
goCtx context.Context,
initiator string,
receiver string,
kavaERC20Address string,
amount sdk.Int,
) error
}

// Keeper provide underlying storage of StateDB
type Keeper interface {
// Read methods
Expand All @@ -64,7 +48,4 @@ type Keeper interface {
SetCode(ctx sdk.Context, codeHash []byte, code []byte)
SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error
DeleteAccount(ctx sdk.Context, addr common.Address) error

IBCTransferKeeper() IBCTransferKeeper
EvmutilKeeper() EvmutilKeeper
}
20 changes: 0 additions & 20 deletions x/evm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
Expand Down Expand Up @@ -472,22 +471,3 @@ func (s *StateDB) SetError(err error) {

s.sdkError = err
}

func (s *StateDB) IBCTransfer(goCtx context.Context, msg *ibctransfertypes.MsgTransfer) (*ibctransfertypes.MsgTransferResponse, error) {
resp, err := s.keeper.IBCTransferKeeper().Transfer(goCtx, msg)
if err != nil {
return nil, err
}

return resp, nil
}

func (s *StateDB) ConvertERC20ToCoin(
goCtx context.Context,
initiator string,
receiver string,
kavaERC20Address string,
amount sdk.Int,
) error {
return s.keeper.EvmutilKeeper().ConvertERC20ToCoin(goCtx, initiator, receiver, kavaERC20Address, amount)
}

0 comments on commit 457e857

Please sign in to comment.