oneshot-python 0.8.0__tar.gz → 0.8.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.
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/PKG-INFO +1 -1
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/oneshot/client.py +30 -22
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/pyproject.toml +1 -1
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/.gitignore +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/README.md +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/oneshot/__init__.py +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/oneshot/_errors.py +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/oneshot/x402.py +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/tests/__init__.py +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/tests/test_balance.py +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/tests/test_x402.py +0 -0
- {oneshot_python-0.8.0 → oneshot_python-0.8.1}/uv.lock +0 -0
|
@@ -25,7 +25,7 @@ from oneshot._errors import (
|
|
|
25
25
|
)
|
|
26
26
|
from oneshot.x402 import sign_payment_authorization, encode_payment_header, parse_payment_required
|
|
27
27
|
|
|
28
|
-
SDK_VERSION = "0.8.
|
|
28
|
+
SDK_VERSION = "0.8.1"
|
|
29
29
|
|
|
30
30
|
# ---------------------------------------------------------------------------
|
|
31
31
|
# Environment configuration
|
|
@@ -157,29 +157,37 @@ class OneShotClient:
|
|
|
157
157
|
|
|
158
158
|
self._log(f"Payment required: {payment_request['amount']} USDC")
|
|
159
159
|
|
|
160
|
-
# Step 3 — Sign x402 payment (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
160
|
+
# Step 3 — Sign x402 payment (skip if credits cover full cost)
|
|
161
|
+
amount = float(payment_request["amount"])
|
|
162
|
+
if amount == 0:
|
|
163
|
+
self._log("Credits cover full cost — skipping payment signature")
|
|
164
|
+
headers = {**self._headers()}
|
|
165
|
+
if quote_id:
|
|
166
|
+
headers["x-quote-id"] = quote_id
|
|
167
|
+
resp2 = await client.post(url, headers=headers, json=payload)
|
|
168
|
+
else:
|
|
169
|
+
auth = sign_payment_authorization(
|
|
170
|
+
private_key=self._private_key,
|
|
171
|
+
from_address=self.address,
|
|
172
|
+
to_address=payment_request["recipient"],
|
|
173
|
+
amount=payment_request["amount"],
|
|
174
|
+
token_address=payment_request["token_address"],
|
|
175
|
+
chain_id=payment_request["chain_id"],
|
|
176
|
+
network=f"eip155:{payment_request['chain_id']}",
|
|
177
|
+
accepted=accepted,
|
|
178
|
+
resource=parsed_req.get("resource"),
|
|
179
|
+
extensions=parsed_req.get("extensions"),
|
|
180
|
+
)
|
|
173
181
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
# Step 4 — Re-POST with payment headers (x402 format)
|
|
183
|
+
headers = {
|
|
184
|
+
**self._headers(),
|
|
185
|
+
"payment-signature": encode_payment_header(auth),
|
|
186
|
+
}
|
|
187
|
+
if quote_id:
|
|
188
|
+
headers["x-quote-id"] = quote_id
|
|
181
189
|
|
|
182
|
-
|
|
190
|
+
resp2 = await client.post(url, headers=headers, json=payload)
|
|
183
191
|
|
|
184
192
|
if resp2.status_code not in (200, 201, 202):
|
|
185
193
|
raise ToolError(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "oneshot-python"
|
|
3
|
-
version = "0.8.
|
|
3
|
+
version = "0.8.1"
|
|
4
4
|
description = "Core Python SDK for the OneShot API — HTTP client with x402 payment handling"
|
|
5
5
|
readme = {text = "Core Python SDK for the OneShot API", content-type = "text/plain"}
|
|
6
6
|
license = "MIT"
|
|
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
|