generic

package
v9.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrGetBlockCall = libErr.Error("get block call")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block[A, S, P any] struct {
	Header     types.Header          `json:"header"`
	Extrinsics []*Extrinsic[A, S, P] `json:"extrinsics"`
}

Block implements the GenericBlock interface.

func (*Block[A, S, P]) GetExtrinsics

func (b *Block[A, S, P]) GetExtrinsics() []GenericExtrinsic[A, S, P]

func (*Block[A, S, P]) GetHeader

func (b *Block[A, S, P]) GetHeader() types.Header

type Chain

type Chain[
	A, S, P any,
	B GenericSignedBlock[A, S, P],
] interface {
	GetBlock(blockHash types.Hash) (B, error)
	GetBlockLatest() (B, error)
}

Chain defines an interface for a client that can return a generic block B.

The generic block B allows for multiple implementation of the block that can differ for each substrate chain implementation.

func NewChain

func NewChain[
	A, S, P any,
	B GenericSignedBlock[A, S, P],
](client client.Client) Chain[A, S, P, B]

NewChain creates a new instance of Chain.

type ChainMock

type ChainMock[A interface{}, S interface{}, P interface{}, B GenericSignedBlock[A, S, P]] struct {
	mock.Mock
}

ChainMock is an autogenerated mock type for the Chain type

func NewChainMock

func NewChainMock[A interface{}, S interface{}, P interface{}, B GenericSignedBlock[A, S, P]](t NewChainMockT) *ChainMock[A, S, P, B]

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

func (*ChainMock[A, S, P, B]) GetBlock

func (_m *ChainMock[A, S, P, B]) GetBlock(blockHash types.Hash) (B, error)

GetBlock provides a mock function with given fields: blockHash

func (*ChainMock[A, S, P, B]) GetBlockLatest

func (_m *ChainMock[A, S, P, B]) GetBlockLatest() (B, error)

GetBlockLatest provides a mock function with given fields:

type DefaultChain

DefaultChain is the Chain interface with defaults for the generic types:

Address - types.MultiAddress Signature - types.MultiSignature PaymentFields - DefaultPaymentFields Block - *DefaultGenericSignedBlock

func NewDefaultChain

func NewDefaultChain(client client.Client) DefaultChain

NewDefaultChain creates a new DefaultChain.

type DefaultGenericSignedBlock

type DefaultGenericSignedBlock = SignedBlock[
	types.MultiAddress,
	types.MultiSignature,
	DefaultPaymentFields,
]

DefaultGenericSignedBlock is the SignedBlock with defaults for the generic types:

Address - types.MultiAddress Signature - types.MultiSignature PaymentFields - DefaultPaymentFields

type DefaultPaymentFields

type DefaultPaymentFields struct {
	Tip types.UCompact
}

DefaultPaymentFields represents the default payment fields found in the extrinsics of most substrate chains.

type Extrinsic

type Extrinsic[A, S, P any] struct {
	// Version is the encoded version flag (which encodes the raw transaction version and signing information in one byte)
	Version byte `json:"version"`
	// Signature is the ExtrinsicSignature, its presence depends on the Version flag
	Signature *ExtrinsicSignature[A, S, P] `json:"signature"`
	// Method is the call this extrinsic wraps
	Method types.Call `json:"method"`
}

Extrinsic implements the GenericExtrinsic interface.

func (*Extrinsic[A, S, P]) Decode

func (e *Extrinsic[A, S, P]) Decode(decoder scale.Decoder) error

Decode decodes the extrinsic based on the data present in the decoder.

func (*Extrinsic[A, S, P]) GetCall

func (e *Extrinsic[A, S, P]) GetCall() types.Call

func (*Extrinsic[A, S, P]) GetSignature

func (e *Extrinsic[A, S, P]) GetSignature() GenericExtrinsicSignature[A, S, P]

func (*Extrinsic[A, S, P]) GetVersion

func (e *Extrinsic[A, S, P]) GetVersion() byte

func (*Extrinsic[A, S, P]) IsSigned

func (e *Extrinsic[A, S, P]) IsSigned() bool

