/* import {
  ApplicationServiceError,
  type IApplicationServiceError,
} from "@/contexts/common/application/services/ApplicationServiceError";
import { IAdapter, RepositoryBuilder } from "@/contexts/common/domain";
import { Result, UniqueID } from "@shared/contexts";
import { NullOr } from "@shared/utilities";
import { IInvoiceParticipantAddress, IInvoiceParticipantAddressRepository } from "../../domain";

export const participantAddressFinder = async (
  addressId: UniqueID,
  adapter: IAdapter,
  repository: RepositoryBuilder<IInvoiceParticipantAddressRepository>
) => {
  if (addressId.isNull()) {
    return Result.fail<IApplicationServiceError>(
      ApplicationServiceError.create(
        ApplicationServiceError.INVALID_REQUEST_PARAM,
        `Participant address ID required`
      )
    );
  }

  const transaction = adapter.startTransaction();
  let address: NullOr<IInvoiceParticipantAddress> = null;

  try {
    await transaction.complete(async (t) => {
      address = await repository({ transaction: t }).getById(addressId);
    });

    if (address === null) {
      return Result.fail<IApplicationServiceError>(
        ApplicationServiceError.create(ApplicationServiceError.NOT_FOUND_ERROR, "", {
          id: addressId.toString(),
          entity: "participant address",
        })
      );
    }

    return Result.ok<IInvoiceParticipantAddress>(address);
  } catch (error: unknown) {
    const _error = error as Error;

    if (repository().isRepositoryError(_error)) {
      return Result.fail<IApplicationServiceError>(
        ApplicationServiceError.create(
          ApplicationServiceError.REPOSITORY_ERROR,
          _error.message,
          _error
        )
      );
    }

    return Result.fail<IApplicationServiceError>(
      ApplicationServiceError.create(
        ApplicationServiceError.UNEXCEPTED_ERROR,
        _error.message,
        _error
      )
    );
  }
};
 */
