Handle stopped assets container when running locally

This commit is contained in:
Willian Mitsuda 2022-03-30 22:58:25 -03:00
parent 1a493e23dd
commit 562f490e27

View File

@ -25,13 +25,14 @@ export const useChainInfoFromMetadataFile = (
const [chainInfo, setChainInfo] = useState<ChainInfo | undefined>(undefined); const [chainInfo, setChainInfo] = useState<ChainInfo | undefined>(undefined);
useEffect(() => { useEffect(() => {
if (chainId === undefined) { if (assetsURLPrefix === undefined || chainId === undefined) {
setChainInfo(undefined); setChainInfo(undefined);
return; return;
} }
const readChainInfo = async () => { const readChainInfo = async () => {
const res = await fetch(chainInfoURL(assetsURLPrefix!, chainId)); try {
const res = await fetch(chainInfoURL(assetsURLPrefix, chainId));
if (!res.ok) { if (!res.ok) {
setChainInfo(defaultChainInfo); setChainInfo(defaultChainInfo);
return; return;
@ -43,6 +44,11 @@ export const useChainInfoFromMetadataFile = (
nativeDecimals: info.nativeCurrency.decimals, nativeDecimals: info.nativeCurrency.decimals,
nativeSymbol: info.nativeCurrency.symbol, nativeSymbol: info.nativeCurrency.symbol,
}); });
} catch (err) {
// ignore
setChainInfo(defaultChainInfo);
return;
}
}; };
readChainInfo(); readChainInfo();
}, [assetsURLPrefix, chainId]); }, [assetsURLPrefix, chainId]);