Thanks @aterga for helping me understand this error. This is actually expected in the sense that I cannot propose an SNS that uses the neuron funds locally if there is no neuron with maturity participating in the neuron funds, as I’m starting from an empty state.
Therefore, to resolve the issue, two things need to be done.
1. Participate to neuron fund
First, in the local NNS dapp, open the neuron I’m using for test purposes and set Participate in neuron's fund
.
2. Get Maturity
The neuron needs maturity, so sure, I can wait, but that’s probably not what one wants to do when testing locally. Fortunately, there is a solution to speed up things, as when spun locally, the Governance canister is deployed with a handy function update_neuron
that can be used to set any fields of the neuron (as long as the one making the request is a controller or hotkey of the neuron).
There is probably a way to do that with dfx and stuff, but given that I’ve got no clue about those tools, I wrote a JS script.
#!/usr/bin/env node
import { assertNonNullish } from '@dfinity/utils';
import { copyFileSync } from 'node:fs';
import { join } from 'node:path';
import { getGovernanceActor, getGovernanceTestActor } from './actor.utils.mjs';
const governanceCanisterId = 'rrkah-fqaaa-aaaaa-aaaaq-cai';
copyFileSync(
join(process.cwd(), 'node_modules/@dfinity/nns/dist/candid/governance.idl.js'),
join(process.cwd(), 'node_modules/@dfinity/nns/dist/candid/governance.idl.mjs')
);
copyFileSync(
join(process.cwd(), 'node_modules/@dfinity/nns/dist/candid/governance_test.idl.js'),
join(process.cwd(), 'node_modules/@dfinity/nns/dist/candid/governance_test.idl.mjs')
);
const updateNeuron = async () => {
const [, , neuronId] = process.argv;
assertNonNullish(neuronId);
const { get_full_neuron } = await getGovernanceActor(governanceCanisterId);
const neuron = await get_full_neuron(BigInt(neuronId));
console.log('Current neuron', neuron.Ok);
const updateNeuron = {
...neuron.Ok,
maturity_e8s_equivalent: 100_000_000_000_000n
};
const { update_neuron } = await getGovernanceTestActor(governanceCanisterId);
await update_neuron(updateNeuron);
};
await updateNeuron();
Just copying the above code won’t work. Check out the repo for everything: https://github.com/peterpeterparker/proposals.network