Skip to content

Commit

Permalink
support web3 v6 and v7
Browse files Browse the repository at this point in the history
  • Loading branch information
Elnaril committed Dec 20, 2024
1 parent 5bf82ab commit 5f5a2cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions uniswap_universal_router_decoder/_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
from eth_abi.exceptions import DecodingError
from web3 import Web3
from web3.contract.contract import BaseContractFunction
from web3.exceptions import Web3ValueError
from web3.exceptions import Web3Exception
from web3.types import (
ChecksumAddress,
HexBytes,
HexStr,
TxData,
)

from uniswap_universal_router_decoder._abi_builder import _ABIMap
from uniswap_universal_router_decoder._abi_builder import (
_ABIMap,
build_abi_type_list,
)
from uniswap_universal_router_decoder._constants import (
_pool_manager_abi,
_position_manager_abi,
Expand Down Expand Up @@ -206,7 +209,7 @@ def contract_error(
error_abi.append(item)
contract = self._w3.eth.contract(abi=error_abi)
error, params = contract.decode_function_input(contract_error)
return error.name, params
except Web3ValueError:
return f"{error.fn_name}({','.join(build_abi_type_list(error.abi))})", params
except (ValueError, Web3Exception):
"""The error is not defined in this ABI"""
return "Unknown error", {}

0 comments on commit 5f5a2cc

Please sign in to comment.