Documentation ¶
Index ¶
- Variables
- type Manager
- func (m *Manager) GetMessageByFullName(fullName string) (types.Message, bool)
- func (m *Manager) GetMessageByID(id types.MessageID) types.Message
- func (m *Manager) GetMessageByType(mType reflect.Type) (types.Message, bool)
- func (m *Manager) GetRegisteredMessages() []types.Message
- func (m *Manager) RegisterMessage(msgType types.Message, msgReflectType reflect.Type) error
- type MessageOption
- type MessageType
- func (t *MessageType[In, Out]) ABIEncode(v any) ([]byte, error)
- func (t *MessageType[In, Out]) AddError(wCtx engine.Context, hash types.TxHash, err error)
- func (t *MessageType[In, Out]) Decode(bytes []byte) (any, error)
- func (t *MessageType[In, Out]) DecodeEVMBytes(bz []byte) (any, error)
- func (t *MessageType[In, Out]) Each(wCtx engine.Context, fn func(TxData[In]) (Out, error))
- func (t *MessageType[In, Out]) Encode(a any) ([]byte, error)
- func (t *MessageType[In, Out]) FullName() string
- func (t *MessageType[In, Out]) GetInFieldInformation() map[string]any
- func (t *MessageType[In, Out]) GetReceipt(wCtx engine.Context, hash types.TxHash) (v Out, errs []error, ok bool)
- func (t *MessageType[In, Out]) Group() string
- func (t *MessageType[In, Out]) ID() types.MessageID
- func (t *MessageType[In, Out]) In(wCtx engine.Context) []TxData[In]
- func (t *MessageType[In, Out]) IsEVMCompatible() bool
- func (t *MessageType[In, Out]) Name() string
- func (t *MessageType[In, Out]) SetID(id types.MessageID) error
- func (t *MessageType[In, Out]) SetResult(wCtx engine.Context, hash types.TxHash, result Out)
- type TxData
Constants ¶
This section is empty.
Variables ¶
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 ¶
GetMessageByFullName returns the message with the given full name, if it exists.
func (*Manager) GetMessageByID ¶
GetMessageByID iterates over the all registered messages and returns the types.Message associated with the MessageID.
func (*Manager) GetMessageByType ¶
func (*Manager) GetRegisteredMessages ¶
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 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]) 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]) 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 (*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