IsSigned returns true if the extrinsic is signed.

func (*Extrinsic[A, S, P]) Type

func (e *Extrinsic[A, S, P]) Type() uint8

Type returns the raw transaction version.

func (*Extrinsic[A, S, P]) UnmarshalJSON

func (e *Extrinsic[A, S, P]) UnmarshalJSON(bz []byte) error

UnmarshalJSON fills Extrinsic with the JSON encoded byte array given by bz

type ExtrinsicSignature

type ExtrinsicSignature[A, S, P any] struct {
	Signer        A
	Signature     S
	Era           types.ExtrinsicEra
	Nonce         types.UCompact
	PaymentFields P
}

ExtrinsicSignature implements the GenericExtrinsicSignature interface.

func (*ExtrinsicSignature[A, S, P]) GetEra

func (e *ExtrinsicSignature[A, S, P]) GetEra() types.ExtrinsicEra

func (*ExtrinsicSignature[A, S, P]) GetNonce

func (e *ExtrinsicSignature[A, S, P]) GetNonce() types.UCompact

func (*ExtrinsicSignature[A, S, P]) GetPaymentFields

func (e *ExtrinsicSignature[A, S, P]) GetPaymentFields() P

func (*ExtrinsicSignature[A, S, P]) GetSignature

func (e *ExtrinsicSignature[A, S, P]) GetSignature() S

func (*ExtrinsicSignature[A, S, P]) GetSigner

func (e *ExtrinsicSignature[A, S, P]) GetSigner() A

type GenericBlock

type GenericBlock[A, S, P any] interface {
	GetHeader() types.Header
	GetExtrinsics() []GenericExtrinsic[A, S, P]
}

GenericBlock is the interface that holds information about the header and extrinsics of a block.

This interface is generic over types A, S, P, please check GenericExtrinsicSignature for more information about these generic types.

type GenericExtrinsic

type GenericExtrinsic[A, S, P any] interface {
	GetVersion() byte
	GetSignature() GenericExtrinsicSignature[A, S, P]
	GetCall() types.Call
}

GenericExtrinsic is the interface that holds the extrinsic information.

This interface is generic over types A, S, P, please check GenericExtrinsicSignature for more information about these generic types.

type GenericExtrinsicSignature

type GenericExtrinsicSignature[A, S, P any] interface {
	GetSigner() A
	GetSignature() S
	GetEra() types.ExtrinsicEra
	GetNonce() types.UCompact
	GetPaymentFields() P
}

GenericExtrinsicSignature is the interface that holds the extrinsic signature information.

This interface is generic over the following types:

A - Signer, the default implementation for this is the types.MultiAddress type which can support a variable number of addresses.

S - Signature, the default implementation for this is the types.MultiSignature type which can support multiple signature curves.

P - PaymentFields (ChargeAssetTx in substrate), the default implementation for this is the DefaultPaymentFields which holds information about the tip sent for the extrinsic.

type GenericSignedBlock

type GenericSignedBlock[A, S, P any] interface {
	GetGenericBlock() GenericBlock[A, S, P]
	GetJustification() []byte
}

GenericSignedBlock is the interface that represents the block of a particular chain.

This interface is generic over types A, S, P, please check GenericExtrinsicSignature for more information about these generic types.

type NewChainMockT

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

type PaymentFieldsWithAssetID

type PaymentFieldsWithAssetID struct {
	Tip     types.UCompact
	AssetID types.Option[types.UCompact]
}

PaymentFieldsWithAssetID represents the payment fields found on chains that require an asset ID, such as statemint.

type SignedBlock

type SignedBlock[A, S, P any] struct {
	Block         *Block[A, S, P] `json:"block"`
	Justification []byte          `json:"justification"`
}

SignedBlock implements the GenericSignedBlock interface.

func (*SignedBlock[A, S, P]) GetGenericBlock

func (s *SignedBlock[A, S, P]) GetGenericBlock() GenericBlock[A, S, P]

func (*SignedBlock[A, S, P]) GetJustification

func (s *SignedBlock[A, S, P]) GetJustification() []byte

Jump to

Keyboard shortcuts

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