paynode-sdk-python 1.1.1__py3-none-any.whl → 1.1.2__py3-none-any.whl

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.
paynode_sdk/client.py CHANGED
@@ -171,7 +171,7 @@ class PayNodeAgentClient:
171
171
  def pay_with_permit_auto(self, router_addr, token_addr, merchant_addr, amount, order_id):
172
172
  """Combines sign_permit and on-chain submission."""
173
173
  sig = self.sign_permit(token_addr, router_addr, amount)
174
- router_abi = [{"inputs": [{"name": "p", "type": "address"}, {"name": "t", "type": "address"}, {"name": "m", "type": "address"}, {"name": "a", "type": "uint256"}, {"name": "o", "type": "bytes32"}, {"name": "d", "type": "uint256"}, {"name": "v", "type": "uint8"}, {"name": "r", "type": "bytes32"}, {"name": "s", "type": "bytes32"}], "name": "payWithPermit", "outputs": [], "stateMutability": "nonpayable", "type": "function"}]
174
+ router_abi = [{"inputs": [{"name": "payer", "type": "address"}, {"name": "token", "type": "address"}, {"name": "merchant", "type": "address"}, {"name": "amount", "type": "uint256"}, {"name": "orderId", "type": "bytes32"}, {"name": "deadline", "type": "uint256"}, {"name": "v", "type": "uint8"}, {"name": "r", "type": "bytes32"}, {"name": "s", "type": "bytes32"}], "name": "payWithPermit", "outputs": [], "stateMutability": "nonpayable", "type": "function"}]
175
175
  router = self.w3.eth.contract(address=Web3.to_checksum_address(router_addr), abi=router_abi)
176
176
  order_id_bytes = self.w3.keccak(text=order_id)
177
177
 
@@ -199,7 +199,7 @@ class PayNodeAgentClient:
199
199
 
200
200
  def _execute_pay(self, router_addr, token_addr, merchant_addr, amount, order_id):
201
201
  """Standard pay method (fallback)."""
202
- router_abi = [{"inputs": [{"name": "t", "type": "address"}, {"name": "m", "type": "address"}, {"name": "a", "type": "uint256"}, {"name": "o", "type": "bytes32"}], "name": "pay", "outputs": [], "stateMutability": "nonpayable", "type": "function"}]
202
+ router_abi = [{"inputs": [{"name": "token", "type": "address"}, {"name": "merchant", "type": "address"}, {"name": "amount", "type": "uint256"}, {"name": "orderId", "type": "bytes32"}], "name": "pay", "outputs": [], "stateMutability": "nonpayable", "type": "function"}]
203
203
  router = self.w3.eth.contract(address=Web3.to_checksum_address(router_addr), abi=router_abi)
204
204
  order_id_bytes = self.w3.keccak(text=order_id)
205
205
  current_gas_price = int(self.w3.eth.gas_price * 1.2)
paynode_sdk/middleware.py CHANGED
@@ -12,7 +12,7 @@ class PayNodeMiddleware(BaseHTTPMiddleware):
12
12
  def __init__(
13
13
  self,
14
14
  app: Any,
15
- rpc_url: str,
15
+ rpc_urls: list | str,
16
16
  contract_address: str,
17
17
  merchant_address: str,
18
18
  chain_id: int,
@@ -25,7 +25,7 @@ class PayNodeMiddleware(BaseHTTPMiddleware):
25
25
  ):
26
26
  super().__init__(app)
27
27
  # The Verifier holds the state of the idempotency store
28
- self.verifier = PayNodeVerifier(rpc_url, contract_address, chain_id, store=store)
28
+ self.verifier = PayNodeVerifier(rpc_urls=rpc_urls, contract_address=contract_address, chain_id=chain_id, store=store)
29
29
  self.merchant_address = merchant_address
30
30
  self.contract_address = contract_address
31
31
  self.currency = currency
paynode_sdk/verifier.py CHANGED
@@ -4,10 +4,20 @@ from .idempotency import MemoryIdempotencyStore
4
4
  from web3 import Web3
5
5
 
6
6
  class PayNodeVerifier:
7
- def __init__(self, rpc_url=None, contract_address=None, chain_id=None, w3=None, store=None, accepted_tokens=None):
7
+ def __init__(self, rpc_urls=None, contract_address=None, chain_id=None, w3=None, store=None, accepted_tokens=None):
8
8
  self.w3 = w3
9
- if not self.w3 and rpc_url:
10
- self.w3 = Web3(Web3.HTTPProvider(rpc_url))
9
+ if not self.w3 and rpc_urls:
10
+ urls = rpc_urls if isinstance(rpc_urls, list) else [rpc_urls]
11
+ for rpc in urls:
12
+ try:
13
+ temp_w3 = Web3(Web3.HTTPProvider(rpc, request_kwargs={'timeout': 5}))
14
+ if temp_w3.is_connected():
15
+ self.w3 = temp_w3
16
+ break
17
+ except Exception:
18
+ continue
19
+ if not self.w3:
20
+ raise PayNodeException("Failed to connect to any provided RPC nodes.", ErrorCode.RPC_ERROR)
11
21
  self.contract_address = contract_address
