env

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2023 License: LGPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeContractAddr added in v1.0.0

func ComputeContractAddr(tx *types.Transaction, from common.Address) common.Address

func FormatMapKey added in v0.24.3

func FormatMapKey(prefix, key []byte) []byte

Types

type CallContext

type CallContext interface {
	Caller() common.Address
	ContractAddr() common.Address
	Epoch() uint16
	Nonce() uint32
	PayAmount() *big.Int
	CodeHash() common.Hash
}

type CallContextImpl

type CallContextImpl struct {
	// contains filtered or unexported fields
}

func NewCallContextImpl

func NewCallContextImpl(tx *types.Transaction, from *common.Address, codeHash common.Hash) *CallContextImpl

func (*CallContextImpl) Caller added in v1.0.0

func (c *CallContextImpl) Caller() common.Address

func (*CallContextImpl) CodeHash

func (c *CallContextImpl) CodeHash() common.Hash

func (*CallContextImpl) ContractAddr

func (c *CallContextImpl) ContractAddr() common.Address

func (*CallContextImpl) Epoch

func (c *CallContextImpl) Epoch() uint16

func (*CallContextImpl) Nonce

func (c *CallContextImpl) Nonce() uint32

func (*CallContextImpl) PayAmount

func (c *CallContextImpl) PayAmount() *big.Int

type DeployContextImpl

type DeployContextImpl struct {
	// contains filtered or unexported fields
}

func NewDeployContextImpl

func NewDeployContextImpl(tx *types.Transaction, from *common.Address, codeHash common.Hash) *DeployContextImpl

func (*DeployContextImpl) Caller added in v1.0.0

func (d *DeployContextImpl) Caller() common.Address

func (*DeployContextImpl) CodeHash

func (d *DeployContextImpl) CodeHash() common.Hash

func (*DeployContextImpl) ContractAddr

func (d *DeployContextImpl) ContractAddr() common.Address

func (*DeployContextImpl) Epoch

func (d *DeployContextImpl) Epoch() uint16

func (*DeployContextImpl) Nonce

func (d *DeployContextImpl) Nonce() uint32

func (*DeployContextImpl) PayAmount

func (d *DeployContextImpl) PayAmount() *big.Int

type Env

type Env interface {
	BlockNumber() uint64
	BlockTimeStamp() int64
	SetValue(ctx CallContext, key []byte, value []byte)
	GetValue(ctx CallContext, key []byte) []byte
	RemoveValue(ctx CallContext, key []byte)
	Send(ctx CallContext, dest common.Address, amount *big.Int) error
	MinFeePerGas() *big.Int
	Balance(address common.Address) *big.Int
	BlockSeed() []byte
	NetworkSize() int
	State(sender common.Address) state.IdentityState
	PubKey(addr common.Address) []byte
	Iterate(ctx CallContext, minKey []byte, maxKey []byte, f func(key []byte, value []byte) bool)
	BurnAll(ctx CallContext)
	ReadContractData(contractAddr common.Address, key []byte) []byte
	Event(name string, args ...[]byte)
	Epoch() uint16
	ContractStake(common.Address) *big.Int
	MoveToStake(ctx CallContext, amount *big.Int) error
	Delegatee(addr common.Address) *common.Address
	DiscriminationFlags(addr common.Address) state.DiscriminationFlag
}

type EnvImp

type EnvImp struct {
	// contains filtered or unexported fields
}

func NewEnvImp

func NewEnvImp(s *appstate.AppState, block *types.Header, gasCounter *GasCounter, statsCollector collector.StatsCollector) *EnvImp

func (*EnvImp) Balance

func (e *EnvImp) Balance(address common.Address) *big.Int

func (*EnvImp) BlockNumber

func (e *EnvImp) BlockNumber() uint64

func (*EnvImp) BlockSeed

func (e *EnvImp) BlockSeed() []byte

func (*EnvImp) BlockTimeStamp

func (e *EnvImp) BlockTimeStamp() int64

func (*EnvImp) BurnAll

func (e *EnvImp) BurnAll(ctx CallContext)

func (*EnvImp) Commit

func (e *EnvImp) Commit() []*types.TxEvent

func (*EnvImp) ContractStake

func (e *EnvImp) ContractStake(contract common.Address) *big.Int

func (*EnvImp) Delegatee added in v0.25.0

func (e *EnvImp) Delegatee(addr common.Address) *common.Address

func (*EnvImp) Deploy

func (e *EnvImp) Deploy(ctx CallContext)

func (*EnvImp) DiscriminationFlags added in v1.1.0

func (e *EnvImp) DiscriminationFlags(addr common.Address) state.DiscriminationFlag

func (*EnvImp) Epoch

func (e *EnvImp) Epoch() uint16

func (*EnvImp) Event

func (e *EnvImp) Event(name string, args ...[]byte)

func (*EnvImp) GetValue

func (e *EnvImp) GetValue(ctx CallContext, key []byte) []byte

func (*EnvImp) Iterate

func (e *EnvImp) Iterate(ctx CallContext, minKey []byte, maxKey []byte, f func(key []byte, value []byte) (stopped bool))

func (*EnvImp) MinFeePerGas

func (e *EnvImp) MinFeePerGas() *big.Int

func (*EnvImp) MoveToStake

func (e *EnvImp) MoveToStake(ctx CallContext, amount *big.Int) error

func (*EnvImp) NetworkSize

func (e *EnvImp) NetworkSize() int

func (*EnvImp) PubKey

func (e *EnvImp) PubKey(addr common.Address) []byte

func (*EnvImp) ReadContractData

func (e *EnvImp) ReadContractData(contractAddr common.Address, key []byte) []byte

func (*EnvImp) RemoveValue

func (e *EnvImp) RemoveValue(ctx CallContext, key []byte)

func (*EnvImp) Reset

func (e *EnvImp) Reset()

func (*EnvImp) Send

func (e *EnvImp) Send(ctx CallContext, dest common.Address, amount *big.Int) error

func (*EnvImp) SetValue

func (e *EnvImp) SetValue(ctx CallContext, key []byte, value []byte)

func (*EnvImp) State

func (e *EnvImp) State(sender common.Address) state.IdentityState

func (*EnvImp) Terminate

func (e *EnvImp) Terminate(ctx CallContext, keysToSave [][]byte, dest common.Address)

type GasCounter

type GasCounter struct {
	UsedGas int
	// contains filtered or unexported fields
}

func (*GasCounter) AddGas

func (g *GasCounter) AddGas(gas int)

func (*GasCounter) Reset

func (g *GasCounter) Reset(gasLimit int)

type Map

type Map struct {
	// contains filtered or unexported fields
}

func NewMap

func NewMap(prefix []byte, env Env, ctx CallContext) *Map

prefix length should be less common.MaxContractStoreKeyLength or prefix will be truncated

func (*Map) Get

func (m *Map) Get(key []byte) []byte

func (*Map) Iterate

func (m *Map) Iterate(f func(key []byte, value []byte) bool)

func (*Map) Remove

func (m *Map) Remove(key []byte)

func (*Map) Set

func (m *Map) Set(key []byte, value []byte)

type ReadContextImpl

type ReadContextImpl struct {
	Contract common.Address
	Hash     common.Hash
}

func (*ReadContextImpl) Caller added in v1.0.0

func (r *ReadContextImpl) Caller() common.Address

func (*ReadContextImpl) CodeHash

func (r *ReadContextImpl) CodeHash() common.Hash

func (*ReadContextImpl) ContractAddr

func (r *ReadContextImpl) ContractAddr() common.Address

func (*ReadContextImpl) Epoch

func (r *ReadContextImpl) Epoch() uint16

func (*ReadContextImpl) Nonce

func (r *ReadContextImpl) Nonce() uint32

func (*ReadContextImpl) PayAmount

func (r *ReadContextImpl) PayAmount() *big.Int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL