laconicd-deprecated/x/evm/vm/geth/precompiles.go
Federico Kunze Küllmer acf15474e7
imp(evm): stateless custom precompiles (#1272)
* release: v0.17.0 changelog (#1153)

* release: v0.17.0 changelog

* rm newline

* update link

* imp(evm): EVM interface

* fixes

* fix lint

* fix lint pt 2

* initial wiring for stateful contracts

* Apply suggestions from code review

Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com>

* changelog

* comments from review

* lint

Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com>
2022-09-15 13:54:02 +02:00

28 lines
768 B
Go

package geth
import (
"math/big"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
evm "github.com/evmos/ethermint/x/evm/vm"
)
// GetPrecompiles returns all the precompiled contracts defined given the
// current chain configuration and block height.
func GetPrecompiles(cfg *params.ChainConfig, blockNumber *big.Int) evm.PrecompiledContracts {
var precompiles evm.PrecompiledContracts
switch {
case cfg.IsBerlin(blockNumber):
precompiles = vm.PrecompiledContractsBerlin
case cfg.IsIstanbul(blockNumber):
precompiles = vm.PrecompiledContractsIstanbul
case cfg.IsByzantium(blockNumber):
precompiles = vm.PrecompiledContractsByzantium
default:
precompiles = vm.PrecompiledContractsHomestead
}
return precompiles
}