diff --git a/components/chainSelect/ChainSelect.tsx b/components/chainSelect/ChainSelect.tsx index 9ef95b4..189f718 100644 --- a/components/chainSelect/ChainSelect.tsx +++ b/components/chainSelect/ChainSelect.tsx @@ -41,7 +41,7 @@ const ChainSelect = () => { const { state, dispatch } = useAppContext(); // UI State - const [chainArray, setChainArray] = useState([]); + const [chainArray, setChainArray] = useState([]); const [chainOptions, setChainOptions] = useState([]); const [chainError, setChainError] = useState(null); const [showSettings, setShowSettings] = useState(false); @@ -61,20 +61,28 @@ const ChainSelect = () => { const [tempRegistryName, setRegistryName] = useState(state.chain.registryName); const [tempExplorerLink, setExplorerLink] = useState(state.chain.explorerLink); - const url = "https://api.github.com/repos/cosmos/chain-registry/contents"; + const chainsUrl = "https://api.github.com/repos/cosmos/chain-registry/contents"; + const testnetsUrl = "https://api.github.com/repos/cosmos/chain-registry/contents/testnets"; const getGhJson = useCallback(async () => { // getting chain info from this repo: https://github.com/cosmos/chain-registry try { - const res = await axios.get(url); - const chains = res.data.filter((item: GithubChainRegistryItem) => { - return item.type == "dir" && !item.name.startsWith(".") && item.name != "testnets"; - }); - setChainArray(chains); - const options = chains.map(({ name }: GithubChainRegistryItem, index: number) => { - return { label: name, value: index }; - }); + const { data: chains } = await axios.get(chainsUrl); + const { data: testnets } = await axios.get(testnetsUrl); + + const allChains: GithubChainRegistryItem[] = [...chains, ...testnets].filter( + (item: GithubChainRegistryItem) => { + return item.type == "dir" && !item.name.startsWith(".") && !item.name.startsWith("_"); + }, + ); + setChainArray(allChains); + + const options = allChains.map(({ name }: GithubChainRegistryItem, index: number) => ({ + label: name, + value: index, + })); setChainOptions(options); + assert(state.chain.registryName, "registryName missing"); setSelectValue(findExistingOption(options, state.chain.registryName)); // eslint-disable-next-line @typescript-eslint/no-explicit-any