Open
Conversation
Co-authored-by: Evgeny Kuzyakov <h3r0k1ll3r@gmail.com>
evgenykuzyakov
approved these changes
Sep 17, 2021
Comment on lines
168
to
174
| let tokens = { | ||
| if let Some(token) = token { | ||
| vec![token] | ||
| vec![token.clone()] | ||
| } else { | ||
| view_farmer.get_ref().rewards.keys().collect::<Vec<_>>() | ||
| view_farmer.get_ref().rewards.keys().map(|x| x.clone()).collect::<Vec<_>>() | ||
| } | ||
| }; |
Contributor
There was a problem hiding this comment.
Why clone it, if you still borrowing it below? Is it because of the immutable/mutable burrow later?
Contributor
Author
There was a problem hiding this comment.
Yes, I use it mutable later. It's like to get an independent snapshot of all reward tokens into tokens.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add two interfaces to support claim and withdraw in one TX:
claim_and_withdraw_by_farm(&mut self, farm_id: FarmId, withdraw_all_tokens: bool)If
withdraw_all_tokensis true, all reward tokens will be withdrew to user's wallet. Otherwise, only reward token of that farm would be withdrew.claim_and_withdraw_by_seed(&mut self, seed_id: SeedId)This interface would withdraw all reward tokens into user's wallet.