example

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package example provides smart contracts for building example of system work.

Entities:

MemberDomain - domain that allows to add new members to system.

Usage:

	factory := NewMemberDomainFactory(factoryParent)
	mDomain, error := factory.Create(domainParent)

	record, err := mDomain.CreateMember()
	memberProxy, err := mDomain.GetMember(record)

Member - smart contract that represent user of the system.

Usage:

	// because type of member is a child of memberDomain
	factory := NewMemberFactory(memberDomain)
	m, error := factory.Create(parent)

////

WalletDomain - domain that allows to add new wallets to system

Usage:

	factory := NewWalletDomainFactory(factoryParent)
	wDomain, err := factory.Create(domainParent)

	// since Create inject composite to member
	err := wDomain.CreateWallet(member)

Wallet - smart contract that represent wallet

Usage:
	factory := NewWalletFactory(walletDomain)
	w, err := factory.Create(parent)

////

Get user balance example:
	wFactory := NewWalletFactory(walletDomain)

	w := m.GetOrCreateComposite(wFactory)
	w.GetBalance()

////

Allowance - smart contract that represent allowance during money transmission between wallets

Usage:
	factory := NewAllowanceFactory(walletDomain)
	al, err := factory.Create(parent)

Index

Constants

View Source
const MemberDomainName = "MemberDomain"

MemberDomainName is a name for member domain.

View Source
const WalletDomainName = "WalletDomain"

WalletDomainName is a name for wallet domain.

Variables

This section is empty.

Functions

func NewAllowanceFactory added in v0.0.3

func NewAllowanceFactory(parent object.Parent) (object.CompositeFactory, error)

func NewMemberDomainFactory

func NewMemberDomainFactory(parent object.Parent) object.Factory

NewMemberDomainFactory creates new factory for MemberDomain.

func NewMemberFactory

func NewMemberFactory(parent object.Parent) object.Factory

NewMemberFactory creates new factory for Member.

func NewWalletDomainFactory

func NewWalletDomainFactory(pt object.Parent) object.Factory

func NewWalletFactory

func NewWalletFactory(parent object.Parent) object.CompositeFactory

Types

type Allowance added in v0.0.3

type Allowance interface {
	object.Composite
	contract.SmartContract
	GetAmount() int
	GetSender() object.Reference
	GetReceiver() object.Reference
	MarkCompleted()
	IsCompleted() bool
}

func NewAllowanceWithParams added in v0.0.3

func NewAllowanceWithParams(parent object.Parent, class object.CompositeFactory, sender object.Reference, receiver object.Reference, amount int) (Allowance, error)

type AllowanceCompositeCollection added in v0.0.3

type AllowanceCompositeCollection struct {
	contract.BaseCompositeCollection
	// contains filtered or unexported fields
}

func (*AllowanceCompositeCollection) GetClass added in v0.0.3

func (acc *AllowanceCompositeCollection) GetClass() object.Proxy

func (*AllowanceCompositeCollection) GetClassID added in v0.0.3

func (acc *AllowanceCompositeCollection) GetClassID() string

func (*AllowanceCompositeCollection) GetInterfaceKey added in v0.0.3

func (*AllowanceCompositeCollection) GetInterfaceKey() string

func (*AllowanceCompositeCollection) GetParent added in v0.0.3

func (acc *AllowanceCompositeCollection) GetParent() object.Parent

type Member

type Member interface {
	object.ComposingContainer
	contract.SmartContract
	GetUsername() string
	GetPublicKey() string
}

type MemberDomain

type MemberDomain interface {
	// Base domain implementation.
	domain.Domain
	// CreateMember is used to create new member as a child to domain storage.
	CreateMember() (string, error)
	// GetMember returns member from its record in domain storage.
	GetMember(string) (Member, error)
}

MemberDomain is a contract that allows to add new members to system.

type Wallet

type Wallet interface {
	object.Composite
	contract.SmartContract
	GetBalance() (int, error)
}

type WalletDomain

type WalletDomain interface {
	// Base domain implementation.
	domain.Domain
	// CreateWallet is used to create new wallet as a child to domain storage and inject composite to member
	CreateWallet(m Member) error
}

WalletDomain is a contract that allows to add new wallets to system.

Jump to

Keyboard shortcuts

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