getAccountInfoCached method

Future<AccountInfo> getAccountInfoCached({
  1. required String id,
  2. required String operator,
})

Implementation

Future<AccountInfo> getAccountInfoCached({
  required String id,
  required String operator,
}) async {
  if (_accountInfoCache.containsKey(id)) {
    return Future.value(_accountInfoCache[id]);
  }

  late AccountInfo accountInfo;
  try {
    accountInfo = await getAccountInfo(id: id, operator: operator);
  } catch (e) {
    // The account does not exist or we can't resolve it currently
    accountInfo =
        AccountInfo(accountId: hex.decode(id), publicName: 'Unknown');
  }

  _accountInfoCache[id] = accountInfo;
  return accountInfo;
}