getTransactionOwnerships method

Future<Map<String, List<Ownership>>> getTransactionOwnerships(
  1. List<String> addresses
)

getTransactionOwnerships @param {List

Implementation

Future<Map<String, List<Ownership>>> getTransactionOwnerships(
  List<String> addresses,
) async {
  if (addresses.isEmpty) {
    return {};
  }

  try {
    final transactionMap = await getTransaction(
      addresses,
      request:
          'data { ownerships { secret, authorizedPublicKeys { encryptedSecretKey, publicKey } } }',
    );

    final ownershipsMap = <String, List<Ownership>>{};

    transactionMap.forEach(
      (key, value) {
        if (value.data != null && value.data!.ownerships != null) {
          ownershipsMap[key] = value.data!.ownerships!;
        }
      },
    );

    return removeAliasPrefix<List<Ownership>>(ownershipsMap) ?? {};
  } catch (e) {
    log('getTransactionOwnerships: error=$e');
  }

  return {};
}