/
API.hs
32 lines (27 loc) · 1.11 KB
/
API.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeOperators #-}
module Marlowe.Run.Wallet.V1.API where
import Cardano.Prelude
import Data.Aeson (ToJSON)
import Marlowe.Run.Dto (AssetsDto, ToDto (..), WalletIdDto)
import qualified Marlowe.Run.Wallet.V1 as Domain
import qualified Marlowe.Run.Wallet.V1.CentralizedTestnet.API as CentralizedTestnet
import Servant.API (Capture, Get, JSON, (:<|>), (:>))
data GetTotalFundsResponse =
GetTotalFundsResponse
{ assets :: !AssetsDto
, sync :: !Double
}
deriving stock (Eq, Generic, Show)
deriving anyclass (ToJSON)
instance ToDto Domain.GetTotalFundsResponse GetTotalFundsResponse where
toDto Domain.GetTotalFundsResponse{..} =
GetTotalFundsResponse (toDto assets) sync
type API =
(Capture "wallet-id" WalletIdDto :> "total-funds" :> Get '[JSON] GetTotalFundsResponse)
:<|> ("centralized-testnet" :> CentralizedTestnet.API)