-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat(dist): Add WithdrawDelegationWithoutSend function to avoid hitting the wallet #48
feat(dist): Add WithdrawDelegationWithoutSend function to avoid hitting the wallet #48
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 good for now, left a suggestions for refactoring and note on tests 👍
func (k Keeper) WithdrawDelegationRewardsWithoutSending(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI) (sdk.Coins, error) { | ||
// check existence of delegator starting info | ||
if !k.HasDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) { | ||
return nil, types.ErrEmptyDelegationDistInfo | ||
} |
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.
would be good to refactor the shared code bits with the withdrawDelegationRewards
method
if finalRewards.IsZero() { | ||
baseDenom, _ := sdk.GetBaseDenom() | ||
if baseDenom == "" { | ||
baseDenom = sdk.DefaultBondDenom | ||
} | ||
|
||
// Note, we do not call the NewCoins constructor as we do not want the zero | ||
// coin removed. | ||
finalRewards = sdk.Coins{sdk.NewCoin(baseDenom, math.ZeroInt())} | ||
} |
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.
also would be good to add tests for this 👍
k.DeleteDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) | ||
|
||
if finalRewards.IsZero() { | ||
baseDenom, _ := sdk.GetBaseDenom() |
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.
this could be an issue since it's hardcoded
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change