/** ISO 20022 / SWIFT MT-103+ canonical message (off-chain full payload; on-chain hashes). */
export type IsoMessageTypeCode = 0 | 1 | 2 | 3 | 4 | 5;

/** 0=unknown, 1=MT103, 2=pacs.008, 3=pain.001, 4=chain138 synthetic, 5=KTT/telex */
export const MSG_TYPE = {
  UNKNOWN: 0 as IsoMessageTypeCode,
  MT103: 1 as IsoMessageTypeCode,
  PACS008: 2 as IsoMessageTypeCode,
  PAIN001: 3 as IsoMessageTypeCode,
  CHAIN138_SYNTH: 4 as IsoMessageTypeCode,
  KTT: 5 as IsoMessageTypeCode,
} as const;

export type CanonicalPaymentMessage = {
  msgType: 'MT103' | 'pacs.008' | 'pain.001' | 'chain138.synthetic' | 'KTT' | 'TELEX_KTT';
  msgTypeCode: IsoMessageTypeCode;
  instructionId: string;
  instructionIdBytes32: string;
  endToEndId: string;
  endToEndIdHash: string;
  msgId: string;
  uetr: string;
  uetrBytes32: string;
  accountRefId: string;
  counterpartyRefId: string;
  debtorId: string;
  creditorId: string;
  purpose: string;
  settlementMethod: string;
  categoryPurpose: string;
  currencyCode: string;
  amountRaw: string;
  amountSmallestUnit: string;
  tokenAddress?: string;
  payloadHash: string;
  /** keccak256(testKeyProof || normalizedBody) when KTT test-key verified off-chain */
  authAttestationHash?: string;
  debtorRefHash: string;
  creditorRefHash: string;
  purposeHash: string;
  chain138TxHash: string;
  valueDateIso?: string;
};

export type PaymentLeafIsoInput = {
  txHash: string;
  from: string;
  to: string;
  value: bigint;
  blockNumber: number;
  blockTimestamp: number;
  valueUsd?: string;
  nativeValueUsd?: string;
  totalTransfersUsd?: string;
  receiptHash?: string;
  logCount?: number;
  token?: string;
  tokenSymbol?: string;
};
