import json


def load_contract(file_abi, file_bin, file_address=None):
    """
    Load contract from disk. Returns: address, ABI and Bin from the contract
    """
    if file_address is not None:
        try:
            contract_address = json.load(open(file_address, 'r'))["address"]
        except FileNotFoundError:
            contract_address = None
    else:
        contract_address = None
    abi = json.load(open(file_abi, 'r'))
    contract_bin = json.load(open(file_bin, 'r'))["bin"]

    return contract_address, abi, contract_bin