Skip to content

Commit

Permalink
Temporary Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Mar 13, 2024
1 parent 638be0d commit afdacb8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
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,
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, nil, nil,
nil, geth.NewEVM, tracer, evmSs,
)

Expand Down
2 changes: 2 additions & 0 deletions x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms

// EstimateGas implements eth_estimateGas rpc api.
func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*types.EstimateGasResponse, error) {
fmt.Printf("EstimateGas: 1\n")

if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
Expand Down
7 changes: 7 additions & 0 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Keeper struct {
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,6 +95,7 @@ func NewKeeper(
sk types.StakingKeeper,
fmk types.FeeMarketKeeper,
ibcTransferKeeper statedb.IBCTransferKeeper,
evmutilKeeper statedb.EvmutilKeeper,
customPrecompiles evm.PrecompiledContracts,
evmConstructor evm.Constructor,
tracer string,
Expand Down Expand Up @@ -122,6 +124,7 @@ func NewKeeper(
stakingKeeper: sk,
feeMarketKeeper: fmk,
ibcTransferKeeper: ibcTransferKeeper,
evmutilKeeper: evmutilKeeper,
storeKey: storeKey,
transientKey: transientKey,
customPrecompiles: customPrecompiles,
Expand Down Expand Up @@ -408,3 +411,7 @@ func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, er
func (k Keeper) IBCTransferKeeper() statedb.IBCTransferKeeper {
return k.ibcTransferKeeper
}

func (k Keeper) EvmutilKeeper() statedb.EvmutilKeeper {
return k.evmutilKeeper
}
11 changes: 11 additions & 0 deletions x/evm/statedb/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ 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 @@ -56,4 +66,5 @@ type Keeper interface {
DeleteAccount(ctx sdk.Context, addr common.Address) error

IBCTransferKeeper() IBCTransferKeeper
EvmutilKeeper() EvmutilKeeper
}
10 changes: 10 additions & 0 deletions x/evm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,13 @@ func (s *StateDB) IBCTransfer(goCtx context.Context, msg *ibctransfertypes.MsgTr

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 afdacb8

Please sign in to comment.