Skip to content
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

Add AddAmount/SubAmount method to sdk.Coin #9079

Closed
4 tasks
hallazzang opened this issue Apr 8, 2021 · 2 comments · Fixed by #9091
Closed
4 tasks

Add AddAmount/SubAmount method to sdk.Coin #9079

hallazzang opened this issue Apr 8, 2021 · 2 comments · Fixed by #9091

Comments

@hallazzang
Copy link
Contributor

Summary

sdk.Coin has Add() and Sub() methods but I think it'd be good to have AddAmount() and SubAmount() methods too.

Problem Definition

If someone wants to subtract some amount from existing coin, one should right:

amount := sdk.NewInt(1000)
result := existingCoin.Sub(sdk.NewCoin(existingCoin.Denom, amount))

But that's a bit redundant that we have to type existingCoin twice.
We should do it better with:

amount := sdk.NewInt(1000)
result := existingCoin.SubAmount(amount)

And it'll improve code readability a lot.

Proposal

Implement AddAmount() and SubAmount() to sdk.Coin.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@amaury1093
Copy link
Contributor

amaury1093 commented Apr 9, 2021

This sounds okay to me, would you like to create a PR?

@hallazzang
Copy link
Contributor Author

@AmauryM Yep, I'll create PR right away.

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 a pull request may close this issue.

2 participants