Skip to content

Commit dbd1267

Browse files
committed
fix(direct-send): pass token balance to verified fiat calculator
The direct send flow was not passing the token balance to verifiedFiatCalculator.compute(), so the calculator's balance capping logic never fired. This caused submit intent failures when a user tried to send back a small received amount in a different currency (e.g. 0.01 CAD displayed as 0.01 USD when the actual USD value was ~0.007). Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent e7119fe commit dbd1267

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • apps/flipcash/features/direct-send/src/main/kotlin/com/flipcash/app/directsend/internal

apps/flipcash/features/direct-send/src/main/kotlin/com/flipcash/app/directsend/internal/SendFlowViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.flipcash.app.core.send.SendStep
1414
import com.flipcash.app.featureflags.FeatureFlag
1515
import com.flipcash.app.featureflags.FeatureFlagController
1616
import com.flipcash.app.permissions.PickedContact
17+
import com.flipcash.app.tokens.TokenCoordinator
1718
import com.flipcash.features.directsend.R
1819
import com.flipcash.services.user.UserManager
1920
import com.getcode.manager.BottomBarManager
@@ -56,6 +57,7 @@ internal class SendFlowViewModel @Inject constructor(
5657
private val exchange: Exchange,
5758
private val verifiedFiatCalculator: VerifiedFiatCalculator,
5859
private val transactionController: TransactionController,
60+
private val tokenCoordinator: TokenCoordinator,
5961
) : BaseViewModel<SendFlowViewModel.State, SendFlowViewModel.Event>(
6062
initialState = State(),
6163
updateStateForEvent = updateStateForEvent,
@@ -264,9 +266,11 @@ internal class SendFlowViewModel @Inject constructor(
264266

265267
val source = owner.withTimelockForToken(token)
266268

269+
val balance = tokenCoordinator.balanceForToken(token)
267270
val verifiedFiat = verifiedFiatCalculator.compute(
268271
amount = amount,
269272
token = token,
273+
balance = balance,
270274
rate = rate,
271275
).getOrElse { error ->
272276
dispatchEvent(Event.SendStateUpdated())

0 commit comments

Comments
 (0)