contract

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package contract provides interface and default implementation of smart contract.

Usage:

parent := NewBaseSmartContract(nil)
child := NewBaseSmartContract(parent)

classID := child.GetClassID()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSmartContract

type BaseSmartContract struct {
	Reference      *object.Reference
	CompositeMap   map[string]object.Composite
	ChildStorage   storage.Storage
	ContextStorage storage.Storage
	Parent         object.Parent
}

BaseSmartContract is a base implementation of ComposingContainer, Callable and TypedObject interfaces.

func NewBaseSmartContract

func NewBaseSmartContract(parent object.Parent) *BaseSmartContract

NewBaseSmartContract creates new BaseSmartContract instance with empty CompositeMap, ChildStorage and specific parent.

func (*BaseSmartContract) AddChild

func (sc *BaseSmartContract) AddChild(child object.Child) (string, error)

AddChild add new child to smart contract's ChildStorage.

func (*BaseSmartContract) CreateComposite

func (sc *BaseSmartContract) CreateComposite(compositeFactory object.CompositeFactory) (object.Composite, error)

CreateComposite allows to create composites inside smart contract.

func (*BaseSmartContract) GetChild

func (sc *BaseSmartContract) GetChild(key string) (object.Child, error)

GetChild get child from smart contract's ChildStorage.

func (*BaseSmartContract) GetChildStorage

func (sc *BaseSmartContract) GetChildStorage() storage.Storage

GetChildStorage return storage with children of smart contract.

func (*BaseSmartContract) GetClassID

func (sc *BaseSmartContract) GetClassID() string

GetClassID return string representation of object's class.

func (*BaseSmartContract) GetComposite

func (sc *BaseSmartContract) GetComposite(key string) (object.Composite, error)

GetComposite return composite by its key (if its exist inside smart contract).

func (*BaseSmartContract) GetContext

func (sc *BaseSmartContract) GetContext() []string

GetContext return list of keys in ContextStorage.

func (*BaseSmartContract) GetContextStorage

func (sc *BaseSmartContract) GetContextStorage() storage.Storage

GetContextStorage return storage with objects, which smart contract's children will have access to.

func (*BaseSmartContract) GetOrCreateComposite

func (sc *BaseSmartContract) GetOrCreateComposite(interfaceKey string, compositeFactory object.CompositeFactory) (object.Composite, error)

GetOrCreateComposite return composite by its key if its exist inside smart contract and create new one otherwise.

func (*BaseSmartContract) GetParent

func (sc *BaseSmartContract) GetParent() object.Parent

GetParent return parent of smart contract.

func (*BaseSmartContract) GetReference

func (sc *BaseSmartContract) GetReference() *object.Reference

GetReference return reference to BaseSmartContract instance.

type SmartContract

type SmartContract interface {
	object.Callable
}

SmartContract marks that object is smart contract. TODO: Composite work interface

Jump to

Keyboard shortcuts

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