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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oneshot-python
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: Core Python SDK for the OneShot API — HTTP client with x402 payment handling
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -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.0"
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 (v2 format with accepted requirements + Bazaar metadata)
161
- auth = sign_payment_authorization(
162
- private_key=self._private_key,
163
- from_address=self.address,
164
- to_address=payment_request["recipient"],
165
- amount=payment_request["amount"],
166
- token_address=payment_request["token_address"],
167
- chain_id=payment_request["chain_id"],
168
- network=f"eip155:{payment_request['chain_id']}",
169
- accepted=accepted,
170
- resource=parsed_req.get("resource"),
171
- extensions=parsed_req.get("extensions"),
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
- # Step 4 — Re-POST with payment headers (x402 format)
175
- headers = {
176
- **self._headers(),
177
- "payment-signature": encode_payment_header(auth),
178
- }
179
- if quote_id:
180
- headers["x-quote-id"] = quote_id
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
- resp2 = await client.post(url, headers=headers, json=payload)
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.0"
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