Thanks! It seems to have worked out, and I no longer face the error.
If anyone is ever interested in the solution:
- Once you have spun up a CMC and an NNS governance canister, you must make a proposal.
- When you spin up the Governance canister, you must provide it with a neuron.
- This neuron is then used to make the proposal.
- The proposal should include a timestamp for the XDR rate that is more recent than 30 days old.
- Diverged should be used in such a way that the CMC stops querying the exchange rate.
Here is the code for the make proposal part:
import {IDL} from '@dfinity/candid';
import {GovernanceCanister, NnsFunction, type MakeProposalRequest} from '@dfinity/nns';
import {createAgent} from '@dfinity/utils';
import {MAIN_IDENTITY_KEY} from '../../constants/constants';
import type {ModuleInstallParams} from '../../types/module';
import {NEURON_ID} from './governance.constants';
export const makeIcpXdrProposal = async ({identities}: Pick<ModuleInstallParams, 'identities'>) => {
const {[MAIN_IDENTITY_KEY]: identity} = identities;
const agent = await createAgent({
identity,
host: 'http://127.0.0.1:5987',
fetchRootKey: true
});
const {makeProposal} = GovernanceCanister.create({
agent
});
const arg = IDL.encode(
[
IDL.Record({
data_source: IDL.Text,
timestamp_seconds: IDL.Nat64,
xdr_permyriad_per_icp: IDL.Nat64,
reason: IDL.Opt(
IDL.Variant({
OldRate: IDL.Null,
DivergedRate: IDL.Null,
EnableAutomaticExchangeRateUpdates: IDL.Null
})
)
})
],
[
{
data_source: '{"icp":["Binance"],"sdr":"xe.com"}', // Example of payload data found it some proposal
timestamp_seconds: BigInt(Math.floor(Date.now() / 1000)), // Timestamp should not be < than 30 days from now
xdr_permyriad_per_icp: BigInt(41388),
reason: [{DivergedRate: null}]
}
]
);
const request: MakeProposalRequest = {
neuronId: BigInt(NEURON_ID),
url: 'https://forum.dfinity.org',
title: 'ICP/XDR Conversion Rate',
summary: `Set ICP/XDR conversion rate to ${41_388}`,
action: {
ExecuteNnsFunction: {
nnsFunctionId: NnsFunction.IcpXdrConversionRate,
payloadBytes: arg
}
}
};
await makeProposal(request);
};