contractpb

package
v0.0.0-...-0b06f50 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: BSD-3-Clause Imports: 19 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)
View Source
var (
	ErrServiceNotFound = errors.New("service not found")
)

Functions

func Call

func Call(ctx Context, addr diadem.Address, inpb proto.Message, outpb proto.Message) error

func CallEVM

func CallEVM(ctx Context, addr diadem.Address, input []byte, output *[]byte) error

func CallMethod

func CallMethod(ctx Context, addr diadem.Address, method string, inpb proto.Message, outpb proto.Message) error

func MakePluginContract

func MakePluginContract(c Contract) plugin.Contract

func StaticCall

func StaticCall(ctx StaticContext, addr diadem.Address, inpb proto.Message, outpb proto.Message) error

func StaticCallEVM

func StaticCallEVM(ctx StaticContext, addr diadem.Address, input []byte, output *[]byte) error

func StaticCallMethod

func StaticCallMethod(ctx StaticContext, addr diadem.Address, method string, inpb proto.Message, outpb proto.Message) error

Types

type BinaryPBMarshaler

type BinaryPBMarshaler struct {
}

func (*BinaryPBMarshaler) Marshal

func (m *BinaryPBMarshaler) Marshal(w io.Writer, pb proto.Message) error

type BinaryPBUnmarshaler

type BinaryPBUnmarshaler struct {
}

func (*BinaryPBUnmarshaler) Unmarshal

func (m *BinaryPBUnmarshaler) Unmarshal(r io.Reader, pb proto.Message) error

type Context

type Context interface {
	plugin.VolatileAPI
	StaticContext
	Set(key []byte, pb proto.Message) error
	Delete(key []byte)
	HasPermission(token []byte, roles []string) (bool, []string)
	GrantPermissionTo(addr diadem.Address, token []byte, role string)
	RevokePermissionFrom(addr diadem.Address, token []byte, role string)
	GrantPermission(token []byte, roles []string)
}

Context is the high-level context provided to Go contract methods that mutate state.

func WrapPluginContext

func WrapPluginContext(ctx plugin.Context) Context

type Contract

type Contract interface {
	Meta() (plugin.Meta, error)
}

type PBMarshaler

type PBMarshaler interface {
	Marshal(w io.Writer, pb proto.Message) error
}

func MarshalerFactory

func MarshalerFactory(encoding plugin.EncodingType) (PBMarshaler, error)

type PBUnmarshaler

type PBUnmarshaler interface {
	Unmarshal(r io.Reader, pb proto.Message) error
}

func UnmarshalerFactory

func UnmarshalerFactory(encoding plugin.EncodingType) (PBUnmarshaler, error)

type RequestDispatcher

type RequestDispatcher struct {
	Contract
	// contains filtered or unexported fields
}

RequestDispatcher dispatches Request(s) to contract methods. The dispatcher takes care of unmarshalling requests and marshalling responses from/to protobufs or JSON - based on the content type specified in the Request.ContentType/Accept fields.

func NewRequestDispatcher

func NewRequestDispatcher(contract Contract) (*RequestDispatcher, error)

func (*RequestDispatcher) Call

func (*RequestDispatcher) Init

func (s *RequestDispatcher) Init(ctx plugin.Context, req *plugin.Request) error

func (*RequestDispatcher) StaticCall

type StaticContext

type StaticContext interface {
	plugin.StaticAPI
	Get(key []byte, pb proto.Message) error
	Range(prefix []byte) plugin.RangeData
	Has(key []byte) bool
	Block() diadem.BlockHeader
	Now() time.Time
	Message() plugin.Message
	ContractAddress() diadem.Address
	Logger() *diadem.Logger
	GetEvmTxReceipt([]byte) (ptypes.EvmTxReceipt, error)
	HasPermissionFor(addr diadem.Address, token []byte, roles []string) (bool, []string)
	FeatureEnabled(name string, defaultVal bool) bool
	Config() *cctypes.Config
	Validators() []*types.Validator
	EnabledFeatures() []string
	// ContractRecord retrieves the contract meta data stored in the Registry.
	// NOTE: This method requires Registry v2.
	ContractRecord(contractAddr diadem.Address) (*plugin.ContractRecord, error)
}

StaticContext is the high-level context provided to Go contract methods that don't mutate state.

func WrapPluginStaticContext

func WrapPluginStaticContext(ctx plugin.StaticContext) StaticContext

Jump to

Keyboard shortcuts

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