getAllAddressBalances method

Future<List<Balance>> getAllAddressBalances(
  1. List<ToplAddress> addresses, {
  2. int batchSize = 50,
})

Retrieves balances for multiple addresses. If there are more than batchSize addresses to process this method will process via chunks of batchSize addresses

Implementation

Future<List<Balance>> getAllAddressBalances(List<ToplAddress> addresses,
    {int batchSize = 50}) async {
  final result = <Balance>[];
  await Future.forEach(_splitArray(addresses, batchSize),
      (List<ToplAddress> batch) async {
    final balances = await _getBalances(batch);
    if (balances.isEmpty) return;
    result.addAll(balances);
  });
  return result;
}