import { PublicKey , TransactionInstruction } from '@solana/web3.js' ; import { withCreateProposal } from '@solana/spl-governance' ; import { withAddSignatory } from '@solana/spl-governance' ; import { sendTransactionWithNotifications } from '../tools/transactions' ; import { RpcContext } from '@solana/spl-governance' ; import { VoteType } from '@solana/spl-governance' ; export const createProposal = async ( { connection , wallet , programId , programVersion , walletPubkey } , realm , governance , tokenOwnerRecord , name , descriptionLink , governingTokenMint , proposalIndex ) : Promise < PublicKey > => { let instructions = [ ] ; let governanceAuthority = walletPubkey ; let signatory = walletPubkey ; let payer = walletPubkey ; const voteType = VoteType . SINGLE_CHOICE ; const options = [ 'Approve' ] ; const useDenyOption = true ; const proposalAddress = await withCreateProposal ( instructions , programId , programVersion , realm , governance , tokenOwnerRecord , name , descriptionLink , governingTokenMint , governanceAuthority , proposalIndex , voteType , options , useDenyOption , payer ) ; await withAddSignatory ( instructions , programId , proposalAddress , tokenOwnerRecord , governanceAuthority , signatory , payer ) ; await sendTransactionWithNotifications ( connection , wallet , instructions , [ ] , 'Creating proposal' , 'Proposal has been created' ) ; return proposalAddress ; } ;