Skip to content

Conversation

marco-sundsk
Copy link
Contributor

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_tokens is 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.

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<_>>()
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why clone it, if you still borrowing it below? Is it because of the immutable/mutable burrow later?

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, I use it mutable later. It's like to get an independent snapshot of all reward tokens into tokens.

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