From dc4aeaf279ae6070a7733a856c54e7decc434b89 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 21:34:00 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.16.4 → v0.16.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.16.4...v0.16.5) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cfc6de1..c29f3d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.16.4 + rev: v0.16.5 hooks: - id: ruff args: [--fix] From 880af54281fefc8d92105fca3ce7dfb55b97f795 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 21:34:10 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/examples.md | 20 +++++++++++--------- docs/installation.md | 1 + docs/usage.md | 39 +++++++++++++++++---------------------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/docs/examples.md b/docs/examples.md index 8dd62bc..c2d4883 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -291,15 +291,17 @@ def transfer_ledger(client: CryptoBotClient, asset: Asset = None): """Build a ledger of all outgoing transfers.""" ledger = [] for transfer in client.iter_transfers(asset=asset, page_size=200): - ledger.append({ - "id": transfer.transfer_id, - "user_id": transfer.user_id, - "asset": transfer.asset.name, - "amount": transfer.amount, - "status": transfer.status.name, - "spend_id": transfer.spend_id, - "completed_at": transfer.completed_at, - }) + ledger.append( + { + "id": transfer.transfer_id, + "user_id": transfer.user_id, + "asset": transfer.asset.name, + "amount": transfer.amount, + "status": transfer.status.name, + "spend_id": transfer.spend_id, + "completed_at": transfer.completed_at, + } + ) total = sum(Decimal(str(t["amount"])) for t in ledger) return {"entries": ledger, "total": str(total), "count": len(ledger)} diff --git a/docs/installation.md b/docs/installation.md index fa7c231..d1ac065 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -22,6 +22,7 @@ pip install "cryptobot-python[docs]" ```python from cryptobot import CryptoBotClient + print(CryptoBotClient) ``` diff --git a/docs/usage.md b/docs/usage.md index edba89d..565733f 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -52,11 +52,7 @@ print(f"Bot Username: {app.payment_processing_bot_username}") Create a simple invoice for cryptocurrency payment: ```python -invoice = client.create_invoice( - asset=Asset.USDT, - amount=5.25, - description="Coffee order #42" -) +invoice = client.create_invoice(asset=Asset.USDT, amount=5.25, description="Coffee order #42") print(f"Invoice URL: {invoice.bot_invoice_url}") print(f"Invoice ID: {invoice.invoice_id}") @@ -76,7 +72,7 @@ invoice = client.create_invoice( payload="user_123_premium", # Custom payload for tracking allow_comments=True, # Allow user comments allow_anonymous=False, # Require user identification - expires_in=3600 # Expire after 1 hour + expires_in=3600, # Expire after 1 hour ) ``` @@ -91,7 +87,7 @@ try: asset=Asset.TON, amount=0.5, spend_id="transfer_001", # Unique spend ID to prevent duplicates - comment="Payment for services" + comment="Payment for services", ) print(f"Transfer completed: {transfer.transfer_id}") except CryptoBotError as e: @@ -164,13 +160,7 @@ Retrieve information about existing invoices: invoices = client.get_invoices() # Get invoices with filters -paid_invoices = client.get_invoices( - asset=Asset.USDT, - invoice_ids=[123, 456], - status=Status.paid, - offset=0, - count=50 -) +paid_invoices = client.get_invoices(asset=Asset.USDT, invoice_ids=[123, 456], status=Status.paid, offset=0, count=50) ``` `invoice_ids` accepts either a comma-separated string (`"123,456"`) or `list[int]` (`[123, 456]`). @@ -384,6 +374,7 @@ from fastapi import FastAPI, Request, HTTPException app = FastAPI() api_token = os.environ["CRYPTOBOT_API_TOKEN"] + @app.post("/webhook") async def webhook_handler(request: Request): # Read the raw body first (required for signature verification) @@ -408,13 +399,13 @@ The library supports these assets (see {class}`cryptobot.models.Asset` for the c from cryptobot.models import Asset # Available assets -Asset.BTC # Bitcoin -Asset.TON # Toncoin -Asset.ETH # Ethereum -Asset.USDT # Tether -Asset.USDC # USD Coin -Asset.BNB # Binance Coin -Asset.TRX # TRON +Asset.BTC # Bitcoin +Asset.TON # Toncoin +Asset.ETH # Ethereum +Asset.USDT # Tether +Asset.USDC # USD Coin +Asset.BNB # Binance Coin +Asset.TRX # TRON ``` ## Advanced Patterns @@ -498,6 +489,7 @@ def wait_for_payment(client, invoice_id, max_attempts=60, delay=5): raise TimeoutError("Payment timeout") + # Usage invoice = client.create_invoice(asset=Asset.USDT, amount=10) print(f"Waiting for payment: {invoice.bot_invoice_url}") @@ -516,6 +508,7 @@ Calculate total revenue from paid invoices: ```python from decimal import Decimal + def calculate_revenue(client, asset=None): """Calculate total revenue from paid invoices""" invoices = client.get_invoices(status=Status.paid, asset=asset) @@ -532,6 +525,7 @@ def calculate_revenue(client, asset=None): return revenue_by_asset + # Usage revenue = calculate_revenue(client) for asset, total in revenue.items(): @@ -557,7 +551,7 @@ def create_flexible_invoice(client, amount_usd, description): amount=amount_usd, description=description, allow_comments=True, - expires_in=3600 # 1 hour + expires_in=3600, # 1 hour ) # Show equivalent amounts in other currencies @@ -572,6 +566,7 @@ def create_flexible_invoice(client, amount_usd, description): return invoice + # Usage invoice = create_flexible_invoice(client, 50.0, "Premium subscription") ```