Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed concise and implicit contract #2505

Merged
merged 3 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 1 addition & 55 deletions docs/contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ Contract Factories

These factories are not intended to be initialized directly.
Instead, create contract objects using the :meth:`w3.eth.contract() <web3.eth.Eth.contract>`
method. By default, the contract factory is :class:`Contract`. See the
example in :class:`ConciseContract` for specifying an alternate factory.
method. By default, the contract factory is :class:`Contract`.

.. py:class:: Contract(address)

Expand All @@ -118,59 +117,6 @@ example in :class:`ConciseContract` for specifying an alternate factory.

The address parameter can be a hex address or an ENS name, like ``mycontract.eth``.

.. py:class:: ConciseContract(Contract())

.. warning:: Deprecated: This method is deprecated in favor of the :class:`~ContractCaller` API
or the verbose syntax

This variation of :class:`Contract` is designed for more succinct read access,
without making write access more wordy. This comes at a cost of losing
access to features like ``deploy()`` and properties like ``address``. It is
recommended to use the classic ``Contract`` for those use cases.
Just to be be clear, `ConciseContract` only exposes contract functions and all
other `Contract` class methods and properties are not available with the `ConciseContract`
API. This includes but is not limited to ``contract.address``, ``contract.abi``, and
``contract.deploy()``.

Create this type of contract by passing a :py:class:`Contract` instance to
:class:`ConciseContract`:


.. code-block:: python

>>> concise = ConciseContract(myContract)


This variation invokes all methods as a call, so if the classic contract had a method like
``contract.functions.owner().call()``, you could call it with ``concise.owner()`` instead.

For access to send a transaction or estimate gas, you can add a keyword argument like so:


.. code-block:: python

>>> concise.withdraw(amount, transact={'from': eth.accounts[1], 'gas': 100000, ...})

>>> # which is equivalent to this transaction in the classic contract:

>>> contract.functions.withdraw(amount).transact({'from': eth.accounts[1], 'gas': 100000, ...})

.. py:class:: ImplicitContract(Contract())

.. warning:: Deprecated: This method is deprecated in favor of the verbose syntax

This variation mirrors :py:class:`ConciseContract`, but it invokes all methods as a
transaction rather than a call, so if the classic contract had a method like
``contract.functions.owner.transact()``, you could call it with ``implicit.owner()`` instead.

Create this type of contract by passing a :py:class:`Contract` instance to
:class:`ImplicitContract`:


.. code-block:: python

>>> concise = ImplicitContract(myContract)


Properties
----------
Expand Down
9 changes: 1 addition & 8 deletions docs/web3.eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1451,11 +1451,4 @@ Contracts
.. py:method:: Eth.set_contract_factory(contractFactoryClass)

Modify the default contract factory from ``Contract`` to ``contractFactoryClass``.
Future calls to ``Eth.contract()`` will then default to ``contractFactoryClass``.

An example of an alternative Contract Factory is ``ConciseContract``.

.. py:method:: Eth.setContractFactory(contractFactoryClass)

.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.eth.Eth.set_contract_factory()`
Future calls to ``Eth.contract()`` will then default to ``contractFactoryClass``.
1 change: 1 addition & 0 deletions newsfragments/2505.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed ConciseContract and ImplicitContract from contract.
137 changes: 0 additions & 137 deletions tests/core/contracts/test_concise_contract.py

This file was deleted.

119 changes: 0 additions & 119 deletions tests/core/contracts/test_implicit_contract.py

This file was deleted.

Loading