plugin

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: 28 Imported by: 24

Documentation

Index

Constants

View Source
const Name = "gogoproto"

Name is the name registered for the proto compressor.

Variables

View Source
var (
	EncodingType_JSON      = ptypes.EncodingType_JSON
	EncodingType_PROTOBUF3 = ptypes.EncodingType_PROTOBUF3
)
View Source
var Handshake = extplugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "diadem_CONTRACT",
	MagicCookieValue: "diademrocks",
}

Handshake is a common handshake that is shared by plugin and host.

Functions

func Serve

func Serve(contract Contract)

Types

type API

type API interface {
	StaticAPI
	VolatileAPI
}

type Code

type Code = ptypes.PluginCode

type Context

type Context interface {
	StaticContext
	VolatileAPI
	Set(key, value []byte)
	Delete(key []byte)
}

Context is the low-level context provided to RequestDispatcher.StaticCall().

type Contract

type Contract interface {
	Meta() (Meta, error)
	Init(ctx Context, req *Request) error
	Call(ctx Context, req *Request) (*Response, error)
	StaticCall(ctx StaticContext, req *Request) (*Response, error)
}

type ContractMethodCall

type ContractMethodCall = ptypes.ContractMethodCall

type ContractRecord

type ContractRecord struct {
	ContractName    string
	ContractAddress diadem.Address
	CreatorAddress  diadem.Address
}

type EncodingType

type EncodingType = ptypes.EncodingType

type ExternalPlugin

type ExternalPlugin struct {
	extplugin.NetRPCUnsupportedPlugin
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl Contract
}

func (*ExternalPlugin) GRPCClient

func (p *ExternalPlugin) GRPCClient(ctx context.Context, broker *extplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*ExternalPlugin) GRPCServer

func (p *ExternalPlugin) GRPCServer(broker *extplugin.GRPCBroker, s *grpc.Server) error

type FEvent

type FEvent struct {
	Event  []byte
	Topics []string
}

type FakeContext

type FakeContext struct {
	Events []FEvent
	// contains filtered or unexported fields
}

func CreateFakeContext

func CreateFakeContext(caller, address diadem.Address) *FakeContext

func (*FakeContext) Block

func (c *FakeContext) Block() types.BlockHeader

func (*FakeContext) Call

func (c *FakeContext) Call(addr diadem.Address, input []byte) ([]byte, error)

func (*FakeContext) CallEVM

func (c *FakeContext) CallEVM(addr diadem.Address, input []byte, value *diadem.BigUInt) ([]byte, error)

func (*FakeContext) Config

func (c *FakeContext) Config() *cctypes.Config

func (*FakeContext) ContractAddress

func (c *FakeContext) ContractAddress() diadem.Address

func (*FakeContext) ContractRecord

func (c *FakeContext) ContractRecord(contractAddr diadem.Address) (*ContractRecord, error)

func (*FakeContext) CreateContract

func (c *FakeContext) CreateContract(contract Contract) diadem.Address

func (*FakeContext) Delete

func (c *FakeContext) Delete(key []byte)

func (*FakeContext) Emit

func (c *FakeContext) Emit(event []byte)

func (*FakeContext) EmitTopics

func (c *FakeContext) EmitTopics(event []byte, topics ...string)

func (*FakeContext) EnabledFeatures

func (c *FakeContext) EnabledFeatures() []string

func (*FakeContext) FeatureEnabled

func (c *FakeContext) FeatureEnabled(name string, defaultVal bool) bool

func (*FakeContext) Get

func (c *FakeContext) Get(key []byte) []byte

func (*FakeContext) GetEvmTxReceipt

func (c *FakeContext) GetEvmTxReceipt([]byte) (ptypes.EvmTxReceipt, error)

func (*FakeContext) Has

func (c *FakeContext) Has(key []byte) bool

func (*FakeContext) Message

func (c *FakeContext) Message() Message

func (*FakeContext) Now

func (c *FakeContext) Now() time.Time

func (*FakeContext) Range

func (c *FakeContext) Range(prefix []byte) RangeData

func (*FakeContext) RegisterContract

func (c *FakeContext) RegisterContract(contractName string, contractAddr, creatorAddr diadem.Address)

func (*FakeContext) Resolve

func (c *FakeContext) Resolve(name string) (diadem.Address, error)

func (*FakeContext) Set

func (c *FakeContext) Set(key []byte, value []byte)

func (*FakeContext) SetConfigSetting

func (c *FakeContext) SetConfigSetting(name, value string) error

func (*FakeContext) SetFeature

func (c *FakeContext) SetFeature(name string, val bool)

func (*FakeContext) SetTime

func (c *FakeContext) SetTime(t time.Time)

func (*FakeContext) StaticCall

func (c *FakeContext) StaticCall(addr diadem.Address, input []byte) ([]byte, error)

func (*FakeContext) StaticCallEVM

func (c *FakeContext) StaticCallEVM(addr diadem.Address, input []byte) ([]byte, error)

func (*FakeContext) Validators

