{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Cardano.Wallet.Mock.API
( API
) where
import Cardano.Wallet.Mock.Types (WalletInfo)
import Data.List.NonEmpty (NonEmpty)
import Ledger (CardanoAddress, PaymentPubKeyHash)
import Ledger.Tx (CardanoTx)
import Ledger.Tx.Constraints.OffChain (UnbalancedTx)
import Plutus.V1.Ledger.Api (Value)
import Servant.API (Capture, Get, JSON, NoContent, Post, QueryParam, ReqBody, (:<|>), (:>))
import Wallet.Emulator.Error (WalletAPIError)
type API walletId
= "create" :> QueryParam "funds" Integer :> Post '[JSON] WalletInfo
:<|> Capture "walletId" walletId :> "submit-txn" :> ReqBody '[JSON] CardanoTx :> Post '[JSON] NoContent
:<|> Capture "walletId" walletId :> "own-payment-public-key-hash" :> Get '[JSON] PaymentPubKeyHash
:<|> Capture "walletId" walletId :> "own-addresses" :> Get '[JSON] (NonEmpty CardanoAddress)
:<|> Capture "walletId" walletId :> "balance-tx" :> ReqBody '[JSON] UnbalancedTx :> Post '[JSON] (Either WalletAPIError CardanoTx)
:<|> Capture "walletId" walletId :> "total-funds" :> Get '[JSON] Value
:<|> Capture "walletId" walletId :> "sign" :> ReqBody '[JSON] CardanoTx :> Post '[JSON] CardanoTx