getCoinBalancesOwnedByAddress method

Future<List<SuiObjectResponse>> getCoinBalancesOwnedByAddress(
  1. String address, {
  2. String? typeArg,
})

Implementation

Future<List<SuiObjectResponse>> getCoinBalancesOwnedByAddress(
  String address,
  {String? typeArg}
) async {
  final objects = await getOwnedObjects(address);
  final coinIds = objects
    .data
    .where((x) => Coin.isCoin(x)
              && (typeArg == null || typeArg == Coin.getCoinTypeArg(x)))
    .map((y) => y.data!.objectId);

  final result = await getObjectBatch(coinIds.toList());
  return result;
}