import { rollupChainToIdentifier } from './chainIdentifier.js';
import { networks } from './networks.js';
import { base, baseSepolia, optimism, optimismSepolia } from 'viem/chains';
// TODO: move this override logic into @eth-optimism/viem/chains
const TEMP_overrideBlockExplorerUrlByChainId = {
    [baseSepolia.id]: 'https://base-sepolia.blockscout.com/',
    [base.id]: 'https://base.blockscout.com/',
    [optimismSepolia.id]: 'https://optimism-sepolia.blockscout.com/',
    [optimism.id]: 'https://optimism.blockscout.com/',
};
export const sourceChains = networks.map(network => network.sourceChain);
export const rollupChains = networks
    .flatMap(network => network.chains)
    .map(chain => {
    let newChain = {
        ...chain,
    };
    if (TEMP_overrideBlockExplorerUrlByChainId[chain.id]) {
        newChain = {
            ...newChain,
            blockExplorers: {
                default: {
                    name: 'Blockscout',
                    url: TEMP_overrideBlockExplorerUrlByChainId[chain.id],
                },
            },
        };
    }
    return newChain;
});
export const chains = [...sourceChains, ...rollupChains];
export const chainById = chains.reduce((acc, chain) => {
    acc[chain.id] = chain;
    return acc;
}, {});
export const rollupChainByIdentifier = rollupChains.reduce((acc, chain) => {
    acc[rollupChainToIdentifier(chain)] = chain;
    return acc;
}, {});
