getCoins method

  1. @override
Future<Page<CoinData>> getCoins(
  1. String address, {
  2. String coinType = '0x2::sui::SUI',
  3. String? cursor,
  4. int? limit,
})
override

Coin objects of coinType owned by address.

Implementation

@override
Future<Page<CoinData>> getCoins(
  String address, {
  String coinType = '0x2::sui::SUI',
  String? cursor,
  int? limit,
}) async {
  final normalized = normalizeStructTagString(coinType);
  final data = await _client.executeData(
    _getOwnedObjectsOperation,
    generated.Variables$Query$GetOwnedObjects(
      address: address,
      type: '0x2::coin::Coin<$normalized>',
      first: limit,
      after: cursor,
    ),
  );
  final connection = data.address?.objects;
  if (connection == null) return const Page(data: [], hasNextPage: false);
  return Page(
    data: connection.nodes.map(_mapCoin).toList(),
    hasNextPage: connection.pageInfo.hasNextPage,
    nextCursor: connection.pageInfo.endCursor,
  );
}