Handle stopped assets container when running locally
This commit is contained in:
parent
1a493e23dd
commit
562f490e27
@ -25,24 +25,30 @@ 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 {
|
||||||
if (!res.ok) {
|
const res = await fetch(chainInfoURL(assetsURLPrefix, chainId));
|
||||||
|
if (!res.ok) {
|
||||||
|
setChainInfo(defaultChainInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const info = await res.json();
|
||||||
|
|
||||||
|
setChainInfo({
|
||||||
|
nativeName: info.nativeCurrency.name,
|
||||||
|
nativeDecimals: info.nativeCurrency.decimals,
|
||||||
|
nativeSymbol: info.nativeCurrency.symbol,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
// ignore
|
||||||
setChainInfo(defaultChainInfo);
|
setChainInfo(defaultChainInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const info = await res.json();
|
|
||||||
|
|
||||||
setChainInfo({
|
|
||||||
nativeName: info.nativeCurrency.name,
|
|
||||||
nativeDecimals: info.nativeCurrency.decimals,
|
|
||||||
nativeSymbol: info.nativeCurrency.symbol,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
readChainInfo();
|
readChainInfo();
|
||||||
}, [assetsURLPrefix, chainId]);
|
}, [assetsURLPrefix, chainId]);
|
||||||
|
Loading…
Reference in New Issue
Block a user