ApeWorX / ape-etherscan

Etherscan explorer plugin using EVM-based networks for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
26 stars 25 forks source link

publish contract source got compile Version type conflict [APE-1591] #108

Closed gcc2ge closed 9 months ago

gcc2ge commented 11 months ago

Environment information

$ ape --version
# 0.6.26

$ ape plugins list
# Installed Plugins
  alchemy      0.6.5
  etherscan    0.6.10
  foundry      0.6.19
  polygon      0.6.7
  solidity     0.6.11

What went wrong?

Please include information like:

Traceback (most recent call last): File "/Users/user/Downloads/ape-learn/venv/bin/ape", line 8, in sys.exit(cli()) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/ape/_cli.py", line 37, in invoke return super().invoke(ctx) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/ape_run/_cli.py", line 74, in invoke return super().invoke(ctx) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/ape/cli/commands.py", line 29, in invoke super().invoke(ctx) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/ape_run/_cli.py", line 148, in call main_ns["main"]() # Execute the script File "/Users/user/Downloads/ape-learn/scripts/test.py", line 19, in main explorer.publish_contract(c) File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/ape_etherscan/explorer.py", line 60, in publish_contract return verifier.attempt_verification() File "/Users/user/Downloads/ape-learn/venv/lib/python3.9/site-packages/ape_etherscan/verify.py", line 253, in attempt_verification settings = all_settings[version] KeyError: Version('0.8.13+commit.abaa5c0e')

How can it be fixed?

file: venv/lib/python3.9/site-packages/ape_etherscan/verify.py , line 250

compiler_plugin = self.compiler_manager.registered_compilers[self._ext]
all_settings = compiler_plugin.get_compiler_settings(
    [self._source_path], base_path=self._base_path
) # version type from semantic_version import Version
settings = all_settings[version] # version type from packaging.version import Version
optimizer = settings.get("optimizer", {})
antazoey commented 9 months ago

Everyone is on packaging.version.Version now!