From 40c8cfa874382af195e347b5bfc842310b6e80b1 Mon Sep 17 00:00:00 2001
From: alfred-mk <alfredmwaik@gmail.com>
Date: Thu, 20 Mar 2025 16:11:59 +0300
Subject: [PATCH] Use the default vouchersResp

---
 handlers/application/menuhandler.go | 52 ++++++++++++++---------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go
index 2da5f22..e215d58 100644
--- a/handlers/application/menuhandler.go
+++ b/handlers/application/menuhandler.go
@@ -1956,22 +1956,22 @@ func (h *MenuHandlers) SetDefaultVoucher(ctx context.Context, sym string, input
 			}
 
 			// Fetch vouchers from the API using the public key
-			// vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey))
-			// if err != nil {
-			// 	fmt.Println("setting the flag_no_active_voucher")
-			// 	res.FlagSet = append(res.FlagSet, flag_no_active_voucher)
-			// 	return res, nil
-			// }
-
-			vouchersResp := []dataserviceapi.TokenHoldings{
-				{
-					ContractAddress: "0xcB453B742Bc8BE1BAa03Ce1927e287788d0aF065",
-					TokenSymbol:     "PES",
-					TokenDecimals:   "6",
-					Balance:         "10000000",
-				},
+			vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey))
+			if err != nil {
+				fmt.Println("setting the flag_no_active_voucher")
+				res.FlagSet = append(res.FlagSet, flag_no_active_voucher)
+				return res, nil
 			}
 
+			// vouchersResp := []dataserviceapi.TokenHoldings{
+			// 	{
+			// 		ContractAddress: "0xcB453B742Bc8BE1BAa03Ce1927e287788d0aF065",
+			// 		TokenSymbol:     "PES",
+			// 		TokenDecimals:   "6",
+			// 		Balance:         "10000000",
+			// 	},
+			// }
+
 			fmt.Println("fetched user vouchers in SetDefaultVoucher", "public_key", string(publicKey), "vouchers", vouchersResp)
 
 			// Return if there is no voucher
@@ -2050,20 +2050,20 @@ func (h *MenuHandlers) CheckVouchers(ctx context.Context, sym string, input []by
 	}
 
 	// Fetch vouchers from the API using the public key
-	// vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey))
-	// if err != nil {
-	// 	return res, nil
-	// }
-
-	vouchersResp := []dataserviceapi.TokenHoldings{
-		{
-			ContractAddress: "0xcB453B742Bc8BE1BAa03Ce1927e287788d0aF065",
-			TokenSymbol:     "PES",
-			TokenDecimals:   "6",
-			Balance:         "10000000",
-		},
+	vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey))
+	if err != nil {
+		return res, nil
 	}
 
+	// vouchersResp := []dataserviceapi.TokenHoldings{
+	// 	{
+	// 		ContractAddress: "0xcB453B742Bc8BE1BAa03Ce1927e287788d0aF065",
+	// 		TokenSymbol:     "PES",
+	// 		TokenDecimals:   "6",
+	// 		Balance:         "10000000",
+	// 	},
+	// }
+
 	fmt.Println("fetched user vouchers", "public_key", string(publicKey), "vouchers", vouchersResp)
 
 	// check the current active sym and update the data