File tree Expand file tree Collapse file tree
give/src/main/kotlin/com/flipcash/app/give/internal
send/src/main/kotlin/com/flipcash/app/send/internal
services/opencode/src/main/kotlin/com/getcode/opencode Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -228,7 +228,14 @@ internal class GiveScreenViewModel @Inject constructor(
228228 exchange.fetchRatesIfNeeded()
229229 }
230230
231- val amountFiat = data.amountData.amount.let { LocalFiat (it, rate) }
231+ val localizedAmount = Fiat (data.amountData.amount, rate.currency)
232+
233+ val amountFiat = LocalFiat (
234+ usdc = localizedAmount.convertingTo(exchange.rateToUsd(rate.currency)!! ),
235+ converted = localizedAmount,
236+ rate = rate,
237+ )
238+
232239 val bill = Bill .Cash (amount = amountFiat)
233240 dispatchEvent(Event .UpdateLoadingState (loading = false , success = true ))
234241 dispatchEvent(Event .PresentBill (bill))
Original file line number Diff line number Diff line change @@ -228,7 +228,12 @@ internal class SendScreenViewModel @Inject constructor(
228228 exchange.fetchRatesIfNeeded()
229229 }
230230
231- val amountFiat = data.amountData.amount.let { LocalFiat (it, rate) }
231+ val localizedAmount = Fiat (data.amountData.amount, rate.currency)
232+ val amountFiat = LocalFiat (
233+ usdc = localizedAmount.convertingTo(exchange.rateToUsd(rate.currency)!! ),
234+ converted = localizedAmount,
235+ rate = rate,
236+ )
232237 val bill = Bill .Cash (amount = amountFiat, kind = Bill .Kind .remote)
233238 dispatchEvent(Event .UpdateLoadingState (loading = false , success = true ))
234239 dispatchEvent(Event .PresentBill (bill))
Original file line number Diff line number Diff line change @@ -45,14 +45,14 @@ internal class IntentRemoteSend(
4545
4646 // 2. Transfer all funds from primary account to the created gift card
4747 val transferToGiftCardAccount = ActionPublicTransfer .newInstance(
48- amount = amount.converted ,
48+ amount = amount.usdc ,
4949 sourceCluster = sourceCluster,
5050 destination = openGiftCardAccount.owner.vaultPublicKey
5151 )
5252
5353 // 3. Allow auto-returning back to the primary if not collected
5454 val withdrawToDestination = ActionPublicWithdraw .newInstance(
55- amount = amount.converted ,
55+ amount = amount.usdc ,
5656 sourceCluster = giftCard.cluster,
5757 destination = sourceCluster.vaultPublicKey,
5858 canAutoReturn = true
Original file line number Diff line number Diff line change @@ -210,8 +210,8 @@ internal fun Message.asProtobufMessage(): MessagingService.Message {
210210
211211internal fun LocalFiat.asExchangeData (): TransactionService .ExchangeData {
212212 return TransactionService .ExchangeData .newBuilder()
213- .setQuarks(converted .quarks.toLong())
214- .setCurrency(rate.currency .name.lowercase())
213+ .setQuarks(usdc .quarks.toLong())
214+ .setCurrency(converted.currencyCode .name.lowercase())
215215 .setExchangeRate(rate.fx)
216216 .setNativeAmount(converted.doubleValue)
217217 .build()
Original file line number Diff line number Diff line change @@ -9,13 +9,6 @@ data class LocalFiat(
99 val converted : Fiat ,
1010 val rate : Rate
1111) {
12- // Constructor from string amount
13- constructor (value: String , rate: Rate ) : this (
14- usdc = Fiat (value, CurrencyCode .USD ),
15- converted = Fiat (value, rate.currency),
16- rate = rate
17- )
18-
1912 @Throws(Exception ::class )
2013 constructor (exchangeData: ExchangeData .WithRate ): this (
2114 usdc = Fiat (exchangeData.quarks.toULong(), CurrencyCode .USD ),
@@ -29,12 +22,6 @@ data class LocalFiat(
2922 ),
3023 )
3124
32- // Replace rate
33- fun replacing (rate : Rate ): LocalFiat = copy(
34- converted = Fiat (usdc.doubleValue, rate.currency),
35- rate = rate
36- )
37-
3825 companion object {
3926 val Zero = LocalFiat (
4027 usdc = Fiat (0 ),
You can’t perform that action at this time.
0 commit comments