registry

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrRecursiveDecodersResolving            = libErr.Error("recursive decoders resolving")
	ErrErrorsTypeNotFound                    = libErr.Error("errors type not found")
	ErrErrorsTypeNotVariant                  = libErr.Error("errors type not a variant")
	ErrErrorFieldsRetrieval                  = libErr.Error("error fields retrieval")
	ErrCallsTypeNotFound                     = libErr.Error("calls type not found")
	ErrCallsTypeNotVariant                   = libErr.Error("calls type not a variant")
	ErrCallFieldsRetrieval                   = libErr.Error("call fields retrieval")
	ErrEventsTypeNotFound                    = libErr.Error("events type not found")
	ErrEventsTypeNotVariant                  = libErr.Error("events type not a variant")
	ErrEventFieldsRetrieval                  = libErr.Error("event fields retrieval")
	ErrFieldDecoderForRecursiveFieldNotFound = libErr.Error("field decoder for recursive field not found")
	ErrRecursiveFieldResolving               = libErr.Error("recursive field resolving")
	ErrFieldTypeNotFound                     = libErr.Error("field type not found")
	ErrFieldDecoderRetrieval                 = libErr.Error("field decoder retrieval")
	ErrCompactFieldTypeNotFound              = libErr.Error("compact field type not found")
	ErrCompositeTypeFieldsRetrieval          = libErr.Error("composite type fields retrieval")
	ErrArrayFieldTypeNotFound                = libErr.Error("array field type not found")
	ErrVectorFieldTypeNotFound               = libErr.Error("vector field type not found")
	ErrFieldTypeDefinitionNotSupported       = libErr.Error("field type definition not supported")
	ErrVariantTypeFieldsRetrieval            = libErr.Error("variant type fields decoding")
	ErrCompactTupleItemTypeNotFound          = libErr.Error("compact tuple item type not found")
	ErrCompactTupleItemFieldDecoderRetrieval = libErr.Error("compact tuple item field decoder retrieval")
	ErrCompactCompositeFieldTypeNotFound     = libErr.Error("compact composite field type not found")
	ErrCompactCompositeFieldDecoderRetrieval = libErr.Error("compact composite field decoder retrieval")
	ErrArrayItemFieldDecoderRetrieval        = libErr.Error("array item field decoder retrieval")
	ErrSliceItemFieldDecoderRetrieval        = libErr.Error("slice item field decoder retrieval")
	ErrTupleItemTypeNotFound                 = libErr.Error("tuple item type not found")
	ErrTupleItemFieldDecoderRetrieval        = libErr.Error("tuple item field decoder retrieval")
	ErrBitStoreTypeNotFound                  = libErr.Error("bit store type not found")
	ErrBitStoreTypeNotSupported              = libErr.Error("bit store type not supported")
	ErrBitOrderTypeNotFound                  = libErr.Error("bit order type not found")
	ErrBitOrderCreation                      = libErr.Error("bit order creation")
	ErrPrimitiveTypeNotSupported             = libErr.Error("primitive type not supported")
	ErrTypeFieldDecoding                     = libErr.Error("type field decoding")
	ErrVariantByteDecoding                   = libErr.Error("variant byte decoding")
	ErrVariantFieldDecoderNotFound           = libErr.Error("variant field decoder not found")
	ErrArrayItemDecoderNotFound              = libErr.Error("array item decoder not found")
	ErrArrayItemDecoding                     = libErr.Error("array item decoding")
	ErrSliceItemDecoderNotFound              = libErr.Error("slice item decoder not found")
	ErrSliceLengthDecoding                   = libErr.Error("slice length decoding")
	ErrSliceItemDecoding                     = libErr.Error("slice item decoding")
	ErrCompositeFieldDecoding                = libErr.Error("composite field decoding")
	ErrValueDecoding                         = libErr.Error("value decoding")
	ErrRecursiveFieldDecoderNotFound         = libErr.Error("recursive field decoder not found")
	ErrBitVecDecoding                        = libErr.Error("bit vec decoding")
	ErrNilTypeDecoder                        = libErr.Error("nil type decoder")
	ErrNilField                              = libErr.Error("nil field")
	ErrNilFieldDecoder                       = libErr.Error("nil field decoder")
	ErrFieldEncode                           = libErr.Error("field encoding")
	ErrDecodeToTarget                        = libErr.Error("decode to target")
	ErrDecodedFieldNotFound                  = libErr.Error("decoded field not found")
	ErrDecodedFieldValueTypeMismatch         = libErr.Error("decoded field value type mismatch")
	ErrDecodedFieldValueProcessingError      = libErr.Error("decoded field value processing error")
	ErrDecodedFieldValueNotAGenericSlice     = libErr.Error("decoded field value is not a generic slice")
)

