ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
889 stars 131 forks source link

`Contract` does not raise a warning if it can't find a contract type #777

Closed fubuloubu closed 2 years ago

fubuloubu commented 2 years ago

Environment information

$ ape --version
0.2.7

$ ape plugins list
Installed Plugins:
  hardhat      0.2.2
  solidity     0.2.3
  tokens       0.2.0
  infura       0.2.0
  etherscan    0.2.1
  alchemy      0.2.0
  foundry      0.2.0
  vyper        0.2.0
  ens          0.2.0

What went wrong?

There should be a warning raised if it's not possible to find a contract type for a given address using Contract. Here are some scenarios:

  1. No ExplorerAPI plugins (for the given network)
  2. Explorer fails to find a contract type
  3. If there is no code at that address or something else
# ape console --network :mainnet
In [1]: c = Contract("0x4332f8a38f14bd3d8d1553af27d7c7ac6c27278d")
# Should raise a warning here

In [2]: c
Out[2]: <Address 0x4332f8a38f14bd3d8d1553af27d7c7ac6c27278d>

How can it be fixed?

It used to do this, so might be a regression

nazariyv commented 2 years ago

In my case, I think this happens because my geth node was in snap mode and I was seeing execution reverted logs on eth_calls when instantiating the Contract. Will report back when full sync finishes.

nazariyv commented 2 years ago

this issue did not relate to the sync mode, it was simply me missing the etherscan ape plugin.