Documentation ¶
Overview ¶
Package contract provides interface and default implementation of smart contract.
Usage:
parent := NewBaseSmartContract(nil) child := NewBaseSmartContract(parent) classID := child.GetClassID()
Index ¶
- type BaseSmartContract
- func (sc *BaseSmartContract) AddChild(child object.Child) (string, error)
- func (sc *BaseSmartContract) CreateComposite(compositeFactory object.CompositeFactory) (object.Composite, error)
- func (sc *BaseSmartContract) GetChild(key string) (object.Child, error)
- func (sc *BaseSmartContract) GetChildStorage() storage.Storage
- func (sc *BaseSmartContract) GetClassID() string
- func (sc *BaseSmartContract) GetComposite(key string) (object.Composite, error)
- func (sc *BaseSmartContract) GetContext() []string
- func (sc *BaseSmartContract) GetContextStorage() storage.Storage
- func (sc *BaseSmartContract) GetOrCreateComposite(interfaceKey string, compositeFactory object.CompositeFactory) (object.Composite, error)
- func (sc *BaseSmartContract) GetParent() object.Parent
- func (sc *BaseSmartContract) GetReference() *object.Reference
- type SmartContract
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 ¶
SmartContract marks that object is smart contract. TODO: Composite work interface