Interface JsonRpcClient


@Beta public interface JsonRpcClient
A feign HTTP client for interacting with the rippled JSON RPC API. This client is strictly responsible for making network calls and deserializing responses. All higher order functionality such as signing and serialization should be implemented in a wrapper class.

Note: This client is currently marked as Beta, and should be used as a reference implementation ONLY.

  • Field Details

    • logger

      static final org.slf4j.Logger logger
    • HEADER_ACCEPT

      static final String HEADER_ACCEPT
      See Also:
    • HEADER_CONTENT_TYPE

      static final String HEADER_CONTENT_TYPE
      See Also:
    • APPLICATION_JSON

      static final String APPLICATION_JSON
      See Also:
    • objectMapper

      static final com.fasterxml.jackson.databind.ObjectMapper objectMapper
    • SERVICE_UNAVAILABLE_STATUS

      static final int SERVICE_UNAVAILABLE_STATUS
      See Also:
    • RETRY_INTERVAL

      static final Duration RETRY_INTERVAL
  • Method Details

    • construct

      static JsonRpcClient construct(okhttp3.HttpUrl rippledUrl)
      Constructs a new client for the given url.
      Parameters:
      rippledUrl - url for the faucet server.
      Returns:
      A JsonRpcClient that can make request to rippledUrl
    • postRpcRequest

      com.fasterxml.jackson.databind.JsonNode postRpcRequest(JsonRpcRequest rpcRequest)
      Send a POST request to the rippled server with rpcRequest in the request body.
      Parameters:
      rpcRequest - A rippled JSON RPC API request object.
      Returns:
      A JsonNode which can be manually parsed containing the response.
    • send

      default <T extends XrplResult> T send(JsonRpcRequest request, Class<T> resultType) throws JsonRpcClientErrorException
      Send a given request to rippled.
      Type Parameters:
      T - The extension of XrplResult corresponding to the request method.
      Parameters:
      request - The JsonRpcRequest to send to the server.
      resultType - The type of XrplResult that should be returned.
      Returns:
      The JsonRpcClient representing the result of the request.
      Throws:
      JsonRpcClientErrorException - If rippled returns an error message, or if the response could not be deserialized to the provided JsonRpcRequest type.
    • send

      default <T extends XrplResult> T send(JsonRpcRequest request, com.fasterxml.jackson.databind.JavaType resultType) throws JsonRpcClientErrorException
      Send a given request to rippled. Unlike send(JsonRpcRequest, Class), this override requires a JavaType as the resultType, which can be useful when expecting a XrplResult with type parameters. In this case, you can use an ObjectMapper's TypeFactory to construct parameterized types.
      Type Parameters:
      T - The extension of XrplResult corresponding to the request method.
      Parameters:
      request - The JsonRpcRequest to send to the server.
      resultType - The type of XrplResult that should be returned, converted to a JavaType.
      Returns:
      The JsonRpcClient representing the result of the request.
      Throws:
      JsonRpcClientErrorException - If rippled returns an error message, or if the response could not be deserialized to the provided JsonRpcRequest type.
    • checkForError

      default void checkForError(com.fasterxml.jackson.databind.JsonNode response) throws JsonRpcClientErrorException
      Parse the response JSON to detect a possible error response message.
      Parameters:
      response - The JsonNode containing the JSON response from rippled.
      Throws:
      JsonRpcClientErrorException - If rippled returns an error message.