You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix initialization of Contract function and events (#3540)
* Do not invoke ``ens`` until it is actually used:
- ``web3.ens`` invokes the ``@property`` getter on ``ens``. This
getter sets ``self._ens`` on the ``web3`` object if it is empty.
We do not need to do invoke this getter until ``ens`` is actually
called. Instead, use the pointer to ``self._ens`` directly to avoid
overhead when the majority of uses may not even be using ENS.
* DRY contract function instantiation:
- When initializing a contract, we create the ``ContractFunction`` objects
for each function and assign them to the ``contract.functions`` attribute.
Then we instantiate the ``contract.caller`` and inside the ``ContractCaller``
init, we re-instantiate each contract function. Pass these around instead
which will prevent so many calls for validation. They are already built,
so there is no reason to build them again.
* Async changes related to 999ef9a
* Silence some warnings on wrong type expectations.
* Try using self inside ContractFunction __call__():
- Instead of re-building the ``ContractFunction`` object, use the
already existing ``self`` object reference.
* Remove seting `abi` on the clone since it already contains it.
* Call contract function using the instance properly to prevent ambiguous errors.
Add fixture contract with ambiguous functions and arguments.
* ContractFuncion `__call__` now uses self unless it does not match the arguments.
Initialize ContractFunction and ContractEvent with `signature`.
Create ContractFunctions with properties for the function name and also private properties with each function signature
Create ContractEvents with properties for the event name and also private properties with each event signature
* Use built contract functions for async contract caller init; add tests
- Pass the already built contract functions in the contract init when
initializing the contract caller for ``AsyncContract``.
- Add reasonable init time test for ``Contract`` and ``AsyncContract`` so
that we know when code deviates from the expected performance.
* Corrections based on feedback
* Document functions and events for latest changes.
Include comments for overloaded functions with similar arguments.
* Newsfragment for #3540
---------
Co-authored-by: Stuart Reed <[email protected]>
Execute the specified function by sending a new public transaction.
@@ -1040,12 +1096,10 @@ Fallback Function
1040
1096
1041
1097
Builds a transaction dictionary based on the contract fallback function call.
1042
1098
1043
-
Events
1044
-
------
1045
-
1046
-
.. py:class:: ContractEvents
1099
+
Contract Events
1100
+
---------------
1047
1101
1048
-
The named events exposed through the :py:attr:`Contract.events` property are of the ContractEvents type. This class is not to be used directly, but instead through :py:attr:`Contract.events`.
1102
+
The named events exposed through the :py:attr:`Contract.events` property are of the ContractEvent type. This class is not to be used directly, but instead through :py:attr:`Contract.events`.
:py:class:`ContractEvent` provides methods to interact with contract events. Positional and keyword arguments supplied to the contract event subclass will be used to find the contract event by signature.
Similar to process_receipt_, but only processes one log at a time, instead of a whole transaction receipt.
1165
1257
Will return a single :ref:`Event Log Object <event-log-object>` if there are no errors encountered during processing. If an error is encountered during processing, it will be raised.
Contract functions and events no longer initialize for each call. Retrieval of overloaded functions and events is now deterministic. Any ambiguity will result in an exception being raised.
0 commit comments