import { TransactionRequest } from '@/domain/aggregates/transaction-request';
import { ChainType, TxHash } from '@/domain/value-objects';

export const TRANSACTION_REQUEST_REPOSITORY = Symbol('TRANSACTION_REQUEST_REPOSITORY');

export interface ITransactionRequestRepository {
  /**
   * 保存交易请求
   */
  save(request: TransactionRequest): Promise<TransactionRequest>;

  /**
   * 根据ID查找
   */
  findById(id: bigint): Promise<TransactionRequest | null>;

  /**
   * 根据交易哈希查找
   */
  findByTxHash(txHash: TxHash): Promise<TransactionRequest | null>;

  /**
   * 根据来源查找
   */
  findBySource(sourceService: string, sourceOrderId: string): Promise<TransactionRequest | null>;

  /**
   * 查找待处理的请求
   */
  findPending(chainType: ChainType): Promise<TransactionRequest[]>;

  /**
   * 查找已广播待确认的请求
   */
  findBroadcasted(chainType: ChainType): Promise<TransactionRequest[]>;

  /**
   * 查找失败可重试的请求
   */
  findRetryable(chainType: ChainType, maxRetries: number): Promise<TransactionRequest[]>;
}
