contractapi

package
v0.0.0-...-c1c5777 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contract

type Contract struct {
	Name                      string
	Info                      metadata.InfoMetadata
	TransactionContextHandler SettableTransactionContextInterface
}

func (*Contract) GetInfo

func (c *Contract) GetInfo() metadata.InfoMetadata

GetInfo returns the info about the contract for use in metadata

func (*Contract) GetName

func (c *Contract) GetName() string

GetName returns the name of the contract

func (*Contract) GetTransactionContextHandler

func (c *Contract) GetTransactionContextHandler() SettableTransactionContextInterface

GetTransactionContextHandler returns the current transaction context set for the contract. If none has been set then TransactionContext will be returned

type ContractImpl

type ContractImpl struct {
	DefaultContract string

	Info                  metadata.InfoMetadata
	TransactionSerializer serializer.TransactionSerializer
	// contains filtered or unexported fields
}

func NewContract

func NewContract(contract ContractInterface) (*ContractImpl, error)

func (*ContractImpl) Init

func (*ContractImpl) Invoke

func (*ContractImpl) Start

func (ci *ContractImpl) Start() error

type ContractInterface

type ContractInterface interface {
	GetInfo() metadata.InfoMetadata
	GetName() string
	GetTransactionContextHandler() SettableTransactionContextInterface
}

type SettableTransactionContextInterface

type SettableTransactionContextInterface interface {
	// SetStub should provide a way to pass the stub from a chaincode transaction
	// call to the transaction context so that it can be used by contract functions.
	// This is called by Init/Invoke with the stub passed.
	SetStub(stubInterface shim.ContractStubInterface)
}

SettableTransactionContextInterface defines functions a valid transaction context should have. Transaction context's set for contracts to be used in chaincode must implement this interface.

type TransactionContext

type TransactionContext struct {
	// contains filtered or unexported fields
}

func (*TransactionContext) GetStub

func (*TransactionContext) SetStub

func (ctx *TransactionContext) SetStub(stub shim.ContractStubInterface)

type TransactionContextInterface

type TransactionContextInterface interface {
	// GetStub should provide a way to access the stub set by Init/Invoke
	GetStub() shim.ContractStubInterface
}

TransactionContextInterface defines the interface which TransactionContext meets. This can be taken by transacton functions on a contract which has not set a custom transaction context to allow transaction functions to take an interface to simplify unit testing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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