-
Notifications
You must be signed in to change notification settings - Fork 49
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 split coins into parts to qclient #338
base: develop
Are you sure you want to change the base?
Add split coins into parts to qclient #338
Conversation
client/cmd/split.go
Outdated
"github.com/shopspring/decimal" | ||
"github.com/spf13/cobra" | ||
"source.quilibrium.com/quilibrium/monorepo/node/protobufs" | ||
) | ||
|
||
func getCoinAmount(coinaddr []byte) *big.Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a more efficient way to query the amount of a specific coin address, so I adopted the approach from client/cmd/coins.go
.
If there's a better way I'm happy to refactor :)
One suggestion: add a --amounts flag to create 3 equal tokens in that amount and the rest as a remainder. E.g. # Original token 0x0001 has amount 10.0000 QUIL
qclient token split 0x0001 --parts 3 --amounts 1
# coins after split using --amounts
qclient token coins
7.000000000000 QUIL (Coin 0x0002) # split automatic remainder
1.000000000000 QUIL (Coin 0x0003) # split part 1
1.000000000000 QUIL (Coin 0x0004) # split part 2
1.000000000000 QUIL (Coin 0x0005) # split part 3 |
Thanks for your suggestion @tjsturos! It's been implemented :) |
Added tests for the split operations. @CassOnMars let me know if you prefer a single commit per PR :) |
Adds flags
-p/--parts
and-a/--part-amount
, allowing you to split a coin into parts without needing to calculate and specifying the amounts.Example - Split a coin into the specified amounts:
Example - Split a coin into three parts:
Note: Coin 0x1111 is the remainder.
Example - Split a coin into two parts using the specified amounts:
Note: Coin 0x1111 is the remainder.