BramblClient constructor

BramblClient({
  1. Dio? httpClient,
  2. String? basePathOverride,
  3. List<Interceptor>? interceptors,
})

Starts a client that connects to a JSON rpc API, available at basePath. The httpClient will be used to send requests to the rpc server. An isolate will be used to perform expensive operations, such as signing transactions or computing private keys.

Implementation

BramblClient({
  Dio? httpClient,
  String? basePathOverride,
  List<Interceptor>? interceptors,
})  : _operations = ExpensiveOperations(),
      jsonRpc = JsonRPC(
          dio: httpClient ??
              Dio(BaseOptions(
                  baseUrl: basePathOverride ?? basePath,
                  contentType: 'application/json',
                  connectTimeout: 5000,
                  receiveTimeout: 3000))) {
  if (interceptors == null) {
    jsonRpc.dio.interceptors.add(ApiKeyAuthInterceptor());
    jsonRpc.dio.interceptors
        .add(RetryInterceptor(dio: jsonRpc.dio, logger: log));
  } else {
    jsonRpc.dio.interceptors.addAll(interceptors);
  }
}