Skip to content

Commit

Permalink
Fixup ErrNoSuchWallet in readIsStakeKeyRegistered
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Jul 3, 2020
1 parent f29112d commit 97d9d7f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/core/src/Cardano/Wallet/DB/Sqlite.hs
Expand Up @@ -626,14 +626,15 @@ newDBLayer trace defaultFieldValues mDatabaseFile = do
(StakeKeyCertificate wid sl True)

, readIsStakeKeyRegistered = \(PrimaryKey wid) -> ExceptT $ do
val <- fmap entityVal <$> selectFirst
[StakeKeyCertWalletId ==. wid]
[Desc StakeKeyCertSlot]

return $ case val of
Nothing -> Left $ ErrNoSuchWallet wid
Just (StakeKeyCertificate _ _ isReg) -> Right isReg

selectWallet wid >>= \case
Nothing -> pure $ Left $ ErrNoSuchWallet wid
Just{} -> do
val <- fmap entityVal <$> selectFirst
[StakeKeyCertWalletId ==. wid]
[Desc StakeKeyCertSlot]
return $ case val of
Nothing -> Right False
Just (StakeKeyCertificate _ _ isReg) -> Right isReg

{-----------------------------------------------------------------------
Tx History
Expand Down

0 comments on commit 97d9d7f

Please sign in to comment.