Currency From String
Overview
This issue was created as a result of the following F/U:
- [ ] @MSevey started a [discussion](https://gitlab.com/NebulousLabs/Sia/-/merge_requests/4973#note_507186554):
> F/U: I would change `ParseCurrency` to `ParseCurrnecyStr` (or something) so that then all these calls can just call `ParseCurrency` and get `types.Currency` back. It doesn't make sense that we should have to parse a parsed value. Also looks like `ParseCurrency` generates a big int and then calls `String()` on it.
>
> Looking at where `ParseCurrency` is called I'm not sure why it returns a string in the first place. Pretty much everywhere then immediately calls `fmt.Sscan` to convert into a currency. `ParseCurrency` should just do that.
It's a low-priority task I decided to split off into a separate issue to not lose track of it. I'm tagging it as a good beginner issue.
Design or Proposal
ParseCurrency
should be returning a Currency
as opposed to the value as a string in hastings. I think it would make sense to have it as a method on the currency called LoadString
, in order for it to be consistent with other structs like SiaPublicKey
or SiaPath
and the likes.
Edited by Peter-Jan Brone