/**
 * 未分配算力同步事件
 * 用于同步待解锁算力到 mining-service
 */
export class UnallocatedContributionSyncedEvent {
  static readonly EVENT_TYPE = 'UnallocatedContributionSynced';
  static readonly AGGREGATE_TYPE = 'UnallocatedContribution';

  constructor(
    public readonly sourceAdoptionId: bigint,
    public readonly sourceAccountSequence: string,
    public readonly wouldBeAccountSequence: string | null,
    public readonly contributionType: string, // LEVEL_NO_ANCESTOR, LEVEL_OVERFLOW, BONUS_TIER_1, BONUS_TIER_2, BONUS_TIER_3
    public readonly amount: string,
    public readonly reason: string | null,
    public readonly effectiveDate: Date,
    public readonly expireDate: Date,
  ) {}

  toPayload(): Record<string, any> {
    return {
      eventType: UnallocatedContributionSyncedEvent.EVENT_TYPE,
      sourceAdoptionId: this.sourceAdoptionId.toString(),
      sourceAccountSequence: this.sourceAccountSequence,
      wouldBeAccountSequence: this.wouldBeAccountSequence,
      contributionType: this.contributionType,
      amount: this.amount,
      reason: this.reason,
      effectiveDate: this.effectiveDate.toISOString(),
      expireDate: this.expireDate.toISOString(),
    };
  }
}
