Skip to content

Commit 3611782

Browse files
committed
rebase to main and clear remaining issues
1 parent a0ba33a commit 3611782

File tree

7 files changed

+19
-35
lines changed

7 files changed

+19
-35
lines changed

newsfragments/3414.internal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Run ``mypy`` locally using ``pre-commit`` hook, instead of within ``pre-commit`` container

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
install_requires=[
6464
"aiohttp>=3.7.4.post0",
6565
"eth-abi>=5.0.1",
66-
"eth-account>=0.12.2",
66+
"eth-account>=0.13.1",
6767
"eth-hash[pycryptodome]>=0.5.1",
6868
"eth-typing>=5.0.0b1",
6969
"eth-utils>=5.0.0b1",

web3/_utils/events.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ def _log_entry_data_to_bytes(
113113
def construct_event_topic_set(
114114
event_abi: ABIEvent,
115115
abi_codec: ABICodec,
116-
arguments: Optional[Union[Sequence[Any], Dict[str, Any]]] = None,
116+
arguments: Optional[Union[List[Any], Tuple[Any], Dict[str, Any]]] = None,
117117
) -> List[HexStr]:
118118
if arguments is None:
119119
arguments = {}
120-
if isinstance(arguments, (list, tuple)):
120+
elif isinstance(arguments, (list, tuple)):
121121
if len(arguments) != len(event_abi["inputs"]):
122122
raise Web3ValueError(
123123
"When passing an argument list, the number of arguments must "
@@ -127,14 +127,12 @@ def construct_event_topic_set(
127127
arg["name"]: [arg_value]
128128
for arg, arg_value in zip(event_abi["inputs"], arguments)
129129
}
130-
131130
normalized_args = {
132131
key: value if is_list_like(value) else [value]
133-
# type ignored b/c arguments is always a dict at this point
134-
for key, value in arguments.items() # type: ignore
132+
for key, value in arguments.items()
135133
}
136134

137-
event_topic = encode_hex(event_abi_to_log_topic(cast(Dict[str, Any], event_abi)))
135+
event_topic = encode_hex(event_abi_to_log_topic(event_abi))
138136
indexed_args = get_indexed_event_inputs(event_abi)
139137
zipped_abi_and_args = [
140138
(arg, normalized_args.get(arg["name"], [None])) for arg in indexed_args
@@ -475,7 +473,7 @@ async def deploy(self, async_w3: "AsyncWeb3") -> "AsyncLogFilter":
475473

476474
def initialize_event_topics(event_abi: ABIEvent) -> Union[bytes, List[Any]]:
477475
if event_abi["anonymous"] is False:
478-
return event_abi_to_log_topic(cast(Dict[str, Any], event_abi))
476+
return event_abi_to_log_topic(event_abi)
479477
else:
480478
return list()
481479

web3/_utils/filters.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
Sequence,
1111
Tuple,
1212
Union,
13-
cast,
1413
)
1514

1615
from eth_abi.codec import (
@@ -79,9 +78,9 @@ def construct_event_filter_params(
7978
address: Optional[ChecksumAddress] = None,
8079
) -> Tuple[List[List[Optional[HexStr]]], FilterParams]:
8180
filter_params: FilterParams = {}
82-
topic_set: Union[
83-
Sequence[HexStr], Sequence[Sequence[HexStr]]
84-
] = construct_event_topic_set(event_abi, abi_codec, argument_filters)
81+
topic_set: Sequence[HexStr] = construct_event_topic_set(
82+
event_abi, abi_codec, argument_filters
83+
)
8584

8685
if topics is not None:
8786
if len(topic_set) > 1:
@@ -91,10 +90,7 @@ def construct_event_filter_params(
9190
)
9291
topic_set = topics
9392

94-
if len(topic_set) == 1 and is_list_like(topic_set[0]):
95-
filter_params["topics"] = cast(Sequence[HexStr], topic_set[0])
96-
else:
97-
filter_params["topics"] = topic_set
93+
filter_params["topics"] = topic_set
9894

9995
if address and contract_address:
10096
if is_list_like(address):

web3/contract/base_contract.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,9 @@ def get_function_by_selector(
830830
self, selector: Union[bytes, int, HexStr]
831831
) -> "BaseContractFunction":
832832
def callable_check(fn_abi: ABIFunction) -> bool:
833-
return encode_hex(
834-
function_abi_to_4byte_selector(cast(Dict[str, Any], fn_abi))
835-
) == to_4byte_hex(selector)
833+
return encode_hex(function_abi_to_4byte_selector(fn_abi)) == to_4byte_hex(
834+
selector
835+
)
836836

837837
fns = self.find_functions_by_identifier(
838838
self.abi, self.w3, self.address, callable_check

web3/contract/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
from web3.types import (
6262
ABIElementIdentifier,
6363
BlockIdentifier,
64+
RPCEndpoint,
6465
StateOverride,
6566
TContractFn,
6667
TxParams,
@@ -227,7 +228,7 @@ def call_contract_function(
227228
)
228229
normalized_data = map_abi_data(_normalizers, output_types, output_data)
229230

230-
if decode_tuples:
231+
if decode_tuples and abi_callable["type"] == "function":
231232
decoded = named_tree(abi_callable["outputs"], normalized_data)
232233
normalized_data = recursive_dict_to_namedtuple(decoded)
233234

@@ -438,7 +439,6 @@ async def async_call_contract_function(
438439
current_request_id, contract_call_return_data_formatter
439440
)
440441
else:
441-
# request_information == ((method, params), response_formatters)
442442
BatchingReturnData: TypeAlias = Tuple[
443443
Tuple[RPCEndpoint, Any], Tuple[Any, ...]
444444
]

web3/middleware/signing.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
TYPE_CHECKING,
77
Any,
88
Collection,
9-
Dict,
109
Iterable,
11-
Sequence,
1210
Tuple,
1311
TypeVar,
1412
Union,
@@ -21,6 +19,9 @@
2119
from eth_account.signers.local import (
2220
LocalAccount,
2321
)
22+
from eth_account.types import (
23+
TransactionDictType as EthAccountTxParams,
24+
)
2425
from eth_keys.datatypes import (
2526
PrivateKey,
2627
)
@@ -46,9 +47,6 @@
4647
async_fill_nonce,
4748
async_fill_transaction_defaults,
4849
)
49-
from web3._utils.compat import (
50-
TypeAlias,
51-
)
5250
from web3._utils.method_formatters import (
5351
STANDARD_NORMALIZERS,
5452
)
@@ -216,15 +214,6 @@ async def async_request_processor(self, method: "RPCEndpoint", params: Any) -> A
216214
return method, params
217215
else:
218216
account = self._accounts[to_checksum_address(tx_from)]
219-
EthAccountTxParams: TypeAlias = Dict[
220-
str,
221-
Union[
222-
Sequence[Dict[str, Union[HexStr, Sequence[HexStr]]]],
223-
bytes,
224-
HexStr,
225-
int,
226-
],
227-
]
228217
raw_tx = account.sign_transaction(
229218
cast(EthAccountTxParams, filled_transaction)
230219
).raw_transaction

0 commit comments

Comments
 (0)