Open banteg opened 3 years ago
Yeah, this absolutely makes sense and shouldn't be that hard to implement.
I looked a bit more into it. It seems removing this line is enough https://github.com/eth-brownie/brownie/blob/4a399b1323b75226a801c16af1cc170273506bef/brownie/network/contract.py#L1006
Are there any negative side effects to be aware of?
Update: It seems to break quite a bit of stuff.
What was wrong?
Brownie caches interfaces the same way it caches contract metadata from compiling from source. This can mess with the user expectations when they simply meant to poke at a contract to see if it responds to methods of a certain interface.
In Solidity interfaces are ephemeral, we should follow the same behavior and not associate a potentially incomplete or erroneous ABI with a contract address. Current workaround after using an incorrect interface is to call
Contract.from_explorer
on that address to overwrite the metadata.Ephemeral interfaces would allow things like testing whether an unknown code at address follows a certain interface without worrying it would break further invocations. An example could be discerning between Uniswap/Balancer/Curve pools.
How can it be fixed?
Don't cache
interface.Something(address)
as canonical ABI for theaddress
, handle it like Solidity does.