isValidNamespaceAccounts function

ErrorObject? isValidNamespaceAccounts(
  1. SessionNamespaces input,
  2. String method
)

Implementation

ErrorObject? isValidNamespaceAccounts(
  SessionNamespaces input,
  String method,
) {
  ErrorObject? error;
  input.values.forEach((namespace) {
    if (error != null) return;
    final validAccountsError =
        isValidAccounts(namespace.accounts, '$method namespace');
    final validExtensionError = isValidExtension(namespace, method);
    if (validAccountsError != null) {
      error = validAccountsError;
    } else if (validExtensionError != null) {
      error = validExtensionError;
    } else if (namespace.extension != null) {
      namespace.extension!.forEach((extension) {
        if (error != null) return;
        final validAccountsError =
            isValidAccounts(extension.accounts, '$method extension');
        if (validAccountsError != null) {
          error = validAccountsError;
        }
      });
    }
  });

  return error;
}