github.com/onflow/flow-go@v0.33.17/fvm/evm/types/address.go (about)

     1  package types
     2  
     3  import (
     4  	"math/big"
     5  
     6  	gethCommon "github.com/ethereum/go-ethereum/common"
     7  )
     8  
     9  // Address is an EVM-compatible address
    10  type Address gethCommon.Address
    11  
    12  // AddressLength holds the number of bytes used for each EVM address
    13  const AddressLength = gethCommon.AddressLength
    14  
    15  // NewAddress constructs a new Address
    16  func NewAddress(addr gethCommon.Address) Address {
    17  	return Address(addr)
    18  }
    19  
    20  // EmptyAddress is an empty evm address
    21  var EmptyAddress = Address(gethCommon.Address{})
    22  
    23  // Bytes returns a byte slice for the address
    24  func (fa Address) Bytes() []byte {
    25  	return fa[:]
    26  }
    27  
    28  // ToCommon returns the geth address
    29  func (fa Address) ToCommon() gethCommon.Address {
    30  	return gethCommon.Address(fa)
    31  }
    32  
    33  // NewAddressFromBytes constructs a new address from bytes
    34  func NewAddressFromBytes(inp []byte) Address {
    35  	return Address(gethCommon.BytesToAddress(inp))
    36  }
    37  
    38  // NewAddressFromString constructs a new address from an string
    39  func NewAddressFromString(str string) Address {
    40  	return NewAddressFromBytes([]byte(str))
    41  }
    42  
    43  type GasLimit uint64
    44  
    45  type Code []byte
    46  
    47  type Data []byte
    48  
    49  // AsBigInt process the data and return it as a big integer
    50  func (d Data) AsBigInt() *big.Int {
    51  	return new(big.Int).SetBytes(d)
    52  }