message

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEVMTypeNotSet = errors.New("EVM type is not set")
)

Functions

This section is empty.

Types

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) GetMessageByFullName

func (m *Manager) GetMessageByFullName(fullName string) (types.Message, bool)

GetMessageByFullName returns the message with the given full name, if it exists.

func (*Manager) GetMessageByID

func (m *Manager) GetMessageByID(id types.MessageID) types.Message

GetMessageByID iterates over the all registered messages and returns the types.Message associated with the MessageID.

func (*Manager) GetMessageByType

func (m *Manager) GetMessageByType(mType reflect.Type) (types.Message, bool)

func (*Manager) GetRegisteredMessages

func (m *Manager) GetRegisteredMessages() []types.Message

GetRegisteredMessages returns the list of all registered messages

func (*Manager) RegisterMessage

func (m *Manager) RegisterMessage(msgType types.Message, msgReflectType reflect.Type) error

type MessageOption

type MessageOption[In, Out any] func(mt *MessageType[In, Out]) //nolint:revive // this is fine for now

func WithCustomMessageGroup

func WithCustomMessageGroup[In, Out any](group string) MessageOption[In, Out]

WithCustomMessageGroup sets a custom group for the message. By default, messages are registered under the "game" group which maps it to the /tx/game/:txType route. This option allows you to set a custom group, which allow you to register the message under /tx/<custom_group>/:txType.

func WithMsgEVMSupport

func WithMsgEVMSupport[In, Out any]() MessageOption[In, Out]

type MessageType

type MessageType[In, Out any] struct {
	// contains filtered or unexported fields
}

MessageType manages a user defined state transition message struct.

func NewMessageType

func NewMessageType[In, Out any](
	name string,
	opts ...MessageOption[In, Out],
) *MessageType[In, Out]

NewMessageType creates a new message type. It accepts two generic type parameters: the first for the message input, which defines the data needed to make a state transition, and the second for the message output, commonly used for the results of a state transition. By default, messages will be grouped under the "game" group, however an option may be passed in to change this.

func (*MessageType[In, Out]) ABIEncode

func (t *MessageType[In, Out]) ABIEncode(v any) ([]byte, error)

ABIEncode encodes the input to the message's matching evm type. If the input is not either of the message's evm types, an error is returned.

func (*MessageType[In, Out]) AddError

func (t *MessageType[In, Out]) AddError(wCtx engine.Context, hash types.TxHash, err error)

func (*MessageType[In, Out]) Decode

func (t *MessageType[In, Out]) Decode(bytes []byte) (any, error)

func (*MessageType[In, Out]) DecodeEVMBytes

func (t *MessageType[In, Out]) DecodeEVMBytes(bz []byte) (any, error)

DecodeEVMBytes decodes abi encoded solidity structs into the message's "In" type.

func (*MessageType[In, Out]) Each

func (t *MessageType[In, Out]) Each(wCtx engine.Context, fn func(TxData[In]) (Out, error))

func (*MessageType[In, Out]) Encode

func (t *MessageType[In, Out]) Encode(a any) ([]byte, error)

func (*MessageType[In, Out]) FullName

func (t *MessageType[In, Out]) FullName() string

func (*MessageType[In, Out]) GetInFieldInformation

func (t *MessageType[In, Out]) GetInFieldInformation() map[string]any

GetInFieldInformation returns a map of the fields of the message's "In" type and it's field types.

func (*MessageType[In, Out]) GetReceipt

func (t *MessageType[In, Out]) GetReceipt(wCtx engine.Context, hash types.TxHash) (
	v Out, errs []error, ok bool,
)

func (*MessageType[In, Out]) Group

func (t *MessageType[In, Out]) Group() string

func (*MessageType[In, Out]) ID

func (t *MessageType[In, Out]) ID() types.MessageID

func (*MessageType[In, Out]) In

func (t *MessageType[In, Out]) In(wCtx engine.Context) []TxData[In]

In extracts all the TxData in the tx pool that match this MessageType's ID.

func (*MessageType[In, Out]) IsEVMCompatible

func (t *MessageType[In, Out]) IsEVMCompatible() bool

func (*MessageType[In, Out]) Name

func (t *MessageType[In, Out]) Name() string

func (*MessageType[In, Out]) SetID

func (t *MessageType[In, Out]) SetID(id types.MessageID) error

func (*MessageType[In, Out]) SetResult

func (t *MessageType[In, Out]) SetResult(wCtx engine.Context, hash types.TxHash, result Out)

type TxData

type TxData[In any] struct {
	Hash types.TxHash
	Msg  In
	Tx   *sign.Transaction
}

Jump to

Keyboard shortcuts

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