From 3111893edefd3c8247d506907593a485eaa4f086 Mon Sep 17 00:00:00 2001 From: "Tal A. Baskin" Date: Wed, 23 Oct 2024 10:06:04 +0300 Subject: [PATCH] Update uniswap.py This change fixes a ValueError exception caused by web3.py, when using self.w3.net.version it can return a hexadecimal number which needs to be handled differently than a regular integer. --- uniswap/uniswap.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/uniswap/uniswap.py b/uniswap/uniswap.py index 183c349..800dd85 100644 --- a/uniswap/uniswap.py +++ b/uniswap/uniswap.py @@ -132,8 +132,13 @@ def __init__( if enable_caching: self.w3.middleware_onion.inject(_get_eth_simple_cache_middleware(), layer=0) - - self.netid = int(self.w3.net.version) + + try: + self.netid = int(self.w3.net.version) + except ValueError: + # Happens when w3.net.version returns a hex representation of an int + self.netid = int(self.w3.net.version, 16) + if self.netid in _netid_to_name: self.netname = _netid_to_name[self.netid] else: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy