All checks were successful
Publish to PyPI Registry / publish (release) Successful in 23s
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.
35 lines
1.1 KiB
Python
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,
|
|
)
|