getVoteAccounts method

Future<RPCResponse<GetVoteAccounts>> getVoteAccounts({
  1. String? votePubkey,
  2. bool? keepUnstakedDelinquents,
  3. int? delinquentSlotDistance,
})

get Vote Accounts

Implementation

Future<RPCResponse<GetVoteAccounts>> getVoteAccounts({
  String? votePubkey,
  bool? keepUnstakedDelinquents,
  int? delinquentSlotDistance,
}) async {
  final params = [];

  if (votePubkey != null) {
    params.add({"votePubkey": votePubkey});
  }

  if (keepUnstakedDelinquents != null) {
    params.add({"keepUnstakedDelinquents": keepUnstakedDelinquents});
  }

  if (delinquentSlotDistance != null) {
    params.add({"delinquentSlotDistance": delinquentSlotDistance});
  }

  final body = json.encode({
    "jsonrpc": "2.0",
    "id": 1,
    "method": RPCMethod.getVoteAccounts,
    "params": params
  });
  final response = await _httpClient.post(_url, data: body);

  return RPCResponse<GetVoteAccounts>.fromJson(
    response.data,
    onData: (Map<String, dynamic> value) {
      return GetVoteAccounts.fromJson(value);
    },
  );
}