-
Notifications
You must be signed in to change notification settings - Fork 355
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
Native balance refactoring #87
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks quite good. I just left some comments on naming and some usage details to make this a bit clearer. Logic looks good. Except maybe the is_empty
Also, I would rebase on master since #86 was merged.
c877128
to
f25477e
Compare
7e2373d
to
c9d315e
Compare
I like how it is now. Normalizing is a relatively costly (and mutable) operation, and in this way we don't enforce it on every Also, with your proposal for checking for empty balances using an iterator, Finally, I moved that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I would just remove the normalize and merge
You can, in the sense that the But, keeping it does no harm, as normalization is a good thing, i. e. it's better to store a normalized balance that an un-normalized one. I just didn't want to couple the normalization with the empty check, because of, you know, purity. :-) Suppose in the future we notice that normalizing is an expensive operation, by example when you have a large list of coins. We can add a check / modification to the main contract code, to account for that. That is: now we can change normalization, and normalization usage in a per-contract basis, without affecting |
This is a good point and if we did other manipulations on the array (like with escrow), I would add it. For now, I would remove it and save the gas costs. And we use that where we want to do more array manipulations (and maybe optimize all the NativeBalance ops to work with normalize balances) |
Refactor cw1-subkeys native
Balance
intocw0
.Use it in the cw20-atomic-swap contract
Balance
.Closes the native part of #76.