import { Connection , PublicKey } from '@solana/web3.js' ; import { getBorshProgramAccounts , MemcmpFilter , pubkeyFilter , } from '../core/api' ; import { ChatMessage , GOVERNANCE_CHAT_PROGRAM_ID } from './accounts' ; import { GOVERNANCE_CHAT_SCHEMA } from './serialisation' ; export function getGovernanceChatMessages ( connection , proposal ) { return getBorshProgramAccounts ( connection , GOVERNANCE_CHAT_PROGRAM_ID , _ => GOVERNANCE_CHAT_SCHEMA , ChatMessage , [ pubkeyFilter ( 1 , proposal ) as MemcmpFilter ] ) ; } export function getGovernanceChatMessagesByVoter ( connection , voter ) { return getBorshProgramAccounts ( connection , GOVERNANCE_CHAT_PROGRAM_ID , _ => GOVERNANCE_CHAT_SCHEMA , ChatMessage , [ pubkeyFilter ( 33 , voter ) as MemcmpFilter ] ) ; }