Skip to content

Commit

Permalink
Fix getTotalFunds
Browse files Browse the repository at this point in the history
  • Loading branch information
hrajchert committed Jan 18, 2022
1 parent c491e46 commit 2f0bf79
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions marlowe-dashboard-client/src/API/Marlowe/Wallet.purs
@@ -0,0 +1,24 @@
module API.Marlowe.Run.Wallet
( getTotalFunds
) where

import Prologue
import API.Request (doGetRequest)
import API.Url (toUrlPiece)
import Component.Contacts.Types (WalletId)
import Control.Monad.Error.Class (class MonadError)
import Effect.Aff.Class (class MonadAff)
import Marlowe.Run.Wallet.V1 (GetTotalFundsResponse) as BE
import Servant.PureScript (AjaxError)

getTotalFunds
:: forall m
. MonadAff m
=> MonadError AjaxError m
=> WalletId
-> m BE.GetTotalFundsResponse
getTotalFunds wallet =
doGetRequest
$ "/api/wallet/v1/"
<> toUrlPiece wallet
<> "/total-funds"
8 changes: 6 additions & 2 deletions marlowe-dashboard-client/src/Capability/Wallet.purs
Expand Up @@ -10,6 +10,7 @@ module Capability.Wallet

import Prologue

import API.Marlowe.Run.Wallet as WBE
import API.Marlowe.Run.Wallet.CentralizedTestnet
( RestoreError
, RestoreWalletOptions
Expand All @@ -21,7 +22,7 @@ import Bridge (toBack, toFront)
import Component.Contacts.Types (WalletId, WalletInfo)
import Control.Monad.Except (lift, runExceptT)
import Halogen (HalogenM)
import Marlowe as WBE
-- import Marlowe as WBE
import Marlowe.Run.Wallet.V1 (GetTotalFundsResponse)
import Plutus.V1.Ledger.Tx (Tx)
import Types (AjaxResponse)
Expand All @@ -43,7 +44,10 @@ instance monadWalletAppM :: ManageWallet AppM where
MockAPI.submitWalletTransaction (toBack wallet) tx
getWalletInfo wallet = map (map toFront) $ runExceptT $ MockAPI.getWalletInfo
(toBack wallet)
getWalletTotalFunds = runExceptT <<< WBE.getApiWalletV1ByWalletidTotalfunds
-- TODO: we use a manual getTotalFunds because a problem with the toUrlPiece from
-- PureScript servant.
-- getWalletTotalFunds = runExceptT <<< WBE.getApiWalletV1ByWalletidTotalfunds
getWalletTotalFunds = runExceptT <<< WBE.getTotalFunds
signTransaction wallet tx = runExceptT $ MockAPI.signTransaction
(toBack wallet)
tx
Expand Down

0 comments on commit 2f0bf79

Please sign in to comment.