@@ -86,17 +86,18 @@ class TipPaymentViewModel @Inject constructor(
86
86
}
87
87
}
88
88
89
- private val minUsdLimit: Kin
90
- get() {
91
- return KinAmount .fromFiatAmount(minUsdFiatLimit, exchange.rateForUsd()!! ).kin
89
+ private val minLimit: (rate: Rate ) -> Kin = { rate ->
90
+ KinAmount .fromFiatAmount(minFiatLimit(rate), rate).kin
92
91
}
93
92
94
93
private val maxFiatLimit: (rate: Rate ) -> Double = { rate ->
95
94
(transactionRepository.sendLimitFor(rate.currency) ? : SendLimit .Zero ).nextTransaction
96
95
}
97
96
98
- private val minUsdFiatLimit: Double
99
- get() = (transactionRepository.sendLimitFor(CurrencyCode .USD ) ? : SendLimit .Zero ).maxPerTransaction / 250.0
97
+ private val minFiatLimit: (rate: Rate ) -> Double = { rate ->
98
+ (transactionRepository.sendLimitFor(rate.currency)
99
+ ? : SendLimit .Zero ).maxPerTransaction / 250.0
100
+ }
100
101
101
102
102
103
private val hasAvailableTransactionLimit: (amount: KinAmount , rate: Rate ) -> Boolean = { amount, _ ->
@@ -111,7 +112,7 @@ class TipPaymentViewModel @Inject constructor(
111
112
get() = transactionRepository.hasAvailableDailyLimit()
112
113
113
114
private val isTipLargeEnough: (amount: KinAmount ) -> Boolean = { amount ->
114
- amount.kin >= minUsdLimit
115
+ amount.kin >= minLimit(amount.rate)
115
116
}
116
117
117
118
suspend fun onSubmit (): KinAmount ? {
@@ -160,7 +161,7 @@ class TipPaymentViewModel @Inject constructor(
160
161
161
162
if (! isTipLargeEnough(amount)) {
162
163
// min amount is based on send limit for USD
163
- val kin = KinAmount .fromFiatAmount(minUsdFiatLimit, exchange.rateForUsd() !! ).kin
164
+ val kin = KinAmount .fromFiatAmount(minFiatLimit(amount.rate), amount.rate ).kin
164
165
// convert min amount in USD to selected currency
165
166
val normalizedAmount = KinAmount .newInstance(kin, rate)
166
167
// format for display
0 commit comments