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

Duplicate coins allowed in ParseCoins #6716

Closed
2 of 4 tasks
colin-axner opened this issue Jul 14, 2020 · 1 comment · Fixed by #7027
Closed
2 of 4 tasks

Duplicate coins allowed in ParseCoins #6716

colin-axner opened this issue Jul 14, 2020 · 1 comment · Fixed by #7027
Labels

Comments

@colin-axner
Copy link
Contributor

colin-axner commented Jul 14, 2020

Summary

Duplicate coins are not checked for in ParseCoins, but they are in NewCoins

Problem Definition

It was not specified in the godoc if this is intentional so I thought I would open up an issue. There exist inconsistencies between using parse and new. Parsing coins calls parse coin which calls NewCoin which will panic on invalid coin denoms, but it doesn't call NewCoins which panics on dup denoms.

Proposal

Update ParseCoins to return an error on duplicate denoms (and perhaps remove zero coins as well?). Maybe there are reasons when want zero and dup coins to be parsed?

OR

Update godoc to specify more detailed reasoning on the inconsistencies between Parse and New validation and when these should be appropriately used or what functions they should be used in conjunction with (IsValid). I noticed this discrepancy when reviewing relayer code that could have easily just parsed the coins without doing validation checks and then passed this as an msg arg. It would be bad if an application made the validation check assumption with parsing.


For Admin Use

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

I'm not sure if there was rhyme or reason behind that, but probably it's just a bug. We need to be consistent above all else, so if Coins removes duplicates, then so should DecCoins (or vice versa).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants