Skip to content

Commit

Permalink
rework: use withWorkerCtx helper function in server
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jan 22, 2021
1 parent 0d6d568 commit bf956e0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -1277,13 +1277,12 @@ listAssets
=> ctx
-> ApiT WalletId
-> Handler [ApiAsset]
listAssets ctx (ApiT wid) =
Handler $ ExceptT $ withDatabase df wid $ \db -> runHandler $ do
let wrk = hoistResource db (MsgFromWorker wid) ctx
(cp, _meta, _pending) <- liftHandler $ W.readWallet @_ @s @k wrk wid
pure $ map (toApiAsset metadata) $ F.toList $ W.getAssets $ cp ^. #utxo
listAssets ctx (ApiT wid) = do
utxo <- withWorkerCtx @_ @s @k ctx wid liftE liftE $ \wrk -> liftHandler $ do
(cp, _meta, _pending) <- W.readWallet @_ @s @k wrk wid
pure (cp ^. #utxo)
pure $ map (toApiAsset metadata) $ F.toList $ W.getAssets utxo
where
df = ctx ^. dbFactory @s @k
metadata = Nothing -- TODO: Use data from metadata server

getAsset
Expand Down

0 comments on commit bf956e0

Please sign in to comment.