-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Include web3 middleware in ENS.fromWeb3() #2239
Include web3 middleware in ENS.fromWeb3() #2239
Conversation
5519282
to
80f4216
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚢
- Feature: Add ``middlewares`` property to ``NamedElementOnion`` / ``web3.middleware_onion`` which returns all middlewares, as (middleware, name) tuples, in appropriate order to be imported into a new Web3 instance. - Bugfix: Include the middlewares from the web3 instance passed into ENS.fromWeb3(). This allows geth_poa_middleware to be used as it is currently expected to be used.
80f4216
to
633fc7d
Compare
self, provider: 'BaseProvider' = cast('BaseProvider', default), addr: ChecksumAddress = None | ||
self, | ||
provider: 'BaseProvider' = cast('BaseProvider', default), | ||
middlewares: Optional[Sequence[Tuple['Middleware', str]]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change if someone was passing the address as the second param without the keyword before. Is it important for middlewares to be the second arg? Sorry I wasn't there for the review yesterday!
Note that now I do get an exception in my code that I did not get before, see partial stack here (
I seem to only get this problem with the ENS lookup, not with using the normal Web3 object with the caching middleware. |
What was wrong?
From recent comments on issue #425:
ENS.fromWeb3()
does not make use of existing middlewares present in theWeb3
instance that is passed in to the method. This led to issues usinggeth_poa_middleware
.Closes #1657
How was it fixed?
Web3
instance's middlewares when instantiating theENS
instance from aWeb3
instance.middlewares
property to theNamedElementOnion
data structure /web3.middleware_onion
that returns a list of all current middlewares in appropriate order to be passed in to a newWeb3
instance.Todo:
Cute Animal Picture