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

feat: add account identifier + balance to neuron list. #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ielashi
Copy link
Contributor

@ielashi ielashi commented May 8, 2023

The command to list neurons only returned the neuron IDs. This commit extends this information to include the account identifier as well as the balance of the neuron.

The list of neurons are rendered in a table that looks like this:

npm run execute -- neuron list

╔════╤══════════════════════╤══════════════════════════════════════════════════════════════════╤═══════════════╗
║ #  │ Neuron ID            │ Account Identifier                                               │ Balance (e8s) ║
╟────┼──────────────────────┼──────────────────────────────────────────────────────────────────┼───────────────╢
║ 1  │ 123                  │ XXXXX                                                            │ 123           ║
╟────┼──────────────────────┼──────────────────────────────────────────────────────────────────┼───────────────╢
║ 2  │ 456                  │ XXXXX                                                            │ 123           ║
╚════╧══════════════════════╧══════════════════════════════════════════════════════════════════╧═══════════════╝

The command to list neurons only returned the neuron IDs. This commit
extends this information to include the account identifier as well as
the balance of the neuron.

The list of neurons are rendered in a table that looks like this:

```
npm run execute -- neuron list

╔════╤══════════════════════╤══════════════════════════════════════════════════════════════════╤═══════════════╗
║ #  │ Neuron ID            │ Account Identifier                                               │ Balance (e8s) ║
╟────┼──────────────────────┼──────────────────────────────────────────────────────────────────┼───────────────╢
║ 1  │ 123                  │ XXXXX                                                            │ 123           ║
╟────┼──────────────────────┼──────────────────────────────────────────────────────────────────┼───────────────╢
║ 2  │ 456                  │ XXXXX                                                            │ 123           ║
╚════╧══════════════════════╧══════════════════════════════════════════════════════════════════╧═══════════════╝

```
@ielashi ielashi requested a review from lmuntaner May 8, 2023 20:01
Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks great!

I added a comment

n.fullNeuron!.accountIdentifier
);

const balance = await ledger.accountBalance({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use cachedNeuronStake - neuronFees from the Neuron?

This way you'd avoid an extra call per neuron.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because these are not necessarily accurate - there's a delay between that cached number and the real value, so we might as well get the real value. The calls to the ledger are quite cheap.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But a query call is not secure. Is that still better than the information in the neuron?

Or should we do an update call certified: true?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants