Repository: ethereum/web3.py

Issue:
Rename `encodeABI` in base_contract
### What was wrong?

Method doesn't follow standard Python conventions, should be `encode_abi`.

### How can it be fixed?

Deprecate in v6.
For v7, rename the class method and update references.

Discussion:

Patch:
diff --git a/docs/overview.rst b/docs/overview.rst
index e1ed45bd..8f707733 100644
--- a/docs/overview.rst
+++ b/docs/overview.rst
@@ -269,7 +269,7 @@ API
 - :attr:`Contract.events <web3.contract.Contract.events>`
 - :attr:`Contract.fallback <web3.contract.Contract.fallback.call>`
 - :meth:`Contract.constructor() <web3.contract.Contract.constructor>`
-- :meth:`Contract.encodeABI() <web3.contract.Contract.encodeABI>`
+- :meth:`Contract.encode_abi() <web3.contract.Contract.encode_abi>`
 - :attr:`web3.contract.ContractFunction <web3.contract.ContractFunction>`
 - :attr:`web3.contract.ContractEvents <web3.contract.ContractEvents>`
 
diff --git a/docs/v7_migration.rst b/docs/v7_migration.rst
index 9cd24be0..22105f6a 100644
--- a/docs/v7_migration.rst
+++ b/docs/v7_migration.rst
@@ -9,6 +9,12 @@ project depends on web3.py ``v7``, you'll probably need to make some changes.
 
 Breaking Changes:
 
+Middlewares -> Middleware
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+All references to ``middlewares`` have been replaced with the more grammatically
+correct ``middleware``. Notably, this includes when a provider needs to be
+instantiated with custom middleware.
 
 Class-Based Middleware Model
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -148,3 +154,4 @@ Miscellaneous Changes
 - ``get_default_ipc_path()`` and ``get_dev_ipc_path()`` now return the path value
   without checking if the ``geth.ipc`` file exists.
 - ``Web3.is_address()`` returns ``True`` for non-checksummed addresses.
+- ``Contract.encodeABI()`` has been renamed to ``Contract.encode_abi()``.
diff --git a/docs/web3.contract.rst b/docs/web3.contract.rst
index f5082e29..776f8df6 100644
--- a/docs/web3.contract.rst
+++ b/docs/web3.contract.rst
@@ -301,18 +301,18 @@ Each Contract Factory exposes the following methods.
         filter_builder.fromBlock = "latest"
         filter_builder.fromBlock = 0  # raises a ValueError
 
+.. py:classmethod:: Contract.encode_abi(fn_name, args=None, kwargs=None, data=None)
 
-.. py:classmethod:: Contract.encodeABI(fn_name, args=None, kwargs=None, data=None)
+    Encodes the arguments using the Ethereum ABI for the contract function that
+    matches the given ``fn_name`` and arguments ``args``. The ``data`` parameter
+    defaults to the function selector.
 
-   Encodes the arguments using the Ethereum ABI for the contract function that
-   matches the given ``fn_name`` and arguments ``args``. The ``data`` parameter
-   defaults to the function selector.
-
-   .. code-block:: python
+    .. code-block:: python
 
-      >>> contract.encodeABI(fn_name="register", args=["rainbows", 10])
+      >>> contract.encode_abi(fn_name="register", args=["rainbows", 10])
       "0xea87152b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000087261696e626f7773000000000000000000000000000000000000000000000000"
 
+
 .. py:classmethod:: Contract.all_functions()
 
     Returns a list of all the functions present in a Contract where every function is
diff --git a/ens/async_ens.py b/ens/async_ens.py
index 0e870802..761502ed 100644
--- a/ens/async_ens.py
+++ b/ens/async_ens.py
@@ -490,7 +490,7 @@ class AsyncENS(BaseENS):
         ):
             contract_func_with_args = (fn_name, [node])
 
