Skip to content

Commit

Permalink
chunk fees (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 authored Oct 27, 2024
1 parent 43fdb35 commit 6e178ce
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
12 changes: 10 additions & 2 deletions actions/createLUTproposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { deduplicateObjsFilter } from '@utils/instructionTools'
import { sendSignAndConfirmTransactions } from '@utils/modifiedMangolana'
import { InstructionDataWithHoldUpTime } from './createProposal'
import { fetchProgramVersion } from '@hooks/queries/useProgramVersionQuery'
// import { chargeFee, PROPOSAL_FEE } from './createChargeFee'
import { chargeFee, PROPOSAL_FEE } from './createChargeFee'

/** This is a modified version of createProposal that makes a lookup table, which is useful for especially large instructions */
// TODO make a more generic, less redundant solution
Expand Down Expand Up @@ -106,7 +106,6 @@ export const createLUTProposal = async (
payer
)

// instructions.push(...chargeFee(wallet.publicKey!, PROPOSAL_FEE))
// TODO: Return signatoryRecordAddress from the SDK call
const signatoryRecordAddress = await getSignatoryRecordAddress(
programId,
Expand Down Expand Up @@ -275,6 +274,15 @@ export const createLUTProposal = async (
.then((res) => res.value)
if (lookupTableAccount === null) throw new Error()

txes.push({
instructionsSet: [
...chargeFee(wallet.publicKey!, PROPOSAL_FEE).map((x) => ({
transactionInstruction: x,
signers: [],
})),
],
sequenceType: SequenceType.Sequential,
})
await sendTransactionsV3({
callbacks,
connection,
Expand Down
23 changes: 20 additions & 3 deletions actions/createProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import { trySentryLog } from '@utils/logs'
import { deduplicateObjsFilter } from '@utils/instructionTools'
import { NftVoterClient } from '@utils/uiTypes/NftVoterClient'
import { fetchProgramVersion } from '@hooks/queries/useProgramVersionQuery'
// import { chargeFee, PROPOSAL_FEE } from './createChargeFee'
import { chargeFee, PROPOSAL_FEE } from './createChargeFee'

export interface InstructionDataWithHoldUpTime {
data: InstructionData | null
holdUpTime: number | undefined
Expand Down Expand Up @@ -142,8 +143,6 @@ export const createProposal = async (
payer
)

// instructions.push(...chargeFee(wallet.publicKey!, PROPOSAL_FEE))

// TODO: Return signatoryRecordAddress from the SDK call
const signatoryRecordAddress = await getSignatoryRecordAddress(
programId,
Expand Down Expand Up @@ -248,6 +247,15 @@ export const createProposal = async (
sequenceType: SequenceType.Sequential,
}
})
txes.push({
instructionsSet: [
...chargeFee(wallet.publicKey!, PROPOSAL_FEE).map((x) => ({
transactionInstruction: x,
signers: [],
})),
],
sequenceType: SequenceType.Sequential,
})

await sendTransactionsV3({
callbacks,
Expand Down Expand Up @@ -290,6 +298,15 @@ export const createProposal = async (
]

// should add checking user has enough sol, refer castVote
instructionsChunks.push({
instructionsSet: [
...chargeFee(wallet.publicKey!, PROPOSAL_FEE).map((x) => ({
transactionInstruction: x,
signers: [],
})),
],
sequenceType: SequenceType.Sequential,
})

await sendTransactionsV3({
connection,
Expand Down
27 changes: 18 additions & 9 deletions cli/helpers/createBase64Proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
getVoterPDA,
getVoterWeightPDA,
} from 'VoteStakeRegistry/sdk/accounts'
// import { chargeFee, PROPOSAL_FEE } from 'actions/createChargeFee'
import { chargeFee, PROPOSAL_FEE } from 'actions/createChargeFee'

export const createBase64Proposal = async (
connection: Connection,
Expand Down Expand Up @@ -110,8 +110,6 @@ export const createBase64Proposal = async (
payer
)

// instructions.push(...chargeFee(wallet.publicKey!, PROPOSAL_FEE))

const signatoryRecordAddress = await getSignatoryRecordAddress(
governanceProgram,
proposalAddress,
Expand Down Expand Up @@ -152,13 +150,24 @@ export const createBase64Proposal = async (
await sendSignAndConfirmTransactions({
connection,
wallet,
transactionInstructions: txChunks.map((txChunk) => ({
instructionsSet: txChunk.map((tx) => ({
signers: [],
transactionInstruction: tx,
transactionInstructions: [
...txChunks.map((txChunk) => ({
instructionsSet: txChunk.map((tx) => ({
signers: [],
transactionInstruction: tx,
})),
sequenceType: SequenceType.Sequential,
})),
sequenceType: SequenceType.Sequential,
})),
{
instructionsSet: [
...chargeFee(wallet.publicKey!, PROPOSAL_FEE).map((x) => ({
transactionInstruction: x,
signers: [],
})),
],
sequenceType: SequenceType.Sequential,
},
],
})
return proposalAddress
}

0 comments on commit 6e178ce

Please sign in to comment.