Variables

This section is empty.

Functions

func GetDecodedFieldAsSliceOfType

func GetDecodedFieldAsSliceOfType[T any](
	decodedFields DecodedFields,
	fieldPredicateFn DecodedFieldPredicateFn,
) ([]T, error)

GetDecodedFieldAsSliceOfType returns the value of the field that matches the provided predicate func as a slice of the provided generic argument.

func GetDecodedFieldAsType

func GetDecodedFieldAsType[T any](
	decodedFields DecodedFields,
	fieldPredicateFn DecodedFieldPredicateFn,
) (T, error)

GetDecodedFieldAsType returns the value of the field that matches the provided predicate func as the provided generic argument.

func ProcessDecodedFieldValue

func ProcessDecodedFieldValue[T any](
	decodedFields DecodedFields,
	fieldPredicateFn DecodedFieldPredicateFn,
	valueProcessingFn DecodedValueProcessingFn[T],
) (T, error)

ProcessDecodedFieldValue applies the processing func to the value of the field that matches the provided predicate func.

func TestFactory_CreateCallRegistry_CallTypeNotAVariant

func TestFactory_CreateCallRegistry_CallTypeNotAVariant(t *testing.T)

func TestFactory_CreateCallRegistry_CallsTypeNotFound

func TestFactory_CreateCallRegistry_CallsTypeNotFound(t *testing.T)

func TestFactory_CreateCallRegistry_GetTypeFieldsError

func TestFactory_CreateCallRegistry_GetTypeFieldsError(t *testing.T)

func TestFactory_CreateCallRegistry_NoPalletWithCalls

func TestFactory_CreateCallRegistry_NoPalletWithCalls(t *testing.T)

func TestFactory_CreateCallRegistry_Overrides

func TestFactory_CreateCallRegistry_Overrides(t *testing.T)

func TestFactory_CreateCallRegistry_WithLiveMetadata

func TestFactory_CreateCallRegistry_WithLiveMetadata(t *testing.T)

func TestFactory_CreateErrorRegistryWithLiveMetadata

func TestFactory_CreateErrorRegistryWithLiveMetadata(t *testing.T)

func TestFactory_CreateErrorRegistry_ErrorsTypeNotAVariant

func TestFactory_CreateErrorRegistry_ErrorsTypeNotAVariant(t *testing.T)

func TestFactory_CreateErrorRegistry_ErrorsTypeNotFound

func TestFactory_CreateErrorRegistry_ErrorsTypeNotFound(t *testing.T)

func TestFactory_CreateErrorRegistry_GetTypeFieldsError

func TestFactory_CreateErrorRegistry_GetTypeFieldsError(t *testing.T)

func TestFactory_CreateErrorRegistry_NoPalletWithErrors

func TestFactory_CreateErrorRegistry_NoPalletWithErrors(t *testing.T)

func TestFactory_CreateEventRegistry_EventTypeNotAVariant

func TestFactory_CreateEventRegistry_EventTypeNotAVariant(t *testing.T)

func TestFactory_CreateEventRegistry_EventsTypeNotFound

func TestFactory_CreateEventRegistry_EventsTypeNotFound(t *testing.T)

func TestFactory_CreateEventRegistry_GetTypeFieldError

func TestFactory_CreateEventRegistry_GetTypeFieldError(t *testing.T)

func TestFactory_CreateEventRegistry_NoPalletWithEvents

func TestFactory_CreateEventRegistry_NoPalletWithEvents(t *testing.T)

func TestFactory_CreateEventRegistry_Overrides

func TestFactory_CreateEventRegistry_Overrides(t *testing.T)

