multiGetObjects method

  1. @override
Future<List<SuiObjectResponse>> multiGetObjects(
  1. List<String> objectIds, {
  2. SuiObjectDataOptions? options,
})
override

Implementation

@override
Future<List<SuiObjectResponse>> multiGetObjects(
  List<String> objectIds, {
  SuiObjectDataOptions? options,
}) async {
  final results = await core.getObjects(
    objectIds,
    readMask: const [
      'object_id',
      'version',
      'digest',
      'owner',
      'object_type',
    ],
  );
  return results.map((r) {
    if (r.hasError()) {
      return SuiObjectResponse.fromJson({
        'error': {
          'code': 'notExists',
          'object_id': null,
        },
      });
    }
    final o = r.object;
    return SuiObjectResponse.fromJson({
      'data': {
        'objectId': o.objectId,
        'digest': o.digest,
        'version': o.version.toString(),
        'type': o.hasObjectType() ? o.objectType : null,
        'owner': _ownerJson(o.hasOwner() ? o.owner : null),
      },
    });
  }).toList();
}