# Buggy code
def _request_chain_metadata(self) -> Dict[str, Any]:
    """Subscan API metadata documentation:
    https://docs.api.subscan.io/#metadata
    """
    response = self._request_explorer_api(endpoint="metadata")
    if response.status_code != HTTPStatus.OK:
        message = (
            f"{self.chain} chain metadata request was not successful. "
            f"Response status code: {response.status_code}. "
            f"Response text: {response.text}.",
        )
        log.error(message)
        raise RemoteError(message)
    try:
        result = rlk_jsonloads_dict(response.text)
    except JSONDecodeError as e:
        message = (
            f"{self.chain} chain metadata request returned invalid JSON "
            f"response: {response.text}.",
        )
        log.error(message)
        raise RemoteError(message) from e

    log.debug(f"{self.chain} subscan API metadata", result=result)
    return result


# Traceback (ValueError)
2021-01-17T09:45:53.929Z: Starting packaged python subprocess: /tmp/lefteris/.mount_rotki-bd0Awo/resources/rotkehlchen_py_dist/rotkehlchen-1.12.1-linux --api-port 4242 --loglevel debug --api-cors app://* --logfile /home/lefteris/.config/rotki/logs/rotkehlchen.log
2021-01-17T09:45:53.935Z: The Python sub-process started on port: 4242 (PID: 19124)
^C2021-01-17T09:54:44.510Z: Exiting the application
2021-01-17T09:54:44.675Z: Traceback (most recent call last):
File "rotkehlchen/chain/substrate/manager.py", line 408, in _get_node_interface
File "site-packages/substrateinterface/base.py", line 450, in __init__
ValueError: Type registry preset 'kusama' not found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "src/gevent/greenlet.py", line 818, in gevent._greenlet.Greenlet.run
File "rotkehlchen/chain/substrate/manager.py", line 240, in _connect_node
File "rotkehlchen/chain/substrate/manager.py", line 418, in _get_node_interface
AttributeError: Invalid SubstrateInterface instantiation
2021-01-17T09:47:30Z <Greenlet at 0x7fcc0ff06cb0: <bound method SubstrateManager._connect_node of <rotkehlchen.chain.substrate.manager.SubstrateManager object at 0x7fcc167b5f90>>(node=<KusamaNodeName.OWN: 0>, endpoint='http://localhost:9933')> failed with AttributeError

Traceback (most recent call last):
File "rotkehlchen/chain/substrate/manager.py", line 408, in _get_node_interface
File "site-packages/substrateinterface/base.py", line 450, in __init__
ValueError: Type registry preset 'kusama' not found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "src/gevent/greenlet.py", line 818, in gevent._greenlet.Greenlet.run
File "rotkehlchen/chain/substrate/manager.py", line 240, in _connect_node
File "rotkehlchen/chain/substrate/manager.py", line 418, in _get_node_interface
AttributeError: Invalid SubstrateInterface instantiation
2021-01-17T09:47:30Z <Greenlet at 0x7fcc0fe8d5f0: <bound method SubstrateManager._connect_node of <rotkehlchen.chain.substrate.manager.SubstrateManager object at 0x7fcc167b5f90>>(node=<KusamaNodeName.PARITY: 1>, endpoint='https://kusama-rpc.polkadot.io/')> failed with AttributeError

# Fixed code
def _request_chain_metadata(self) -> Dict[str, Any]:
    """Subscan API metadata documentation:
    https://docs.api.subscan.io/#metadata
    """
    response = self._request_explorer_api(endpoint="metadata")
    if response.status_code != HTTPStatus.OK:
        message = (
            f"{self.chain} chain metadata request was not successful. "
            f"Response status code: {response.status_code}. "
            f"Response text: {response.text}."
        )
        log.error(message)
        raise RemoteError(message)
    try:
        result = rlk_jsonloads_dict(response.text)
    except JSONDecodeError as e:
        message = (
            f"{self.chain} chain metadata request returned invalid JSON "
            f"response: {response.text}."
        )
        log.error(message)
        raise RemoteError(message) from e

    log.debug(f"{self.chain} subscan API metadata", result=result)
    return result