From 716ae4eda3aaacd77dd9361724d9ad3fb785e1a4 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Thu, 2 Jan 2025 09:05:50 +0500 Subject: [PATCH] chore: add alerts in App.tsx --- ui/src/App.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 76e1617..e24f74b 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -76,6 +76,11 @@ const setup = async () => { }; const connectWallet = async () => { + try { + await fetch(ENDPOINTS.RPC); + } catch (error) { + throw new Error('Chain is not running. Please start the chain first!'); + } await suggestChain('https://local.agoric.net/network-config'); const wallet = await makeAgoricWalletConnection(watcher, ENDPOINTS.RPC); useAppStore.setState({ wallet }); @@ -88,9 +93,14 @@ const connectWallet = async () => { const makeOffer = (giveValue: bigint, wantChoices: Record) => { const { wallet, offerUpInstance, brands } = useAppStore.getState(); - if (!offerUpInstance) throw Error('no contract instance'); - if (!(brands && brands.IST && brands.Item)) + if (!offerUpInstance) { + alert('No contract instance found on the chain RPC: ' + ENDPOINTS.RPC); + throw Error('no contract instance'); + } + if (!(brands && brands.IST && brands.Item)) { + alert('Brands not available'); throw Error('brands not available'); + } const value = makeCopyBag(entries(wantChoices)); const want = { Items: { brand: brands.Item, value } };