-
Notifications
You must be signed in to change notification settings - Fork 55
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
Feature claim and withdraw #45
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Evgeny Kuzyakov <[email protected]>
ref-farming/src/actions_of_reward.rs
Outdated
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<_>>() | ||
} | ||
}; |
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.
Why clone it, if you still borrowing it below? Is it because of the immutable/mutable burrow later?
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.
Yes, I use it mutable later. It's like to get an independent snapshot of all reward tokens into tokens
.
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.