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 ¶
- type BaseSmartContract
- func (sc *BaseSmartContract) AddChild(child object.Child) (string, error)
- func (sc *BaseSmartContract) CreateComposite(compositeFactory factory.CompositeFactory) (factory.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) (factory.Composite, error)
- func (sc *BaseSmartContract) GetContext() []string
- func (sc *BaseSmartContract) GetContextStorage() storage.Storage
- func (sc *BaseSmartContract) GetOrCreateComposite(compositeFactory factory.CompositeFactory) (factory.Composite, error)
- func (sc *BaseSmartContract) GetParent() object.Parent
- func (sc *BaseSmartContract) GetResolver() resolver.Resolver
- type BaseSmartContractProxy
- type InternalSmartContract
- type SmartContract
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
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
InternalSmartContract contains private method.
type SmartContract ¶
SmartContract marks that object is smart contract. TODO: Composite work interface