"""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, )