Skip to content

Commit

Permalink
feat: detect eip-1167 and legacy vyper proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
banteg committed Mar 9, 2021
1 parent b4c33a9 commit aae1767
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions brownie/network/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,17 @@ def _fetch_from_explorer(address: str, action: str, silent: bool) -> Dict:
if address in _unverified_addresses:
raise ValueError(f"Source for {address} has not been verified")

code = web3.eth.getCode(address).hex()[2:]
# EIP-1167: Minimal Proxy Contract
if code[:20] == "363d3d373d3d3d363d73" and code[60:] == "5af43d82803e903d91602b57fd5bf3":
address = _resolve_address(code[20:60])
# Vyper <0.2.9 `create_forwarder_to`
elif (
code[:30] == "366000600037611000600036600073"
and code[70:] == "5af4602c57600080fd5b6110006000f3"
):
address = _resolve_address(code[30:70])

params: Dict = {"module": "contract", "action": action, "address": address}
if "etherscan" in url:
if os.getenv("ETHERSCAN_TOKEN"):
Expand Down

0 comments on commit aae1767

Please sign in to comment.