import { PublicKey , SYSVAR_CLOCK_PUBKEY , TransactionInstruction , } from '@solana/web3.js' ; import { GOVERNANCE_SCHEMA } from './serialisation' ; import { serialize } from 'borsh' ; import { FlagInstructionErrorArgs } from './instructions' ; export const withFlagInstructionError = ( instructions , programId , proposal , tokenOwnerRecord , governanceAuthority , proposalInstruction ) => { const args = new FlagInstructionErrorArgs ( ) ; const data = Buffer . from ( serialize ( GOVERNANCE_SCHEMA , args ) ) ; const keys = [ { pubkey : proposal , isWritable : true , isSigner : false , } , { pubkey : tokenOwnerRecord , isWritable : false , isSigner : false , } , { pubkey : governanceAuthority , isWritable : false , isSigner : true , } , { pubkey : proposalInstruction , isWritable : true , isSigner : false , } , { pubkey : SYSVAR_CLOCK_PUBKEY , isSigner : false , isWritable : false , } , ] ; instructions . push ( new TransactionInstruction ( { keys , programId , data , } ) ) ; } ;