import { ClaimKey } from '@coinweb/contract-kit';

export enum HistoryKey {
  HISTORY_ITEM = 'HISTORY_ITEM',
  HISTORY_ACCESS = 'HISTORY_ACCESS',
}

export const createHistoryAccessFirstPart = () => [HistoryKey.HISTORY_ACCESS];

export const creteHistoryAccessKey = (id: string) =>
  ({
    first_part: createHistoryAccessFirstPart(),
    second_part: [id],
  }) satisfies ClaimKey;

export const createHistoryItemFirstPart = (historyId: string) => [HistoryKey.HISTORY_ITEM, historyId];

export const createHistoryItemKey = (historyId: string, timestamp: number, uniqueId: string | number, order: number) =>
  ({
    first_part: createHistoryItemFirstPart(historyId),
    second_part: [Number.MAX_SAFE_INTEGER - timestamp, order, uniqueId],
  }) satisfies ClaimKey;
