Skip to content
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 a command for displaying the balance for a wallet #68

Closed
mitchmindtree opened this issue Dec 24, 2022 · 1 comment · Fixed by #95
Closed

Add a command for displaying the balance for a wallet #68

mitchmindtree opened this issue Dec 24, 2022 · 1 comment · Fixed by #95
Assignees
Labels
enhancement New feature or request

Comments

@mitchmindtree
Copy link
Contributor

No description provided.

@mitchmindtree mitchmindtree added the enhancement New feature or request label Dec 24, 2022
@adlerjohn
Copy link
Contributor

It would be nice if there was also an option to list exact UTXOs instead of just a total balance.

@mitchmindtree mitchmindtree changed the title Add a command for displaying the balance for a wallet balance Add a command for displaying the balance for a wallet Jan 30, 2023
@mitchmindtree mitchmindtree self-assigned this Feb 26, 2023
mitchmindtree added a commit that referenced this issue Mar 2, 2023
… asset balances (#95)

Show the balance of the specified account:
```console
forc wallet account <ix> balance
```

Show the total balance for the whole wallet:
```console
forc wallet balance
```

Show the balance of each non-empty account prior to the wallet total:
```console
forc wallet balance --accounts
```

Demo:

```console
$ forc wallet account 0 balance
Please enter your password to verify account 0:
Verifying account 0
Connecting to https://node-beta-2.fuel.network/
Fetching the balance of the following account:
    0: fuel1htrldg7wpelrnhvad8lwcep57duhpxmj2h6a55nhr4md4839cy2q04p3tu

Account 0:
  Asset ID                                                           Amount
  0x0000000000000000000000000000000000000000000000000000000000000000 1000000000

$ forc wallet account 1 balance
Please enter your password to verify account 1:
Verifying account 1
Connecting to https://node-beta-2.fuel.network/
Fetching the balance of the following account:
    1: fuel1vjnvqkvea7hhluhh8alwt7yuq0nj7d0sfa2vxu3q5drna5ujrzmqy0k43h

Account 1:
  Asset ID                                                           Amount
  0x0000000000000000000000000000000000000000000000000000000000000000 500000000

$ forc wallet account 2 balance
Please enter your password to verify account 2:
Verifying account 2
Connecting to https://node-beta-2.fuel.network/
Fetching the balance of the following account:
    2: fuel13c78d66334nqnrat322gfszne77a8tklhfklkshk0fmdq2e0dscsdyrs8u

Account 2:
  Account empty. Visit the faucet to acquire some test funds: https://faucet-beta-2.fuel.network

$ forc wallet balance
Please enter your password to verify accounts:
Verifying account 0
Verifying account 1
Verifying account 2
Verifying account 9
Connecting to https://node-beta-2.fuel.network/
Fetching and summing balances of the following accounts:
    0: fuel1htrldg7wpelrnhvad8lwcep57duhpxmj2h6a55nhr4md4839cy2q04p3tu
    1: fuel1vjnvqkvea7hhluhh8alwt7yuq0nj7d0sfa2vxu3q5drna5ujrzmqy0k43h
    2: fuel13c78d66334nqnrat322gfszne77a8tklhfklkshk0fmdq2e0dscsdyrs8u
    9: fuel14f6e7arrxqz8vjc0dyp8yhzng9r2u4wjvm89falk9d2y9vv6l6mq5rj3mf

Total:
  Asset ID                                                           Amount
  0x0000000000000000000000000000000000000000000000000000000000000000 1500000000

$ forc wallet balance --accounts
Please enter your password to verify accounts:
Verifying account 0
Verifying account 1
Verifying account 2
Verifying account 9
Connecting to https://node-beta-2.fuel.network/
Fetching and summing balances of the following accounts:
    0: fuel1htrldg7wpelrnhvad8lwcep57duhpxmj2h6a55nhr4md4839cy2q04p3tu
    1: fuel1vjnvqkvea7hhluhh8alwt7yuq0nj7d0sfa2vxu3q5drna5ujrzmqy0k43h
    2: fuel13c78d66334nqnrat322gfszne77a8tklhfklkshk0fmdq2e0dscsdyrs8u
    9: fuel14f6e7arrxqz8vjc0dyp8yhzng9r2u4wjvm89falk9d2y9vv6l6mq5rj3mf

Account 0:
  Asset ID                                                           Amount
  0x0000000000000000000000000000000000000000000000000000000000000000 1000000000

Account 1:
  Asset ID                                                           Amount
  0x0000000000000000000000000000000000000000000000000000000000000000 500000000

Total:
  Asset ID                                                           Amount
  0x0000000000000000000000000000000000000000000000000000000000000000 1500000000
```

Just like for the `account` and `accounts` subcommands, the
`--unverified` flag allows for retrieving the address associated with an
account index without verification to avoid the need to re-enter the
password (useful for testing).

The `--node-url` flag allows for specifying the network URL. This PR
defaults the value to the beta-2 network. Thinking further, we may
prefer to default to a local network for safety, and require that remote
networks are specified manually. I'll update the PR to make this change.

This should make it easier to test and implement #65.

## TODO

- [x] Add a more general wallet balance summary command that aggregates
the balance of each known account.

### Follow-up

- Add option for listing all individual UTXOs (not just full balance).
#97.

Closes #68

---------

Co-authored-by: Kaya Gökalp <kaya.gokalp@fuel.sh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants