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 ¶
- Variables
- func InjectFakeContext(step uint, ctx *CallContext, reset ...bool)
- func SaveToLedger(contract BaseContractInterface, class core.RecordRef) core.RecordRef
- type BaseContract
- func (bc *BaseContract) AddChild(child BaseContractInterface, class core.RecordRef) core.RecordRef
- func (bc *BaseContract) GetChildrenTyped(r core.RecordRef) []ProxyInterface
- func (bc *BaseContract) GetClass() core.RecordRef
- func (bc *BaseContract) GetContext(debug ...string) *CallContext
- func (bc *BaseContract) GetReference() core.RecordRef
- func (bc *BaseContract) InjectDelegate(delegate BaseContractInterface, class core.RecordRef) core.RecordRef
- func (bc *BaseContract) SelfDestructRequest()
- func (bc *BaseContract) SetContext(ctx *CallContext)
- type BaseContractInterface
- type CallContext
- type ProxyInterface
Constants ¶
This section is empty.
Variables ¶
var FakeChildren = make(map[string]map[string][]ProxyInterface)
var FakeContexts = make(map[uint]*CallContext)
var FakeDelegates = make(map[string]map[string]ProxyInterface)
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
BaseContractInterface is an interface to deal with any contract same way
func GetImplementationFor ¶
func GetImplementationFor(o core.RecordRef, r core.RecordRef) ProxyInterface