-            calldata = resolver.encodeABI(*contract_func_with_args)
+            calldata = resolver.encode_abi(*contract_func_with_args)
             contract_call_result = await resolver.caller.resolve(
                 ens_encode_name(normal_name),
                 calldata,
diff --git a/ens/ens.py b/ens/ens.py
index a2793774..c427d9d9 100644
--- a/ens/ens.py
+++ b/ens/ens.py
@@ -477,7 +477,7 @@ class ENS(BaseENS):
         if _resolver_supports_interface(resolver, ENS_EXTENDED_RESOLVER_INTERFACE_ID):
             contract_func_with_args = (fn_name, [node])
 
-            calldata = resolver.encodeABI(*contract_func_with_args)
+            calldata = resolver.encode_abi(*contract_func_with_args)
             contract_call_result = resolver.caller.resolve(
                 ens_encode_name(normal_name),
                 calldata,
diff --git a/newsfragments/3277.docs.rst b/newsfragments/3277.docs.rst
new file mode 100644
index 00000000..5c2a7651
--- /dev/null
+++ b/newsfragments/3277.docs.rst
@@ -0,0 +1,1 @@
+Add note about middlewares change to v7 migration guide.
diff --git a/newsfragments/3281.removal.rst b/newsfragments/3281.removal.rst
new file mode 100644
index 00000000..38938f34
--- /dev/null
+++ b/newsfragments/3281.removal.rst
@@ -0,0 +1,1 @@
+Remove ``Contract.encodeABI()`` in favor of ``Contract.encode_abi()`` to follow standard conventions.
\ No newline at end of file
diff --git a/web3/contract/base_contract.py b/web3/contract/base_contract.py
index 75c5b5f5..b7f14dfc 100644
--- a/web3/contract/base_contract.py
+++ b/web3/contract/base_contract.py
@@ -723,7 +723,7 @@ class BaseContract:
     #  Public API
     #
     @combomethod
-    def encodeABI(
+    def encode_abi(
         cls,
         fn_name: str,
         args: Optional[Any] = None,


Test patch:
diff --git a/tests/core/contracts/test_contract_method_abi_encoding.py b/tests/core/contracts/test_contract_method_abi_encoding.py
index 470ccc9e..27b76c2a 100644
--- a/tests/core/contracts/test_contract_method_abi_encoding.py
+++ b/tests/core/contracts/test_contract_method_abi_encoding.py
@@ -64,7 +64,7 @@ ABI_D = json.loads(
 )
 def test_contract_abi_encoding(w3, abi, arguments, data, expected):
     contract = w3.eth.contract(abi=abi)
-    actual = contract.encodeABI("a", arguments, data=data)
+    actual = contract.encode_abi("a", arguments, data=data)
     assert actual == expected
 
 
@@ -116,7 +116,7 @@ def test_contract_abi_encoding_non_strict(
     w3_non_strict_abi, abi, arguments, data, expected
 ):
     contract = w3_non_strict_abi.eth.contract(abi=abi)
-    actual = contract.encodeABI("a", arguments, data=data)
+    actual = contract.encode_abi("a", arguments, data=data)
     assert actual == expected
 
 
@@ -128,7 +128,7 @@ def test_contract_abi_encoding_kwargs(w3):
             "0x6f8d2fa18448afbfe4f82143c384484ad09a0271f3a3c0eb9f629e703f883125",
         ],
     }
-    actual = contract.encodeABI("byte_array", kwargs=kwargs)
+    actual = contract.encode_abi("byte_array", kwargs=kwargs)
     assert (
         actual
         == "0xf166d6f8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000025595c210956e7721f9b692e702708556aa9aabb14ea163e96afa56ffbe9fa8096f8d2fa18448afbfe4f82143c384484ad09a0271f3a3c0eb9f629e703f883125"  # noqa: E501
@@ -146,7 +146,7 @@ def test_contract_abi_encoding_kwargs(w3):
 def test_contract_abi_encoding_strict_with_error(w3, arguments):
     contract = w3.eth.contract(abi=ABI_C)
     with pytest.raises(Web3ValidationError):
-        contract.encodeABI("a", arguments, data=None)
+        contract.encode_abi("a", arguments, data=None)
 
 
 @pytest.mark.parametrize(
@@ -195,5 +195,5 @@ def test_contract_abi_encoding_strict_with_error(w3, arguments):
 )
 def test_contract_abi_encoding_strict(w3, abi, arguments, data, expected):
     contract = w3.eth.contract(abi=abi)
-    actual = contract.encodeABI("a", arguments, data=data)
+    actual = contract.encode_abi("a", arguments, data=data)
     assert actual == expected
diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py
index 3651a5ff..613c8250 100644
--- a/web3/_utils/module_testing/eth_module.py
+++ b/web3/_utils/module_testing/eth_module.py
@@ -1336,7 +1336,7 @@ class AsyncEthModuleTest:
         async_revert_contract: "Contract",
         async_unlocked_account: ChecksumAddress,
     ) -> None:
-        data = async_revert_contract.encodeABI(
+        data = async_revert_contract.encode_abi(
             fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
         )
         txn_params = async_revert_contract._prepare_transaction(
@@ -1356,7 +1356,7 @@ class AsyncEthModuleTest:
         async_revert_contract: "Contract",
         async_unlocked_account: ChecksumAddress,
     ) -> None:
-        data = async_revert_contract.encodeABI(fn_name="Unauthorized")
+        data = async_revert_contract.encode_abi(fn_name="Unauthorized")
         txn_params = async_revert_contract._prepare_transaction(
             fn_name="customErrorWithoutMessage",
             transaction={
@@ -3788,7 +3788,7 @@ class EthModuleTest:
         revert_contract: "Contract",
         unlocked_account: ChecksumAddress,
     ) -> None:
-        data = revert_contract.encodeABI(
+        data = revert_contract.encode_abi(
             fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
         )
         txn_params = revert_contract._prepare_transaction(
@@ -3808,7 +3808,7 @@ class EthModuleTest:
         revert_contract: "Contract",
         unlocked_account: ChecksumAddress,
     ) -> None:
-        data = revert_contract.encodeABI(fn_name="Unauthorized")
+        data = revert_contract.encode_abi(fn_name="Unauthorized")
         txn_params = revert_contract._prepare_transaction(
             fn_name="customErrorWithoutMessage",
             transaction={
@@ -4097,7 +4097,7 @@ class EthModuleTest:
         revert_contract: "Contract",
         unlocked_account: ChecksumAddress,
     ) -> None:
-        data = revert_contract.encodeABI(
+        data = revert_contract.encode_abi(
             fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
         )
         txn_params = revert_contract._prepare_transaction(
@@ -4117,7 +4117,7 @@ class EthModuleTest:
         revert_contract: "Contract",
         unlocked_account: ChecksumAddress,
     ) -> None:
-        data = revert_contract.encodeABI(fn_name="Unauthorized")
+        data = revert_contract.encode_abi(fn_name="Unauthorized")
         txn_params = revert_contract._prepare_transaction(
             fn_name="customErrorWithoutMessage",
             transaction={