// src/blockchain/web3modal.js
import { createWeb3Modal, defaultConfig } from '@web3modal/ethers'

const projectId = 'a2302c95fedb32f4c64672a41159df37' // Get from https://cloud.walletconnect.com

const chains = [
    {
        chainId: 42161,
        name: 'Arbitrum One',
        currency: 'ETH',
        explorerUrl: 'https://arbiscan.io',
        rpcUrl: 'https://arbitrum-mainnet.infura.io'
    },
    {
        chainId: 1337,
        name: 'Dexorder Alpha Testnet',
        currency: 'TETH',
        explorerUrl: '',
        rpcUrl: 'https://rpc.alpha.dexorder.com'
    },
    {
        chainId: 31337,
        name: 'Mockchain',
        currency: 'TETH',
        explorerUrl: '',
        rpcUrl: 'http://localhost:8545'
    }
]

const ethersConfig = defaultConfig({
    metadata: {
        name: 'Dexorder',
        description: 'Dexorder Trading Platform',
        url: window.location.origin,
        icons: ['https://your-icon-url.com']
    },
    defaultChainId: 42161,
    enableEIP6963: false, // Disable to prevent wallets from auto-announcing
    enableInjected: true,
    enableCoinbase: true,
    rpcUrl: 'https://arbitrum-mainnet.infura.io'
})

export const web3modal = createWeb3Modal({
    ethersConfig,
    chains,
    projectId,
    enableAnalytics: false,
    themeMode: 'dark',
    featuredWalletIds: [
        'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96' // MetaMask
    ],
})