diff --git a/docs/contracts.rst b/docs/contracts.rst index b2e51ad935..b445624738 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -244,11 +244,6 @@ Each Contract Factory exposes the following methods. >>> txn_receipt['contractAddress'] '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318' -.. py:classmethod:: Contract.constructor(*args, **kwargs).estimateGas(transaction=None, block_identifier=None) - :noindex: - - .. warning:: Deprecated: This method is deprecated in favor of :py:meth:`Contract.constructor(*args, **kwargs).estimate_gas` - .. py:classmethod:: Contract.constructor(*args, **kwargs).estimate_gas(transaction=None, block_identifier=None) :noindex: @@ -272,11 +267,6 @@ Each Contract Factory exposes the following methods. >>> token_contract.constructor(web3.eth.coinbase, 12345).estimate_gas() 12563 -.. py:classmethod:: Contract.constructor(*args, **kwargs).buildTransaction(transaction=None) - :noindex: - - .. warning:: Deprecated: This method is deprecated in favor of :py:meth:`Contract.constructor(*args, **kwargs).build_transaction` - .. py:classmethod:: Contract.constructor(*args, **kwargs).build_transaction(transaction=None) :noindex: @@ -843,10 +833,6 @@ Methods a "missing trie node" error, because Ethereum node may have purged the past state from its database. `More information about archival nodes here `_. -.. py:method:: ContractFunction.estimateGas(transaction, block_identifier=None) - - .. warning:: Deprecated: This method is deprecated in favor of :class:`~estimate_gas` - .. py:method:: ContractFunction.estimate_gas(transaction, block_identifier=None) Call a contract function, executing the transaction locally using the @@ -874,10 +860,6 @@ Methods The parameter ``block_identifier`` is not enabled in geth nodes, hence passing a value of ``block_identifier`` when connected to a geth nodes would result in an error like: ``ValueError: {'code': -32602, 'message': 'too many arguments, want at most 1'}`` - -.. py:method:: ContractFunction.buildTransaction(transaction) - - .. warning:: Deprecated: This method is deprecated in favor of :class:`~build_transaction` .. py:method:: ContractFunction.build_transaction(transaction) @@ -941,7 +923,7 @@ Fallback Function Call fallback function, executing the transaction locally using the ``eth_call`` API. This will not create a new public transaction. -.. py:method:: Contract.fallback.estimateGas(transaction) +.. py:method:: Contract.fallback.estimate_gas(transaction) Call fallback function and return the gas estimation. @@ -949,7 +931,7 @@ Fallback Function Execute fallback function by sending a new public transaction. -.. py:method:: Contract.fallback.buildTransaction(transaction) +.. py:method:: Contract.fallback.build_transaction(transaction) Builds a transaction dictionary based on the contract fallback function call. diff --git a/docs/examples.rst b/docs/examples.rst index 83d41a6ee7..7488ba2b44 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -361,7 +361,7 @@ The following example demonstrates a few things: store_var_contract = w3.eth.contract(address=address, abi=contract_interface["abi"]) - gas_estimate = store_var_contract.functions.setVar(255).estimateGas() + gas_estimate = store_var_contract.functions.setVar(255).estimate_gas() print(f'Gas estimate to transact with setVar: {gas_estimate}') if gas_estimate < 100000: @@ -674,7 +674,7 @@ Just remember that you have to sign all transactions locally, as infura does not .. code-block:: python - transaction = contract.functions.function_Name(params).buildTransaction() + transaction = contract.functions.function_Name(params).build_transaction() transaction.update({ 'gas' : appropriate_gas_amount }) transaction.update({ 'nonce' : w3.eth.get_transaction_count('Your_Wallet_Address') }) signed_tx = w3.eth.account.sign_transaction(transaction, private_key) diff --git a/docs/web3.eth.account.rst b/docs/web3.eth.account.rst index a331c3b733..12e8d7872b 100644 --- a/docs/web3.eth.account.rst +++ b/docs/web3.eth.account.rst @@ -356,7 +356,7 @@ To sign a transaction locally that will invoke a smart contract: >>> unicorn_txn = unicorns.functions.transfer( ... '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', ... 1, - ... ).buildTransaction({ + ... ).build_transaction({ ... 'chainId': 1, ... 'gas': 70000, ... 'maxFeePerGas': w3.toWei('2', 'gwei'), diff --git a/web3/contract.py b/web3/contract.py index 8f89202685..8822ebd78e 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -868,22 +868,6 @@ def build_transaction(self, transaction: Optional[TxParams] = None) -> TxParams: built_transaction = self._build_transaction(transaction) return transactions.fill_transaction_defaults(self.w3, built_transaction) - @combomethod - @deprecated_for("build_transaction") - def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: - """ - Build the transaction dictionary without sending - """ - return self.build_transaction(transaction) - - @combomethod - @deprecated_for("estimate_gas") - def estimateGas( - self, transaction: Optional[TxParams] = None, - block_identifier: Optional[BlockIdentifier] = None - ) -> int: - return self.estimate_gas(transaction, block_identifier) - @combomethod def estimate_gas( self, transaction: Optional[TxParams] = None, @@ -924,7 +908,7 @@ async def estimate_gas( class ConciseMethod: - ALLOWED_MODIFIERS = {'call', 'estimateGas', 'transact', 'buildTransaction'} + ALLOWED_MODIFIERS = {'call', 'estimate_gas', 'transact', 'build_transaction'} def __init__( self, function: 'ContractFunction', @@ -1178,9 +1162,9 @@ def _estimate_gas( estimate_gas_transaction = cast(TxParams, dict(**transaction)) if 'data' in estimate_gas_transaction: - raise ValueError("Cannot set 'data' field in estimateGas transaction") + raise ValueError("Cannot set 'data' field in estimate_gas transaction") if 'to' in estimate_gas_transaction: - raise ValueError("Cannot set to in estimateGas transaction") + raise ValueError("Cannot set to in estimate_gas transaction") if self.address: estimate_gas_transaction.setdefault('to', self.address) @@ -1191,7 +1175,7 @@ def _estimate_gas( if 'to' not in estimate_gas_transaction: if isinstance(self, type): raise ValueError( - "When using `Contract.estimateGas` from a contract factory " + "When using `Contract.estimate_gas` from a contract factory " "you must provide a `to` address with the transaction" ) else: @@ -1211,7 +1195,7 @@ def _build_transaction(self, transaction: Optional[TxParams] = None) -> TxParams if not self.address and 'to' not in built_transaction: raise ValueError( - "When using `ContractFunction.buildTransaction` from a contract factory " + "When using `ContractFunction.build_transaction` from a contract factory " "you must provide a `to` address with the transaction" ) if self.address and 'to' in built_transaction: @@ -1339,13 +1323,6 @@ def estimate_gas( **self.kwargs ) - @deprecated_for("estimate_gas") - def estimateGas( - self, transaction: Optional[TxParams] = None, - block_identifier: Optional[BlockIdentifier] = None - ) -> int: - return self.estimate_gas(transaction, block_identifier) - def build_transaction(self, transaction: Optional[TxParams] = None) -> TxParams: built_transaction = self._build_transaction(transaction) @@ -1360,10 +1337,6 @@ def build_transaction(self, transaction: Optional[TxParams] = None) -> TxParams: **self.kwargs ) - @deprecated_for("build_transaction") - def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: - return self.build_transaction(transaction) - class AsyncContractFunction(BaseContractFunction): @@ -2224,7 +2197,7 @@ def estimate_gas_for_function( **kwargs: Any) -> int: """Estimates gas cost a function call would take. - Don't call this directly, instead use :meth:`Contract.estimateGas` + Don't call this directly, instead use :meth:`Contract.estimate_gas` on your contract instance. """ estimate_transaction = prepare_transaction( @@ -2253,7 +2226,7 @@ async def async_estimate_gas_for_function( **kwargs: Any) -> int: """Estimates gas cost a function call would take. - Don't call this directly, instead use :meth:`Contract.estimateGas` + Don't call this directly, instead use :meth:`Contract.estimate_gas` on your contract instance. """ estimate_transaction = prepare_transaction( @@ -2281,7 +2254,7 @@ def build_transaction_for_function( **kwargs: Any) -> TxParams: """Builds a dictionary with the fields required to make the given transaction - Don't call this directly, instead use :meth:`Contract.buildTransaction` + Don't call this directly, instead use :meth:`Contract.build_transaction` on your contract instance. """ prepared_transaction = prepare_transaction( @@ -2311,7 +2284,7 @@ async def async_build_transaction_for_function( **kwargs: Any) -> TxParams: """Builds a dictionary with the fields required to make the given transaction - Don't call this directly, instead use :meth:`Contract.buildTransaction` + Don't call this directly, instead use :meth:`Contract.build_transaction` on your contract instance. """ prepared_transaction = prepare_transaction(