diff --git a/services/flipcash/src/main/kotlin/com/flipcash/services/internal/domain/UserFlagsMapper.kt b/services/flipcash/src/main/kotlin/com/flipcash/services/internal/domain/UserFlagsMapper.kt index 0156fce55..c55b96d1d 100644 --- a/services/flipcash/src/main/kotlin/com/flipcash/services/internal/domain/UserFlagsMapper.kt +++ b/services/flipcash/src/main/kotlin/com/flipcash/services/internal/domain/UserFlagsMapper.kt @@ -22,7 +22,9 @@ internal class UserFlagsMapper @Inject constructor(): preferredOnRampProvider = from.preferredOnRampProvider.toDomain().takeIf { it != OnRampProvider.Unknown }, supportedOnRampProviders = from.supportedOnRampProvidersList.map { it.toDomain() }, minimumVersion = from.minBuildNumber, - billExchangeDataTimeout = from.billExchangeDataTimeout.seconds.toDuration(DurationUnit.SECONDS), + billExchangeDataTimeout = if (from.hasBillExchangeDataTimeout()) { + from.billExchangeDataTimeout.seconds.toDuration(DurationUnit.SECONDS) + } else null, newCurrencyPurchaseAmount = Fiat(quarks = from.newCurrencyPurchaseAmount), newCurrencyFeeAmount = Fiat(quarks = from.newCurrencyFeeAmount), withdrawalFeeAmount = Fiat(quarks = from.withdrawalFeeAmount), diff --git a/services/flipcash/src/main/kotlin/com/flipcash/services/models/UserFlags.kt b/services/flipcash/src/main/kotlin/com/flipcash/services/models/UserFlags.kt index 6b4f46e72..fcdac2249 100644 --- a/services/flipcash/src/main/kotlin/com/flipcash/services/models/UserFlags.kt +++ b/services/flipcash/src/main/kotlin/com/flipcash/services/models/UserFlags.kt @@ -12,6 +12,9 @@ data class UserFlags( val preferredOnRampProvider: OnRampProvider?, val supportedOnRampProviders: List, val minimumVersion: Int?, + // How long a verified exchange rate stays usable for a bill. Absent when the + // server hasn't set a timeout (not the same as a zero-length one, which + // disables verified exchange data entirely). val billExchangeDataTimeout: Duration?, val newCurrencyPurchaseAmount: Fiat, val newCurrencyFeeAmount: Fiat, diff --git a/services/flipcash/src/test/kotlin/com/flipcash/services/internal/domain/UserFlagsMapperTest.kt b/services/flipcash/src/test/kotlin/com/flipcash/services/internal/domain/UserFlagsMapperTest.kt index 12f85c3ed..b48e78de5 100644 --- a/services/flipcash/src/test/kotlin/com/flipcash/services/internal/domain/UserFlagsMapperTest.kt +++ b/services/flipcash/src/test/kotlin/com/flipcash/services/internal/domain/UserFlagsMapperTest.kt @@ -116,6 +116,15 @@ class UserFlagsMapperTest { assertEquals(30.seconds, result.billExchangeDataTimeout) } + @Test + fun `bill exchange data timeout is null when unset, not zero`() { + val proto = userFlags { } + + val result = mapper.map(proto) + + assertNull(result.billExchangeDataTimeout) + } + @Test fun `maps new currency purchase amount`() { val proto = userFlags {