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

Fix/tinder gov bug fix #1658

Merged
merged 66 commits into from
Sep 19, 2024
Merged

Fix/tinder gov bug fix #1658

merged 66 commits into from
Sep 19, 2024

Conversation

antonijzelinskij
Copy link
Contributor

#8695mxtfw
#8695mwrd4


return asset.freeInPlanks >= votingPower.amount
return if (asset.freeInPlanks >= votingPower.amount) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldnt dublicate the fact that "free balance is used for voting". We can extract it to extension like Asset.availableToVote. Otherwise it becomes error prone for future changes

@@ -140,16 +143,23 @@ class TinderGovBasketViewModel(
val availableToVoteReferenda = availableToVoteReferendaFlow.first()

val removedReferenda = basket.filter { availableToVoteReferenda.contains(it.referendumId).not() }
.filter { interactor.basketItemValidForVote(it) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange. Why does removed referenda is filtered list is by the validity? Even if its correct (e.g. if you aim to filter out "invalid by voting power" referenda and only show number "invalid by status" this code doesnt make sense for the external reader who might not know the context

if (removedReferenda.isNotEmpty()) {
interactor.removeBasketItems(removedReferenda)

itemsWasRemovedFromBasketAction.awaitAction()
itemsWasRemovedFromBasketAction.awaitAction(getFormattedAmountAvailableToVote())

closeScreenIfBasketIsEmpty()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we wont attempt to close the screen if there was some "invalid valid" referenda that was removed?

Comment on lines 54 to 56
fun <T> List<T>.countBy(predicate: (T) -> Boolean): Int {
return filter { predicate(it) }.size
}
Copy link
Member

@valentunn valentunn Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrc there was count {} extension in stdlib already? Also countring by performing filtering is a bit unefficient as we have to allocate an extra list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes We has this extension, thank you. I'll change it

VoteTinderGovValidationFailure.AlreadyDelegatingVotes -> handleAlreadyDelegatingVotes(resourceManager)

is VoteTinderGovValidationFailure.AmountIsTooBig -> {
handleAmountIsTooBig(resourceManager, failure)
Copy link
Member

@valentunn valentunn Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line looks redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thank you

@antonijzelinskij antonijzelinskij merged commit 9befa65 into develop Sep 19, 2024
1 check passed
@antonijzelinskij antonijzelinskij deleted the fix/tinder-gov-bug-fix branch September 19, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants