diff --git a/newsfragments/2941.bugfix.rst b/newsfragments/2941.bugfix.rst new file mode 100644 index 0000000000..2edefe319a --- /dev/null +++ b/newsfragments/2941.bugfix.rst @@ -0,0 +1 @@ +Add check for null withdrawal field on get_block response diff --git a/web3/_utils/method_formatters.py b/web3/_utils/method_formatters.py index 89a941386c..dbc3aa1274 100644 --- a/web3/_utils/method_formatters.py +++ b/web3/_utils/method_formatters.py @@ -297,7 +297,9 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]: ) ), "transactionsRoot": apply_formatter_if(is_not_null, to_hexbytes(32)), - "withdrawals": apply_formatter_to_array(withdrawal_result_formatter), + "withdrawals": apply_formatter_if( + is_not_null, apply_list_to_array_formatter(withdrawal_result_formatter) + ), "withdrawalsRoot": apply_formatter_if(is_not_null, to_hexbytes(32)), }