func TestFactory_CreateEventRegistry_WithLiveMetadata

func TestFactory_CreateEventRegistry_WithLiveMetadata(t *testing.T)

func TestFactory_Overrides

func TestFactory_Overrides(t *testing.T)

func TestFactory_getArrayFieldType

func TestFactory_getArrayFieldType(t *testing.T)

func TestFactory_getArrayFieldType_ItemFieldTypeError

func TestFactory_getArrayFieldType_ItemFieldTypeError(t *testing.T)

func TestFactory_getCompactFieldType_CompactComposite

func TestFactory_getCompactFieldType_CompactComposite(t *testing.T)

func TestFactory_getCompactFieldType_CompactTuple

func TestFactory_getCompactFieldType_CompactTuple(t *testing.T)

func TestFactory_getFieldDecoder_Array

func TestFactory_getFieldDecoder_Array(t *testing.T)

func TestFactory_getFieldDecoder_Array_TypeNotFoundError

func TestFactory_getFieldDecoder_Array_TypeNotFoundError(t *testing.T)

func TestFactory_getFieldDecoder_BitSequence

func TestFactory_getFieldDecoder_BitSequence(t *testing.T)

func TestFactory_getFieldDecoder_BitSequence_BitOrderCreationError

func TestFactory_getFieldDecoder_BitSequence_BitOrderCreationError(t *testing.T)

func TestFactory_getFieldDecoder_BitSequence_BitOrderTypeNotFound

func TestFactory_getFieldDecoder_BitSequence_BitOrderTypeNotFound(t *testing.T)

func TestFactory_getFieldDecoder_BitSequence_BitStoreFieldTypeError

func TestFactory_getFieldDecoder_BitSequence_BitStoreFieldTypeError(t *testing.T)

func TestFactory_getFieldDecoder_BitSequence_BitStoreTypeNotFound

func TestFactory_getFieldDecoder_BitSequence_BitStoreTypeNotFound(t *testing.T)

func TestFactory_getFieldDecoder_Compact

func TestFactory_getFieldDecoder_Compact(t *testing.T)

func TestFactory_getFieldDecoder_Compact_TypeNotFoundError

func TestFactory_getFieldDecoder_Compact_TypeNotFoundError(t *testing.T)

func TestFactory_getFieldDecoder_Composite

func TestFactory_getFieldDecoder_Composite(t *testing.T)

func TestFactory_getFieldDecoder_Composite_FieldError

func TestFactory_getFieldDecoder_Composite_FieldError(t *testing.T)

func TestFactory_getFieldDecoder_Primitive

func TestFactory_getFieldDecoder_Primitive(t *testing.T)

func TestFactory_getFieldDecoder_Slice

func TestFactory_getFieldDecoder_Slice(t *testing.T)

func TestFactory_getFieldDecoder_Slice_TypeNotFoundError

func TestFactory_getFieldDecoder_Slice_TypeNotFoundError(t *testing.T)

func TestFactory_getFieldDecoder_Tuple

func TestFactory_getFieldDecoder_Tuple(t *testing.T)

func TestFactory_getFieldDecoder_Tuple_NilTuple

func TestFactory_getFieldDecoder_Tuple_NilTuple(t *testing.T)

func TestFactory_getFieldDecoder_UnsupportedTypeError

func TestFactory_getFieldDecoder_UnsupportedTypeError(t *testing.T)

func TestFactory_getFieldDecoder_Variant

func TestFactory_getFieldDecoder_Variant(t *testing.T)

func TestFactory_getSliceFieldType

func TestFactory_getSliceFieldType(t *testing.T)

func TestFactory_getSliceFieldType_ItemFieldTypeError

func TestFactory_getSliceFieldType_ItemFieldTypeError(t *testing.T)

func TestFactory_getTupleType

func TestFactory_getTupleType(t *testing.T)

func TestFactory_getTupleType_TupleItemFieldDecoderError

func TestFactory_getTupleType_TupleItemFieldDecoderError(t *testing.T)

func TestFactory_getTupleType_TupleItemNotFound

func TestFactory_getTupleType_TupleItemNotFound(t *testing.T)

func TestFactory_getTypeFields

func TestFactory_getTypeFields(t *testing.T)

