Repository: ethereum/web3.py

Issue:
Standardize `apply_formatter_to_array` 
* Version: v6

### What was wrong?

The eth-utils and web3 `apply_formatter_to_array` functions are slightly different. We should standardize on one or the other (probably the eth-utils version). The `apply_formatter_to_array` function in web3 converts the return value to an array and the eth-utils version does not.



Discussion:
if the desire is to standardize on one should we just remove apply_formatter_to_array from web3 and utilize the one from eth-utils?

Resolving patch:
diff --git a/web3/_utils/formatters.py b/web3/_utils/formatters.py
--- a/web3/_utils/formatters.py
+++ b/web3/_utils/formatters.py
@@ -6,7 +6,6 @@
     Callable,
     Dict,
     Iterable,
-    Sequence,
     Tuple,
     TypeVar,
 )
@@ -19,7 +18,6 @@
     is_list_like,
     is_string,
     to_dict,
-    to_list,
 )
 from eth_utils.curried import (
     apply_formatter_at_index,
@@ -56,15 +54,6 @@ def apply_formatters_to_args(
     )
 
 
-@curry
-@to_list
-def apply_formatter_to_array(
-    formatter: Callable[[TValue], TReturn], value: Sequence[TValue]
-) -> Iterable[TReturn]:
-    for item in value:
-        yield formatter(item)
-
-
 def map_collection(func: Callable[..., TReturn], collection: Any) -> Any:
     """
     Apply func to each element of a collection, or value of a dictionary.
diff --git a/web3/providers/eth_tester/middleware.py b/web3/providers/eth_tester/middleware.py
--- a/web3/providers/eth_tester/middleware.py
+++ b/web3/providers/eth_tester/middleware.py
@@ -30,7 +30,6 @@
 )
 
 from web3._utils.formatters import (
-    apply_formatter_to_array,
     apply_formatters_to_args,
     apply_key_map,
     hex_to_integer,
@@ -38,6 +37,9 @@
     is_array_of_dicts,
     static_return,
 )
+from web3._utils.method_formatters import (
+    apply_list_to_array_formatter,
+)
 from web3.middleware import (
     construct_formatting_middleware,
 )
@@ -88,8 +90,8 @@ def is_hexstr(value: Any) -> bool:
     "nonce": to_integer_if_hex,
     "maxFeePerGas": to_integer_if_hex,
     "maxPriorityFeePerGas": to_integer_if_hex,
-    "accessList": apply_formatter_to_array(
-        apply_key_map({"storageKeys": "storage_keys"})
+    "accessList": apply_list_to_array_formatter(
+        (apply_key_map({"storageKeys": "storage_keys"}))
     ),
 }
 transaction_request_formatter = apply_formatters_to_dict(TRANSACTION_REQUEST_FORMATTERS)
@@ -142,7 +144,7 @@ def is_hexstr(value: Any) -> bool:
 
 TRANSACTION_RESULT_FORMATTERS = {
     "to": apply_formatter_if(partial(operator.eq, ""), static_return(None)),
-    "access_list": apply_formatter_to_array(
+    "access_list": apply_list_to_array_formatter(
         apply_key_map({"storage_keys": "storageKeys"}),
     ),
 }
@@ -189,7 +191,7 @@ def is_hexstr(value: Any) -> bool:
 
 
 RECEIPT_RESULT_FORMATTERS = {
-    "logs": apply_formatter_to_array(log_result_remapper),
+    "logs": apply_list_to_array_formatter(log_result_remapper),
 }
 receipt_result_formatter = apply_formatters_to_dict(RECEIPT_RESULT_FORMATTERS)
 
@@ -285,15 +287,15 @@ def is_hexstr(value: Any) -> bool:
     RPCEndpoint("eth_newPendingTransactionFilter"): integer_to_hex,
     RPCEndpoint("eth_getLogs"): apply_formatter_if(
         is_array_of_dicts,
-        apply_formatter_to_array(log_result_remapper),
+        apply_list_to_array_formatter(log_result_remapper),
     ),
     RPCEndpoint("eth_getFilterChanges"): apply_formatter_if(
         is_array_of_dicts,
-        apply_formatter_to_array(log_result_remapper),
+        apply_list_to_array_formatter(log_result_remapper),
     ),
     RPCEndpoint("eth_getFilterLogs"): apply_formatter_if(
         is_array_of_dicts,
-        apply_formatter_to_array(log_result_remapper),
+        apply_list_to_array_formatter(log_result_remapper),
     ),
     # EVM
     RPCEndpoint("evm_snapshot"): integer_to_hex,


Test patch: