Repository: eth-brownie/brownie
Issue: Infinite loop fetching source from etherscan

### Environment information

* `brownie` Version: 1.9.7
* `solc` Version: 0.4.24
* Python Version: 3.8.2
* OS: ubuntu linux (docker)

### What was wrong?

```
$ brownie console --network mainnet 
Brownie v1.9.7 - Python development framework for Ethereum

AppProject is the active project.
Brownie environment is ready.
>>> Contract.from_explorer("0x080bf510FCbF18b91105470639e9561022937712")                                                                                         
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
^C  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 650, in from_explorer
    implementation_contract = Contract.from_explorer(as_proxy_for)
  File "brownie/network/contract.py", line 650, in from_explorer
    implementation_contract = Contract.from_explorer(as_proxy_for)
  File "brownie/network/contract.py", line 650, in from_explorer
    implementation_contract = Contract.from_explorer(as_proxy_for)
  File line, line 31, in times]
  File "brownie/network/contract.py", line 624, in from_explorer
    data = _fetch_from_explorer(address, "getsourcecode", silent)
  File "brownie/network/contract.py", line 1242, in _fetch_from_explorer
    response = requests.get(url, params=params, headers=REQUEST_HEADERS)
  File "requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "requests/sessions.py", line 685, in send
    r.content
  File "requests/models.py", line 829, in content
    self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
  File "requests/models.py", line 751, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "urllib3/response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "urllib3/response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/usr/lib/python3.8/http/client.py", line 454, in read
    n = self.readinto(b)
  File "/usr/lib/python3.8/http/client.py", line 498, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
KeyboardInterrupt: 
>>>          
```

This is one of 0x's contracts: https://etherscan.io/address/0x080bf510FCbF18b91105470639e9561022937712#code


Changed files:
brownie/network/contract.py

diff --git a/brownie/network/contract.py b/brownie/network/contract.py
index a0a5fead..b1b97688 100644
--- a/brownie/network/contract.py
+++ b/brownie/network/contract.py
@@ -645,6 +645,9 @@ class Contract(_DeployedContractBase):
         if as_proxy_for is None and data["result"][0].get("Implementation"):
             as_proxy_for = _resolve_address(data["result"][0]["Implementation"])
 
+        if as_proxy_for == address:
+            as_proxy_for = None
+
         # if this is a proxy, fetch information for the implementation contract
         if as_proxy_for is not None:
             implementation_contract = Contract.from_explorer(as_proxy_for)