Skip to content

Commit

Permalink
Fix validator setup failure
Browse files Browse the repository at this point in the history
Use max range value as a rate instead of null if the validator is closed
for delegation. Null value caused failure of the transaction.
  • Loading branch information
Radiokot committed Sep 19, 2024
1 parent ca2a9a8 commit f795fab
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
having no ability to reveal the seed phrase
- Ability to use Wallet private key to restore a wallet

### Fixed

- Inability to configure a validator closed for delegation

## [1.2.0] - 2024-08-27

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ data class BakerDelegationData(
var energy: Long? = null
var accountNonce: AccountNonce? = null
var amount: BigInteger? = null
var finalizationCommissionRate: Double? = null
var bakingCommissionRate: Double? = null
var transactionCommissionRate: Double? = null
var chainParameters: ChainParameters? = null
set(value) {
field = value
finalizationCommissionRate = value?.finalizationCommissionRange?.max
bakingCommissionRate = value?.bakingCommissionRange?.max
transactionCommissionRate = value?.transactionCommissionRange?.max
}
var bakerPoolStatus: BakerPoolStatus? = null
var passiveDelegation: PassiveDelegation? = null
var cost: BigInteger? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ data class ChainParameters(
val accountCreationLimit: Int,
val minimumEquityCapital: BigInteger,
val bakingCommissionRange: BakingCommissionRange,
val bakingCommissionRate: Double? = null,
val transactionCommissionRange: TransactionCommissionRange,
val transactionCommissionRate: Double? = null,
val finalizationCommissionRange: FinalizationCommissionRange,
val euroPerEnergy: SimpleFraction,
@SerializedName("microGTUPerEuro")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,21 @@ class BakerRegistrationConfirmationActivity : BaseDelegationBakerActivity(
}

binding.apply {
if (viewModel.bakerDelegationData.chainParameters?.transactionCommissionRate != null) {
if (viewModel.bakerDelegationData.transactionCommissionRate != null) {
transactionFeeTitle.visibility = View.VISIBLE
transactionFeeStatus.visibility = View.VISIBLE
transactionFeeStatus.text =
percentFormat.format(viewModel.bakerDelegationData.chainParameters?.transactionCommissionRate)
percentFormat.format(viewModel.bakerDelegationData.transactionCommissionRate)
} else {
transactionFeeTitle.visibility = View.GONE
transactionFeeStatus.visibility = View.GONE
}

if (viewModel.bakerDelegationData.chainParameters?.bakingCommissionRate != null) {
if (viewModel.bakerDelegationData.bakingCommissionRate != null) {
bakingTitle.visibility = View.VISIBLE
bakingStatus.visibility = View.VISIBLE
bakingStatus.text =
percentFormat.format(viewModel.bakerDelegationData.chainParameters?.bakingCommissionRate)
percentFormat.format(viewModel.bakerDelegationData.bakingCommissionRate)
} else {
bakingTitle.visibility = View.GONE
bakingStatus.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class BakerRegistrationOpenActivity : BaseDelegationBakerActivity(
) {
true
} else {
viewModel.bakerDelegationData.oldCommissionRates?.transactionCommission != viewModel.bakerDelegationData.chainParameters?.transactionCommissionRate ||
viewModel.bakerDelegationData.oldCommissionRates?.bakingCommission != viewModel.bakerDelegationData.chainParameters?.bakingCommissionRate
viewModel.bakerDelegationData.oldCommissionRates?.transactionCommission != viewModel.bakerDelegationData.transactionCommissionRate ||
viewModel.bakerDelegationData.oldCommissionRates?.bakingCommission != viewModel.bakerDelegationData.bakingCommissionRate
}
if (gotoNextPage) gotoNextPage()
else showNoChange()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ class DelegationBakerViewModel(application: Application) : AndroidViewModel(appl
}

fun commissionRatesHasChanged(): Boolean =
bakerDelegationData.oldCommissionRates?.bakingCommission != bakerDelegationData.chainParameters?.bakingCommissionRate ||
bakerDelegationData.oldCommissionRates?.transactionCommission != bakerDelegationData.chainParameters?.transactionCommissionRate

bakerDelegationData.oldCommissionRates?.bakingCommission != bakerDelegationData.bakingCommissionRate ||
bakerDelegationData.oldCommissionRates?.transactionCommission != bakerDelegationData.transactionCommissionRate

fun openStatusHasChanged(): Boolean {
return bakerDelegationData.bakerPoolInfo?.openStatus != bakerDelegationData.oldOpenStatus
Expand Down Expand Up @@ -529,11 +528,11 @@ class DelegationBakerViewModel(application: Application) : AndroidViewModel(appl
if (bakerDelegationData.type == REMOVE_BAKER) null else bakerDelegationData.bakerKeys

val transactionFeeCommission =
if (bakerDelegationData.type == REGISTER_BAKER || bakerDelegationData.type == CONFIGURE_BAKER || bakerDelegationData.type == UPDATE_BAKER_POOL) bakerDelegationData.chainParameters?.transactionCommissionRate else null
if (bakerDelegationData.type == REGISTER_BAKER || bakerDelegationData.type == CONFIGURE_BAKER || bakerDelegationData.type == UPDATE_BAKER_POOL) bakerDelegationData.transactionCommissionRate else null
val bakingRewardCommission =
if (bakerDelegationData.type == REGISTER_BAKER || bakerDelegationData.type == CONFIGURE_BAKER || bakerDelegationData.type == UPDATE_BAKER_POOL) bakerDelegationData.chainParameters?.bakingCommissionRate else null
if (bakerDelegationData.type == REGISTER_BAKER || bakerDelegationData.type == CONFIGURE_BAKER || bakerDelegationData.type == UPDATE_BAKER_POOL) bakerDelegationData.bakingCommissionRate else null
val finalizationRewardCommission =
if (bakerDelegationData.type == REGISTER_BAKER || bakerDelegationData.type == CONFIGURE_BAKER || bakerDelegationData.type == UPDATE_BAKER_POOL) bakerDelegationData.chainParameters?.finalizationCommissionRange?.max else null
if (bakerDelegationData.type == REGISTER_BAKER || bakerDelegationData.type == CONFIGURE_BAKER || bakerDelegationData.type == UPDATE_BAKER_POOL) bakerDelegationData.finalizationCommissionRate else null
val transferInput = CreateTransferInput(
from,
keys,
Expand Down Expand Up @@ -777,9 +776,7 @@ class DelegationBakerViewModel(application: Application) : AndroidViewModel(appl
transactionRate: Double?,
bakingRate: Double?,
) {
bakerDelegationData.chainParameters = bakerDelegationData.chainParameters?.copy(
bakingCommissionRate = bakingRate,
transactionCommissionRate = transactionRate,
)
bakerDelegationData.transactionCommissionRate = transactionRate
bakerDelegationData.bakingCommissionRate = bakingRate
}
}

0 comments on commit f795fab

Please sign in to comment.