import { ChainId } from 'wallet/src/constants/chains'
import { SafetyLevel } from 'wallet/src/data/__generated__/types-and-hooks'

export type SearchResult =
  | TokenSearchResult
  | WalletSearchResult
  | EtherscanSearchResult
  | NFTCollectionSearchResult

export enum SearchResultType {
  ENSAddress,
  Unitag,
  Token,
  Etherscan,
  NFTCollection,
}

export interface SearchResultBase {
  type: SearchResultType
  searchId?: string
}

export type WalletSearchResult = ENSAddressSearchResult | UnitagSearchResult

export interface ENSAddressSearchResult extends SearchResultBase {
  type: SearchResultType.ENSAddress
  address: Address
  ensName?: string
  primaryENSName?: string
}

export interface UnitagSearchResult extends SearchResultBase {
  type: SearchResultType.Unitag
  address: Address
  unitag: string
}

export interface TokenSearchResult extends SearchResultBase {
  type: SearchResultType.Token
  chainId: ChainId
  symbol: string
  address: Address | null
  name: string | null
  logoUrl: string | null
  safetyLevel: SafetyLevel | null
}

export interface NFTCollectionSearchResult extends SearchResultBase {
  type: SearchResultType.NFTCollection
  chainId: ChainId
  address: Address
  name: string
  imageUrl: string | null
  isVerified: boolean
}

export interface EtherscanSearchResult extends SearchResultBase {
  type: SearchResultType.Etherscan
  address: Address
}
