/**
 * Type definitions for MetaMask integration
 */

export interface EthereumProvider {
  request(args: { method: string; params?: unknown[] }): Promise<unknown>;
  isMetaMask?: boolean;
  on?: (event: string, handler: (...args: unknown[]) => void) => void;
  removeListener?: (event: string, handler: (...args: unknown[]) => void) => void;
}

export interface AddEthereumChainParameter {
  chainId: string;
  chainName: string;
  nativeCurrency: {
    name: string;
    symbol: string;
    decimals: number;
  };
  rpcUrls: string[];
  blockExplorerUrls?: string[];
  iconUrls?: string[];
}

export interface WatchAssetParameters {
  type: 'ERC20';
  options: {
    address: string;
    symbol: string;
    decimals: number;
    image?: string;
  };
}

export interface MetaMaskError extends Error {
  code: number;
  data?: unknown;
}

declare global {
  interface Window {
    ethereum?: EthereumProvider;
  }
}

