-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add available balance to payments page
- Loading branch information
Showing
7 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/ui/src/Cardano/Wallet/UI/Deposit/Handlers/Payments/Balance.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Cardano.Wallet.UI.Deposit.Handlers.Payments.Balance | ||
( getAvailableBalance | ||
) | ||
where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet.Deposit.REST | ||
( WalletResource | ||
, availableBalance | ||
) | ||
import Cardano.Wallet.Read | ||
( Coin (..) | ||
, Value (..) | ||
) | ||
import Cardano.Wallet.UI.Common.Layer | ||
( SessionLayer | ||
) | ||
import Cardano.Wallet.UI.Deposit.Handlers.Lib | ||
( catchRunWalletResourceHtml | ||
) | ||
import Cardano.Wallet.UI.Deposit.Types.Payments | ||
( Receiver (..) | ||
) | ||
import Servant | ||
( Handler | ||
) | ||
|
||
import qualified Data.ByteString.Lazy.Char8 as BL8 | ||
|
||
getAvailableBalance | ||
:: SessionLayer WalletResource | ||
-> [Receiver] | ||
-> (Coin -> Coin -> html) | ||
-> (BL8.ByteString -> html) | ||
-> Handler html | ||
getAvailableBalance layer receivers render alert = | ||
catchRunWalletResourceHtml layer alert id $ do | ||
ValueC r _ <- availableBalance | ||
let afterTransaction = r | ||
- CoinC (sum $ fmap (fromIntegral . amount) receivers) | ||
pure $ render r afterTransaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters