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 support for external modules to web3 instance #2288

Merged
merged 2 commits into from Jan 5, 2022

Commits on Jan 5, 2022

  1. Add support for external modules to web3 instance

    - added web3.attach_module() to attach a single module to a web3 instance e.g. w3.attach_module('module1', ModuleClass1)
    - added support for initializing the instance with external modules e.g. w3 = Web3(..., external_modules={'module1': ModuleClass1})
    - modules can be passed in without needing to be a tuple or list if they don't contain submodules i.e. pass in the class by itself instead a tuple with 1 argument, (ModuleClass1,)
    - added tests for the above
    - updated docs for web3 main to include usage examples for the above changes
    fselmo committed Jan 5, 2022
    Copy the full SHA
    1190d9d View commit details
    Browse the repository at this point in the history
  2. Changes from comments on PR ethereum#2288

    - Add a test to make sure a tuple with a single module class still works for backwards compatibility.
    - Take out the docstring examples for `attach_modules()` and leave them only in the docs. The consensus is that lengthy docstrings reiterating what is in the documentation would just crowd out our files and make the code harder to read. Instead, we should opt for brief yet useful despritions in the method docstrings.
    - Change the method to allow for a dict as the argument, as is in the constructor, so that multiple modules may be attached if desired.
    - Use the attach_modules utility method as an underscore-aliased internal method for clarity
    fselmo committed Jan 5, 2022
    Copy the full SHA
    95bd986 View commit details
    Browse the repository at this point in the history