func (c *FakeContext) Validators() []*diadem.Validator

func (*FakeContext) WithAddress

func (c *FakeContext) WithAddress(addr diadem.Address) *FakeContext

func (*FakeContext) WithBlock

func (c *FakeContext) WithBlock(header diadem.BlockHeader) *FakeContext

func (*FakeContext) WithSender

func (c *FakeContext) WithSender(caller diadem.Address) *FakeContext

func (*FakeContext) WithValidators

func (c *FakeContext) WithValidators(validators []*types.Validator) *FakeContext

type GRPCAPIClient

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

func (*GRPCAPIClient) Call

func (c *GRPCAPIClient) Call(addr diadem.Address, input []byte) ([]byte, error)

func (*GRPCAPIClient) CallEVM

func (c *GRPCAPIClient) CallEVM(addr diadem.Address, input []byte, value *diadem.BigUInt) ([]byte, error)

func (*GRPCAPIClient) ContractRecord

func (c *GRPCAPIClient) ContractRecord(contractAddr diadem.Address) (*ContractRecord, error)

func (*GRPCAPIClient) Delete

func (c *GRPCAPIClient) Delete(key []byte)

func (*GRPCAPIClient) Get

func (c *GRPCAPIClient) Get(key []byte) []byte

func (*GRPCAPIClient) GetEvmTxReceipt

func (c *GRPCAPIClient) GetEvmTxReceipt(hash []byte) (types.EvmTxReceipt, error)

func (*GRPCAPIClient) Has

func (c *GRPCAPIClient) Has(key []byte) bool

func (*GRPCAPIClient) Range

func (c *GRPCAPIClient) Range(prefix []byte) RangeData

func (*GRPCAPIClient) Resolve

func (c *GRPCAPIClient) Resolve(name string) (diadem.Address, error)

func (*GRPCAPIClient) Set

func (c *GRPCAPIClient) Set(key, value []byte)

func (*GRPCAPIClient) StaticCall

func (c *GRPCAPIClient) StaticCall(addr diadem.Address, input []byte) ([]byte, error)

func (*GRPCAPIClient) StaticCallEVM

func (c *GRPCAPIClient) StaticCallEVM(addr diadem.Address, input []byte) ([]byte, error)

type GRPCContext

type GRPCContext struct {
	*GRPCAPIClient
	// contains filtered or unexported fields
}

func MakeGRPCContext

func MakeGRPCContext(conn *grpc.ClientConn, req *types.ContractCallRequest) *GRPCContext

func (*GRPCContext) Block

func (c *GRPCContext) Block() diadem.BlockHeader

func (*GRPCContext) Config

func (c *GRPCContext) Config() *cctypes.Config

func (*GRPCContext) ContractAddress

func (c *GRPCContext) ContractAddress() diadem.Address

func (*GRPCContext) Emit

func (c *GRPCContext) Emit(data []byte)

func (*GRPCContext) EmitTopics

func (c *GRPCContext) EmitTopics(data []byte, topics ...string)

func (*GRPCContext) EnabledFeatures

func (c *GRPCContext) EnabledFeatures() []string

func (*GRPCContext) FeatureEnabled

func (c *GRPCContext) FeatureEnabled(name string, defaultVal bool) bool

func (*GRPCContext) Message

func (c *GRPCContext) Message() Message

func (*GRPCContext) Now

func (c *GRPCContext) Now() time.Time

func (*GRPCContext) Validators

func (c *GRPCContext) Validators() []*ltypes.Validator

type GRPCContractServer

type GRPCContractServer struct {
	Impl Contract
	// contains filtered or unexported fields
}

func (*GRPCContractServer) Call

func (*GRPCContractServer) Init

func (*GRPCContractServer) Meta

func (*GRPCContractServer) StaticCall

type Message

type Message struct {
	Sender diadem.Address
}

type Meta

type Meta = ptypes.ContractMeta

type RangeData

type RangeData []*RangeEntry

RangeData an array of key value pairs for a range of data

type RangeEntry

type RangeEntry struct {
	Key   []byte
	Value []byte
}

RangeEntry a single entry in a range

type Request

type Request = ptypes.Request

type Response

type Response = ptypes.Response

type StaticAPI

type StaticAPI interface {
	StaticCall(addr diadem.Address, input []byte) ([]byte, error)
	StaticCallEVM(addr diadem.Address, input []byte) ([]byte, error)
	Resolve(name string) (diadem.Address, error)
	EmitTopics(event []byte, topics ...string)
	Emit(event []byte)
}

type StaticContext

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

StaticContext is the low-level context provided to RequestDispatcher.Call(). The primary implementation of this interface is plugin.contractContext (diademchain/plugin package). For external GRPC contracts plugin.contractContext is wrapped by GRPCContext (go-diadem/plugin package).

type VolatileAPI

type VolatileAPI interface {
	Call(addr diadem.Address, input []byte) ([]byte, error)
	CallEVM(addr diadem.Address, input []byte, value *diadem.BigUInt) ([]byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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