import { mainnet, sepolia } from 'viem/chains';
import { supersimL1 } from '@eth-optimism/viem/chains';
import { superchainRegistryChainList } from './superchainRegistryChainList.js';
const sourceChains = [
    {
        identifier: 'mainnet',
        chain: mainnet,
    },
    {
        identifier: 'sepolia',
        chain: sepolia,
    },
    {
        identifier: 'supersim',
        chain: supersimL1,
    },
    {
        identifier: 'interop-alpha',
        chain: sepolia,
    },
];
export const sourceIdentifierByChainId = sourceChains.reduce((acc, chain) => {
    acc[chain.chain.id] = chain.identifier;
    return acc;
}, {});
export const sourceChainByIdentifier = sourceChains.reduce((acc, chain) => {
    acc[chain.identifier] = chain.chain;
    return acc;
}, {});
// TODO: this is error prone, update @eth-optimism/viem to export a mapping from name to identifier
const supersimIdentifierByChainId = {
    901: 'supersim/supersiml2a',
    902: 'supersim/supersiml2b',
    903: 'supersim/supersiml2c',
    904: 'supersim/supersiml2d',
    905: 'supersim/supersiml2e',
};
const interopAlphaIdentifierByChainId = {
    420120000: 'interop-alpha/interop-alpha-0',
    420120001: 'interop-alpha/interop-alpha-1',
};
// TODO: this is error prone (and becomes outdated with chainlist updates), update @eth-optimism/viem to export a mapping from name to identifier
const superchainRegistryIdentifierByChainId = superchainRegistryChainList.reduce((acc, chainListItem) => {
    acc[chainListItem.chainId] = chainListItem.identifier;
    return acc;
}, {});
const identifierByChainId = {
    ...superchainRegistryIdentifierByChainId,
    ...supersimIdentifierByChainId,
    ...interopAlphaIdentifierByChainId,
};
export const rollupChainToIdentifier = (chain) => {
    return identifierByChainId[chain.id];
};
