Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
RedstonedLife authored Oct 23, 2024
commit 3111893edefd3c8247d506907593a485eaa4f086
9 changes: 7 additions & 2 deletions uniswap/uniswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down