|
| 1 | +// Copyright 2025 the libevm authors. |
| 2 | +// |
| 3 | +// The libevm additions to go-ethereum are free software: you can redistribute |
| 4 | +// them and/or modify them under the terms of the GNU Lesser General Public License |
| 5 | +// as published by the Free Software Foundation, either version 3 of the License, |
| 6 | +// or (at your option) any later version. |
| 7 | +// |
| 8 | +// The libevm additions are distributed in the hope that they will be useful, |
| 9 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
| 11 | +// General Public License for more details. |
| 12 | +// |
| 13 | +// You should have received a copy of the GNU Lesser General Public License |
| 14 | +// along with the go-ethereum library. If not, see |
| 15 | +// <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +// Package legacy provides converters between legacy types and their refactored |
| 18 | +// equivalents. |
| 19 | + |
| 20 | +package legacy |
| 21 | + |
| 22 | +import ( |
| 23 | + "math/big" |
| 24 | + |
| 25 | + "github.com/holiman/uint256" |
| 26 | + |
| 27 | + "github.com/ava-labs/libevm/common" |
| 28 | + "github.com/ava-labs/libevm/core/types" |
| 29 | + "github.com/ava-labs/libevm/core/vm" |
| 30 | + "github.com/ava-labs/libevm/libevm" |
| 31 | + "github.com/ava-labs/libevm/params" |
| 32 | +) |
| 33 | + |
| 34 | +var _ vm.PrecompileEnvironment = (*stubPrecompileEnvironment)(nil) |
| 35 | + |
| 36 | +// stubPrecompileEnvironment implements [vm.PrecompileEnvironment] for testing. |
| 37 | +type stubPrecompileEnvironment struct { |
| 38 | + gasToReturn uint64 |
| 39 | + gasUsed uint64 |
| 40 | +} |
| 41 | + |
| 42 | +// Gas returns the gas supplied to the precompile. |
| 43 | +func (s *stubPrecompileEnvironment) Gas() uint64 { |
| 44 | + return s.gasToReturn |
| 45 | +} |
| 46 | + |
| 47 | +// UseGas records the gas used by the precompile. |
| 48 | +func (s *stubPrecompileEnvironment) UseGas(gas uint64) bool { |
| 49 | + s.gasUsed += gas |
| 50 | + return true |
| 51 | +} |
| 52 | + |
| 53 | +func (s *stubPrecompileEnvironment) Call(addr common.Address, input []byte, gas uint64, value *uint256.Int, _ ...vm.CallOption) (ret []byte, _ error) { |
| 54 | + return nil, nil |
| 55 | +} |
| 56 | + |
| 57 | +func (s *stubPrecompileEnvironment) ChainConfig() *params.ChainConfig { return nil } |
| 58 | +func (s *stubPrecompileEnvironment) Rules() params.Rules { return params.Rules{} } |
| 59 | +func (s *stubPrecompileEnvironment) StateDB() vm.StateDB { return nil } |
| 60 | +func (s *stubPrecompileEnvironment) ReadOnlyState() libevm.StateReader { return nil } |
| 61 | +func (s *stubPrecompileEnvironment) IncomingCallType() vm.CallType { return vm.Call } |
| 62 | +func (s *stubPrecompileEnvironment) Addresses() *libevm.AddressContext { return nil } |
| 63 | +func (s *stubPrecompileEnvironment) ReadOnly() bool { return false } |
| 64 | +func (s *stubPrecompileEnvironment) Value() *uint256.Int { return nil } |
| 65 | +func (s *stubPrecompileEnvironment) BlockHeader() (h types.Header, err error) { return h, nil } |
| 66 | +func (s *stubPrecompileEnvironment) BlockNumber() *big.Int { return nil } |
| 67 | +func (s *stubPrecompileEnvironment) BlockTime() uint64 { return 0 } |
0 commit comments