func TestFactory_getTypeFields_FieldDecoderRetrievalError

func TestFactory_getTypeFields_FieldDecoderRetrievalError(t *testing.T)

func TestFactory_getTypeFields_FieldTypeNotFoundError

func TestFactory_getTypeFields_FieldTypeNotFoundError(t *testing.T)

func TestFactory_getVariantFieldType_CompositeVariantTypeFieldError

func TestFactory_getVariantFieldType_CompositeVariantTypeFieldError(t *testing.T)

func Test_GetDecodedFieldAsSliceOfType

func Test_GetDecodedFieldAsSliceOfType(t *testing.T)

func Test_GetDecodedFieldAsSliceOfType_DecodedFieldNotFound

func Test_GetDecodedFieldAsSliceOfType_DecodedFieldNotFound(t *testing.T)

func Test_GetDecodedFieldAsSliceOfType_NotAGenericSlice

func Test_GetDecodedFieldAsSliceOfType_NotAGenericSlice(t *testing.T)

func Test_GetDecodedFieldAsSliceOfType_SliceItemTypeMismatch

func Test_GetDecodedFieldAsSliceOfType_SliceItemTypeMismatch(t *testing.T)

func Test_GetDecodedFieldAsType

func Test_GetDecodedFieldAsType(t *testing.T)

func Test_GetDecodedFieldAsType_FieldNotFound

func Test_GetDecodedFieldAsType_FieldNotFound(t *testing.T)

func Test_GetDecodedFieldAsType_ValueTypeMismatch

func Test_GetDecodedFieldAsType_ValueTypeMismatch(t *testing.T)

func Test_ProcessDecodedFieldValue

func Test_ProcessDecodedFieldValue(t *testing.T)

func Test_ProcessDecodedFieldValue_FieldNotFoundError

func Test_ProcessDecodedFieldValue_FieldNotFoundError(t *testing.T)

func Test_ProcessDecodedFieldValue_FieldValueProcessingError

func Test_ProcessDecodedFieldValue_FieldValueProcessingError(t *testing.T)

func Test_TypeDecoder

func Test_TypeDecoder(t *testing.T)

func Test_TypeDecoder_FieldDecodingError

func Test_TypeDecoder_FieldDecodingError(t *testing.T)

func Test_getPrimitiveType_UnsupportedTypeError

func Test_getPrimitiveType_UnsupportedTypeError(t *testing.T)

Types

type ArrayDecoder

type ArrayDecoder struct {
	Length      uint
	ItemDecoder FieldDecoder
}

ArrayDecoder holds information about the length of the array and the FieldDecoder used for its items.

func (*ArrayDecoder) Decode

func (a *ArrayDecoder) Decode(decoder *scale.Decoder) (any, error)

type BitSequenceDecoder

type BitSequenceDecoder struct {
	FieldName string
	BitOrder  types.BitOrder
}

BitSequenceDecoder holds decoding information for a bit sequence.

func (*BitSequenceDecoder) Decode

func (b *BitSequenceDecoder) Decode(decoder *scale.Decoder) (any, error)

type CallRegistry

type CallRegistry map[types.CallIndex]*TypeDecoder

CallRegistry maps a call name to its TypeDecoder.

type CompositeDecoder

type CompositeDecoder struct {
	FieldName string
	Fields    []*Field
}

CompositeDecoder holds all the information required to decoder a struct/composite.

func (*CompositeDecoder) Decode

func (e *CompositeDecoder) Decode(decoder *scale.Decoder) (any, error)

type DecodedField

type DecodedField struct {
	Name        string
	Value       any
	LookupIndex int64
}

DecodedField holds the name, value and lookup index of a field that was decoded.

func (DecodedField) Encode

func (d DecodedField) Encode(encoder scale.Encoder) error

type DecodedFieldPredicateFn

type DecodedFieldPredicateFn func(fieldIndex int, field *DecodedField) bool

type DecodedFields

type DecodedFields []*DecodedField

type DecodedValueProcessingFn

type DecodedValueProcessingFn[T any] func(value any) (T, error)

type ErrorID

type ErrorID struct {
	ModuleIndex types.U8
	ErrorIndex  [4]types.U8
}

type ErrorRegistry

