Skip to content

Add AddAmount/SubAmount method to sdk.Coin #9079

Closed
@hallazzang

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions