contract

package
v0.0.0-...-c820c6a Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMethodNotFound = fmt.Errorf("unrecognized method")
View Source
var ToychainContractAddr = types.Address("toychain")
View Source
var ToychainContractCid = identCid("toychain")

Functions

This section is empty.

Types

type Actor

type Actor struct {
	Code   *cid.Cid
	Memory *cid.Cid
	Nonce  uint64
}

type CallContext

type CallContext struct {
	Ctx           context.Context
	From          types.Address
	FromNonce     uint64
	State         *State
	ContractState *ContractState
	Address       types.Address
}

CallContext is information accessible to the contract during a given invocation

type Contract

type Contract interface {
	Call(ctx *CallContext, method string, args []interface{}) (interface{}, error)
}

type ContractState

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

func (*ContractState) Flush

func (cs *ContractState) Flush(ctx context.Context) (*cid.Cid, error)

func (*ContractState) Get

func (cs *ContractState) Get(ctx context.Context, k string) ([]byte, error)

func (*ContractState) Node

func (cs *ContractState) Node() *hamt.Node

func (*ContractState) Set

func (cs *ContractState) Set(ctx context.Context, k string, val []byte) error

type State

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

func LoadState

func LoadState(ctx context.Context, cs *hamt.CborIpldStore, c *cid.Cid) (*State, error)

func NewState

func NewState(s *hamt.CborIpldStore, r *hamt.Node) *State

func (*State) ActorCall

func (s *State) ActorCall(ctx context.Context, addr types.Address, op func(*ContractState, uint64, Contract) error) error

func (*State) ActorExec

func (s *State) ActorExec(ctx context.Context, tx *types.Transaction) (*types.Receipt, error)

func (*State) ApplyTransactions

func (s *State) ApplyTransactions(ctx context.Context, txs []*types.Transaction) error

func (*State) Copy

func (s *State) Copy() *State

func (*State) Flush

func (s *State) Flush(ctx context.Context) (*cid.Cid, error)

func (*State) GetActor

func (s *State) GetActor(ctx context.Context, a types.Address) (*Actor, error)

func (*State) GetContract

func (s *State) GetContract(ctx context.Context, codeHash *cid.Cid) (Contract, error)

Actually, this probably should take a cid, not an address

func (*State) LoadContractState

func (s *State) LoadContractState(ctx context.Context, mem *cid.Cid) (*ContractState, error)

func (*State) NewContractState

func (s *State) NewContractState() *ContractState

func (*State) NonceForActor

func (s *State) NonceForActor(ctx context.Context, addr types.Address) (uint64, error)

func (*State) SetActor

func (s *State) SetActor(ctx context.Context, a types.Address, act *Actor) error

type ToychainTokenContract

type ToychainTokenContract struct{}

func (*ToychainTokenContract) Call

func (ftc *ToychainTokenContract) Call(ctx *CallContext, method string, args []interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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