From cd5af6b90757e8d48656700a53ddd98176a76f7c Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Wed, 4 Oct 2023 14:10:13 -0500 Subject: [PATCH] Add UFVK support for ZGo shops --- src/ZGoBackend.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 9250006..fcd0358 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -1189,7 +1189,22 @@ routes pipe config = do liftAndCatchIO $ run (upsertViewingKey o' q) status created201 else status forbidden403 - else status badRequest400 -- TODO: add Unified VK support + else case decodeUfvk (C.pack q) of + Nothing -> status badRequest400 + Just fvk -> + if matchOrchardAddress + (C.pack q) + (C.pack . T.unpack $ uaddress u') + then do + owner <- + liftAndCatchIO $ run (findOwner $ uaddress u') + case cast' . Doc =<< owner of + Nothing -> status badRequest400 + Just o' -> do + unless (oviewkey o' /= "") $ do + liftAndCatchIO $ run (upsertViewingKey o' q) + status created201 + else status forbidden403 --Get items associated with the given address get "/api/items" $ do session <- param "session"