55* License: MIT.
66* Doc: https://github.com/Elnaril/uniswap-universal-router-decoder
77"""
8+ from collections .abc import Sequence
89from itertools import chain
910import json
1011from typing import (
1112 Any ,
12- Dict ,
13- List ,
14- Sequence ,
15- Tuple ,
1613 Union ,
1714)
1815
@@ -54,7 +51,7 @@ def __init__(self, w3: Web3, abi_map: ABIMap) -> None:
5451 def _decode_v4_actions (
5552 self ,
5653 actions : bytes ,
57- params : List [bytes ]) -> List [ Tuple [BaseContractFunction , Dict [str , Any ]]]:
54+ params : list [bytes ]) -> list [ tuple [BaseContractFunction , dict [str , Any ]]]:
5855 if len (actions ) != len (params ):
5956 raise ValueError (f"Number of actions { len (actions )} is different from number of params: { len (params )} " )
6057
@@ -69,10 +66,10 @@ def _decode_v4_actions(
6966 decoded_params .append (params [i ].hex ())
7067 return decoded_params
7168
72- def decode_v4_swap (self , actions : bytes , params : List [bytes ]) -> List [ Tuple [BaseContractFunction , Dict [str , Any ]]]:
69+ def decode_v4_swap (self , actions : bytes , params : list [bytes ]) -> list [ tuple [BaseContractFunction , dict [str , Any ]]]:
7370 return self ._decode_v4_actions (actions , params )
7471
75- def decode_v4_pm_call (self , encoded_input : bytes ) -> Dict [str , Any ]:
72+ def decode_v4_pm_call (self , encoded_input : bytes ) -> dict [str , Any ]:
7673 actions , params = decode (["bytes" , "bytes[]" ], encoded_input )
7774 return {"actions" : actions , "params" : self ._decode_v4_actions (actions , params )}
7875
@@ -84,7 +81,7 @@ def __init__(self, w3: Web3, abi_map: ABIMap) -> None:
8481 self ._abi_map = abi_map
8582 self ._v4_decoder = _V4Decoder (w3 , abi_map )
8683
87- def function_input (self , input_data : Union [HexStr , HexBytes ]) -> Tuple [BaseContractFunction , Dict [str , Any ]]:
84+ def function_input (self , input_data : Union [HexStr , HexBytes ]) -> tuple [BaseContractFunction , dict [str , Any ]]:
8885 """
8986 Decode the data sent to an UR function
9087
@@ -147,7 +144,7 @@ def function_input(self, input_data: Union[HexStr, HexBytes]) -> Tuple[BaseContr
147144 decoded_input ["inputs" ] = decoded_command_input
148145 return fct_name , decoded_input
149146
150- def transaction (self , trx_hash : Union [HexBytes , HexStr ]) -> Dict [str , Any ]:
147+ def transaction (self , trx_hash : Union [HexBytes , HexStr ]) -> dict [str , Any ]:
151148 """
152149 Get transaction details and decode the data used to call a UR function.
153150
@@ -166,7 +163,7 @@ def _get_transaction(self, trx_hash: Union[HexBytes, HexStr]) -> TxData:
166163 return self ._w3 .eth .get_transaction (trx_hash )
167164
168165 @staticmethod
169- def v3_path (v3_fn_name : str , path : Union [bytes , str ]) -> Tuple [Union [int , ChecksumAddress ], ...]:
166+ def v3_path (v3_fn_name : str , path : Union [bytes , str ]) -> tuple [Union [int , ChecksumAddress ], ...]:
170167 """
171168 Decode a V3 router path
172169
@@ -180,8 +177,8 @@ def v3_path(v3_fn_name: str, path: Union[bytes, str]) -> Tuple[Union[int, Checks
180177 raise ValueError (f"v3_fn_name must be in { valid_fn_names } " )
181178 path_str = path .hex () if isinstance (path , bytes ) else str (path )
182179 path_str = path_str [2 :] if path_str .startswith ("0x" ) else path_str
183- path_list : List [Union [int , ChecksumAddress ]] = [Web3 .to_checksum_address (path_str [0 :40 ]), ]
184- parsed_remaining_path : List [ List [Union [int , ChecksumAddress ]]] = [
180+ path_list : list [Union [int , ChecksumAddress ]] = [Web3 .to_checksum_address (path_str [0 :40 ]), ]
181+ parsed_remaining_path : list [ list [Union [int , ChecksumAddress ]]] = [
185182 [
186183 int (path_str [40 :][i :i + 6 ], 16 ),
187184 Web3 .to_checksum_address (path_str [40 :][i + 6 :i + 46 ]),
@@ -199,7 +196,7 @@ def contract_error(
199196 self ,
200197 contract_error : Union [str , HexStr ],
201198 abis : Sequence [str ] = (_permit2_abi , _pool_manager_abi , _position_manager_abi , _router_abi ),
202- ) -> Tuple [str , Dict [str , Any ]]:
199+ ) -> tuple [str , dict [str , Any ]]:
203200 """
204201 Decode contract custom errors.
205202
0 commit comments