Constructs a middleware which intercepts requests for any method found in
    the provided mapping of endpoints to generator functions, returning
    whatever response the generator function returns.  Callbacks must be
    functions with the signature `fn(method, params)`.

def construct_result_generator_middleware(result_generators):
    """
    Constructs a middleware which intercepts requests for any method found in
    the provided mapping of endpoints to generator functions, returning
    whatever response the generator function returns.  Callbacks must be
    functions with the signature `fn(method, params)`.
    """
    def result_generator_middleware(make_request, web3):
        def middleware(method, params):
            if method in result_generators:
                result = result_generators[method](method, params)
                return {'result': result}
            else:
                return make_request(method, params)
        return middleware
    return result_generator_middleware