safe_eth.util package

Submodules

safe_eth.util.http module

safe_eth.util.http.build_full_url(base_url: str, url: str) str

Combines a base URL and a relative URL into a complete URL.

Ensures the base URL has the correct scheme (http:// or https://) and removes any duplicate slashes between the base URL and the relative URL.

Parameters:
  • base_url – Base URL

  • url – Relative URL

Returns:

The complete URL formed by combining base_url and url.

safe_eth.util.http.prepare_http_session(pool_connections: int, pool_maxsize: int, retry_count: int = 0, pool_block: bool = False) Session

Prepare http session with custom pooling. See: https://urllib3.readthedocs.io/en/stable/advanced-usage.html https://docs.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter

safe_eth.util.util module

safe_eth.util.util.chunks(elements: Sequence[Any], n: int) Iterable[Any]
Parameters:
  • elements – List

  • n – Number of elements per chunk

Returns:

Yield successive n-sized chunks from l

safe_eth.util.util.to_0x_hex_str(value: bytes) HexStr

Convert bytes to a 0x-prefixed hex string

Parameters:

value – bytes value

Returns:

0x-prefixed hex string

Module contents

safe_eth.util.chunks(elements: Sequence[Any], n: int) Iterable[Any]
Parameters:
  • elements – List

  • n – Number of elements per chunk

Returns:

Yield successive n-sized chunks from l