Documentation ¶
Index ¶
- Constants
- func GetDecodedFieldAsSliceOfType[T any](decodedFields DecodedFields, fieldPredicateFn DecodedFieldPredicateFn) ([]T, error)
- func GetDecodedFieldAsType[T any](decodedFields DecodedFields, fieldPredicateFn DecodedFieldPredicateFn) (T, error)
- func ProcessDecodedFieldValue[T any](decodedFields DecodedFields, fieldPredicateFn DecodedFieldPredicateFn, ...) (T, error)
- type ArrayDecoder
- type BitSequenceDecoder
- type CallRegistry
- type CompositeDecoder
- type DecodedExtrinsic
- type DecodedField
- type DecodedFieldPredicateFn
- type DecodedFields
- type DecodedValueProcessingFn
- type ErrorID
- type ErrorRegistry
- type EventRegistry
- type ExtrinsicDecoder
- type Factory
- type FactoryMock
- func (_m *FactoryMock) CreateCallRegistry(meta *types.Metadata) (CallRegistry, error)
- func (_m *FactoryMock) CreateErrorRegistry(meta *types.Metadata) (ErrorRegistry, error)
- func (_m *FactoryMock) CreateEventRegistry(meta *types.Metadata) (EventRegistry, error)
- func (_m *FactoryMock) CreateExtrinsicDecoder(meta *types.Metadata) (*ExtrinsicDecoder, error)
- type Field
- type FieldDecoder
- type FieldOverride
- type NewFactoryMockT
- type NoopDecoder
- type RecursiveDecoder
- type SliceDecoder
- type TypeDecoder
- type ValueDecoder
- type VariantDecoder
Constants ¶
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") 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") ErrExtrinsicFieldRetrieval = libErr.Error("extrinsic field retrieval") ErrInvalidExtrinsicParams = libErr.Error("invalid extrinsic params") ErrInvalidExtrinsicType = libErr.Error("invalid extrinsic type") ErrInvalidGenericExtrinsicType = libErr.Error("invalid generic extrinsic type") ErrNilExtrinsicDecoder = libErr.Error("nil type decoder") ErrExtrinsicFieldNotFound = libErr.Error("extrinsic field not found") ErrExtrinsicCompactLengthDecoding = libErr.Error("extrinsic compact length decoding") ErrExtrinsicVersionDecoding = libErr.Error("extrinsic version decoding") ErrUnexpectedExtrinsicParam = libErr.Error("unexpected extrinsic param") ErrExtrinsicFieldDecoding = libErr.Error("extrinsic field decoding") )
const ( ExtrinsicAddressName = "Address" ExtrinsicSignatureName = "Signature" ExtrinsicExtraName = "Extra" ExtrinsicCallName = "Call" )
const ( // ExpectedExtrinsicParamsCount is the count of generic params that we expect for a // generic Extrinsic type from the metadata. // // The parameters are expected to be in the following order: // 1. Address // 2. Call // 3. Signature // 4. Extra ExpectedExtrinsicParamsCount = 4 )
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.
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.
type BitSequenceDecoder ¶
BitSequenceDecoder holds decoding information for a bit sequence.
type CallRegistry ¶
type CallRegistry map[types.CallIndex]*TypeDecoder
CallRegistry maps a call name to its TypeDecoder.
type CompositeDecoder ¶
CompositeDecoder holds all the information required to decoder a struct/composite.
type DecodedExtrinsic ¶ added in v1.1.2
type DecodedExtrinsic struct { Version byte DecodedFields DecodedFields }
DecodedExtrinsic is the type returned when an extrinsic is decoded.
func (DecodedExtrinsic) IsSigned ¶ added in v1.1.2
func (d DecodedExtrinsic) IsSigned() bool
IsSigned returns true if the extrinsic is signed.
type DecodedField ¶
DecodedField holds the name, value and lookup index of a field that was decoded.
type DecodedFieldPredicateFn ¶
type DecodedFieldPredicateFn func(fieldIndex int, field *DecodedField) bool
type DecodedFields ¶
type DecodedFields []*DecodedField
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 ExtrinsicDecoder ¶ added in v1.1.2
type ExtrinsicDecoder struct {
Fields []*Field
}
ExtrinsicDecoder holds all the decoders for all the fields of an extrinsic.
func (*ExtrinsicDecoder) Decode ¶ added in v1.1.2
func (d *ExtrinsicDecoder) Decode(decoder *scale.Decoder) (*DecodedExtrinsic, error)
Decode is used to decode the fields of an extrinsic in the following order:
1. Address 2. Signature 3. Extra 4. Call
NOTE - the decoding order is different from the order of the Extrinsic parameters provided in the metadata.
func (*ExtrinsicDecoder) DecodeHex ¶ added in v1.1.3
func (d *ExtrinsicDecoder) DecodeHex(hexEncodedExtrinsic string) (*DecodedExtrinsic, error)
type Factory ¶
type Factory interface { CreateCallRegistry(meta *types.Metadata) (CallRegistry, error) CreateErrorRegistry(meta *types.Metadata) (ErrorRegistry, error) CreateEventRegistry(meta *types.Metadata) (EventRegistry, error) CreateExtrinsicDecoder(meta *types.Metadata) (*ExtrinsicDecoder, 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 ¶
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
func (*FactoryMock) CreateExtrinsicDecoder ¶ added in v1.1.3
func (_m *FactoryMock) CreateExtrinsicDecoder(meta *types.Metadata) (*ExtrinsicDecoder, error)
CreateExtrinsicDecoder 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.
type FieldDecoder ¶
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 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.
type RecursiveDecoder ¶
type RecursiveDecoder struct {
FieldDecoder FieldDecoder
}
RecursiveDecoder is a wrapper for a FieldDecoder that is recursive.
type SliceDecoder ¶
type SliceDecoder struct {
ItemDecoder FieldDecoder
}
SliceDecoder holds a FieldDecoder for the items of a vector/slice.
type TypeDecoder ¶
TypeDecoder holds all information required to decode a particular type.
func (*TypeDecoder) Decode ¶
func (t *TypeDecoder) Decode(decoder *scale.Decoder) (DecodedFields, error)
type VariantDecoder ¶
type VariantDecoder struct {
FieldDecoderMap map[byte]FieldDecoder
}
VariantDecoder holds a FieldDecoder for each variant/enum.