-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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
[wallet] Add merge/split coins command to the wallet #657
Conversation
ce19bef
to
dc83746
Compare
@Clay-Mysten can you please help review the docs? |
|
||
/// Split a coin object into multiple coins. | ||
SplitCoin { | ||
/// Coin to Split, in 20 bytes Hex string |
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.
Optionally, lowercase hex throughout:
https://en.wikipedia.org/wiki/Hexadecimal
Totally not a big deal though.
doc/src/wallet.md
Outdated
Sui wallet. The config file contains information of the accounts and | ||
the Sui network. Sui wallet uses the network information to communicate | ||
the Sui network. The keystore file contains all the public private key pair of the created accounts. |
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.
public-private key pairs
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.
Nice! Like the Displays
doc/src/wallet.md
Outdated
The `accounts` variable contains all of the account's address and key pairs. | ||
This will be used by the wallet to sign transactions. The `authorities` | ||
variable contains Sui network authorities' name, host and port information. | ||
The `accounts` variable contains account's address the wallet manages. |
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.
contains the
doc/src/wallet.md
Outdated
and object data belonging to the account. | ||
|
||
#### Key management | ||
As you might have noticed, the key pairs are stored as plain text in `wallet.conf`, | ||
which is not secure and shouldn't be used in a production environment. We have plans to | ||
The key pairs are stored in `wallet.key`, however, it is not secure |
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.
. However, this is
doc/src/wallet.md
Outdated
@@ -203,17 +205,242 @@ Created new keypair for address : 3F8962C87474F8FB8BFB99151D5F83E677062078 | |||
|
|||
#### Add existing accounts to `wallet.conf` manually. | |||
|
|||
If you have existing key pair from an old wallet config, you can copy the account data manually to the new `wallet.conf`'s accounts section. | |||
If you have existing key pair from an old wallet config, you can copy the account | |||
address manually to the new `wallet.conf`'s accounts section, and add the keypair to the keystore file, |
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.
key pair (for consistency with previous references)
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.
Throughout (three references are joined)
doc/src/wallet.md
Outdated
@@ -203,17 +205,242 @@ Created new keypair for address : 3F8962C87474F8FB8BFB99151D5F83E677062078 | |||
|
|||
#### Add existing accounts to `wallet.conf` manually. | |||
|
|||
If you have existing key pair from an old wallet config, you can copy the account data manually to the new `wallet.conf`'s accounts section. | |||
If you have existing key pair from an old wallet config, you can copy the account | |||
address manually to the new `wallet.conf`'s accounts section, and add the keypair to the keystore file, |
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 would replace the comma at the end of this line with a semicolon (;) since the previous and next sentence are complete.
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.
Also:
If you have an existing key pair
doc/src/wallet.md
Outdated
|
||
FLAGS: | ||
-h, --help Prints help information | ||
--json Return command outputs in json format |
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.
JSON (in description/output)
doc/src/wallet.md
Outdated
|
||
FLAGS: | ||
-h, --help Prints help information | ||
--json Return command outputs in json format |
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.
Returns (to agree with the previous and following Prints)
-V, --version Prints version information | ||
|
||
OPTIONS: | ||
--address <address> Address owning the objects |
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'm not sure what the
argument takes or does. What is the active verb that should proceed "Address owning the objects" here?
doc/src/wallet.md
Outdated
OPTIONS: | ||
--address <address> Address owning the objects | ||
``` | ||
To view the objects owned by the accounts created in genesis, run the following command in the Sui interactive console (substitute the address with one of the genesis address in your wallet): |
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.
of the genesis addresses (plural)
(9C7626A4CBFFCE894518B8A317F06D051597A378, SequenceNumber(0), o#10dd0b5cabf227952a6e731001d3b57039595225eb188ca6e7ac65bf55ac7c6f) | ||
(AFA6A58082E961E8706FFF48A0D531C2BED8A94D, SequenceNumber(0), o#2c4b5c7c8be3055287deb4d445c87cf02603d84155d761bcd71f0457d76254ad) | ||
``` | ||
If you want to view more information about the objects, you can use the `object` command. |
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.
Why are we repeating this here when we have it at the beginning of this section ## View objects owned by the account?
Ah, we should centralize the generic flags (-h, --json, -V) at the beginning, before address
and then focus upon only the new argument (address
, object
, etc.).
doc/src/wallet.md
Outdated
```shell | ||
sui>-$ objects --address 0DC70EA8CA82FE6966900C697B73A235B8E2346F | ||
``` | ||
The result should look similar to the following, which shows the object in the format of (`object_id`, `sequence_number`, `object_hash`). |
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.
Replace "look similar to" with "resemble" throughout
doc/src/wallet.md
Outdated
Type: 0x2::Coin::Coin<0x2::GAS::GAS> | ||
``` | ||
The result shows some basic information about the object, the owner, | ||
version, id, if the object is immutable and the type of the object. |
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.
ID
doc/src/wallet.md
Outdated
The result shows some basic information about the object, the owner, | ||
version, id, if the object is immutable and the type of the object. | ||
If you need a deeper look into the object, you can use the `--json` | ||
flag to view the raw json representation of the object. |
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.
JSON
doc/src/wallet.md
Outdated
sui>-$ objects --address 830F66EA8EA867DDCA479535BC12CE2852E571F2 | ||
Showing 0 results. | ||
``` | ||
To add objects to the account, you can invoke a move function (see [Calling Move code](#calling-move-code) for more information), |
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.
Optionally, simply make "invoke a move function" the link, like so:
you can invoke a move function, or you can transfer...
doc/src/wallet.md
Outdated
Showing 0 results. | ||
``` | ||
To add objects to the account, you can invoke a move function (see [Calling Move code](#calling-move-code) for more information), | ||
or you can transfer one of the existing object from the genesis account to the new account. |
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.
one of the existing objects
doc/src/wallet.md
Outdated
--to <to> Recipient address | ||
``` | ||
To transfer an object to a recipient, you will need the recipient's address, | ||
the object id of the object that you want to transfer, |
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.
object ID
doc/src/wallet.md
Outdated
``` | ||
To transfer an object to a recipient, you will need the recipient's address, | ||
the object id of the object that you want to transfer, | ||
and the gas object' id for the transaction fee payment. |
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.
gas object's ID
Hi @Clay-Mysten , I think you could use the "Start a review" button to batch review them, instead of adding single comment on each review :) |
doc/src/wallet.md
Outdated
the object id of the object that you want to transfer, | ||
and the gas object' id for the transaction fee payment. | ||
|
||
Here is an example of a transfer of object to account `830F66EA8EA867DDCA479535BC12CE2852E571F2`. |
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.
Here is an example transfer of an object to account...
doc/src/wallet.md
Outdated
``` | ||
|
||
## Merging and splitting coin objects | ||
Overtime, the account might receive coins from other account and will become unmanageable when |
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.
from other accounts (plural)
doc/src/wallet.md
Outdated
|
||
## Merging and splitting coin objects | ||
Overtime, the account might receive coins from other account and will become unmanageable when | ||
the number of coins grows; contrarily the account might need to split the coin for payment or |
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.
contrarily,
doc/src/wallet.md
Outdated
|
||
## Merging and splitting coin objects | ||
Overtime, the account might receive coins from other account and will become unmanageable when | ||
the number of coins grows; contrarily the account might need to split the coin for payment or |
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.
split the coins (plural?)
doc/src/wallet.md
Outdated
## Merging and splitting coin objects | ||
Overtime, the account might receive coins from other account and will become unmanageable when | ||
the number of coins grows; contrarily the account might need to split the coin for payment or | ||
for transfer to other account. |
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.
to another account.
doc/src/wallet.md
Outdated
the number of coins grows; contrarily the account might need to split the coin for payment or | ||
for transfer to other account. | ||
|
||
We can use the `merge-coin` command and `split-coin` command to consolidate or split coins. |
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.
or split coins, respectively.
doc/src/wallet.md
Outdated
--gas-budget <gas-budget> Gas budget for this call | ||
--primary-coin <primary-coin> Coin to merge into, in 20 bytes Hex string | ||
``` | ||
Here is an example of how to merge coins, to merge coins, you will need at lease three coin objects - |
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 would replace this first comma with a period, like so:
coins. To
-V, --version Prints version information | ||
|
||
OPTIONS: | ||
--amounts <amounts>... Amount to split out from the coin |
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.
Why do we have ellipsis here:
...
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.
this is generated by the code, it means the --amounts
options can take multiple values
doc/src/wallet.md
Outdated
Updated Gas : Coin { id: B7FD91A802DAF5523CAAB69FF4652FAFA6FF4ADF, value: 99996 } | ||
``` | ||
|
||
### Split coin |
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.
Optionally, make plural:
Split coins
doc/src/wallet.md
Outdated
For splitting coins, you will need at lease two coins to execute the `split-coin` command, | ||
one coin to split, one for the gas payment. | ||
|
||
Here is an example of splitting coin, we are splitting out three new coins from the original coin, |
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.
example of splitting coins (assuming we decided on plural; if not, not worries)
doc/src/wallet.md
Outdated
one coin to split, one for the gas payment. | ||
|
||
Here is an example of splitting coin, we are splitting out three new coins from the original coin, | ||
with values of 1000, 5000 and 3000 respectively, note that the `--amounts` accepts list of values. |
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.
with values of 1000, 5000 and 3000, respectively; note that the --amounts
argument accepts a list of values.
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.
This is an excellent point, by the way. I would have been confused seeing the command next without this. Thanks!
doc/src/wallet.md
Outdated
(B7FD91A802DAF5523CAAB69FF4652FAFA6FF4ADF, SequenceNumber(3), o#839e98b33b3de62bc84c36c35b9fd6cdf3383f9d7c4f760c398cbbc7bef8c932) | ||
(BFA8BAB64ED8F74BA3731C9220FD7462456BC601, SequenceNumber(1), o#6748854128a8b4746fb5bd124eddafc4f9129bae36a8a34af85a8f29b07ee124) | ||
``` | ||
From the result we can see three new coins got created in the transaction. |
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.
coins were created
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.
This is fantastic work, Patrick! An absolutely wonderful addition to our docs.
If you simply want to merge, I will gladly make these non-semantic changes myself. Thanks!
dc83746
to
f75efb6
Compare
merge-coin
andsplit-coin
commends to the walletObjectID
instead ofObjectRef