Types
Core type system for base types in Python and protocol types in the JAM protocol.
Module Organization
Submodules
Module Contents
JAM types.
- class jam.types.Int(value: int | BaseInteger)[source]
Bases:
BaseInteger,Codable- __init__(value: int | BaseInteger)[source]
Initialize an integer.
- 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- 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- 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- 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- 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- 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- 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- 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
- class jam.types.Option(initial: Codable = Null)[source]
Bases:
ChoiceAn 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
- class jam.types.Nullable[source]
-
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
- class jam.types.Dictionary(initial: Mapping[K, V] | None = None)[source]
Bases:
Generic[K,V],Codable,Mapping[K,V],JsonSerdeDictionary 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
- __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
- 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
- values() ValuesView[V][source]
Get view of values.
- class jam.types.Boolean(value: bool)[source]
-
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)
- class jam.types.Bit(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]
Bases:
JsonSerdeA bit is a single binary digit, either 0 or 1.
- class jam.types.String(value: str)[source]
-
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
- 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:
ValueError – If buffer is too short
UnicodeDecodeError – If buffer contains invalid UTF-8
- 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
- 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
- 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.
- 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:
ArrayFixed-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
- class jam.types.Byte(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]
Bases:
BitArrayA 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]
-
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]
- 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.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.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]
-
Block structure.
- __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
- class jam.types.Extrinsic(tickets: TicketsExtrinsic, preimages: PreimagesExtrinsic, guarantees: GuaranteesExtrinsic, assurances: AssurancesExtrinsic, disputes: DisputesExtrinsic)[source]
-
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
- 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]
-
Block header structure.
- parent: ByteArray32
- parent_state_root: ByteArray32
- extrinsic_hash: ByteArray32
- epoch_mark: OptionalEpochMark
- tickets_mark: OptionalTicketsMark
- offenders_mark: OffendersMark
- 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
- 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]
-
Service information structure.
- code_hash: ByteArray32
- __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
- class jam.types.ImportSpec(tree_root: ByteArray32, index: U16)[source]
-
Import specification structure.
- tree_root: ByteArray32
- __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
- class jam.types.ExtrinsicSpec(hash: ByteArray32, len: U32)[source]
-
Extrinsic specification structure.
- hash: ByteArray32
- __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
- class jam.types.Authorizer(code_hash: ByteArray32, params: Bytes)[source]
-
Authorizer structure.
- code_hash: ByteArray32
- __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
- class jam.types.RefineContext(anchor: ByteArray32, state_root: ByteArray32, beefy_root: ByteArray32, lookup_anchor: ByteArray32, lookup_anchor_slot: U32, prerequisites: OpaqueHashes)[source]
-
Refine context structure.
- anchor: ByteArray32
- state_root: ByteArray32
- beefy_root: ByteArray32
- lookup_anchor: ByteArray32
- 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
- class jam.types.WorkExecResult(initial: Dict[str, Codable[T]] | Codable[T])[source]
Bases:
ChoiceWork execution result choice.
- 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:
DecodeError – If buffer is invalid or too short
ValueError – If types list is empty
- class jam.types.WorkResult(service_id: U32, code_hash: ByteArray32, payload_hash: ByteArray32, accumulate_gas: U64, result: WorkExecResult)[source]
-
Work result structure.
- code_hash: ByteArray32
- payload_hash: ByteArray32
- 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
- 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]
-
Work item structure.
- code_hash: ByteArray32
- import_segments: ImportSpecs
- extrinsic: ExtrinsicSpecs
- __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
- class jam.types.WorkPackage(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems)[source]
-
Work package structure.
- authorizer: Authorizer
- context: RefineContext
- __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
- 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]
-
Work report structure.
- package_spec: WorkPackageSpec
- context: RefineContext
- authorizer_hash: ByteArray32
- 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
- class jam.types.WorkPackageSpec(hash: ByteArray32, length: U32, erasure_root: ByteArray32, exports_root: ByteArray32, exports_count: U16)[source]
-
Work package specification structure.
- hash: ByteArray32
- erasure_root: ByteArray32
- exports_root: ByteArray32
- __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
- class jam.types.SegmentRootLookupItem(work_package_hash: ByteArray32, segment_tree_root: ByteArray32)[source]
-
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
- class jam.types.TicketEnvelope(attempt: U8, signature: ByteArray784)[source]
-
Ticket entry structure.
- 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
- class jam.types.TicketBody(id: ByteArray32, attempt: U8)[source]
-
Ticket body structure.
- id: ByteArray32
- __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
- 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]
-
Verdict structure.
- target: ByteArray32
- 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
- class jam.types.Culprit(target: ByteArray32, key: ByteArray32, signature: ByteArray64)[source]
-
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
- class jam.types.Judgement(vote: Boolean, index: U16, signature: ByteArray64)[source]
-
Judgement structure.
- 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
- class jam.types.DisputesExtrinsic(verdicts: Verdicts, culprits: Culprits, faults: Faults)[source]
-
Disputes extrinsic structure.
- __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
- class jam.types.Fault(target: ByteArray32, vote: Boolean, key: ByteArray32, signature: ByteArray64)[source]
-
Fault structure.
- target: ByteArray32
- 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
- class jam.types.DisputesRecords(good: WorkReportHashes, bad: WorkReportHashes, wonky: WorkReportHashes, offenders: Offenders)[source]
-
Disputes records structure.
- good: WorkReportHashes
- bad: WorkReportHashes
- wonky: WorkReportHashes
- __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
- class jam.types.AvailabilityAssignment(report: WorkReport, timeout: U32)[source]
-
Availability assignment structure.
- report: WorkReport
- __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
- class jam.types.AvailabilityAssignments(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]
-
- 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]
-
- 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]
-
Block information structure.
- header_hash: ByteArray32
- 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
- class jam.types.BlocksHistory(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]
-
- 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]
-
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
- class jam.types.ValidatorMetadata(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]
Bases:
ByteArray128Validator metadata structure.
- class jam.types.ValidatorData(bandersnatch: ByteArray32, ed25519: ByteArray32, bls: ByteArray144, metadata: ValidatorMetadata)[source]
-
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
- 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