Merge pull request #46 from SebastianBor/fix/use-source-mint-decimals-for-voting-mints

Proposals: Use source mint decimals for voting mints
This commit is contained in:
Jordan Prince 2021-04-06 14:49:34 -05:00 committed by GitHub
commit 69b745286c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import {
TimelockStateLayout, TimelockStateLayout,
} from '../models/timelock'; } from '../models/timelock';
const { cache } = contexts.Accounts;
const { sendTransactions } = contexts.Connection; const { sendTransactions } = contexts.Connection;
const { createMint, createTokenAccount } = actions; const { createMint, createTokenAccount } = actions;
const { notify } = utils; const { notify } = utils;
@ -39,6 +40,15 @@ export const createProposal = async (
AccountLayout.span, AccountLayout.span,
); );
const sourceMintDecimals = (
await cache.queryMint(
connection,
useGovernance
? timelockConfig.info.governanceMint
: timelockConfig.info.councilMint,
)
).decimals;
const { const {
sigMint, sigMint,
voteMint, voteMint,
@ -62,6 +72,7 @@ export const createProposal = async (
mintRentExempt, mintRentExempt,
timelockConfig, timelockConfig,
useGovernance, useGovernance,
sourceMintDecimals,
); );
let createTimelockAccountsSigners: Account[] = []; let createTimelockAccountsSigners: Account[] = [];
@ -186,6 +197,7 @@ async function getAssociatedAccountsAndInstructions(
mintRentExempt: number, mintRentExempt: number,
timelockConfig: ParsedAccount<TimelockConfig>, timelockConfig: ParsedAccount<TimelockConfig>,
useGovernance: boolean, useGovernance: boolean,
sourceMintDecimals: number,
): Promise<ValidationReturn> { ): Promise<ValidationReturn> {
const PROGRAM_IDS = utils.programIds(); const PROGRAM_IDS = utils.programIds();
@ -224,7 +236,7 @@ async function getAssociatedAccountsAndInstructions(
voteMintInstructions, voteMintInstructions,
wallet.publicKey, wallet.publicKey,
mintRentExempt, mintRentExempt,
0, sourceMintDecimals,
authority, authority,
authority, authority,
voteMintSigners, voteMintSigners,
@ -234,7 +246,7 @@ async function getAssociatedAccountsAndInstructions(
voteMintInstructions, voteMintInstructions,
wallet.publicKey, wallet.publicKey,
mintRentExempt, mintRentExempt,
0, sourceMintDecimals,
authority, authority,
authority, authority,
voteMintSigners, voteMintSigners,
@ -244,7 +256,7 @@ async function getAssociatedAccountsAndInstructions(
voteMintInstructions, voteMintInstructions,
wallet.publicKey, wallet.publicKey,
mintRentExempt, mintRentExempt,
0, sourceMintDecimals,
authority, authority,
authority, authority,
voteMintSigners, voteMintSigners,