Fix updateNeuron not to change the neuron subaccount #663
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently when you use
updateNeuron
on theGovernanceTestCanister
for testing, there is no way not to change the neuron subaccount in the process while probably you would never want to change the neuron subaccount.This is because when calling
update_neuron
the full neuron, includingaccount
(which is the neuron subaccount) must be specified butnns-js
never returns the neuron subaccount. It only returns theaccountIdentifier
which is derived from the subaccount in a one-way fashion.The current implementation of using the
accountIdentifier
as the neuron account is wrong and results in the neuron account changing each timeupdateNeuron
is used.So in order not to change the subaccount when calling
update_neuron
(and without changing the API ofnns-js
) we must first fetch the neuron to know its subaccount.Changes
toRawNeuron
(which is only used inupdateNeuron
) to take anaccount
parameter to use for the raw neuron.updateNeuron
to first fetch the existing neuron in order to use its account to pass totoRawNeuron
.account
of the fetched neuron matches theaccountIdentifier
of the passed neuron to make sure people don't try to change theaccountIdentifier
while it's not supported.Tests
Todos