github.com/intfoundation/intchain@v0.0.0-20220727031208-4316ad31ca73/core/vm/noop.go (about)

     1  // Copyright 2016 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package vm
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/intfoundation/intchain/common"
    23  	"github.com/intfoundation/intchain/core/types"
    24  )
    25  
    26  func NoopCanTransfer(db StateDB, from common.Address, balance *big.Int) bool {
    27  	return true
    28  }
    29  func NoopTransfer(db StateDB, from, to common.Address, amount *big.Int) {}
    30  
    31  type NoopEVMCallContext struct{}
    32  
    33  func (NoopEVMCallContext) Call(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) {
    34  	return nil, nil
    35  }
    36  func (NoopEVMCallContext) CallCode(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) {
    37  	return nil, nil
    38  }
    39  func (NoopEVMCallContext) Create(caller ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) {
    40  	return nil, common.Address{}, nil
    41  }
    42  func (NoopEVMCallContext) DelegateCall(me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) {
    43  	return nil, nil
    44  }
    45  
    46  type NoopStateDB struct{}
    47  
    48  func (NoopStateDB) CreateAccount(common.Address)                                       {}
    49  func (NoopStateDB) SubBalance(common.Address, *big.Int)                                {}
    50  func (NoopStateDB) AddBalance(common.Address, *big.Int)                                {}
    51  func (NoopStateDB) GetBalance(common.Address) *big.Int                                 { return nil }
    52  func (NoopStateDB) GetNonce(common.Address) uint64                                     { return 0 }
    53  func (NoopStateDB) SetNonce(common.Address, uint64)                                    {}
    54  func (NoopStateDB) GetCodeHash(common.Address) common.Hash                             { return common.Hash{} }
    55  func (NoopStateDB) GetCode(common.Address) []byte                                      { return nil }
    56  func (NoopStateDB) SetCode(common.Address, []byte)                                     {}
    57  func (NoopStateDB) GetCodeSize(common.Address) int                                     { return 0 }
    58  func (NoopStateDB) AddRefund(uint64)                                                   {}
    59  func (NoopStateDB) GetRefund() uint64                                                  { return 0 }
    60  func (NoopStateDB) GetState(common.Address, common.Hash) common.Hash                   { return common.Hash{} }
    61  func (NoopStateDB) SetState(common.Address, common.Hash, common.Hash)                  {}
    62  func (NoopStateDB) Suicide(common.Address) bool                                        { return false }
    63  func (NoopStateDB) HasSuicided(common.Address) bool                                    { return false }
    64  func (NoopStateDB) Exist(common.Address) bool                                          { return false }
    65  func (NoopStateDB) Empty(common.Address) bool                                          { return false }
    66  func (NoopStateDB) RevertToSnapshot(int)                                               {}
    67  func (NoopStateDB) Snapshot() int                                                      { return 0 }
    68  func (NoopStateDB) AddLog(*types.Log)                                                  {}
    69  func (NoopStateDB) AddPreimage(common.Hash, []byte)                                    {}
    70  func (NoopStateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) {}