foundation

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package foundation is a base package for writing smartcontracts in go language. This is client side to use in standalone tests. It have the same signatures as a real realization, but all methods is intended to simulate real ledger behavior in tests.

Index

Constants

This section is empty.

Variables

View Source
var FakeChildren = make(map[string]map[string][]ProxyInterface)
View Source
var FakeContexts = make(map[uint]*CallContext)
View Source
var FakeDelegates = make(map[string]map[string]ProxyInterface)
View Source
var FakeLedger = make(map[string]ProxyInterface)

Functions

func InjectFakeContext

func InjectFakeContext(step uint, ctx *CallContext, reset ...bool)

InjectFakeContext - add mocked context to queue for substitution

func SaveToLedger

func SaveToLedger(contract BaseContractInterface, class core.RecordRef) core.RecordRef

Types

type BaseContract

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

BaseContract is a base class for all contracts.

func (*BaseContract) AddChild

func (bc *BaseContract) AddChild(child BaseContractInterface, class core.RecordRef) core.RecordRef

func (*BaseContract) GetChildrenTyped

func (bc *BaseContract) GetChildrenTyped(r core.RecordRef) []ProxyInterface

func (*BaseContract) GetClass added in v0.0.6

func (bc *BaseContract) GetClass() core.RecordRef

GetClass

func (*BaseContract) GetContext

func (bc *BaseContract) GetContext(debug ...string) *CallContext

GetContext returns current calling context of this object. It exists only for currently called contract.

func (*BaseContract) GetReference added in v0.0.6

func (bc *BaseContract) GetReference() core.RecordRef

GetReference - Returns public reference of contract

func (*BaseContract) InjectDelegate added in v0.0.6

func (bc *BaseContract) InjectDelegate(delegate BaseContractInterface, class core.RecordRef) core.RecordRef

func (*BaseContract) SelfDestructRequest

func (bc *BaseContract) SelfDestructRequest()

func (*BaseContract) SetContext added in v0.0.6

func (bc *BaseContract) SetContext(ctx *CallContext)

type BaseContractInterface

type BaseContractInterface interface {
	SetContext(ctx *CallContext)
	GetReference() core.RecordRef
	GetClass() core.RecordRef
}

BaseContractInterface is an interface to deal with any contract same way

func GetObject

func GetObject(ref core.RecordRef) BaseContractInterface

type CallContext

type CallContext struct {
	Me     core.RecordRef // My Reference.
	Caller core.RecordRef // Reference of calling contract.
	Parent core.RecordRef // Reference to parent or container contract.
	Class  core.RecordRef // Reference to type record on ledger, we have just one type reference, yet.
	Time   time.Time      // Time of Calling side made call.
	Pulse  uint64         // Number of current pulse.
}

CallContext is a context of contract execution

type ProxyInterface added in v0.0.6

type ProxyInterface interface {
	GetReference() core.RecordRef
	GetClass() core.RecordRef
}

BaseContractInterface is an interface to deal with any contract same way

func GetImplementationFor

func GetImplementationFor(o core.RecordRef, r core.RecordRef) ProxyInterface

Jump to

Keyboard shortcuts

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