pax-api 2.4.0__tar.gz → 2.5.1__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.4.0/src/pax_api.egg-info → pax_api-2.5.1}/PKG-INFO +1 -1
- {pax_api-2.4.0 → pax_api-2.5.1}/pyproject.toml +1 -1
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api/__init__.py +1 -1
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api/client.py +14 -7
- {pax_api-2.4.0 → pax_api-2.5.1/src/pax_api.egg-info}/PKG-INFO +1 -1
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api.egg-info/SOURCES.txt +1 -0
- pax_api-2.5.1/tests/test_audit.py +59 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/LICENSE +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/README.md +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/setup.cfg +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api/auth.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api/errors.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api/py.typed +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api/retry.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api/ws_client.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api.egg-info/dependency_links.txt +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api.egg-info/requires.txt +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/src/pax_api.egg-info/top_level.txt +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/tests/test_auth.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/tests/test_client.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/tests/test_errors.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.1}/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.5.1"
|
|
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.5.1"
|
|
30
30
|
|
|
31
31
|
from pax_api.client import PaxClient # noqa: E402
|
|
32
32
|
from pax_api.ws_client import PaxWSClient # noqa: E402
|
|
@@ -27,7 +27,7 @@ from pax_api.auth import sign_request
|
|
|
27
27
|
from pax_api.errors import PaxError, build_error
|
|
28
28
|
from pax_api.retry import run_with_retry
|
|
29
29
|
|
|
30
|
-
__version__ = "2.
|
|
30
|
+
__version__ = "2.5.1" # keep in sync with __init__.py + pyproject.toml
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
# v2: sandbox is a tier on the key, not a separate host. All env aliases
|
|
@@ -430,15 +430,22 @@ class PaxClient:
|
|
|
430
430
|
def verify_merkle_proof(leaf: str, root: str, proof: List[str]) -> bool:
|
|
431
431
|
"""Verify a Merkle inclusion proof locally — no PAX call needed.
|
|
432
432
|
|
|
433
|
-
|
|
434
|
-
batcher
|
|
433
|
+
Sorted-pair SHA-256 over the RAW 32-byte digests (identical to the
|
|
434
|
+
server-side batcher). Each hex leaf/sibling is decoded to its raw
|
|
435
|
+
bytes, the pair is sorted by byte value, the raw bytes are concatenated
|
|
436
|
+
and hashed with SHA-256 — hashing the hex STRINGS instead gives the
|
|
437
|
+
wrong root. This is OpenZeppelin-style sorted-pair ordering but hashed
|
|
438
|
+
with SHA-256, NOT keccak256: stock ``MerkleProof.verify`` hashes with
|
|
439
|
+
keccak256 and will not match these roots. On-chain, verify with a
|
|
440
|
+
SHA-256 sorted-pair verifier (``sha256(abi.encodePacked(a, b))``).
|
|
435
441
|
"""
|
|
436
442
|
import hashlib
|
|
437
|
-
h = leaf
|
|
443
|
+
h = bytes.fromhex(leaf)
|
|
438
444
|
for sibling in proof:
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
445
|
+
s = bytes.fromhex(sibling)
|
|
446
|
+
a, b = (h, s) if h <= s else (s, h)
|
|
447
|
+
h = hashlib.sha256(a + b).digest()
|
|
448
|
+
return h.hex() == root
|
|
442
449
|
|
|
443
450
|
def get_application(self, application_code: str) -> Dict[str, Any]:
|
|
444
451
|
"""GET /v1/apply/{code} — check application review status."""
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Merkle inclusion verifier regression tests.
|
|
2
|
+
|
|
3
|
+
Live-published batch #36937 (4 leaves, seq 1216790..1216793) and its anchored
|
|
4
|
+
merkle_root. The verifier hashes the RAW 32-byte digests (sorted-pair SHA-256),
|
|
5
|
+
matching the publisher. Hashing the hex strings instead yields the wrong root
|
|
6
|
+
(the regression this suite guards against).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import hashlib
|
|
10
|
+
|
|
11
|
+
from pax_api import PaxClient
|
|
12
|
+
|
|
13
|
+
ROOT = "d88ec39a9842420a17a3a1eb7b28ba38e0c65addfab659cfb1853a612bd2a81b"
|
|
14
|
+
LEAVES = [
|
|
15
|
+
"d9d7ab1756d6701e32345df160edcd6fde2f391d92f77e80e9f89a848c06d15a",
|
|
16
|
+
"95dbef5fabf638ff9f37bb8b90bfbf62767bad5f4cdd18fb98aaefa1b3d3056d",
|
|
17
|
+
"1dd4ed233edb578e0edf9771ed34aaf66aea8a6c531e32e8aedd5f8a92a62378",
|
|
18
|
+
"263ccaa0884b697a0e4cd5ff6078c92049440c95396a7f8cda538e6490b2b472",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _hash_pair(a: str, b: str) -> str:
|
|
23
|
+
A, B = bytes.fromhex(a), bytes.fromhex(b)
|
|
24
|
+
x, y = (A, B) if A <= B else (B, A)
|
|
25
|
+
return hashlib.sha256(x + y).hexdigest()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
P01 = _hash_pair(LEAVES[0], LEAVES[1])
|
|
29
|
+
P23 = _hash_pair(LEAVES[2], LEAVES[3])
|
|
30
|
+
# sibling inclusion proof for each leaf index
|
|
31
|
+
PROOFS = [[LEAVES[1], P23], [LEAVES[0], P23], [LEAVES[3], P01], [LEAVES[2], P01]]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_raw_byte_sorted_pair_reconstructs_published_root() -> None:
|
|
35
|
+
assert _hash_pair(P01, P23) == ROOT
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_verify_merkle_proof_accepts_every_valid_leaf() -> None:
|
|
39
|
+
for i, leaf in enumerate(LEAVES):
|
|
40
|
+
assert PaxClient.verify_merkle_proof(leaf, ROOT, PROOFS[i]) is True
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_rejects_tampered_leaf() -> None:
|
|
44
|
+
bad = "e" + LEAVES[0][1:]
|
|
45
|
+
assert PaxClient.verify_merkle_proof(bad, ROOT, PROOFS[0]) is False
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_rejects_tampered_proof_path() -> None:
|
|
49
|
+
bad_proof = [LEAVES[2], P23] # wrong sibling
|
|
50
|
+
assert PaxClient.verify_merkle_proof(LEAVES[0], ROOT, bad_proof) is False
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_old_hex_string_hashing_does_not_match_root() -> None:
|
|
54
|
+
# Pre-fix behaviour: concat hex strings and hash their ASCII bytes.
|
|
55
|
+
h = LEAVES[0]
|
|
56
|
+
for s in PROOFS[0]:
|
|
57
|
+
a, b = (h, s) if h < s else (s, h)
|
|
58
|
+
h = hashlib.sha256((a + b).encode("ascii")).hexdigest()
|
|
59
|
+
assert h != ROOT
|
|
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
|