12
22
  self.chain_id = int(chain_id) if chain_id else None
13
23
  self.store = store or MemoryIdempotencyStore()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: paynode-sdk-python
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: PayNode Protocol Python SDK for AI Agents
5
5
  Author-email: PayNodeLabs <contact@paynode.dev>
6
6
  License: MIT
@@ -0,0 +1,13 @@
1
+ paynode_sdk/__init__.py,sha256=p6URBqxFz1AErG7rIRWKnfwnzAC19qrMURtG7YhVR1I,821
2
+ paynode_sdk/client.py,sha256=rwn6bTSyIuIXd8aLnK5Nnd7R5p8Hx25ETzfNQil6y1k,10639
3
+ paynode_sdk/constants.py,sha256=puqz09qeKcMoigWrqdIzkhtAzFpECxEwHGLvDd3U_CQ,1429
4
+ paynode_sdk/errors.py,sha256=GN0qycgjATT47dF4yZ6Ulg18jf2OwholvYl0pgCvuzo,1121
5
+ paynode_sdk/idempotency.py,sha256=od7HuSxFdejBP0oE4QCzbJdrDZWvziiu09d3BRErU2k,999
6
+ paynode_sdk/middleware.py,sha256=KAcSVaVyApO4evby4vnv1erifqi3VzSBFbWelGGSF_w,3563
7
+ paynode_sdk/verifier.py,sha256=V7VXWqXzkObfN9v9agb7CWiLLwKbX1f2gsIWQE0qDdk,5274
8
+ paynode_sdk/webhook.py,sha256=KxlXGkXe3wpR8ueO8FMW2iypJgWaLwMfxAAZLNRvNDo,8302
9
+ paynode_sdk_python-1.1.2.dist-info/licenses/LICENSE,sha256=U8RjGlEBtXN6PA-qN_N3Uh60jyu3qe26ZBmgt-LAHc4,1069
10
+ paynode_sdk_python-1.1.2.dist-info/METADATA,sha256=_qVjPReImedgxEqo1w4FlZVgead-vXFxAGvR3nZVyx4,2858
11
+ paynode_sdk_python-1.1.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
12
+ paynode_sdk_python-1.1.2.dist-info/top_level.txt,sha256=c6Skc1Xx-9O-JJ7sHghLW8Kyn4hyJoVPUawH1Mu8iTU,12
13
+ paynode_sdk_python-1.1.2.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- paynode_sdk/__init__.py,sha256=p6URBqxFz1AErG7rIRWKnfwnzAC19qrMURtG7YhVR1I,821
2
- paynode_sdk/client.py,sha256=jseyOrGPq7VQdufScIQsxrEEwK2WWoIQdEmGOfkTEls,10584
3
- paynode_sdk/constants.py,sha256=puqz09qeKcMoigWrqdIzkhtAzFpECxEwHGLvDd3U_CQ,1429
4
- paynode_sdk/errors.py,sha256=GN0qycgjATT47dF4yZ6Ulg18jf2OwholvYl0pgCvuzo,1121
5
- paynode_sdk/idempotency.py,sha256=od7HuSxFdejBP0oE4QCzbJdrDZWvziiu09d3BRErU2k,999
6
- paynode_sdk/middleware.py,sha256=Hi7dgbDy_moVnHl8f31YPsl_a3mSygIDAb_nCO9CMLY,3519
7
- paynode_sdk/verifier.py,sha256=rIjRxPZDSWKbf9ghfCu5JJ7Q8oPy0SQprgZWxQiggEg,4795
8
- paynode_sdk/webhook.py,sha256=KxlXGkXe3wpR8ueO8FMW2iypJgWaLwMfxAAZLNRvNDo,8302
9
- paynode_sdk_python-1.1.1.dist-info/licenses/LICENSE,sha256=U8RjGlEBtXN6PA-qN_N3Uh60jyu3qe26ZBmgt-LAHc4,1069
10
- paynode_sdk_python-1.1.1.dist-info/METADATA,sha256=G-9GKKJuNBK6Zz2MwcMDDJpAm2b-LvDjKR3VMQyvHLQ,2858
11
- paynode_sdk_python-1.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
12
- paynode_sdk_python-1.1.1.dist-info/top_level.txt,sha256=c6Skc1Xx-9O-JJ7sHghLW8Kyn4hyJoVPUawH1Mu8iTU,12
13
- paynode_sdk_python-1.1.1.dist-info/RECORD,,