github.com/MetalBlockchain/subnet-evm@v0.4.9/core/vm/contracts_stateful.go (about) 1 // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package vm 5 6 import ( 7 "github.com/MetalBlockchain/subnet-evm/precompile" 8 "github.com/ethereum/go-ethereum/common" 9 ) 10 11 // wrappedPrecompiledContract implements StatefulPrecompiledContract by wrapping stateless native precompiled contracts 12 // in Ethereum. 13 type wrappedPrecompiledContract struct { 14 p PrecompiledContract 15 } 16 17 // newWrappedPrecompiledContract returns a wrapped version of [PrecompiledContract] to be executed according to the StatefulPrecompiledContract 18 // interface. 19 func newWrappedPrecompiledContract(p PrecompiledContract) precompile.StatefulPrecompiledContract { 20 return &wrappedPrecompiledContract{p: p} 21 } 22 23 // Run implements the StatefulPrecompiledContract interface 24 func (w *wrappedPrecompiledContract) Run(accessibleState precompile.PrecompileAccessibleState, caller common.Address, addr common.Address, input []byte, suppliedGas uint64, readOnly bool) (ret []byte, remainingGas uint64, err error) { 25 return RunPrecompiledContract(w.p, input, suppliedGas) 26 } 27 28 // RunStatefulPrecompiledContract confirms runs [precompile] with the specified parameters. 29 func RunStatefulPrecompiledContract(precompile precompile.StatefulPrecompiledContract, accessibleState precompile.PrecompileAccessibleState, caller common.Address, addr common.Address, input []byte, suppliedGas uint64, readOnly bool) (ret []byte, remainingGas uint64, err error) { 30 return precompile.Run(accessibleState, caller, addr, input, suppliedGas, readOnly) 31 }