import { NotFoundError } from '../../../domain/errors/not-found-error';
import { IWalletRepository } from '../../../domain/repositories/wallet-repository';
import { IEncryptionService } from '../../../application/ports/encryption-service';

export class GetWalletSeedPhraseUseCase {
  constructor(
    private readonly walletRepository: IWalletRepository,
    private readonly encryptionService: IEncryptionService,
  ) {}

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

    return this.encryptionService.decrypt(wallet.encryptedPhrase);
  }
}
