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

Dependency deployments cannot be verified in etherscan #65

Open jmonteer opened 1 year ago

jmonteer commented 1 year ago

Environment information

❯ ape --version
0.5.4
❯ ape plugins list
Installed Plugins:
  infura       0.5.2
  vyper        0.5.1
  hardhat      0.5.2
  alchemy      0.5.2
  etherscan    0.5.4
  foundry      0.5.1
  solidity     0.5.2

❯ python --version Python 3.9.9

What went wrong?

deploying a contract using the following:

    strategy_comp_v3 = project.dependencies["strategy-comp-v3"]["master"].Strategy
    strategy_comp_v3 = deployer.deploy(strategy_comp_v3, vault.address, "CompV3LenderUSDC", CASSETV3_ADDRESS, max_priority_fee="1 gwei", max_fee="100 gwei", publish=True)

deploys correctly but it is unable to verify with the following error:

SUCCESS: Contract 'Strategy' deployed to: 0xd0185b3aa44E12015FEbA333660FAb2b8f30dFa0
INFO: Publishing and verifying contract using 'etherscan'.
---------------------------------------------------------------------------
ContractVerificationError                 Traceback (most recent call last)
Cell In[68], line 1
----> 1 strategy_comp_v3 = deployer.deploy(strategy_comp_v3, vault.address, "CompV3LenderUSDC", CASSETV3_ADDRESS, max_priority_fee="1 gwei", max_fee="100 gwei", publish=publish_flag)

File ~/crypto/yearn/yearnv3-lender-deploy/lib/python3.9/site-packages/ape/api/accounts.py:211, in AccountAPI.deploy(self, contract, publish, *args, **kwargs)
    209 if publish:
    210     self.project_manager.track_deployment(instance)
--> 211     self.provider.network.publish_contract(address)
    213 return instance

File ~/crypto/yearn/yearnv3-lender-deploy/lib/python3.9/site-packages/ape/api/networks.py:883, in NetworkAPI.publish_contract(self, address)
    880     raise NetworkError("Unable to publish contract - no explorer plugin installed.")
    882 logger.info(f"Publishing and verifying contract using '{self.explorer.name}'.")
--> 883 self.explorer.publish_contract(address)

File ~/crypto/yearn/yearnv3-lender-deploy/lib/python3.9/site-packages/ape_etherscan/explorer.py:75, in Etherscan.publish_contract(self, address)
     73 def publish_contract(self, address: AddressType):
     74     verifier = SourceVerifier(address, self._client_factory)
---> 75     return verifier.attempt_verification()

File ~/crypto/yearn/yearnv3-lender-deploy/lib/python3.9/site-packages/ape_etherscan/verify.py:232, in SourceVerifier.attempt_verification(self)
    227 compilers_used = [
    228     c for c in manifest.compilers if self._contract_type.name in c.contractTypes
    229 ]
    231 if not compilers_used:
--> 232     raise ContractVerificationError("Compiler data missing from project manifest.")
    234 versions = [Version(c.version) for c in compilers_used]
    235 if not versions:
    236     # Might be impossible to get here.

ContractVerificationError: Compiler data missing from project manifest.

How can it be fixed?

I assume this has to do with how project manifest is dealing with dependencies. If it is a dependency, I guess it should look into .ape/packages/dependency for project manifest