summaryrefslogtreecommitdiff
path: root/src/State.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-12-04 18:45:02 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2021-12-04 18:45:02 +0100
commitd7a8706c3409d7666aa08620e3ae5982797bf0c9 (patch)
tree33b426317a82b33a7e1e05de417c52be466beedf /src/State.hs
parentcac8f382588e33c83f533936ba980ed06d4340aa (diff)
Provide createIdentity function from Identity module
Diffstat (limited to 'src/State.hs')
-rw-r--r--src/State.hs27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/State.hs b/src/State.hs
index 8e9e320..55c55e1 100644
--- a/src/State.hs
+++ b/src/State.hs
@@ -90,32 +90,19 @@ loadLocalStateHead st = loadHeads st >>= \case
hFlush stdout
devName <- T.getLine
- (owner, secret) <- if
- | T.null name -> return (Nothing, Nothing)
- | otherwise -> do
- (secret, public) <- generateKeys st
- (_secretMsg, publicMsg) <- generateKeys st
-
- return . (, Just secret) . Just =<< wrappedStore st =<< sign secret =<<
- wrappedStore st (emptyIdentityData public)
- { iddName = Just name, iddKeyMessage = Just publicMsg }
-
- (devSecret, devPublic) <- generateKeys st
- (_devSecretMsg, devPublicMsg) <- generateKeys st
-
- identity <- wrappedStore st =<< maybe return signAdd secret =<< sign devSecret =<< wrappedStore st (emptyIdentityData devPublic)
- { iddName = if T.null devName then Nothing else Just devName
- , iddOwner = owner
- , iddKeyMessage = Just devPublicMsg
- }
+ owner <- if
+ | T.null name -> return Nothing
+ | otherwise -> Just <$> createIdentity st (Just name) Nothing
+
+ identity <- createIdentity st (if T.null devName then Nothing else Just devName) owner
shared <- wrappedStore st $ SharedState
{ ssPrev = []
, ssType = Just $ sharedTypeID @(Signed IdentityData) Proxy
- , ssValue = [storedRef $ fromMaybe identity owner]
+ , ssValue = [storedRef $ idData $ fromMaybe identity owner]
}
storeHead st $ LocalState
- { lsIdentity = identity
+ { lsIdentity = idData identity
, lsShared = [shared]
}