I am trying to do a democracy vote using the API.
First I am getting the balance of my account:
const balance = (await api.query.system.account(my_account)).data.free;
const voteConfig: Vote = new GenericVote(api.registry, {
aye: true,
conviction: 'None',
});
let vote: PalletDemocracyVoteAccountVote = { asStandard: { vote: voteConfig, balance: balance } };
let txHash = await api.tx.democracy.vote(i, vote).signAndSend(payoutKey, (({ events = [], status }: any) => {
But I am getting the type error below:
/home/nochem/.nvm/versions/node/v17.4.0/lib/node_modules/ts-node/src/index.ts:820
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
votebot.ts:102:48 - error TS2322: Type '{ vote: Vote; balance: u128; }' is not assignable to type '{ readonly vote: Vote; readonly balance: u128; } & Struct<TypesDef<Codec>, { [x: string]: any; }, { [x: string]: string; }>'.
Type '{ vote: Vote; balance: u128; }' is missing the following properties from type 'Struct<TypesDef<Codec>, { [x: string]: any; }, { [x: string]: string; }>': #private, defKeys, getT, isEmpty, and 25 more.
102 let vote: PalletDemocracyVoteAccountVote = { asStandard: { vote: voteConfig, balance: balance } };
~~~~~~~~~~
node_modules/@polkadot/types-augment/lookup/types-substrate.d.ts:430:18
430 readonly asStandard: {
~~~~~~~~~~
The expected type comes from property 'asStandard' which is declared here on type 'PalletDemocracyVoteAccountVote'
at createTSError (/home/nochem/.nvm/versions/node/v17.4.0/lib/node_modules/ts-node/src/index.ts:820:12)
How can I compile the above code?