import { DomainEvent } from './domain-event.base';

export interface TransactionBroadcastedPayload {
  requestId: string;
  chainType: string;
  txHash: string;
  fromAddress: string;
  toAddress: string;
  value: string;
  sourceService: string;
  sourceOrderId: string;
  [key: string]: unknown;
}

/**
 * 交易广播事件
 * 当交易成功广播到链上时触发
 */
export class TransactionBroadcastedEvent extends DomainEvent {
  readonly eventType = 'blockchain.transaction.broadcasted';

  constructor(private readonly payload: TransactionBroadcastedPayload) {
    super();
  }

  toPayload(): TransactionBroadcastedPayload {
    return this.payload;
  }
}
