Skip to content

Commit 9f5177d

Browse files
committed
fix(tokens): filter out zero balanace tokens from select during give
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 831356c commit 9f5177d

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

apps/flipcash/shared/tokens/src/main/kotlin/com/flipcash/app/tokens/ui/SelectTokenViewModel.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,15 @@ class SelectTokenViewModel @Inject constructor(
160160
})
161161
.filter {
162162
val baselineAmount = 0.01.toFiat(rate.currency)
163+
val hasBalance = it.balance.nativeAmount.valueNonZero() &&
164+
it.balance.nativeAmount.valueGreaterThanOrEqualTo(baselineAmount)
163165
when (purpose) {
164166
// show all tokens we have accounts for as deposit targets
165167
TokenPurpose.Deposit -> true
166168
// when reserves are enabled, we must prevent sending USDF directly (it's used for reserves)
167-
TokenPurpose.Select -> !state.reservesEnabled || it.token.address != Mint.usdf
169+
TokenPurpose.Select -> (!state.reservesEnabled || it.token.address != Mint.usdf) && hasBalance
168170
// show all tokens with non-zero balance
169-
else -> {
170-
it.balance.nativeAmount.valueNonZero() &&
171-
it.balance.nativeAmount.valueGreaterThanOrEqualTo(baselineAmount)
172-
}
171+
else -> hasBalance
173172
}
174173
}
175174
}

0 commit comments

Comments
 (0)