Types

Core type system for base types in Python and protocol types in the JAM protocol.

Module Organization

  1. Base Types (base): * Fundamental data types * Direct codec implementations * Generic type building blocks

  2. Protocol Types: * protocol: Core protocol helper types * extrinsics: Extrinsics types * work: Work item and other types * header: Header Structure * block: Block Structure

Submodules

Module Contents

JAM types.

class jam.types.Int(value: int | BaseInteger)[source]

Bases: BaseInteger, Codable

__init__(value: int | BaseInteger)[source]

Initialize an integer.

_validate(value: int) None[source]

Validate the integer value is within bounds.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int][source]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.U8(value: int | BaseInteger)[source]

Bases: FixedInt

byte_size: int = 1
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

has_sign = False
class jam.types.U16(value: int | BaseInteger)[source]

Bases: FixedInt

byte_size: int = 2
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

has_sign = False
class jam.types.U32(value: int | BaseInteger)[source]

Bases: FixedInt

byte_size: int = 4
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

has_sign = False
class jam.types.U64(value: int | BaseInteger)[source]

Bases: FixedInt

byte_size: int = 8
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

has_sign = False
class jam.types.U128(value: int | BaseInteger)[source]

Bases: FixedInt

byte_size: int = 16
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

has_sign = False
class jam.types.U256(value: int | BaseInteger)[source]

Bases: FixedInt

byte_size: int = 32
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

has_sign = False
class jam.types.U512(value: int | BaseInteger)[source]

Bases: FixedInt

byte_size: int = 64
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

has_sign = False
class jam.types.Choice(initial: Dict[str, Codable[T]] | Codable[T])[source]

Bases: Codable[T], JsonSerde, Generic[T]

A choice is a value that can be one of several possible types.

A Choice represents a tagged union type that can hold a value of one of several possible Codable types. The actual type is determined by a tag byte during encoding/decoding.

To use a choice, you need to define all possible types:
>>> @decodable_choice([U8, U16])
>>> class MyChoice(Choice): ...
>>> my_choice: MyChoice = MyChoice(U8(1))
>>> assert my_choice.type == U8
>>> assert my_choice.value == U8(1)
To use a optional choice, we’d pair it with Nullable:
>>> @decodable_choice([U8, Nullable])
>>> class OptionalU8(Choice): ...
>>> my_choice: OptionalU8 = OptionalU8(U8(1))
>>> assert my_choice.type == U8
>>> assert my_choice.value == U8(1)
>>> my_choice: OptionalU8 = OptionalU8(Null)
>>> assert my_choice.type == Nullable
>>> assert my_choice.value is None
To use this as an enum:
>>> @decodable_choice([String, String, String])
>>> class OutputType(Choice): ...
__init__(initial: Dict[str, Codable[T]] | Codable[T])[source]

Initialize Choice.

Parameters:

initial – Mapping of initial choice name and its value. Should have only one key.

Raises:

ValueError – If types list is empty

__set_internal__(value: Dict[str, Codable[T]] | Codable[T]) None[source]

Set the choice value.

Parameters:

value – Value to set. Must be instance of one of the allowed types.

Raises:

ValueError – If value type is not in allowed types list

__get__() Codable[T] | None[source]

Get the current value.

Returns:

Current value or None if not set

__eq__(other: object) bool[source]

Compare for equality.

__bool__() bool[source]

Check if the choice has a value.

__repr__() str[source]

Get string representation.

classmethod from_json(data: Any) Choice[T][source]

Create from JSON representation.

class jam.types.Option(initial: Codable = Null)[source]

Bases: Choice

An option is a choice that can be either None or a value.

__init__(initial: Codable = Null)[source]

Initialize Choice.

Parameters:

initial – Mapping of initial choice name and its value. Should have only one key.

Raises:

ValueError – If types list is empty

static option_to_choice(value: Codable | Nullable) Dict[str, Codable][source]
classmethod from_json(data: Any) Option[source]

Create from JSON representation.

to_json() Any[source]

Convert to JSON representation.

class jam.types.Nullable[source]

Bases: Codable, JsonSerde

Null value implementation.

A Null represents the absence of a value. It is encoded as an empty byte sequence.

Examples

>>> null = Null()
>>> encoded = null.encode()
>>> assert encoded == b""
>>> decoded, size = Null.decode_from(encoded)
>>> assert decoded == null
>>> assert size == 0
__init__()[source]

Initialize Null value.

get() None[source]

Get the null value.

Returns:

None

__repr__() str[source]

Get string representation.

__eq__(other: object) bool[source]

Compare for equality.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Nullable, int][source]

Decode null value from buffer.

Parameters:
  • buffer – Source buffer

  • offset – Starting offset

Returns:

Tuple of (decoded null value, bytes read)

to_json() None[source]

Convert to JSON representation.

classmethod from_json(data: Any) Nullable[source]

Create from JSON representation.

class jam.types.Dictionary(initial: Mapping[K, V] | None = None)[source]

Bases: Generic[K, V], Codable, Mapping[K, V], JsonSerde

Dictionary implementation that supports codec operations.

A dictionary that maps Codable keys to Codable values, providing both standard dictionary operations and codec functionality for serialization/deserialization.

Examples

>>> from jam.types.base.string import String
>>> from jam.types.base.integers import Int
>>> d = Dictionary({String("key"): Int(42)})
>>> d[String("key")]
Int(42)
>>> encoded = d.encode()
>>> decoded, _ = Dictionary.decode_from(String, Int, encoded)
>>> decoded == d
True
key_type: Type[K]
value_type: Type[V]
__init__(initial: Mapping[K, V] | None = None)[source]

Initialize dictionary.

Parameters:

initial – Optional initial key-value pairs

Raises:

TypeError – If any key or value is not Codable

__getitem__(key: K) V[source]

Get value for key.

__iter__() Iterator[K][source]

Iterate over keys.

__len__() int[source]

Get number of items.

__eq__(other: object) bool[source]

Compare for equality.

__repr__() str[source]

Get string representation.

get(key: K, default: V | None = None) V | None[source]

Get value for key, returning default if key not found.

Parameters:
  • key – Key to look up

  • default – Value to return if key not found

Returns:

Value for key or default

items() ItemsView[K, V][source]

Get view of (key, value) pairs.

keys() KeysView[K][source]

Get view of keys.

values() ValuesView[V][source]

Get view of values.

to_json() Dict[Any, Any][source]

Convert to JSON representation.

classmethod from_json(data: Dict[Any, Any] | Sequence[Any]) Self[source]

Create instance from JSON representation.

class jam.types.Boolean(value: bool)[source]

Bases: Codable, JsonSerde

Boolean type that implements the Codable interface.

Examples

>>> b = Boolean(True)
>>> bool(b)
True
>>> b.encode()
b'\x01'
>>> Boolean.decode_from(b'\x01')
(Boolean(True), 1)
__init__(value: bool)[source]

Initialize a Boolean.

Parameters:

value – Python bool value

Raises:

TypeError – If value is not a bool

__bool__() bool[source]

Allow using in boolean context.

__eq__(other: Any) bool[source]

Equal comparison.

__hash__() int[source]

Make hashable.

__repr__() str[source]

String representation.

__bytes__() bytes[source]

Bytes representation.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int][source]

Decode a Boolean from a buffer.

Parameters:
  • buffer – Bytes to decode from

  • offset – Starting position in buffer

Returns:

Tuple of (Boolean instance, bytes read)

