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

Add setter for self._web3 in SlitherReadStorage #1839

Closed
wants to merge 2 commits into from

Conversation

webthethird
Copy link
Contributor

@webthethird webthethird commented Apr 13, 2023

Adds setter for self._web3 in SlitherReadStorage for more flexibility using SRS in other tools.

SlitherReadStorage._web3 depends on SlitherReadStorage.rpc, which is not protected, so it would seem simple enough to just set the RPC if we want to set up our own Web3 provider.

However, in my project I already have a Web3 provider created, and I need to do the following to handle PoA networks:

        # Workaround for PoA networks
        if is_poa:
            self._w3.middleware_onion.inject(geth_poa_middleware, layer=0)

I would then like to set srs.web3 = self._w3 so that subsequent calls to srs.get_slot_values will work with PoA networks.

I suppose the alternative is for my program to store is_poa for later, and then do the following, though this is only necessary because there is no srs.web3 setter:

        srs.rpc = self._rpc_provider
        if self._is_poa:
            srs.web3.middleware_onion.inject(geth_poa_middleware, layer=0)

for more flexibility using SRS in other tools
@@ -79,6 +79,10 @@ def web3(self) -> Web3:
self._web3 = Web3(Web3.HTTPProvider(self.rpc))
return self._web3

@web3.setter
def web3(self, web3: Web3):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add -> None ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@webthethird
Copy link
Contributor Author

I believe we are going a different direction with #1843

@webthethird webthethird deleted the dev-srs-web3-setter branch April 27, 2023 16:31
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.

2 participants