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 BaseCompositeCollection
- func (bcc *BaseCompositeCollection) Add(composite object.Composite)
- func (bcc *BaseCompositeCollection) GetClassID() string
- func (bcc *BaseCompositeCollection) GetInterfaceKey() string
- func (bcc *BaseCompositeCollection) GetList() []object.Composite
- func (bcc *BaseCompositeCollection) GetParent() object.Parent
- type BaseCompositeCollectionProxy
- 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) GetClass() object.Proxy
- func (sc *BaseSmartContract) GetClassID() string
- func (sc *BaseSmartContract) GetComposite(key string, class object.CompositeFactory) (object.Composite, error)
- func (sc *BaseSmartContract) GetContext() []string
- func (sc *BaseSmartContract) GetContextStorage() storage.Storage
- func (sc *BaseSmartContract) GetOrCreateComposite(compositeFactory object.CompositeFactory) (object.Composite, error)
- func (sc *BaseSmartContract) GetParent() object.Parent
- func (sc *BaseSmartContract) GetResolver() object.Resolver
- type BaseSmartContractProxy
- type InternalSmartContract
- type SmartContract
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseCompositeCollection ¶ added in v0.0.3
type BaseCompositeCollection struct {
// contains filtered or unexported fields
}
func NewBaseCompositeCollection ¶ added in v0.0.3
func NewBaseCompositeCollection(parent object.Parent) *BaseCompositeCollection
func (*BaseCompositeCollection) Add ¶ added in v0.0.3
func (bcc *BaseCompositeCollection) Add(composite object.Composite)
func (*BaseCompositeCollection) GetClassID ¶ added in v0.0.3
func (bcc *BaseCompositeCollection) GetClassID() string
func (*BaseCompositeCollection) GetInterfaceKey ¶ added in v0.0.3
func (bcc *BaseCompositeCollection) GetInterfaceKey() string
func (*BaseCompositeCollection) GetList ¶ added in v0.0.3
func (bcc *BaseCompositeCollection) GetList() []object.Composite
func (*BaseCompositeCollection) GetParent ¶ added in v0.0.3
func (bcc *BaseCompositeCollection) GetParent() object.Parent
type BaseCompositeCollectionProxy ¶ added in v0.0.3
type BaseCompositeCollectionProxy struct {
BaseSmartContractProxy
}
func (*BaseCompositeCollectionProxy) Add ¶ added in v0.0.3
func (cp *BaseCompositeCollectionProxy) Add(composite object.Composite)
func (*BaseCompositeCollectionProxy) GetInterfaceKey ¶ added in v0.0.3
func (*BaseCompositeCollectionProxy) GetInterfaceKey() string
func (*BaseCompositeCollectionProxy) GetList ¶ added in v0.0.3
func (cp *BaseCompositeCollectionProxy) GetList() []object.Composite
type BaseSmartContract ¶
type BaseSmartContract struct { object.BaseObject CompositeMap map[string]object.Reference 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, class object.Proxy) *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) GetClass ¶ added in v0.0.3
func (sc *BaseSmartContract) GetClass() object.Proxy
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, class object.CompositeFactory) (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(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) GetResolver ¶ added in v0.0.2
func (sc *BaseSmartContract) GetResolver() object.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) GetClass ¶ added in v0.0.3
func (bp *BaseSmartContractProxy) GetClass() object.Proxy
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(compositeFactory object.CompositeFactory) (object.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