From c27b3c23ecdd53acdbfece747b9bbdb39bf4dae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 27 Aug 2023 18:33:16 +0200 Subject: Replace storedStorage usage with MonadHead --- src/Test.hs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/Test.hs') diff --git a/src/Test.hs b/src/Test.hs index a506345..3f59239 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -426,31 +426,28 @@ cmdWatchSharedIdentity = do cmdUpdateLocalIdentity :: Command cmdUpdateLocalIdentity = do [name] <- asks tiParams - updateLocalHead_ $ \ls -> liftIO $ do + updateLocalHead_ $ \ls -> do Just identity <- return $ validateIdentity $ lsIdentity $ fromStored ls - let st = storedStorage ls - public = idKeyIdentity identity + let public = idKeyIdentity identity - Just secret <- loadKey public + secret <- loadKey public nidata <- maybe (error "created invalid identity") (return . idData) . validateIdentity =<< - wrappedStore st =<< sign secret =<< wrappedStore st (emptyIdentityData public) + mstore =<< sign secret =<< mstore (emptyIdentityData public) { iddPrev = toList $ idDataF identity , iddName = Just name } - wrappedStore st $ (fromStored ls) { lsIdentity = nidata } + mstore (fromStored ls) { lsIdentity = nidata } cmdUpdateSharedIdentity :: Command cmdUpdateSharedIdentity = do [name] <- asks tiParams updateLocalHead_ $ updateSharedState_ $ \case Nothing -> throwError "no existing shared identity" - Just identity -> liftIO $ do - let st = storedStorage $ head $ idDataF identity - public = idKeyIdentity identity - - Just secret <- loadKey public + Just identity -> do + let public = idKeyIdentity identity + secret <- loadKey public maybe (error "created invalid identity") (return . Just . toComposedIdentity) . validateIdentity =<< - wrappedStore st =<< sign secret =<< wrappedStore st (emptyIdentityData public) + mstore =<< sign secret =<< mstore (emptyIdentityData public) { iddPrev = toList $ idDataF identity , iddName = Just name } -- cgit v1.2.3