Files
prime-sdk-python/prime_sdk/transaction.py
Andrew Miller 4a7d8b875a Initial commit: Python SDK for Dragonchain (Prime)
Synchronous Python SDK modeled on prime-sdk-go. Provides DC1-HMAC-SHA256
auth, dataclass models, and resource clients for system, transaction,
transaction-type, smart-contract, and block endpoints, plus a YAML
credentials loader.
2026-05-29 16:53:16 -04:00

44 lines
1.6 KiB
Python

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