class jam.types.Bit(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: JsonSerde

A bit is a single binary digit, either 0 or 1.

__init__(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]
value: int
to_json() int[source]

Convert to JSON representation.

classmethod from_json(value: Any) Bit[source]

Create from JSON representation.

class jam.types.String(value: str)[source]

Bases: Codable, JsonSerde

UTF-8 encoded string type that implements the Codable interface.

Examples

>>> s = String("Hello")
>>> str(s)
'Hello'
>>> len(s)
5
>>> s.encode()
b'\x05Hello'  # Length prefix followed by UTF-8 bytes

Note

String length is measured in UTF-16 code units, which means some Unicode characters (like emojis) may count as 2 units. This matches Python’s string length behavior.

__init__(value: str)[source]

Initialize a string.

Parameters:

value – Python string value

Raises:

TypeError – If value is not a str

__str__() str[source]

Convert to str.

__len__() int[source]

Get string length in UTF-16 code units.

__getitem__(index: int | slice) str[source]

Get character(s) at index or slice.

__contains__(item: str) bool[source]

Check if string contains substring.

__eq__(other: Any) bool[source]

Compare for equality.

__hash__() int[source]

Make hashable.

__add__(other: String | str) String[source]

Concatenate strings.

__repr__() str[source]

Get string representation.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[String, int][source]

Decode a String from a buffer.

Parameters:
  • buffer – Bytes to decode from

  • offset – Starting position in buffer

Returns:

Tuple of (String instance, bytes read)

Raises:
class jam.types.Array(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: BaseSequence, Generic[T]

Fixed-length array is an extension of the BaseSequence, to only allow fixed length arrays.

The array has a fixed length, append, extend, pop, insert, remove, and clear methods are not supported. Elements can be: - Set/Updated at any index - Swapped with another element at any index - Get from any index

__init__(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Initialize array.

Parameters:

initial – Required initial values

Raises:
  • TypeError – If elements are not all of the same Codable type

  • ValueError – If initial values don’t match fixed length

__setitem__(index: int | slice, value: T | Sequence[T]) None[source]

Set item at index or slice.

append(value: T) None[source]

Append value to end of vector.

Parameters:

value – Value to append. Must be instance of the same type as other elements.

Raises:

TypeError – If value is not of the correct type

pop(index: int = -1) T[source]

Remove and return item at index.

Parameters:

index – Index of item to remove

Returns:

Removed item

Raises:

IndexError – If index out of range

insert(index: int, value: T) None[source]

Insert value at index.

Parameters:
  • index – Index to insert at

  • value – Value to insert. Must be instance of the same type as other elements.

Raises:

TypeError – If value is not of the correct type

remove(value: T) None[source]

Remove first occurrence of value.

Parameters:

value – Value to remove

Raises:

ValueError – If value not found

clear() None[source]

Clear all elements.

extend(values: Sequence[T]) None[source]

Extend vector with values.

Parameters:

values – Values to add. Must all be instances of the same type as existing elements.

Raises:

TypeError – If values are not all of the correct type

class jam.types.Vector(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: BaseSequence[T]

Dynamic array implementation that supports codec operations.

The vector grows dynamically as elements are added. All standard sequence operations are supported. All elements must be instances of the same Codable type.

__init__(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Initialize sequence.

Parameters:
  • initial – Initial values

  • codec – Optional codec

class jam.types.ByteArray8(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray16(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray32(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray64(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray96(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray128(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray144(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray256(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ByteArray784(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.BitArray(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: Array

Fixed-length bit sequence implementation that supports codec operations.

A BitSequence represents a fixed-length sequence of bits, where each bit is represented as a Boolean value. The sequence is encoded as a compact bit array.

__init__(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Initialize bit sequence.

Parameters:

value – Initial values. Must match the fixed length. All elements must be Boolean instances.

Raises:
  • TypeError – If elements are not Boolean instances

  • ValueError – If initial values don’t match fixed length

classmethod from_json(data: Any) BitArray[source]

Deserialize from JSON.

class jam.types.Byte(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: BitArray

A single byte value that supports codec operations. Array uses BitSequenceCodec.

A Byte represents an 8-bit array that is encoded as a single byte.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[BitArray, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.Bytes(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: Vector[Byte]

Variable-length byte sequence type.

__init__(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Initialize Bytes.

Parameters:

value – Bytable which is either int, bytes, str, bytearray, memoryview, Sequence[Byte]

hex() str[source]

Get hex representation of Bytes.

classmethod from_json(data: Any) Bytes[source]

Create from JSON representation.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

jam.types.decodable_int(byte_size: int, has_sign=False) Callable[[Type[FixedInt]], Type[FixedInt]][source]

Decorator to make a class decodable as an integer.

jam.types.decodable_array(length: int, element_type: Type[T]) Callable[[Type[Any]], Type[Any]][source]

Decorator that creates a fixed-length array type with a specific element type.

This decorator configures the array class with: 1. Fixed length 2. Element type validation 3. Custom decode_from implementation

jam.types.decodable_bit_array(length: int, bitorder: Literal['msb', 'lsb'] | None = 'msb') Callable[[Type[BitArray]], Type[BitArray]][source]

Extend existing decodable_array to be array of Bits

jam.types.decodable_vector(element_type: Type[T], max_length: int = 9223372036854775807) Callable[[Type[Vector[T]]], Type[Vector[T]]][source]

Decorator to make a class decodable as a vector.

jam.types.decodable_dictionary(key_type: Type[K], value_type: Type[V]) Type[Dictionary[K, V]][source]
jam.types.decodable_choice(cls: Type[Choice]) Type[Choice][source]
jam.types.decodable_option(optional_type: Type[Codable]) Type[Option][source]

Decodable choice

jam.types.BandersnatchPublic

alias of ByteArray32

jam.types.BandersnatchVrfSignature

alias of ByteArray96

jam.types.BandersnatchRingVrfSignature

alias of ByteArray784

jam.types.Ed25519Public

alias of ByteArray32

jam.types.Ed25519Signature

alias of ByteArray64

jam.types.BlsPublic

alias of ByteArray144

jam.types.OpaqueHash

alias of ByteArray32

jam.types.HeaderHash

alias of ByteArray32

jam.types.StateRoot

alias of ByteArray32

jam.types.BeefyRoot

alias of ByteArray32

jam.types.Entropy

alias of ByteArray32

jam.types.TimeSlot

alias of U32

jam.types.ValidatorIndex

alias of U16

jam.types.CoreIndex

alias of U16

jam.types.Gas

alias of U64

jam.types.ServiceId

alias of U32

jam.types.WorkPackageHash

alias of ByteArray32

jam.types.WorkReportHash

alias of ByteArray32

jam.types.ExportsRoot

alias of ByteArray32

jam.types.ErasureRoot

alias of ByteArray32

class jam.types.Block(header: Header, extrinsic: Extrinsic)[source]

Bases: Codable, JsonSerde

Block structure.

header: Header
extrinsic: Extrinsic
__init__(header: Header, extrinsic: Extrinsic) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.Extrinsic(tickets: TicketsExtrinsic, preimages: PreimagesExtrinsic, guarantees: GuaranteesExtrinsic, assurances: AssurancesExtrinsic, disputes: DisputesExtrinsic)[source]

Bases: Codable, JsonSerde

Extrinsic structure.

tickets: TicketsExtrinsic
preimages: PreimagesExtrinsic
guarantees: GuaranteesExtrinsic
assurances: AssurancesExtrinsic
disputes: DisputesExtrinsic
__init__(tickets: TicketsExtrinsic, preimages: PreimagesExtrinsic, guarantees: GuaranteesExtrinsic, assurances: AssurancesExtrinsic, disputes: DisputesExtrinsic) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.Header(parent: ByteArray32, parent_state_root: ByteArray32, extrinsic_hash: ByteArray32, slot: U32, epoch_mark: OptionalEpochMark, tickets_mark: OptionalTicketsMark, offenders_mark: OffendersMark, author_index: U16, entropy_source: ByteArray96, seal: ByteArray96)[source]

Bases: Codable, JsonSerde

Block header structure.

parent: ByteArray32
parent_state_root: ByteArray32
extrinsic_hash: ByteArray32
slot: U32
epoch_mark: OptionalEpochMark
tickets_mark: OptionalTicketsMark
offenders_mark: OffendersMark
author_index: U16
entropy_source: ByteArray96
seal: ByteArray96
__init__(parent: ByteArray32, parent_state_root: ByteArray32, extrinsic_hash: ByteArray32, slot: U32, epoch_mark: OptionalEpochMark, tickets_mark: OptionalTicketsMark, offenders_mark: OffendersMark, author_index: U16, entropy_source: ByteArray96, seal: ByteArray96) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.TicketsMark(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[TicketBody]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.OffendersMark(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[ByteArray32]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ServiceInfo(code_hash: ByteArray32, balance: U64, min_item_gas: U64, min_memo_gas: U64, bytes_data: U64, items: U32)[source]

Bases: Codable, JsonSerde

Service information structure.

code_hash: ByteArray32
balance: U64
min_item_gas: U64
min_memo_gas: U64
bytes_data: U64
items: U32
__init__(code_hash: ByteArray32, balance: U64, min_item_gas: U64, min_memo_gas: U64, bytes_data: U64, items: U32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.ImportSpec(tree_root: ByteArray32, index: U16)[source]

Bases: Codable, JsonSerde

Import specification structure.

tree_root: ByteArray32
index: U16
__init__(tree_root: ByteArray32, index: U16) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.ExtrinsicSpec(hash: ByteArray32, len: U32)[source]

Bases: Codable, JsonSerde

Extrinsic specification structure.

hash: ByteArray32
len: U32
__init__(hash: ByteArray32, len: U32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.Authorizer(code_hash: ByteArray32, params: Bytes)[source]

Bases: Codable, JsonSerde

Authorizer structure.

code_hash: ByteArray32
params: Bytes
__init__(code_hash: ByteArray32, params: Bytes) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.RefineContext(anchor: ByteArray32, state_root: ByteArray32, beefy_root: ByteArray32, lookup_anchor: ByteArray32, lookup_anchor_slot: U32, prerequisites: OpaqueHashes)[source]

Bases: Codable, JsonSerde

Refine context structure.

anchor: ByteArray32
state_root: ByteArray32
beefy_root: ByteArray32
lookup_anchor: ByteArray32
lookup_anchor_slot: U32
prerequisites: OpaqueHashes
__init__(anchor: ByteArray32, state_root: ByteArray32, beefy_root: ByteArray32, lookup_anchor: ByteArray32, lookup_anchor_slot: U32, prerequisites: OpaqueHashes) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.WorkExecResult(initial: Dict[str, Codable[T]] | Codable[T])[source]

Bases: Choice

Work execution result choice.

ok: Bytes
out_of_gas: Nullable
panic: Nullable
bad_code: Nullable
code_oversize: Nullable
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Choice, int]

Decode choice from buffer.

Parameters:
  • types – List of possible types for this choice

  • buffer – Source buffer

  • offset – Starting offset

Returns:

Tuple of (decoded value, bytes read)

Raises:
class jam.types.WorkResult(service_id: U32, code_hash: ByteArray32, payload_hash: ByteArray32, accumulate_gas: U64, result: WorkExecResult)[source]

Bases: Codable, JsonSerde

Work result structure.

service_id: U32
code_hash: ByteArray32
payload_hash: ByteArray32
accumulate_gas: U64
result: WorkExecResult
__init__(service_id: U32, code_hash: ByteArray32, payload_hash: ByteArray32, accumulate_gas: U64, result: WorkExecResult) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.WorkItem(service: U32, code_hash: ByteArray32, payload: Bytes, refine_gas_limit: U64, accumulate_gas_limit: U64, import_segments: ImportSpecs, extrinsic: ExtrinsicSpecs, export_count: U16)[source]

Bases: Codable, JsonSerde

Work item structure.

service: U32
code_hash: ByteArray32
payload: Bytes
refine_gas_limit: U64
accumulate_gas_limit: U64
import_segments: ImportSpecs
extrinsic: ExtrinsicSpecs
export_count: U16
__init__(service: U32, code_hash: ByteArray32, payload: Bytes, refine_gas_limit: U64, accumulate_gas_limit: U64, import_segments: ImportSpecs, extrinsic: ExtrinsicSpecs, export_count: U16) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.WorkPackage(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems)[source]

Bases: Codable, JsonSerde

Work package structure.

authorization: Bytes
auth_code_host: U32
authorizer: Authorizer
context: RefineContext
items: WorkItems
__init__(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.WorkReport(package_spec: WorkPackageSpec, context: RefineContext, core_index: U16, authorizer_hash: ByteArray32, auth_output: Bytes, segment_root_lookup: SegmentRootLookup, results: WorkResults)[source]

Bases: Codable, JsonSerde

Work report structure.

package_spec: WorkPackageSpec
context: RefineContext
core_index: U16
authorizer_hash: ByteArray32
auth_output: Bytes
segment_root_lookup: SegmentRootLookup
results: WorkResults
__init__(package_spec: WorkPackageSpec, context: RefineContext, core_index: U16, authorizer_hash: ByteArray32, auth_output: Bytes, segment_root_lookup: SegmentRootLookup, results: WorkResults) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.WorkPackageSpec(hash: ByteArray32, length: U32, erasure_root: ByteArray32, exports_root: ByteArray32, exports_count: U16)[source]

Bases: Codable, JsonSerde

Work package specification structure.

hash: ByteArray32
length: U32
erasure_root: ByteArray32
exports_root: ByteArray32
exports_count: U16
__init__(hash: ByteArray32, length: U32, erasure_root: ByteArray32, exports_root: ByteArray32, exports_count: U16) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.SegmentRootLookupItem(work_package_hash: ByteArray32, segment_tree_root: ByteArray32)[source]

Bases: Codable, JsonSerde

Segment root lookup item structure.

work_package_hash: ByteArray32
segment_tree_root: ByteArray32
__init__(work_package_hash: ByteArray32, segment_tree_root: ByteArray32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.TicketEnvelope(attempt: U8, signature: ByteArray784)[source]

Bases: Codable, JsonSerde

Ticket entry structure.

attempt: U8
signature: ByteArray784
__init__(attempt: U8, signature: ByteArray784) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.TicketBody(id: ByteArray32, attempt: U8)[source]

Bases: Codable, JsonSerde

Ticket body structure.

id: ByteArray32
attempt: U8
__init__(id: ByteArray32, attempt: U8) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.TicketsAccumulator(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[TicketBody]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.KeysAccumulator(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[ByteArray32]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.TicketsExtrinsic(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[TicketEnvelope]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.Verdict(target: ByteArray32, age: U32, votes: JudgementVotes)[source]

Bases: Codable, JsonSerde

Verdict structure.

target: ByteArray32
age: U32
votes: JudgementVotes
__init__(target: ByteArray32, age: U32, votes: JudgementVotes) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.Culprit(target: ByteArray32, key: ByteArray32, signature: ByteArray64)[source]

Bases: Codable, JsonSerde

Culprit structure.

target: ByteArray32
key: ByteArray32
signature: ByteArray64
__init__(target: ByteArray32, key: ByteArray32, signature: ByteArray64) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.Judgement(vote: Boolean, index: U16, signature: ByteArray64)[source]

Bases: Codable, JsonSerde

Judgement structure.

vote: Boolean
index: U16
signature: ByteArray64
__init__(vote: Boolean, index: U16, signature: ByteArray64) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.DisputesExtrinsic(verdicts: Verdicts, culprits: Culprits, faults: Faults)[source]

Bases: Codable, JsonSerde

Disputes extrinsic structure.

verdicts: Verdicts
culprits: Culprits
faults: Faults
__init__(verdicts: Verdicts, culprits: Culprits, faults: Faults) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.Fault(target: ByteArray32, vote: Boolean, key: ByteArray32, signature: ByteArray64)[source]

Bases: Codable, JsonSerde

Fault structure.

target: ByteArray32
vote: Boolean
key: ByteArray32
signature: ByteArray64
__init__(target: ByteArray32, vote: Boolean, key: ByteArray32, signature: ByteArray64) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.DisputesRecords(good: WorkReportHashes, bad: WorkReportHashes, wonky: WorkReportHashes, offenders: Offenders)[source]

Bases: Codable, JsonSerde

Disputes records structure.

good: WorkReportHashes
bad: WorkReportHashes
wonky: WorkReportHashes
offenders: Offenders
__init__(good: WorkReportHashes, bad: WorkReportHashes, wonky: WorkReportHashes, offenders: Offenders) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.AvailabilityAssignment(report: WorkReport, timeout: U32)[source]

Bases: Codable, JsonSerde

Availability assignment structure.

report: WorkReport
timeout: U32
__init__(report: WorkReport, timeout: U32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.AvailabilityAssignments(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[Choice]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.Mmr(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[Choice]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.BlockInfo(header_hash: ByteArray32, mmr: Mmr, state_root: ByteArray32, reported: List[ReportedWorkPackage])[source]

Bases: Codable, JsonSerde

Block information structure.

header_hash: ByteArray32
mmr: Mmr
state_root: ByteArray32
reported: List[ReportedWorkPackage]
__init__(header_hash: ByteArray32, mmr: Mmr, state_root: ByteArray32, reported: List[ReportedWorkPackage]) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.BlocksHistory(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[BlockInfo]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ReportedWorkPackage(hash: ByteArray32, exports_root: ByteArray32)[source]

Bases: Codable, JsonSerde

Reported work package structure.

hash: ByteArray32
exports_root: ByteArray32
__init__(hash: ByteArray32, exports_root: ByteArray32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.ValidatorMetadata(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray128

Validator metadata structure.

class jam.types.ValidatorData(bandersnatch: ByteArray32, ed25519: ByteArray32, bls: ByteArray144, metadata: ValidatorMetadata)[source]

Bases: Codable, JsonSerde

Validator data structure.

bandersnatch: ByteArray32
ed25519: ByteArray32
bls: ByteArray144
metadata: ValidatorMetadata
__init__(bandersnatch: ByteArray32, ed25519: ByteArray32, bls: ByteArray144, metadata: ValidatorMetadata) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.ValidatorsData(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[ValidatorData]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.ValidatorArray(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[ByteArray32]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing