Skip to content

fix asyncweb3 #112

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

fix asyncweb3 #112

wants to merge 3 commits into from

Conversation

wakamex
Copy link

@wakamex wakamex commented Mar 22, 2025

use middleware or middlewares argument as appropriate for the Web3py version

fixes: #110

@DefiDebauchery
Copy link
Contributor

DefiDebauchery commented Mar 22, 2025

This depends on what version of web3py that @BobTheBuidler wants to target. The middlewares kwarg was changed in 7.0 and there are a number of people still using v6.

I would like to see some modernization of this library for Python itself, but web3py v7 has introduced a lot of changes throughout that people may not be prepared to upgrade.

@wakamex
Copy link
Author

wakamex commented Mar 22, 2025

you're quick! what do you think about this?

# AsyncWeb3 switched to middleware instead of middlewares
# check if AsyncWeb3 has a middleware parameter
if hasattr(AsyncWeb3, "middleware"):
    async_w3 = AsyncWeb3(provider=provider, middleware=middlewares)
else:
    async_w3 = AsyncWeb3(provider=provider, middlewares=middlewares)

@BobTheBuidler
Copy link
Collaborator

Just specify in the docstring which web3py version(s) the change is for and then I'll merge. Thanks for this!

@wakamex
Copy link
Author

wakamex commented Mar 27, 2025

source for the change being v7.0.0-beta.2 (2024-03-11): https://web3py.readthedocs.io/en/stable/release_notes.html

@wakamex
Copy link
Author

wakamex commented Mar 27, 2025

if you're willing to bump the minimum web3py dependency to v7.0.0-beta.2 (or higher) then you can remove some of the AsyncWeb3 workarounds I think, like this one that does the if AsyncWeb3 check #102

@BobTheBuidler
Copy link
Collaborator

BobTheBuidler commented Apr 3, 2025

I prefer to keep the deps as loose as possible here and leave that choice to the user. The above workaround is fine, this code does not run in tight loops as it is so efficiency isn't a huge deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AsyncWeb3 problem
3 participants