Concordium / concordium-reference-wallet-ios

Reference wallet for the Concordium blockchain
Apache License 2.0
11 stars 10 forks source link

Fix updating pool settings while update validator stake #396

Closed ramakser closed 6 months ago

ramakser commented 6 months ago

Purpose

Commission rates are set to 100% in case they are not explicitly set in the validators transaction. Prevent changing commission rates while updates validator stake

Changes

Add private func loadPoolParameters(for bakerID: Int) {...} method to retrieve validator pool commissionRates in case if profile is validator, or load them from chain parameters like it was before. So in this case there will not be changes rates to 100%, while user change only validator stake.

ramakser commented 6 months ago

It took a little while to understand this PR. I'm not too happy about the duplication this introduces and feel like it could have been done in a simpler way: For example you could have constructed the stream in such a way that the final result handled in sink included the appropriate CommissionRates value. Based on whether the account is a baker or not that object would have been created from the pool info or crypto params earlier in the pipeline (like delegatedCapital was).

But it appears to be correct as it is, so I'm approving and letting you decide.

updated ^