Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect value when updating delegation and validation state #226

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ object CurrencyUtil {
return formatGTU(value, withGStroke, decimals)
}

fun formatGTU(value: BigInteger, withGStroke: Boolean = false, decimals: Int = 6): String {
fun formatGTU(
value: BigInteger,
withGStroke: Boolean = false,
decimals: Int = 6,
withCommas: Boolean = true
): String {
if (value == BigInteger.ZERO) return ZERO_AMOUNT
if (decimals <= 0) return value.toString()

Expand Down Expand Up @@ -70,7 +75,9 @@ object CurrencyUtil {
strBuilder.insert(0, "-")
}

return formatGTUWithCommas(strBuilder.toString().removeSuffix(separator.toString()))
val formattedString = strBuilder.toString().removeSuffix(separator.toString())

return if (withCommas) formatGTUWithCommas(formattedString) else formattedString
}

fun formatAndRoundGTU(value: BigInteger, roundDecimals: Int): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class BakerRegisterAmountActivity : BaseDelegationBakerRegisterAmountActivity(
viewModel.bakerDelegationData.account?.baker?.restakeEarnings
binding.amount.setText(
CurrencyUtil.formatGTU(
viewModel.bakerDelegationData.account?.baker?.stakedAmount
value = viewModel.bakerDelegationData.account?.baker?.stakedAmount
?: BigInteger.ZERO,
true
withGStroke = true,
withCommas = false
)
)
binding.amountDesc.text = getString(R.string.baker_update_enter_new_stake)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ class DelegationRegisterAmountActivity : BaseDelegationBakerRegisterAmountActivi
getString(R.string.delegation_update_delegation_amount_enter_amount)
binding.amount.setText(viewModel.bakerDelegationData.account?.delegation?.stakedAmount?.let {
CurrencyUtil.formatGTU(
it,
false
value = it,
withGStroke = false,
withCommas = false
)
})
}
Expand Down
Loading