Documentation ¶
Index ¶
- Constants
- type Block
- type Chain
- type ChainMock
- type DefaultChain
- type DefaultGenericSignedBlock
- type DefaultPaymentFields
- type Extrinsic
- func (e *Extrinsic[A, S, P]) Decode(decoder scale.Decoder) error
- func (e *Extrinsic[A, S, P]) GetCall() types.Call
- func (e *Extrinsic[A, S, P]) GetSignature() GenericExtrinsicSignature[A, S, P]
- func (e *Extrinsic[A, S, P]) GetVersion() byte
- func (e *Extrinsic[A, S, P]) IsSigned() bool
- func (e *Extrinsic[A, S, P]) Type() uint8
- func (e *Extrinsic[A, S, P]) UnmarshalJSON(bz []byte) error
- type ExtrinsicSignature
- type GenericBlock
- type GenericExtrinsic
- type GenericExtrinsicSignature
- type GenericSignedBlock
- type NewChainMockT
- type PaymentFieldsWithAssetID
- type SignedBlock
Constants ¶
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]
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.
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 ¶
GetBlock provides a mock function with given fields: blockHash
func (*ChainMock[A, S, P, B]) GetBlockLatest ¶
GetBlockLatest provides a mock function with given fields:
type DefaultChain ¶
type DefaultChain = Chain[ types.MultiAddress, types.MultiSignature, DefaultPaymentFields, *DefaultGenericSignedBlock, ]
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 ¶
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 ¶
Decode decodes the extrinsic based on the data present in the decoder.
func (*Extrinsic[A, S, P]) GetSignature ¶
func (e *Extrinsic[A, S, P]) GetSignature() GenericExtrinsicSignature[A, S, P]
func (*Extrinsic[A, S, P]) GetVersion ¶
func (*Extrinsic[A, S, P]) UnmarshalJSON ¶
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 PaymentFieldsWithAssetID ¶
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