@@ -38,6 +38,15 @@ type internal CurrencyImageSize =
38
38
39
39
module FrontendHelpers =
40
40
41
+ type CryptoSubUnit =
42
+ | No
43
+ | Specific of multiplier : int * caption : string
44
+
45
+ let Sats =
46
+ CryptoSubUnit.Specific( 100_000_000 , " sats" )
47
+ let Bits =
48
+ CryptoSubUnit.Specific( 1_000_000 , " bits" )
49
+
41
50
type IGlobalAppState =
42
51
[<CLIEvent>]
43
52
abstract member Resumed: IEvent < unit > with get
@@ -109,6 +118,7 @@ module FrontendHelpers =
109
118
110
119
let UpdateBalance ( balance : MaybeCached < decimal >) currency usdRate
111
120
( maybeFrame : Option < Frame >) ( balanceLabel : Label ) ( fiatBalanceLabel : Label )
121
+ ( cryptoSubUnit : CryptoSubUnit )
112
122
: MaybeCached < decimal > =
113
123
let maybeBalanceAmount =
114
124
match balance with
@@ -129,8 +139,18 @@ module FrontendHelpers =
129
139
| None ->
130
140
SPrintF1 " %A (?)" currency, NotFresh( NotAvailable), SPrintF1 " (?) %s " defaultFiatCurrency
131
141
| Some balanceAmount ->
132
- let cryptoAmount = Formatting.DecimalAmountRounding CurrencyType.Crypto balanceAmount
133
- let cryptoAmountStr = SPrintF2 " %A %s " currency cryptoAmount
142
+ let adjustedBalance =
143
+ match cryptoSubUnit with
144
+ | No -> balanceAmount
145
+ | Specific ( multiplier, _ caption) ->
146
+ balanceAmount * decimal multiplier
147
+ let cryptoAmount = Formatting.DecimalAmountRounding CurrencyType.Crypto adjustedBalance
148
+ let cryptoAmountStr =
149
+ match cryptoSubUnit with
150
+ | No ->
151
+ SPrintF2 " %A %s " currency cryptoAmount
152
+ | Specific (_ multiplier, caption) ->
153
+ SPrintF2 " %s %A " cryptoAmount caption
134
154
let fiatAmount , fiatAmountStr = BalanceInUsdString balanceAmount usdRate
135
155
cryptoAmountStr, fiatAmount, fiatAmountStr
136
156
MainThread.BeginInvokeOnMainThread( fun _ ->
@@ -159,6 +179,7 @@ module FrontendHelpers =
159
179
( Some balanceSet.Widgets.Frame)
160
180
balanceSet.Widgets.CryptoLabel
161
181
balanceSet.Widgets.FiatLabel
182
+ CryptoSubUnit.No
162
183
return {
163
184
BalanceSet = balanceSet
164
185
FiatAmount = fiatAmount
@@ -187,6 +208,7 @@ module FrontendHelpers =
187
208
( Some balanceSet.Widgets.Frame)
188
209
balanceSet.Widgets.CryptoLabel
189
210
balanceSet.Widgets.FiatLabel
211
+ CryptoSubUnit.No
190
212
return {
191
213
BalanceSet = balanceSet
192
214
FiatAmount = fiatAmount
0 commit comments