{"version":3,"sources":["../../src/connectors/base.ts","../../src/chains/evm/popular.ts","../../src/chains/svm/popular.ts","../../src/chains/index.ts","../../src/connectors/metamask.ts","../../src/connectors/phantom.ts","../../src/connectors/index.ts"],"names":["BaseConnector","id","name","type","icon","supportedChains","EventEmitter","event","listener","status","error","account","previousAccount","chainId","previousChainId","ethereumMainnet","polygonMainnet","arbitrumMainnet","optimismMainnet","bscMainnet","popularEVMChains","solanaMainnet","solanaDevnet","solanaTestnet","popularSVMChains","getAllChains","getChainById","chain","pendingRequest","requestTimeout","MetaMaskConnector","accounts","currentChainId","parsedChainId","pendingError","connectorError","hexChainId","PhantomConnector","solana","solanaChainId","publicKey","defaultConnectors","getAvailableConnectors","connector","getConnectorById"],"mappings":"sFAaO,IAAeA,CAAf,CAAA,KAAkD,CAavD,WACEC,CAAAA,CAAAA,CACAC,CACAC,CAAAA,CAAAA,CACAC,CACAC,CAAAA,CAAAA,CACA,CAZF,IAAU,CAAA,OAAA,CAA2B,cACrC,CAAA,IAAA,CAAU,MAAgC,CAAA,IAAA,CAC1C,IAAU,CAAA,QAAA,CAA0B,IACpC,CAAA,IAAA,CAAU,QAA2B,CAAA,IAAA,CAUnC,IAAK,CAAA,aAAA,CAAgB,IAAIC,CACzB,CAAA,IAAA,CAAK,EAAKL,CAAAA,CAAAA,CACV,IAAK,CAAA,IAAA,CAAOC,CACZ,CAAA,IAAA,CAAK,IAAOC,CAAAA,CAAAA,CACZ,IAAK,CAAA,IAAA,CAAOC,CACZ,CAAA,IAAA,CAAK,gBAAkBC,EACzB,CAsBA,WAAuB,EAAA,CACrB,OAAO,IAAA,CAAK,OAAY,GAAA,WAC1B,CAKA,SAAA,EAA6B,CAC3B,OAAO,IAAK,CAAA,OACd,CAKA,QAAkC,EAAA,CAChC,OAAO,IAAA,CAAK,MACd,CAKA,YAA4B,CAC1B,OAAO,IAAK,CAAA,QACd,CAKA,UAAA,EAA6B,CAC3B,OAAO,IAAA,CAAK,QACd,CAOA,EAAGE,CAA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K,oBAAqB,CAAA,IAAA,CAAK,IAAI,CAAC,CACjEA,CAAAA,CAAAA,CAAO,IAAI,YAAc,CAAA,IAAA,CAAK,gBAAiB,CAAA,IAAA,CAAK,IAAI,CAAC,CAE7D,EAAA,CAMQ,oBACNE,CAAAA,CAAAA,CACM,CACDA,CAAAA,CAKH,IAAK,CAAA,aAAA,CAAcA,EAAU,QAAS,EAAC,CAHvC,CAAA,IAAA,CAAK,UAAW,GAKpB,CAKQ,gBAAA,EAAyB,CAC/B,IAAA,CAAK,UAAW,GAClB,CACF,ECpMA,IAAMC,CAAiC,CAAA,CACrC,IAAIX,CAAAA,CACJ,IAAIO,CACN,CAMO,CAAA,SAASK,EAAsC,EAAA,CACpD,OAAI,OAAO,MAAW,CAAA,GAAA,CACb,EAGFD,CAAAA,CAAAA,CAAkB,MAAQE,CAAAA,CAAAA,EAG7B,aAAiBA,GAAAA,CAAAA,EACjB,OAAQA,CAAAA,CAAkB,WAAgB,EAAA,UAAA,CAElCA,CAAkB,CAAA,WAAA,EAErB,CAAA,IACR,CACH,CAOO,SAASC,EAAiB3C,CAAAA,CAAAA,CAAmC,CAClE,OAAOwC,CAAkB,CAAA,IAAA,CAAME,CAAcA,EAAAA,CAAAA,CAAU,EAAO1C,GAAAA,CAAE,CAClE","file":"index.mjs","sourcesContent":["import EventEmitter from \"eventemitter3\";\nimport {\n  Connector,\n  ConnectorError,\n  ConnectorEvent,\n  ConnectorStatus,\n} from \"../types/connector\";\nimport { ChainId, ChainType } from \"../types/chain\";\n\n/**\n * Base connector class that implements common functionality\n * All specific wallet connectors should extend this class\n */\nexport abstract class BaseConnector implements Connector {\n  id: string;\n  name: string;\n  type: string;\n  icon: string;\n  supportedChains: ChainType[];\n\n  protected _status: ConnectorStatus = ConnectorStatus.DISCONNECTED;\n  protected _error: ConnectorError | null = null;\n  protected _account: string | null = null;\n  protected _chainId: ChainId | null = null;\n  protected _eventEmitter: EventEmitter;\n\n  constructor(\n    id: string,\n    name: string,\n    type: string,\n    icon: string,\n    supportedChains: ChainType[]\n  ) {\n    this._eventEmitter = new EventEmitter();\n    this.id = id;\n    this.name = name;\n    this.type = type;\n    this.icon = icon;\n    this.supportedChains = supportedChains;\n  }\n\n  /**\n   * Connect to the wallet\n   * @param chainId Optional chain ID to connect to\n   */\n  abstract connect(chainId?: ChainId): Promise<string>;\n\n  /**\n   * Disconnect from the wallet\n   */\n  abstract disconnect(): Promise<void>;\n\n  /**\n   * Switch to a different chain\n   * @param chainId Chain ID to switch to\n   */\n  abstract switchChain(chainId: ChainId): Promise<void>;\n\n  /**\n   * Check if the wallet is connected\n   */\n  isConnected(): boolean {\n    return this._status === ConnectorStatus.CONNECTED;\n  }\n\n  /**\n   * Get the current connection status\n   */\n  getStatus(): ConnectorStatus {\n    return this._status;\n  }\n\n  /**\n   * Get the current error (if any)\n   */\n  getError(): ConnectorError | null {\n    return this._error;\n  }\n\n  /**\n   * Get the connected account address\n   */\n  getAccount(): string | null {\n    return this._account;\n  }\n\n  /**\n   * Get the current chain ID\n   */\n  getChainId(): ChainId | null {\n    return this._chainId;\n  }\n\n  /**\n   * Register an event listener\n   * @param event Event to listen for\n   * @param listener Listener function\n   */\n  on(event: ConnectorEvent, listener: (...args: any[]) => void): void {\n    this._eventEmitter.on(event, listener);\n  }\n\n  /**\n   * Remove an event listener\n   * @param event Event to stop listening for\n   * @param listener Listener function to remove\n   */\n  off(event: ConnectorEvent, listener: (...args: any[]) => void): void {\n    this._eventEmitter.off(event, listener);\n  }\n\n  /**\n   * Remove all event listeners for a specific event\n   * @param event Event to stop listening for\n   */\n  removeAllListeners(event?: ConnectorEvent): void {\n    if (event) {\n      this._eventEmitter.removeAllListeners(event);\n    } else {\n      // Remove all listeners for all events\n      this._eventEmitter.removeAllListeners();\n    }\n  }\n\n  /**\n   * Update the connection status\n   * @param status New status\n   */\n  protected updateStatus(status: ConnectorStatus): void {\n    this._status = status;\n  }\n\n  /**\n   * Update the current error\n   * @param error New error\n   */\n  protected updateError(error: ConnectorError | null): void {\n    this._error = error;\n    if (error) {\n      this._eventEmitter.emit(ConnectorEvent.ERROR, error);\n    }\n  }\n\n  /**\n   * Update the connected account\n   * @param account New account address\n   */\n  protected updateAccount(account: string | null): void {\n    const previousAccount = this._account;\n    this._account = account;\n\n    if (account && account !== previousAccount) {\n      this._eventEmitter.emit(ConnectorEvent.ACCOUNT_CHANGED, account);\n    }\n  }\n\n  /**\n   * Update the current chain ID\n   * @param chainId New chain ID\n   */\n  protected updateChainId(chainId: ChainId | null): void {\n    const previousChainId = this._chainId;\n    this._chainId = chainId;\n\n    if (chainId && chainId !== previousChainId) {\n      this._eventEmitter.emit(ConnectorEvent.CHAIN_CHANGED, chainId);\n    }\n  }\n}\n","import { ChainConfig, NetworkType, ChainType } from \"../../types/chain\";\n\nexport const ethereumMainnet: ChainConfig = {\n  id: 1,\n  name: \"Ethereum\",\n  type: ChainType.EVM,\n  networkType: NetworkType.MAINNET,\n  rpcUrls: [\n    \"https://eth-mainnet.g.alchemy.com/v2/your-api-key\",\n    \"https://mainnet.infura.io/v3/your-api-key\",\n  ],\n  nativeCurrency: {\n    name: \"Ether\",\n    symbol: \"ETH\",\n    decimals: 18,\n  },\n  blockExplorerUrls: [\"https://etherscan.io\"],\n  iconUrl: \"https://cryptologos.cc/logos/ethereum-eth-logo.png\",\n};\n\nexport const polygonMainnet: ChainConfig = {\n  id: 137,\n  name: \"Polygon\",\n  type: ChainType.EVM,\n  networkType: NetworkType.MAINNET,\n  rpcUrls: [\n    \"https://polygon-rpc.com\",\n    \"https://polygon-mainnet.g.alchemy.com/v2/your-api-key\",\n  ],\n  nativeCurrency: {\n    name: \"MATIC\",\n    symbol: \"MATIC\",\n    decimals: 18,\n  },\n  blockExplorerUrls: [\"https://polygonscan.com\"],\n  iconUrl: \"https://cryptologos.cc/logos/polygon-matic-logo.png\",\n};\n\nexport const arbitrumMainnet: ChainConfig = {\n  id: 42161,\n  name: \"Arbitrum\",\n  type: ChainType.EVM,\n  networkType: NetworkType.MAINNET,\n  rpcUrls: [\n    \"https://arb1.arbitrum.io/rpc\",\n    \"https://arb-mainnet.g.alchemy.com/v2/your-api-key\",\n  ],\n  nativeCurrency: {\n    name: \"Ether\",\n    symbol: \"ETH\",\n    decimals: 18,\n  },\n  blockExplorerUrls: [\"https://arbiscan.io\"],\n  iconUrl: \"https://cryptologos.cc/logos/arbitrum-arb-logo.png\",\n};\n\nexport const optimismMainnet: ChainConfig = {\n  id: 10,\n  name: \"Optimism\",\n  type: ChainType.EVM,\n  networkType: NetworkType.MAINNET,\n  rpcUrls: [\n    \"https://mainnet.optimism.io\",\n    \"https://opt-mainnet.g.alchemy.com/v2/your-api-key\",\n  ],\n  nativeCurrency: {\n    name: \"Ether\",\n    symbol: \"ETH\",\n    decimals: 18,\n  },\n  blockExplorerUrls: [\"https://optimistic.etherscan.io\"],\n  iconUrl: \"https://cryptologos.cc/logos/optimism-op-logo.png\",\n};\n\nexport const bscMainnet: ChainConfig = {\n  id: 56,\n  name: \"BNB Smart Chain\",\n  type: ChainType.EVM,\n  networkType: NetworkType.MAINNET,\n  rpcUrls: [\n    \"https://bsc-dataseed.binance.org\",\n    \"https://bsc-dataseed1.defibit.io\",\n  ],\n  nativeCurrency: {\n    name: \"BNB\",\n    symbol: \"BNB\",\n    decimals: 18,\n  },\n  blockExplorerUrls: [\"https://bscscan.com\"],\n  iconUrl: \"https://cryptologos.cc/logos/bnb-bnb-logo.png\",\n};\n\nexport const popularEVMChains = [\n  ethereumMainnet,\n  polygonMainnet,\n  arbitrumMainnet,\n  optimismMainnet,\n  bscMainnet,\n];\n","import { ChainConfig, NetworkType, ChainType } from \"../../types/chain\";\n\nexport const solanaMainnet: ChainConfig = {\n  id: \"mainnet-beta\",\n  name: \"Solana\",\n  type: ChainType.SVM,\n  networkType: NetworkType.MAINNET,\n  rpcUrls: [\n    \"https://api.mainnet-beta.solana.com\",\n    \"https://solana-api.projectserum.com\",\n  ],\n  nativeCurrency: {\n    name: \"Solana\",\n    symbol: \"SOL\",\n    decimals: 9,\n  },\n  blockExplorerUrls: [\"https://explorer.solana.com\"],\n  iconUrl: \"https://cryptologos.cc/logos/solana-sol-logo.png\",\n};\n\nexport const solanaDevnet: ChainConfig = {\n  id: \"devnet\",\n  name: \"Solana Devnet\",\n  type: ChainType.SVM,\n  networkType: NetworkType.DEVNET,\n  rpcUrls: [\"https://api.devnet.solana.com\"],\n  nativeCurrency: {\n    name: \"Solana\",\n    symbol: \"SOL\",\n    decimals: 9,\n  },\n  blockExplorerUrls: [\"https://explorer.solana.com/?cluster=devnet\"],\n  iconUrl: \"https://cryptologos.cc/logos/solana-sol-logo.png\",\n};\n\nexport const solanaTestnet: ChainConfig = {\n  id: \"testnet\",\n  name: \"Solana Testnet\",\n  type: ChainType.SVM,\n  networkType: NetworkType.TESTNET,\n  rpcUrls: [\"https://api.testnet.solana.com\"],\n  nativeCurrency: {\n    name: \"Solana\",\n    symbol: \"SOL\",\n    decimals: 9,\n  },\n  blockExplorerUrls: [\"https://explorer.solana.com/?cluster=testnet\"],\n  iconUrl: \"https://cryptologos.cc/logos/solana-sol-logo.png\",\n};\n\nexport const popularSVMChains = [solanaMainnet, solanaDevnet, solanaTestnet];\n","import { ChainAdapter, ChainConfig, ChainType } from \"../types/chain\";\nimport { EVMChainAdapter } from \"./evm\";\nimport { SVMChainAdapter } from \"./svm\";\n\n// Import popular chains\nimport { popularEVMChains } from \"./evm/popular\";\nimport { popularSVMChains } from \"./svm/popular\";\n\n// Export chain adapters\nexport { EVMChainAdapter, SVMChainAdapter };\n\n// Export popular chains\nexport { popularEVMChains, popularSVMChains };\n\n// Chain adapter registry\nconst chainAdapters: Record<ChainType, ChainAdapter> = {\n  [ChainType.EVM]: new EVMChainAdapter(),\n  [ChainType.SVM]: new SVMChainAdapter(),\n};\n\n/**\n * Get a chain adapter for the specified chain type\n * @param chainType Chain type\n * @returns Chain adapter\n */\nexport function getChainAdapter(chainType: ChainType): ChainAdapter {\n  const adapter = chainAdapters[chainType];\n  if (!adapter) {\n    throw new Error(`Chain adapter not found for chain type: ${chainType}`);\n  }\n  return adapter;\n}\n\n/**\n * Get a chain adapter for the specified chain configuration\n * @param chainConfig Chain configuration\n * @returns Chain adapter\n */\nexport function getChainAdapterForChain(\n  chainConfig: ChainConfig\n): ChainAdapter {\n  return getChainAdapter(chainConfig.type);\n}\n\n/**\n * Get all supported chains\n * @returns Array of chain configurations\n */\nexport function getAllChains(): ChainConfig[] {\n  return [...popularEVMChains, ...popularSVMChains];\n}\n\n/**\n * Get a chain configuration by ID\n * @param chainId Chain ID\n * @returns Chain configuration or null if not found\n */\nexport function getChainById(chainId: string | number): ChainConfig | null {\n  return getAllChains().find((chain) => chain.id === chainId) || null;\n}\n","import { BaseConnector } from \"./base\";\nimport { ChainId, ChainType, ChainConfig } from \"../types/chain\";\nimport {\n  ConnectorError,\n  ConnectorEvent,\n  ConnectorStatus,\n} from \"../types/connector\";\nimport { getChainById } from \"../chains\";\n\ndeclare global {\n  interface Window {\n    ethereum?: any;\n  }\n}\n\n// Track pending requests to prevent duplicates\nlet pendingRequest = false;\nlet requestTimeout: NodeJS.Timeout | null = null;\n\n/**\n * MetaMask connector\n * Implements wallet connection for MetaMask and other EVM-compatible wallets\n */\nexport class MetaMaskConnector extends BaseConnector {\n  // Store bound event handlers to prevent memory leaks\n  private boundAccountsChanged: (accounts: string[]) => void;\n  private boundChainChanged: (chainId: string) => void;\n  private boundDisconnect: () => void;\n\n  constructor() {\n    super(\n      \"metamask\",\n      \"MetaMask\",\n      \"injected\",\n      \"https://metamask.io/images/metamask-fox.svg\",\n      [ChainType.EVM] // MetaMask only supports EVM chains\n    );\n\n    // Bind event handlers once to prevent memory leaks\n    this.boundAccountsChanged = this.handleAccountsChanged.bind(this);\n    this.boundChainChanged = this.handleChainChanged.bind(this);\n    this.boundDisconnect = this.handleDisconnect.bind(this);\n  }\n\n  /**\n   * Check if MetaMask is available\n   */\n  isAvailable(): boolean {\n    return typeof window !== \"undefined\" && !!window.ethereum;\n  }\n\n  /**\n   * Connect to MetaMask\n   * @param chainId Optional chain ID to connect to\n   */\n  async connect(chainId?: ChainId): Promise<string> {\n    if (!this.isAvailable()) {\n      const error: ConnectorError = {\n        code: \"wallet_unavailable\",\n        message: \"MetaMask is not installed\",\n      };\n      this.updateError(error);\n      this.updateStatus(ConnectorStatus.ERROR);\n      throw error;\n    }\n\n    // Check if the user has explicitly disconnected before\n    const hasDisconnected =\n      localStorage.getItem(\"metamask_disconnected\") === \"true\";\n    if (hasDisconnected) {\n      // User has explicitly disconnected, don't auto-connect\n      const error: ConnectorError = {\n        code: \"user_disconnected\",\n        message: \"User has explicitly disconnected. Please connect manually.\",\n      };\n      this.updateError(error);\n      this.updateStatus(ConnectorStatus.ERROR);\n      throw error;\n    }\n\n    // Check if there's already a pending request\n    if (pendingRequest) {\n      const error: ConnectorError = {\n        code: \"request_pending\",\n        message:\n          \"A wallet connection request is already pending. Please check your wallet extension.\",\n      };\n      this.updateError(error);\n      this.updateStatus(ConnectorStatus.ERROR);\n      throw error;\n    }\n\n    try {\n      this.updateStatus(ConnectorStatus.CONNECTING);\n      pendingRequest = true;\n\n      // Set a timeout to reset the pending flag after 30 seconds\n      // This prevents the app from getting stuck if the user never responds to the wallet\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n      }\n      requestTimeout = setTimeout(() => {\n        pendingRequest = false;\n      }, 30000); // 30 seconds timeout\n\n      // Request accounts\n      const accounts = await window.ethereum.request({\n        method: \"eth_requestAccounts\",\n      });\n\n      // Clear the timeout and reset the pending flag\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n        requestTimeout = null;\n      }\n      pendingRequest = false;\n\n      const account = accounts[0];\n\n      // Get current chain ID\n      const currentChainId = await window.ethereum.request({\n        method: \"eth_chainId\",\n      });\n      const parsedChainId = parseInt(currentChainId, 16);\n\n      // If a specific chain ID is requested, switch to it\n      if (chainId && parsedChainId !== chainId) {\n        await this.switchChain(chainId);\n      }\n\n      // Set up event listeners\n      this.setupEventListeners();\n\n      // Update state\n      this.updateAccount(account);\n      this.updateChainId(parsedChainId);\n      this.updateStatus(ConnectorStatus.CONNECTED);\n      this.updateError(null);\n\n      // Clear the disconnected flag since the user has successfully connected\n      localStorage.removeItem(\"metamask_disconnected\");\n\n      // Emit connect event\n      this._eventEmitter.emit(ConnectorEvent.CONNECT, account);\n\n      return account;\n    } catch (error: any) {\n      // Clear the timeout and reset the pending flag\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n        requestTimeout = null;\n      }\n      pendingRequest = false;\n\n      // Handle specific MetaMask errors\n      if (error.code === -32002) {\n        const pendingError: ConnectorError = {\n          code: \"request_already_pending\",\n          message:\n            \"A wallet connection request is already pending. Please check your MetaMask extension and approve or reject the request.\",\n          details: error,\n        };\n        this.updateError(pendingError);\n        this.updateStatus(ConnectorStatus.ERROR);\n        throw pendingError;\n      }\n\n      const connectorError: ConnectorError = {\n        code: error.code || \"connection_error\",\n        message: error.message || \"Failed to connect to MetaMask\",\n        details: error,\n      };\n      this.updateError(connectorError);\n      this.updateStatus(ConnectorStatus.ERROR);\n      throw connectorError;\n    }\n  }\n\n  /**\n   * Disconnect from MetaMask\n   */\n  async disconnect(): Promise<void> {\n    // Only proceed if we're connected\n    if (this._status === ConnectorStatus.DISCONNECTED) {\n      return;\n    }\n\n    // Set a flag in localStorage to indicate that the user has explicitly disconnected\n    localStorage.setItem(\"metamask_disconnected\", \"true\");\n\n    // First remove our internal event listeners\n    this.removeAllListeners();\n\n    // Then remove MetaMask event listeners\n    this.removeEventListeners();\n\n    // Update state\n    this.updateAccount(null);\n    this.updateChainId(null);\n    this.updateStatus(ConnectorStatus.DISCONNECTED);\n    this.updateError(null);\n\n    // Emit disconnect event\n    this._eventEmitter.emit(ConnectorEvent.DISCONNECT);\n  }\n\n  /**\n   * Switch to a different chain\n   * @param chainId Chain ID to switch to\n   */\n  async switchChain(chainId: ChainId): Promise<void> {\n    if (!this.isAvailable() || !this.isConnected()) {\n      const error: ConnectorError = {\n        code: \"not_connected\",\n        message: \"Not connected to MetaMask\",\n      };\n      this.updateError(error);\n      throw error;\n    }\n\n    // Check if there's already a pending request\n    if (pendingRequest) {\n      const error: ConnectorError = {\n        code: \"request_pending\",\n        message:\n          \"A wallet request is already pending. Please check your wallet extension.\",\n      };\n      this.updateError(error);\n      throw error;\n    }\n\n    try {\n      pendingRequest = true;\n\n      // Set a timeout to reset the pending flag after 30 seconds\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n      }\n      requestTimeout = setTimeout(() => {\n        pendingRequest = false;\n      }, 30000); // 30 seconds timeout\n\n      // Convert chainId to hex if it's a number\n      const hexChainId =\n        typeof chainId === \"number\" ? `0x${chainId.toString(16)}` : chainId;\n\n      // Try to switch to the chain\n      await window.ethereum.request({\n        method: \"wallet_switchEthereumChain\",\n        params: [{ chainId: hexChainId }],\n      });\n\n      // Clear the timeout and reset the pending flag\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n        requestTimeout = null;\n      }\n      pendingRequest = false;\n\n      // Update chain ID\n      this.updateChainId(chainId);\n    } catch (error: any) {\n      // Clear the timeout and reset the pending flag\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n        requestTimeout = null;\n      }\n      pendingRequest = false;\n\n      // Handle specific MetaMask errors\n      if (error.code === -32002) {\n        const pendingError: ConnectorError = {\n          code: \"request_already_pending\",\n          message:\n            \"A wallet request is already pending. Please check your MetaMask extension and approve or reject the request.\",\n          details: error,\n        };\n        this.updateError(pendingError);\n        throw pendingError;\n      }\n\n      // If the chain hasn't been added to MetaMask, add it\n      if (error.code === 4902) {\n        const chain = getChainById(chainId);\n        if (chain) {\n          await this.addChain(chain);\n        } else {\n          throw {\n            code: \"chain_not_found\",\n            message: `Chain with ID ${chainId} not found`,\n          };\n        }\n      } else {\n        const connectorError: ConnectorError = {\n          code: error.code || \"chain_switch_error\",\n          message: error.message || \"Failed to switch chain\",\n          details: error,\n        };\n        this.updateError(connectorError);\n        throw connectorError;\n      }\n    }\n  }\n\n  /**\n   * Add a chain to MetaMask\n   * @param chain Chain configuration\n   */\n  private async addChain(chain: ChainConfig): Promise<void> {\n    // Check if there's already a pending request\n    if (pendingRequest) {\n      const error: ConnectorError = {\n        code: \"request_pending\",\n        message:\n          \"A wallet request is already pending. Please check your wallet extension.\",\n      };\n      this.updateError(error);\n      throw error;\n    }\n\n    try {\n      pendingRequest = true;\n\n      // Set a timeout to reset the pending flag after 30 seconds\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n      }\n      requestTimeout = setTimeout(() => {\n        pendingRequest = false;\n      }, 30000); // 30 seconds timeout\n\n      await window.ethereum.request({\n        method: \"wallet_addEthereumChain\",\n        params: [\n          {\n            chainId:\n              typeof chain.id === \"number\"\n                ? `0x${chain.id.toString(16)}`\n                : chain.id,\n            chainName: chain.name,\n            nativeCurrency: chain.nativeCurrency,\n            rpcUrls: chain.rpcUrls,\n            blockExplorerUrls: chain.blockExplorerUrls,\n          },\n        ],\n      });\n\n      // Clear the timeout and reset the pending flag\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n        requestTimeout = null;\n      }\n      pendingRequest = false;\n    } catch (error: any) {\n      // Clear the timeout and reset the pending flag\n      if (requestTimeout) {\n        clearTimeout(requestTimeout);\n        requestTimeout = null;\n      }\n      pendingRequest = false;\n\n      // Handle specific MetaMask errors\n      if (error.code === -32002) {\n        const pendingError: ConnectorError = {\n          code: \"request_already_pending\",\n          message:\n            \"A wallet request is already pending. Please check your MetaMask extension and approve or reject the request.\",\n          details: error,\n        };\n        this.updateError(pendingError);\n        throw pendingError;\n      }\n\n      const connectorError: ConnectorError = {\n        code: error.code || \"add_chain_error\",\n        message: error.message || \"Failed to add chain\",\n        details: error,\n      };\n      this.updateError(connectorError);\n      throw connectorError;\n    }\n  }\n\n  /**\n   * Set up event listeners for MetaMask events\n   */\n  private setupEventListeners(): void {\n    if (window.ethereum) {\n      window.ethereum.on(\"accountsChanged\", this.boundAccountsChanged);\n      window.ethereum.on(\"chainChanged\", this.boundChainChanged);\n      window.ethereum.on(\"disconnect\", this.boundDisconnect);\n    }\n  }\n\n  /**\n   * Remove event listeners\n   */\n  private removeEventListeners(): void {\n    if (window.ethereum) {\n      window.ethereum.removeListener(\n        \"accountsChanged\",\n        this.boundAccountsChanged\n      );\n      window.ethereum.removeListener(\"chainChanged\", this.boundChainChanged);\n      window.ethereum.removeListener(\"disconnect\", this.boundDisconnect);\n    }\n  }\n\n  /**\n   * Handle accounts changed event\n   * @param accounts New accounts\n   */\n  private handleAccountsChanged(accounts: string[]): void {\n    if (accounts.length === 0) {\n      // User disconnected\n      this.disconnect();\n    } else {\n      // Account changed\n      this.updateAccount(accounts[0]);\n    }\n  }\n\n  /**\n   * Handle chain changed event\n   * @param chainId New chain ID\n   */\n  private handleChainChanged(chainId: string): void {\n    const parsedChainId = parseInt(chainId, 16);\n    this.updateChainId(parsedChainId);\n  }\n\n  /**\n   * Handle disconnect event\n   */\n  private handleDisconnect(): void {\n    // Only update the state without emitting events to prevent recursion\n    this.updateStatus(ConnectorStatus.DISCONNECTED);\n    this.updateAccount(null);\n    this.updateChainId(null);\n    this.updateError(null);\n\n    // Remove event listeners\n    this.removeEventListeners();\n  }\n}\n","import { BaseConnector } from \"./base\";\nimport { ChainId, ChainType } from \"../types/chain\";\nimport {\n  ConnectorError,\n  ConnectorEvent,\n  ConnectorStatus,\n} from \"../types/connector\";\nimport { getChainById } from \"../chains\";\n\ndeclare global {\n  interface Window {\n    phantom?: {\n      solana?: {\n        isPhantom?: boolean;\n        connect: () => Promise<{ publicKey: { toString: () => string } }>;\n        disconnect: () => Promise<void>;\n        on: (event: string, handler: (...args: any[]) => void) => void;\n        off: (event: string, handler: (...args: any[]) => void) => void;\n        request: (request: { method: string; params?: any }) => Promise<any>;\n      };\n    };\n  }\n}\n\n/**\n * Phantom connector\n * Implements wallet connection for Phantom (Solana)\n */\nexport class PhantomConnector extends BaseConnector {\n  constructor() {\n    super(\n      \"phantom\",\n      \"Phantom\",\n      \"injected\",\n      \"https://phantom.app/img/logo.png\",\n      [ChainType.SVM] // Phantom supports Solana\n    );\n  }\n\n  /**\n   * Check if Phantom is available\n   */\n  isAvailable(): boolean {\n    return typeof window !== \"undefined\" && !!window.phantom?.solana?.isPhantom;\n  }\n\n  /**\n   * Connect to Phantom\n   * @param chainId Optional chain ID to connect to\n   */\n  async connect(chainId?: ChainId): Promise<string> {\n    if (!this.isAvailable()) {\n      const error: ConnectorError = {\n        code: \"wallet_unavailable\",\n        message: \"Phantom is not installed\",\n      };\n      this.updateError(error);\n      this.updateStatus(ConnectorStatus.ERROR);\n      throw error;\n    }\n\n    try {\n      this.updateStatus(ConnectorStatus.CONNECTING);\n\n      // Connect to Phantom\n      const solana = window.phantom?.solana;\n      if (!solana) {\n        throw new Error(\"Phantom solana provider not found\");\n      }\n\n      const response = await solana.connect();\n      const account = response.publicKey.toString();\n\n      // Set up event listeners\n      this.setupEventListeners();\n\n      // Update state\n      this.updateAccount(account);\n\n      // For Solana, we use the network name as the chain ID\n      // Default to mainnet if not specified\n      const solanaChainId = chainId || \"mainnet-beta\";\n      this.updateChainId(solanaChainId);\n\n      this.updateStatus(ConnectorStatus.CONNECTED);\n      this.updateError(null);\n\n      // Emit connect event\n      this._eventEmitter.emit(ConnectorEvent.CONNECT, account);\n\n      return account;\n    } catch (error: any) {\n      const connectorError: ConnectorError = {\n        code: error.code || \"connection_error\",\n        message: error.message || \"Failed to connect to Phantom\",\n        details: error,\n      };\n      this.updateError(connectorError);\n      this.updateStatus(ConnectorStatus.ERROR);\n      throw connectorError;\n    }\n  }\n\n  /**\n   * Disconnect from Phantom\n   */\n  async disconnect(): Promise<void> {\n    if (this.isAvailable()) {\n      try {\n        const solana = window.phantom?.solana;\n        if (solana) {\n          await solana.disconnect();\n        }\n      } catch (error) {\n        console.error(\"Error disconnecting from Phantom:\", error);\n      }\n    }\n\n    this.removeEventListeners();\n    this.updateAccount(null);\n    this.updateChainId(null);\n    this.updateStatus(ConnectorStatus.DISCONNECTED);\n    this.updateError(null);\n    this._eventEmitter.emit(ConnectorEvent.DISCONNECT);\n  }\n\n  /**\n   * Switch to a different Solana network\n   * @param chainId Chain ID to switch to (e.g., 'mainnet-beta', 'testnet', 'devnet')\n   */\n  async switchChain(chainId: ChainId): Promise<void> {\n    if (!this.isAvailable() || !this.isConnected()) {\n      const error: ConnectorError = {\n        code: \"not_connected\",\n        message: \"Not connected to Phantom\",\n      };\n      this.updateError(error);\n      throw error;\n    }\n\n    try {\n      // Phantom doesn't have a direct method to switch networks\n      // Users need to switch networks manually in the wallet\n      // We can only update our internal state\n      this.updateChainId(chainId);\n\n      // Notify the user that they need to switch networks manually\n      console.warn(\n        \"Please switch to the desired network manually in your Phantom wallet.\"\n      );\n    } catch (error: any) {\n      const connectorError: ConnectorError = {\n        code: error.code || \"chain_switch_error\",\n        message: error.message || \"Failed to switch chain\",\n        details: error,\n      };\n      this.updateError(connectorError);\n      throw connectorError;\n    }\n  }\n\n  /**\n   * Set up event listeners for Phantom events\n   */\n  private setupEventListeners(): void {\n    const solana = window.phantom?.solana;\n    if (solana) {\n      solana.on(\"accountChanged\", this.handleAccountChanged.bind(this));\n      solana.on(\"disconnect\", this.handleDisconnect.bind(this));\n    }\n  }\n\n  /**\n   * Remove event listeners\n   */\n  private removeEventListeners(): void {\n    const solana = window.phantom?.solana;\n    if (solana) {\n      solana.off(\"accountChanged\", this.handleAccountChanged.bind(this));\n      solana.off(\"disconnect\", this.handleDisconnect.bind(this));\n    }\n  }\n\n  /**\n   * Handle account changed event\n   * @param publicKey New public key\n   */\n  private handleAccountChanged(\n    publicKey: { toString: () => string } | null\n  ): void {\n    if (!publicKey) {\n      // User disconnected\n      this.disconnect();\n    } else {\n      // Account changed\n      this.updateAccount(publicKey.toString());\n    }\n  }\n\n  /**\n   * Handle disconnect event\n   */\n  private handleDisconnect(): void {\n    this.disconnect();\n  }\n}\n","import { Connector } from \"../types/connector\";\nimport { BaseConnector } from \"./base\";\nimport { MetaMaskConnector } from \"./metamask\";\nimport { PhantomConnector } from \"./phantom\";\n\n// Export all connectors\nexport { BaseConnector, MetaMaskConnector, PhantomConnector };\n\n// Default connectors\nconst defaultConnectors: Connector[] = [\n  new MetaMaskConnector(), // Use MetaMask for EVM chains\n  new PhantomConnector(),\n];\n\n/**\n * Get all available connectors\n * @returns Array of available connectors\n */\nexport function getAvailableConnectors(): Connector[] {\n  if (typeof window === \"undefined\") {\n    return [];\n  }\n\n  return defaultConnectors.filter((connector) => {\n    // Check if the connector has an isAvailable method\n    if (\n      \"isAvailable\" in connector &&\n      typeof (connector as any).isAvailable === \"function\"\n    ) {\n      return (connector as any).isAvailable();\n    }\n    return true;\n  });\n}\n\n/**\n * Get a connector by ID\n * @param id Connector ID\n * @returns Connector or undefined if not found\n */\nexport function getConnectorById(id: string): Connector | undefined {\n  return defaultConnectors.find((connector) => connector.id === id);\n}\n"]}