From e95788fd6b28c387933439e7cae4aa3374a9fcc9 Mon Sep 17 00:00:00 2001 From: Karandeep Singh Date: Fri, 20 Dec 2024 23:37:38 +0530 Subject: [PATCH] fix: network selection --- .../CheckoutReceipentAddressView.tsx | 23 ++++++++++++++----- .../controllers/GiftDonutModalManager.ts | 5 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/advanced/dapps/chain-abstraction-demo/components/gift-donut-modal-views/CheckoutReceipentAddressView.tsx b/advanced/dapps/chain-abstraction-demo/components/gift-donut-modal-views/CheckoutReceipentAddressView.tsx index c8b927dfc..dac8fec36 100644 --- a/advanced/dapps/chain-abstraction-demo/components/gift-donut-modal-views/CheckoutReceipentAddressView.tsx +++ b/advanced/dapps/chain-abstraction-demo/components/gift-donut-modal-views/CheckoutReceipentAddressView.tsx @@ -10,6 +10,7 @@ import { ArrowLeft, ChevronLeft, Copy, UserRound, X } from "lucide-react"; import { Input } from "../ui/input"; import GiftSvg from "../assets/GiftSVG"; import useGiftDonut from "@/app/hooks/useGiftDonut"; +import { toast } from "sonner"; function CheckoutReceipentAddressView({ onViewChange, @@ -45,13 +46,23 @@ function GiftDonutForm({ }; const handleCheckout = () => { - const to = recipientAddress as `0x${string}`; - const token = giftDonutModalManager.getToken(); - const network = giftDonutModalManager.getNetwork(); - onClose() - giftDonutAsync(to, donutCount, token, network); - + try{ + const to = recipientAddress as `0x${string}`; + const token = giftDonutModalManager.getToken(); + const network = giftDonutModalManager.getNetwork(); + if(!network) { + throw new Error("Network not selected"); + } + onClose() + giftDonutAsync(to, donutCount, token, network); + }catch(e){ + console.error(e) + if(e instanceof Error){ + toast.error(e.message) + } + } }; + return (