From b8e55c64a68763b0953945476cc75206f5354023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 17 May 2022 22:06:01 +0200 Subject: Mergeable class with separate component type --- src/Test.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/Test.hs') diff --git a/src/Test.hs b/src/Test.hs index 8155bdb..455eed5 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -181,7 +181,7 @@ cmdCreateIdentity = do else foldrM (\n o -> Just <$> createIdentity st (Just n) o) Nothing names shared <- case names of - _:_:_ -> (:[]) <$> makeSharedStateUpdate st (idDataF $ finalOwner identity) [] + _:_:_ -> (:[]) <$> makeSharedStateUpdate st (Just $ finalOwner identity) [] _ -> return [] storeHead st $ LocalState @@ -239,8 +239,8 @@ cmdWatchSharedIdentity = do Nothing <- gets tsWatchedSharedIdentity out <- asks tiOutput - w <- liftIO $ watchHeadWith h (lookupSharedValue . lsShared . headObject) $ \sdata -> case validateIdentityF sdata of - Just idt -> do + w <- liftIO $ watchHeadWith h (lookupSharedValue . lsShared . headObject) $ \case + Just (idt :: ComposedIdentity) -> do outLine out $ unwords $ "shared-identity" : map (maybe "" T.unpack . idName) (unfoldOwners idt) Nothing -> do outLine out $ "shared-identity-failed" @@ -265,13 +265,12 @@ cmdUpdateLocalIdentity = do cmdUpdateSharedIdentity :: Command cmdUpdateSharedIdentity = do [name] <- asks tiParams - updateSharedState_ $ \sdata -> do - let Just identity = validateIdentityF sdata - st = storedStorage $ head sdata + updateSharedState_ $ \(Just identity) -> do + let st = storedStorage $ head $ idDataF identity public = idKeyIdentity identity Just secret <- loadKey public - maybe (error "created invalid identity") (return . (:[]) . idData) . validateIdentity =<< + maybe (error "created invalid identity") (return . Just . toComposedIdentity) . validateIdentity =<< wrappedStore st =<< sign secret =<< wrappedStore st (emptyIdentityData public) { iddPrev = toList $ idDataF identity , iddName = Just name -- cgit v1.2.3