"""Transaction endpoints.""" from .client import CONTENT_TYPE_JSON, Client from .models import ( ListTransactionsResponse, Transaction, TransactionBulkRequest, TransactionBulkResponse, TransactionCreateRequest, TransactionCreateResponse, ) class TransactionClient: def __init__(self, client: Client): self._client = client def create(self, req: TransactionCreateRequest) -> TransactionCreateResponse: """Submit a new transaction and return immediately with the assigned ID. This does NOT wait for the transaction to be included in a block. Block processing happens asynchronously on a ~5-second cycle. If you need the block ID (e.g. for interchain verification), poll ``get`` until ``header.block_id`` is populated. """ return self._client.post( "/api/v1/transaction", CONTENT_TYPE_JSON, req, TransactionCreateResponse ) def create_bulk(self, req: TransactionBulkRequest) -> TransactionBulkResponse: """Submit multiple transactions and return immediately with their IDs. Like ``create``, this does not wait for block inclusion. """ return self._client.post( "/api/v1/transaction/bulk", CONTENT_TYPE_JSON, req, TransactionBulkResponse ) def get(self, transaction_id: str) -> Transaction: return self._client.get(f"/api/v1/transaction/{transaction_id}", Transaction) def list(self) -> ListTransactionsResponse: return self._client.get("/api/v1/transaction/", ListTransactionsResponse)