type ErrorRegistry map[ErrorID]*TypeDecoder

ErrorRegistry maps an error name to its TypeDecoder.

type EventRegistry

type EventRegistry map[types.EventID]*TypeDecoder

EventRegistry maps an event ID to its TypeDecoder.

type Factory

type Factory interface {
	CreateCallRegistry(meta *types.Metadata) (CallRegistry, error)
	CreateErrorRegistry(meta *types.Metadata) (ErrorRegistry, error)
	CreateEventRegistry(meta *types.Metadata) (EventRegistry, error)
}

Factory is the interface responsible for generating the according registries from the metadata.

func NewFactory

func NewFactory(fieldOverrides ...FieldOverride) Factory

NewFactory creates a new Factory using the provided overrides, if any.

type FactoryMock

type FactoryMock struct {
	mock.Mock
}

FactoryMock is an autogenerated mock type for the Factory type

func NewFactoryMock

func NewFactoryMock(t NewFactoryMockT) *FactoryMock

NewFactoryMock creates a new instance of FactoryMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*FactoryMock) CreateCallRegistry

func (_m *FactoryMock) CreateCallRegistry(meta *types.Metadata) (CallRegistry, error)

CreateCallRegistry provides a mock function with given fields: meta

func (*FactoryMock) CreateErrorRegistry

func (_m *FactoryMock) CreateErrorRegistry(meta *types.Metadata) (ErrorRegistry, error)

CreateErrorRegistry provides a mock function with given fields: meta

func (*FactoryMock) CreateEventRegistry

func (_m *FactoryMock) CreateEventRegistry(meta *types.Metadata) (EventRegistry, error)

CreateEventRegistry provides a mock function with given fields: meta

type Field

type Field struct {
	Name         string
	FieldDecoder FieldDecoder
	LookupIndex  int64
}

Field represents one field of a TypeDecoder.

func (*Field) Decode

func (f *Field) Decode(decoder *scale.Decoder) (*DecodedField, error)

type FieldDecoder

type FieldDecoder interface {
	Decode(decoder *scale.Decoder) (any, error)
}

FieldDecoder is the interface implemented by all the different types that are available.

type FieldOverride

type FieldOverride struct {
	FieldLookupIndex int64
	FieldDecoder     FieldDecoder
}

FieldOverride is used to override the default FieldDecoder for a particular type.

type NewFactoryMockT

type NewFactoryMockT interface {
	mock.TestingT
	Cleanup(func())
}

type NoopDecoder

type NoopDecoder struct{}

NoopDecoder is a FieldDecoder that does not decode anything. It comes in handy for nil tuples or variants with no inner types.

func (*NoopDecoder) Decode

func (n *NoopDecoder) Decode(_ *scale.Decoder) (any, error)

type RecursiveDecoder

type RecursiveDecoder struct {
	FieldDecoder FieldDecoder
}

RecursiveDecoder is a wrapper for a FieldDecoder that is recursive.

func (*RecursiveDecoder) Decode

func (r *RecursiveDecoder) Decode(decoder *scale.Decoder) (any, error)

type SliceDecoder

type SliceDecoder struct {
	ItemDecoder FieldDecoder
}

SliceDecoder holds a FieldDecoder for the items of a vector/slice.

func (*SliceDecoder) Decode

func (s *SliceDecoder) Decode(decoder *scale.Decoder) (any, error)

type TypeDecoder

type TypeDecoder struct {
	Name   string
	Fields []*Field
}

TypeDecoder holds all information required to decode a particular type.

func (*TypeDecoder) Decode

func (t *TypeDecoder) Decode(decoder *scale.Decoder) (DecodedFields, error)

type ValueDecoder

type ValueDecoder[T any] struct{}

ValueDecoder decodes a primitive type.

func (*ValueDecoder[T]) Decode

func (v *ValueDecoder[T]) Decode(decoder *scale.Decoder) (any, error)

type VariantDecoder

type VariantDecoder struct {
	FieldDecoderMap map[byte]FieldDecoder
}

VariantDecoder holds a FieldDecoder for each variant/enum.

func (*VariantDecoder) Decode

func (v *VariantDecoder) Decode(decoder *scale.Decoder) (any, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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