Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request comes as a result of actually using the library and finding couple of things rather cumbersome to use, in particular the
Coin
type. There is no easy way to work with itsamount
due to the lack of anygetters
on theDecimal
and the type itself only providing addition-related capabilities. I've decided to take a possibly controversial approach of changing theamount
field to anu128
. I've done it for a couple of reasons:Coin
is represented with abig.Int
. (Dec
is used forDecCoin
). Now, the counter argument is thatbig.Int
is capable of representing values up to 2^256 - 1 which is a significantly more than what u128 provides. Plus it can also represent negative values. However, do negative coins make any sense and would be useful on their own? Also, u128 still has higher range than the currentDecimal
with internally usedu64
.Uint128
wrapper around theu128
primitive mostly to help with the serialization for their clients, which is not applicable in this case.What's your opinion on it? I would be more than happy to discuss it and introduce any additional changes. Perhaps rather than going with primitive
u128
a different wrapper with properties equivalent to Go'sbig.Int
would be more appropriate?