From ec01edd0d79b69f62d634b8305e2015fb5733524 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Tue, 16 May 2023 11:06:22 +0900 Subject: [PATCH] fix: handle empty chainData cases. --- packages/utils/src/peripherals/chainData.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/utils/src/peripherals/chainData.ts b/packages/utils/src/peripherals/chainData.ts index a5041deed0..907214fc47 100644 --- a/packages/utils/src/peripherals/chainData.ts +++ b/packages/utils/src/peripherals/chainData.ts @@ -101,11 +101,13 @@ export const getChainData = async (): Promise> => { const url = "https://chaindata.connext.ninja"; try { const data = await fetchJson(url); + if (!data) throw new Error("No chain data found"); return chainDataToMap(data); } catch (err: unknown) { const url = "https://raw.githubusercontent.com/connext/chaindata/main/crossChain.json"; try { const data = await fetchJson(url); + if (!data) throw new Error("No chain data found"); return chainDataToMap(data); } catch (err: unknown) { // Check to see if we have the chain data cached locally.