solver-multirpc 3.1.11__tar.gz → 3.1.13__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.3
2
2
  Name: solver-multirpc
3
- Version: 3.1.11
3
+ Version: 3.1.13
4
4
  Summary: A robust Python library for interacting with Ethereum smart contracts via multiple RPC endpoints, ensuring reliability, availability, and load distribution with automatic retries on failure.
5
5
  License: MIT
6
6
  Author: rorschach
@@ -351,7 +351,7 @@ class BaseMultiRpc(ABC):
351
351
  raise
352
352
 
353
353
  @staticmethod
354
- def _handle_tx_trace(trace: TxTrace, func_name: str, func_args: Tuple, func_kwargs: Dict):
354
+ def _handle_tx_trace(trace: TxTrace, func_name: str, func_args: Tuple, func_kwargs: Dict) -> Exception | None:
355
355
  """
356
356
  You can override this method to customize handling failed transaction.
357
357
 
@@ -391,11 +391,12 @@ class BaseMultiRpc(ABC):
391
391
  tx_err_count += 1
392
392
  timeout *= 2
393
393
 
394
- @staticmethod
395
- async def __get_tx_trace(tx, provider_url, func_name=None, func_args=None, func_kwargs=None):
394
+ @classmethod
395
+ async def __get_tx_trace(cls, tx, provider_url, func_name=None, func_args=None, func_kwargs=None):
396
396
  tx_hash = Web3.to_hex(tx)
397
397
  trace = TxTrace(tx_hash, provider_url)
398
- BaseMultiRpc._handle_tx_trace(trace, func_name, func_args, func_kwargs)
398
+ if exception := cls._handle_tx_trace(trace, func_name, func_args, func_kwargs):
399
+ return exception
399
400
  return TransactionFailedStatus(tx_hash, func_name, func_args, func_kwargs, trace)
400
401
 
401
402
  @staticmethod
@@ -1,3 +1,5 @@
1
+ import json
2
+
1
3
  import requests
2
4
 
3
5
  from multirpc.constants import MultiRPCLogger
@@ -64,12 +66,17 @@ class TxTrace:
64
66
  }
65
67
 
66
68
  response = requests.post(self.rpc, json=data)
69
+ try:
70
+ json_response = response.json()
71
+ except json.decoder.JSONDecodeError:
72
+ MultiRPCLogger.error(f'tx_trace({self.tx_hash}) invalid JSON response: {response.text[:200]}')
73
+ return None
67
74
  if response.status_code == 200:
68
- if error := response.json().get('error'):
75
+ if error := json_response.get('error'):
69
76
  MultiRPCLogger.error(f'failed to get tx({self.tx_hash}) trace with error: {error}')
70
77
  return None
71
78
  return response
72
- MultiRPCLogger.error(f'tx_trace({self.tx_hash}) status = {response.status_code}, \n {response.json()}')
79
+ MultiRPCLogger.error(f'tx_trace({self.tx_hash}) status = {response.status_code}, \n {json_response}')
73
80
 
74
81
  except requests.HTTPError:
75
82
  MultiRPCLogger.exception('Exception in debug_traceTransaction')
@@ -146,8 +153,8 @@ class TxTraceResult:
146
153
  def first_usable_error(self):
147
154
  for error in [self.error()] + self.all_revert_reasons():
148
155
  if error and \
149
- 'execution reverted' not in error and \
150
- 'MultiAccount: Error occurred' not in error and \
151
- 'Execution reverted' not in error:
156
+ 'execution reverted' not in error and \
157
+ 'MultiAccount: Error occurred' not in error and \
158
+ 'Execution reverted' not in error:
152
159
  return error
153
160
  return ''
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "solver-multirpc"
3
- version = "3.1.11"
3
+ version = "3.1.13"
4
4
  description = "A robust Python library for interacting with Ethereum smart contracts via multiple RPC endpoints, ensuring reliability, availability, and load distribution with automatic retries on failure."
5
5
  authors = ["rorschach <rorschach45001@gmail.com>"]
6
6
  license = "MIT"