import { Address } from '../../../domain/entities/address';
import { NotFoundError } from '../../../domain/errors/not-found-error';
import { IWalletRepository } from '../../../domain/repositories/wallet-repository';
import { IAddressRepository } from '../../../domain/repositories/address-repository';

export class GetAllNetworkAddressesForWalletUseCase {
  constructor(
    private readonly walletRepository: IWalletRepository,
    private readonly addressRepository: IAddressRepository,
  ) {}

  async execute(walletId: string): Promise<Address[]> {
    const wallet = await this.walletRepository.findById(walletId);
    if (!wallet) {
      throw new NotFoundError('Wallet', walletId);
    }

    return this.addressRepository.findByWalletId(walletId);
  }
}
