message

package
v1.1.1-beta-railway-test Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func RegisterMessageOnManager

func RegisterMessageOnManager[In any, Out any](manager *Manager, name string, opts ...MessageOption[In, Out]) error

RegisterMessageOnManager registers a single message on a manager. You do not need to provide the message type You just need to provide the input and Output parameters

Types

type Manager

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

func NewManager

func NewManager() *Manager

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) GetMessageByName

func (m *Manager) GetMessageByName(name string) (types.Message, bool)

GetMessageByName returns the message with the given name, if it exists.

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

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 (*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]) 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]) SetGroup

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

func (*MessageType[In, Out]) SetID

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

func (*MessageType[In, Out]) SetName

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

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