Skip to content

Commit

Permalink
Expose lovelaceH html renderer from deposit html common module
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Nov 11, 2024
1 parent 0e5b18c commit 57aa4fb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/ui/src/Cardano/Wallet/UI/Deposit/Html/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Cardano.Wallet.UI.Deposit.Html.Common
, showTimeSecs
, withOriginH
, valueH
, lovelaceH
)
where

Expand Down Expand Up @@ -57,6 +58,9 @@ import Lucid
import Numeric
( showFFloatAlt
)
import Numeric.Natural
( Natural
)

showTime :: UTCTime -> String
showTime = formatTime defaultTimeLocale "%Y-%m-%d %H:%M"
Expand Down Expand Up @@ -91,8 +95,13 @@ txIdH txId =
txId

valueH :: Value -> Html ()
valueH (ValueC (CoinC c) _) = do
span_ $ toHtml $ a ""
valueH (ValueC (CoinC c) _) = lovelaceH $ fromIntegral c

lovelaceH :: Natural -> Html ()
lovelaceH c = do
span_ $ toHtml $ showLovelaceAsAda c
span_ [class_ "opacity-25"] ""
where
a = showFFloatAlt @Double (Just 2) $ fromIntegral c / 1_000_000

showLovelaceAsAda :: Integral a => a -> String
showLovelaceAsAda c =
showFFloatAlt @Double (Just 2) (fromIntegral c / 1_000_000) ""

0 comments on commit 57aa4fb

Please sign in to comment.