I'm working on a Solana program using Anchor ("^0.30.1") and encountered an error while trying to fetch accounts with the all method. I want to retrieve all tickets for a specific lotteryId and filter them by the user's public key. However, I'm receiving the following TypeScript error:
Property 'all' does not exist on type '{ fetch: (address: PublicKey) => Promise<TicketAccount>; }'.ts(2339)
Here’s the relevant part of my code:
if (!wallet?.publicKey) return;const userTickets = await program.account.ticket.all([ { memcmp: { bytes: bs58.encode( new BN(lotteryId).toArrayLike(Buffer, "le", 4) ), offset: 12, }, }, { memcmp: { bytes: wallet.publicKey.toBase58(), offset: 16, }, },]);
How can I resolve this error? Does the all() method need additional setup, or should I use another approach for filtering accounts? Is there a better way to apply memcmp for on-chain filtering of accounts?
Thanks in advance :)