import { BLOCKCHAIN_NAME, BlockchainName } from 'src/core/blockchain/models/blockchain-name';
import { ERC20_TOKEN_ABI } from 'src/core/blockchain/web3-public-service/web3-public/evm-web3-public/constants/erc-20-token-abi';
import { TRC20_CONTRACT_ABI } from 'src/core/blockchain/web3-public-service/web3-public/tron-web3-public/constants/trc-20-contract-abi';

export const HEALTHCHECK = {
    [BLOCKCHAIN_NAME.ETHEREUM]: {
        contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'USDT'
    },
    [BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]: {
        contractAddress: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'BUSD'
    },
    [BLOCKCHAIN_NAME.POLYGON]: {
        contractAddress: '0x7FFB3d637014488b63fb9858E279385685AFc1e2',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'USDT'
    },
    [BLOCKCHAIN_NAME.AVALANCHE]: {
        contractAddress: '0xc7198437980c041c805A1EDcbA50c1Ce5db95118',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'USDT.e'
    },
    [BLOCKCHAIN_NAME.MOONRIVER]: {
        contractAddress: '0xB44a9B6905aF7c801311e8F4E76932ee959c663C',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'USDT'
    },
    [BLOCKCHAIN_NAME.FANTOM]: {
        contractAddress: '0x049d68029688eabf473097a2fc38ef61633a3c7a',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'fUSDT'
    },
    [BLOCKCHAIN_NAME.HARMONY]: {
        contractAddress: '0x3c2b8be99c50593081eaa2a724f0b8285f5aba8f',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: '1USDT'
    },
    [BLOCKCHAIN_NAME.ARBITRUM]: {
        contractAddress: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'USDT'
    },
    [BLOCKCHAIN_NAME.AURORA]: {
        contractAddress: '0x4988a896b1227218e4A686fdE5EabdcAbd91571f',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'USDT'
    },
    [BLOCKCHAIN_NAME.TELOS]: {
        contractAddress: '0xefaeee334f0fd1712f9a8cc375f427d9cdd40d73',
        contractAbi: ERC20_TOKEN_ABI,
        method: 'symbol',
        expected: 'USDT'
    },
    [BLOCKCHAIN_NAME.TRON]: {
        contractAddress: 'TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8',
        contractAbi: TRC20_CONTRACT_ABI,
        method: 'symbol',
        expected: 'USDC'
    }
};

export type HealthcheckAvailableBlockchain = keyof typeof HEALTHCHECK;

export const healthcheckAvailableBlockchains = Object.keys(HEALTHCHECK);

export function isBlockchainHealthcheckAvailable(
    blockchainName: BlockchainName
): blockchainName is HealthcheckAvailableBlockchain {
    return healthcheckAvailableBlockchains.includes(blockchainName);
}
