import {
  CHAIN138_PLACEHOLDER_GAS_SYMBOLS,
  dedupeWalletWatchTokens,
  isDeterministicPlaceholderAddress,
  isWalletWatchEligibleAddress,
} from '@/utils/walletWatchEligible'

describe('walletWatchEligible', () => {
  it('detects GRU transport placeholders on Chain 138', () => {
    expect(isDeterministicPlaceholderAddress('0xcaaa00000000000000000000000000000000008a')).toBe(true)
    expect(isDeterministicPlaceholderAddress('0x93E66202A11B1772E55407B32B44e5Cd8eda7f22')).toBe(false)
  })

  it('marks live canonical addresses as wallet-eligible', () => {
    expect(isWalletWatchEligibleAddress('0xf22258f57794CC8E06237084b353Ab30fFfa640b')).toBe(true)
    expect(isWalletWatchEligibleAddress('0xcaaa00000000000000000000000000000000008a')).toBe(false)
  })

  it('documents the nine gas-family placeholder symbols', () => {
    expect(CHAIN138_PLACEHOLDER_GAS_SYMBOLS).toHaveLength(9)
  })

  it('dedupes wallet watch tokens by symbol preferring live deployments', () => {
    const deduped = dedupeWalletWatchTokens([
      {
        chainId: 138,
        symbol: 'cUSDC',
        address: '0xf22258f57794CC8E06237084b353Ab30fFfa640b',
      },
      {
        chainId: 138,
        symbol: 'cUSDC',
        address: '0x219522c60e83dEe01FC5b0329d6fA8fD84b9D13d',
        extensions: { deploymentVersion: 'v2', deploymentStatus: 'staged' },
      },
    ])
    expect(deduped).toHaveLength(1)
    expect(deduped[0]?.address).toBe('0xf22258f57794CC8E06237084b353Ab30fFfa640b')
  })
})
