Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Alerts in UI for no chain/no contract #111

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -88,9 +93,14 @@ const connectWallet = async () => {

const makeOffer = (giveValue: bigint, wantChoices: Record<string, bigint>) => {
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 } };
Expand Down
Loading