Files
prime-sdk-python/prime_sdk/block.py
Andrew Miller d425b58cfe
All checks were successful
Publish to PyPI Registry / publish (release) Successful in 23s
get_interchain: per_chain + chains options (default first anchor per chain); bump 0.5.0
transaction.get_interchain / block.get_interchain take per_chain= and chains=
kwargs mapping to prime-node's ?perChain=&chains= params. Default (no kwargs)
returns one anchor per chain. Shared interchain_query() helper, exported; pytest.
2026-06-05 10:56:33 -04:00

35 lines
1.1 KiB
Python

"""Block endpoints."""
from typing import List, Optional
from .client import Client
from .interchain import interchain_query
from .models import Block, InterchainTrace
class BlockClient:
def __init__(self, client: Client):
self._client = client
def get(self, block_id: str) -> Block:
return self._client.get(f"/api/v1/block/{block_id}", Block)
def get_interchain(
self,
block_id: str,
per_chain: Optional[int] = None,
chains: Optional[List[str]] = None,
) -> InterchainTrace:
"""Trace a block to the validator (verification) blocks that validated it
and the public-chain interchain anchors those validator blocks were
bundled into.
By default returns the first anchor per public chain (anchor proofs are
chained, so the earliest per chain is the meaningful one). ``per_chain``
caps anchors per chain (1 = first per chain; 0 = all); ``chains``
restricts to specific chain ids."""
return self._client.get(
f"/api/v1/block/{block_id}/interchain{interchain_query(per_chain, chains)}",
InterchainTrace,
)