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

bug: TypeError: Can't instantiate abstract class Infura with abstract methods chain_id #119

Closed
sabotagebeats opened this issue Aug 3, 2021 · 1 comment · Fixed by #121
Labels
category: bug Something isn't working

Comments

@sabotagebeats
Copy link
Contributor

Environment information

  • ape and plugin versions:
$ ape --version
0.1.0a19

$ ape plugins list
Installed plugins:
  ape_solidity (0.1.0a1)
  ape_vyper (0.1.0a6)
  ape_trezor (0.1.0a1.dev16+gc6410f6.d20210802)
  ape_infura (0.1.0a1)
  • Python Version: Python 3.8.10
  • OS: WSL2

What went wrong?

can't run ape with infura anymore

Please include information like:

  • what command you ran: ape console --network ethereum:ropsten:infura

output:

ape console --network ethereum:ropsten:infura
Traceback (most recent call last):
  File "/home/sabotage/.pyenv/versions/apeworx/bin/ape", line 33, in <module>
    sys.exit(load_entry_point('eth-ape==0.1.0a19', 'console_scripts', 'ape')())
  File "/home/sabotage/.pyenv/versions/apeworx/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/sabotage/.pyenv/versions/apeworx/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/sabotage/.pyenv/versions/apeworx/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sabotage/.pyenv/versions/apeworx/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sabotage/.pyenv/versions/apeworx/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/sabotage/ape/ape/src/ape_console/_cli.py", line 33, in cli
    with networks.parse_network_choice(network):
  File "/home/sabotage/ape/ape/src/ape/managers/networks.py", line 138, in parse_network_choice
    return network.use_provider(provider_name)
  File "/home/sabotage/ape/ape/src/ape/api/networks.py", line 251, in use_provider
    self.providers[provider_name](provider_settings=provider_settings),
TypeError: Can't instantiate abstract class Infura with abstract methods chain_id

I think the recent pull with chain_id clashes with the infura plugin

@fubuloubu
Copy link
Member

fubuloubu commented Aug 3, 2021

Yes, so this bug will happen whenever we add an expected abstractmethod to the *API classes. If you try to initialize them without that method implemented, it will raise.

However, this is a bug in that it shouldn't cause ape core to break, it should note the failure and skip loading that plugin module if possible, e.g. change this line:

self.providers[provider_name](provider_settings=provider_settings)

to

try:
    provider = self.providers[provider_name](provider_settings=provider_settings)
except TypeError as e:
    raise Abort(f"Plugin {plugin_name} failed to load!")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants