isValidAccounts function

ErrorObject? isValidAccounts(
  1. List<String> accounts,
  2. String context
)

Implementation

ErrorObject? isValidAccounts(List<String> accounts, String context) {
  ErrorObject? error;
  if (accounts.isNotEmpty) {
    accounts.forEach((account) {
      if (error != null) return;

      if (!isValidAccountId(account)) {
        error = getSdkError(
          SdkErrorKey.UNSUPPORTED_ACCOUNTS,
          context:
              '$context, account $account should be a string and conform to "namespace:chainId:address" format',
        );
      }
    });
  } else {
    error = getSdkError(
      SdkErrorKey.UNSUPPORTED_ACCOUNTS,
      context:
          '$context, accounts should be an array of strings conforming to "namespace:chainId:address" format',
    );
  }

  return error;
}