pax-api 2.2.1__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pax_api-2.2.1/src/pax_api.egg-info → pax_api-2.4.0}/PKG-INFO +1 -1
- {pax_api-2.2.1 → pax_api-2.4.0}/pyproject.toml +1 -1
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api/__init__.py +1 -1
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api/client.py +49 -4
- {pax_api-2.2.1 → pax_api-2.4.0/src/pax_api.egg-info}/PKG-INFO +1 -1
- {pax_api-2.2.1 → pax_api-2.4.0}/LICENSE +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/README.md +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/setup.cfg +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api/auth.py +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api/errors.py +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api/py.typed +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api/retry.py +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api/ws_client.py +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api.egg-info/SOURCES.txt +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api.egg-info/dependency_links.txt +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api.egg-info/requires.txt +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/src/pax_api.egg-info/top_level.txt +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/tests/test_auth.py +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/tests/test_client.py +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/tests/test_errors.py +0 -0
- {pax_api-2.2.1 → pax_api-2.4.0}/tests/test_retry.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pax-api"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.4.0"
|
|
8
8
|
description = "Official Python SDK for the PredictAsiaX Trader Track API — Web3-native prediction markets"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -26,7 +26,7 @@ caps), not a separate host. Same prefix, same URL — promote to production by
|
|
|
26
26
|
upgrading the key's tier.
|
|
27
27
|
"""
|
|
28
28
|
|
|
29
|
-
__version__ = "2.
|
|
29
|
+
__version__ = "2.4.0"
|
|
30
30
|
|
|
31
31
|
from pax_api.client import PaxClient # noqa: E402
|
|
32
32
|
from pax_api.ws_client import PaxWSClient # noqa: E402
|
|
@@ -17,6 +17,8 @@ Environment:
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import json as _json
|
|
20
|
+
import os
|
|
21
|
+
import secrets
|
|
20
22
|
from typing import Any, Callable, Dict, List, Optional
|
|
21
23
|
|
|
22
24
|
import requests
|
|
@@ -25,7 +27,7 @@ from pax_api.auth import sign_request
|
|
|
25
27
|
from pax_api.errors import PaxError, build_error
|
|
26
28
|
from pax_api.retry import run_with_retry
|
|
27
29
|
|
|
28
|
-
__version__ = "2.
|
|
30
|
+
__version__ = "2.4.0" # keep in sync with __init__.py + pyproject.toml
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
# v2: sandbox is a tier on the key, not a separate host. All env aliases
|
|
@@ -114,7 +116,8 @@ class PaxClient:
|
|
|
114
116
|
return headers
|
|
115
117
|
|
|
116
118
|
def _do_request(self, method: str, path: str, params: Optional[Dict[str, Any]] = None,
|
|
117
|
-
json_body: Optional[Dict[str, Any]] = None
|
|
119
|
+
json_body: Optional[Dict[str, Any]] = None,
|
|
120
|
+
extra_headers: Optional[Dict[str, str]] = None) -> Dict[str, Any]:
|
|
118
121
|
url = self.base_url + path
|
|
119
122
|
body = _json.dumps(json_body, separators=(",", ":"), sort_keys=False) if json_body is not None else ""
|
|
120
123
|
# Reconstruct path+query for signing to match what server sees
|
|
@@ -126,6 +129,11 @@ class PaxClient:
|
|
|
126
129
|
if qs:
|
|
127
130
|
path_for_sig = f"{path}?{qs}"
|
|
128
131
|
headers = self._headers_for(method, path_for_sig, body)
|
|
132
|
+
if extra_headers:
|
|
133
|
+
headers.update(extra_headers)
|
|
134
|
+
# Auto-inject Idempotency-Key for POST/PUT/PATCH/DELETE if not set by caller
|
|
135
|
+
if method.upper() in ("POST", "PUT", "PATCH", "DELETE") and "Idempotency-Key" not in headers:
|
|
136
|
+
headers["Idempotency-Key"] = "pax-sdk-" + secrets.token_hex(12)
|
|
129
137
|
|
|
130
138
|
resp = self._session.request(
|
|
131
139
|
method=method,
|
|
@@ -152,9 +160,11 @@ class PaxClient:
|
|
|
152
160
|
return payload
|
|
153
161
|
|
|
154
162
|
def _request(self, method: str, path: str, params: Optional[Dict[str, Any]] = None,
|
|
155
|
-
json_body: Optional[Dict[str, Any]] = None
|
|
163
|
+
json_body: Optional[Dict[str, Any]] = None,
|
|
164
|
+
extra_headers: Optional[Dict[str, str]] = None) -> Dict[str, Any]:
|
|
156
165
|
return run_with_retry(
|
|
157
|
-
lambda: self._do_request(method, path, params=params, json_body=json_body
|
|
166
|
+
lambda: self._do_request(method, path, params=params, json_body=json_body,
|
|
167
|
+
extra_headers=extra_headers),
|
|
158
168
|
max_attempts=self.max_retries,
|
|
159
169
|
)
|
|
160
170
|
|
|
@@ -434,6 +444,41 @@ class PaxClient:
|
|
|
434
444
|
"""GET /v1/apply/{code} — check application review status."""
|
|
435
445
|
return self._request("GET", f"/v1/apply/{application_code}")
|
|
436
446
|
|
|
447
|
+
# ── Revenue / settle (v2.4+) ─────────────────────────────────────────────
|
|
448
|
+
def settle_self(self, *, address: str, asset: str = "USDT",
|
|
449
|
+
network: str = "polygon", min_amount: float = 0) -> Dict[str, Any]:
|
|
450
|
+
"""POST /v1/builders/me/settle — builder self-serve claim of accrued
|
|
451
|
+
execution_builder + acquisition_builder fees. Creates a withdrawal_state
|
|
452
|
+
row; existing pipeline delivers USDT to the provided address.
|
|
453
|
+
Requires api-key auth (uses the caller's user_id as builder identity).
|
|
454
|
+
"""
|
|
455
|
+
return self._request("POST", "/v1/builders/me/settle",
|
|
456
|
+
json_body={"address": address, "asset": asset,
|
|
457
|
+
"network": network, "min_amount": min_amount})
|
|
458
|
+
|
|
459
|
+
def admin_settle_builder(self, user_id: str, *, address: str, asset: str = "USDT",
|
|
460
|
+
network: str = "polygon", min_amount: float = 0,
|
|
461
|
+
admin_key: Optional[str] = None) -> Dict[str, Any]:
|
|
462
|
+
"""POST /v1/admin/builders/{user_id}/settle — admin claim of a specific
|
|
463
|
+
builder's earnings. Requires X-Admin-Key (pass via admin_key arg or
|
|
464
|
+
env ADMIN_HEALTH_TOKEN)."""
|
|
465
|
+
headers = {"X-Admin-Key": admin_key or os.environ.get("ADMIN_HEALTH_TOKEN", "")}
|
|
466
|
+
return self._request("POST", f"/v1/admin/builders/{user_id}/settle",
|
|
467
|
+
json_body={"address": address, "asset": asset,
|
|
468
|
+
"network": network, "min_amount": min_amount},
|
|
469
|
+
extra_headers=headers)
|
|
470
|
+
|
|
471
|
+
def admin_settle_creator(self, user_id: str, *, address: str, asset: str = "USDT",
|
|
472
|
+
network: str = "polygon", min_amount: float = 0,
|
|
473
|
+
admin_key: Optional[str] = None) -> Dict[str, Any]:
|
|
474
|
+
"""POST /v1/admin/creators/{user_id}/settle — admin claim of a specific
|
|
475
|
+
market creator's FEE_MARKET_CREATOR earnings. Requires X-Admin-Key."""
|
|
476
|
+
headers = {"X-Admin-Key": admin_key or os.environ.get("ADMIN_HEALTH_TOKEN", "")}
|
|
477
|
+
return self._request("POST", f"/v1/admin/creators/{user_id}/settle",
|
|
478
|
+
json_body={"address": address, "asset": asset,
|
|
479
|
+
"network": network, "min_amount": min_amount},
|
|
480
|
+
extra_headers=headers)
|
|
481
|
+
|
|
437
482
|
# ── Helpers ──────────────────────────────────────────────────────────────
|
|
438
483
|
def close(self) -> None:
|
|
439
484
|
self._session.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|