contract

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: Apache-2.0 Imports: 6 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()

SmartContractProxy is public interface to call object's methods. If you want to make proxy for your object inherit BaseSmartContractProxy

Usage:

// make your custom domain proxy

type customDomainProxy struct {
	object.BaseSmartContractProxy
}

// create proxy for your custom domain

func newCustomDomainProxy(parent object.Parent) (*customDomainProxy, error) {
	instance, err := newCustomDomain(parent)
	if err != nil {
		return nil, err
	}
	return &customDomainProxy{
		BaseSmartContractProxy: object.BaseSmartContractProxy{
			Instance: instance,
		},
	}, nil
}

proxy, err := newCustomDomainProxy(...)

proxy.GetClassID() is a proxy call for instance method.
proxy.GetParent() is a proxy call for instance method.
proxy.GetOrCreateComposite() is a proxy call for instance method if instance inherit ComposingContainer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSmartContract

type BaseSmartContract struct {
	object.BaseObject
	CompositeMap   map[string]factory.Composite
	ChildStorage   storage.Storage
	ContextStorage storage.Storage
	Parent         object.Parent
	// contains filtered or unexported fields
}

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 factory.CompositeFactory) (factory.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) (factory.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(compositeFactory factory.CompositeFactory) (factory.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) GetResolver added in v0.0.2

func (sc *BaseSmartContract) GetResolver() resolver.Resolver

GetResolver return instance or create it if necessary.

type BaseSmartContractProxy added in v0.0.2

type BaseSmartContractProxy struct {
	resolver.BaseProxy
	Instance object.Child
}

BaseSmartContractProxy is a implementation of Proxy with Instance.

func (*BaseSmartContractProxy) GetClassID added in v0.0.2

func (bp *BaseSmartContractProxy) GetClassID() string

GetClassID is a proxy call for instance method.

func (*BaseSmartContractProxy) GetOrCreateComposite added in v0.0.2

func (bp *BaseSmartContractProxy) GetOrCreateComposite(interfaceKey string, compositeFactory factory.CompositeFactory) (factory.Composite, error)

GetOrCreateComposite is a proxy call for instance method if instance inherit ComposingContainer.

func (*BaseSmartContractProxy) GetParent added in v0.0.2

func (bp *BaseSmartContractProxy) GetParent() object.Parent

GetParent is a proxy call for instance method.

type InternalSmartContract added in v0.0.2

type InternalSmartContract interface {
	object.Child
	GetResolver() resolver.Resolver
}

InternalSmartContract contains private method.

type SmartContract

type SmartContract interface {
	object.Child
}

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