FuelLabs/forc-wallet

Ambiguity between referring to wallet or account in commands (e.g. new, init, list)

mitchmindtree opened this issue · 0 comments

Currently, the new command allows for deriving a new account, while init allows for initializing a wallet. This can be a little confusing for users, as forc wallet new looks a lot like creating a new wallet, when it actually just creates a new account for the default wallet.

Similarly, forc wallet list does not output a list of wallets, rather it outputs a list of accounts.

I propose we use account as a general subcommand for all account-related operations, and remove the init command altogether. This would look like the following:

Existing commands

  • forc wallet new
    • Previously: forc wallet init. Create a new wallet.
  • forc wallet import
    • No change. Imports a wallet from a seed phrase.
  • forc wallet accounts
    • Previously forc wallet list. List all previously derived accounts.
  • forc wallet account new
    • Previously forc wallet new. Create a new account.
  • forc wallet account <ix>
    • Previously forc account <ix>. Derive the acc at the given index.
  • forc wallet account <ix> export-private-key
    • Previously forc wallet export --account-index <ix>.
  • forc wallet account <ix> sign tx <tx-id>
    • Previously forc wallet sign --acount-index <ix> --id <tx-id>. Sign a transaction ID.

Upcoming commands

  • forc wallet account <ix> sign file <path>
    • Sign arbitrary data in the form of bytes read from a file.
  • forc wallet account <ix> sign data <string>
    • Sign arbitrary data in the form of a string.
  • forc wallet account <ix> send --gas-price <price> --gas-limit <lmt> --asset-id <id> <amount>
    • Send assets from the specified account.
  • forc wallet send --gas-price <price> --gas-limit <lmt> --asset-id <id> <amount>
    • Automatically aggregates UTXOs from all accounts to send an asset.

Beyond reducing ambiguity, putting account-specific commands behind a subcommand like this potentially opens up the options for "smart" versions of other commands. E.g. forc wallet sign [tx|file|data] <tx-id|path|string> could potentially automatically derive a new account and use it to sign some data?

We can also handle cases where the user tries to do something account related without creating or specifying a wallet in one place, rather than checking within each of the separate account-related sub-commands individually.