/**
 * Type definitions for admin panel
 */

export enum SmartWalletType {
  GNOSIS_SAFE = 'GNOSIS_SAFE',
  ERC4337 = 'ERC4337',
  CUSTOM = 'CUSTOM',
  EOA = 'EOA', // Externally Owned Account
}

export interface SmartWalletConfig {
  id: string;
  type: SmartWalletType;
  address: string;
  networkId: number;
  owners: string[];
  threshold: number;
  createdAt: number;
  updatedAt: number;
}

export interface OwnerInfo {
  address: string;
  label?: string;
  ensName?: string;
}

export enum TransactionExecutionMethod {
  DIRECT_ONCHAIN = 'DIRECT_ONCHAIN',
  RELAYER = 'RELAYER',
  SIMULATION = 'SIMULATION',
}

export enum TransactionRequestStatus {
  PENDING = 'PENDING',
  APPROVED = 'APPROVED',
  REJECTED = 'REJECTED',
  EXECUTING = 'EXECUTING',
  SUCCESS = 'SUCCESS',
  FAILED = 'FAILED',
}

export interface TransactionRequest {
  id: string;
  from: string;
  to: string;
  value: string;
  data: string;
  gasLimit?: string;
  gasPrice?: string;
  maxFeePerGas?: string;
  maxPriorityFeePerGas?: string;
  nonce?: number;
  method: TransactionExecutionMethod;
  status: TransactionRequestStatus;
  hash?: string;
  createdAt: number;
  executedAt?: number;
  expiresAt?: number;
  error?: string;
  contractAddress?: string; // For admin actions
  functionName?: string; // For admin actions
  args?: any[]; // For admin actions
}

export interface MultiSigApproval {
  transactionId: string;
  approver: string;
  approved: boolean;
  timestamp: number;
  signature?: string;
}

export interface PendingTransaction {
  id: string;
  transaction: TransactionRequest;
  approvals: MultiSigApproval[];
  approvalCount: number;
  requiredApprovals: number;
  canExecute: boolean;
}

export interface GasEstimate {
  gasLimit: string;
  gasPrice?: string;
  maxFeePerGas?: string;
  maxPriorityFeePerGas?: string;
  estimatedCost: string;
  estimatedCostUsd?: string;
}

export interface WalletBalance {
  native: string;
  nativeFormatted: string;
  tokens: any[];
  totalUsdValue?: string;
}

export interface TokenBalance {
  tokenAddress: string;
  symbol: string;
  name: string;
  decimals: number;
  balance: string;
  balanceFormatted: string;
  usdValue?: string;
  logoUri?: string;
}

export interface AdminAction {
  id: string;
  type: 'pause' | 'unpause' | 'setAdmin' | 'anchorStateProof' | 'mirrorTransaction' | 'custom';
  contractAddress: string;
  functionName: string;
  args: any[];
  status: TransactionRequestStatus;
  createdAt: number;
  executedAt?: number;
  hash?: string;
  error?: string;
}

export interface AuditLog {
  id: string;
  timestamp: number;
  user: string;
  action: string;
  resourceType: string;
  resourceId: string;
  ipAddress?: string;
  details?: any;
  status: 'success' | 'failure';
}

export interface AdminPreferences {
  defaultExecutionMethod: TransactionExecutionMethod;
  showAdvancedOptions: boolean;
  autoApprove: boolean;
  theme: 'light' | 'dark';
}
