openbook-dex / openbook-v2

openbook-v2 monorepo, contains solana program and ts client
Other
165 stars 96 forks source link

Possible to fetch multiple order accounts by combining memcmp filters? #229

Closed LukasDeco closed 8 months ago

LukasDeco commented 9 months ago

I currently have some TS code like this:

const passOrders = await openbook.account.openOrdersAccount.all([
        { memcmp: { offset: 8, bytes: owner.toBase58() } },
        { memcmp: { offset: 40, bytes: proposal.account.openbookPassMarket.toBase58() } },
      ]);
      const failOrders = await openbook.account.openOrdersAccount.all([
        { memcmp: { offset: 8, bytes: owner.toBase58() } },
        { memcmp: { offset: 40, bytes: proposal.account.openbookFailMarket.toBase58() } },
      ]);
  but could I possibly do something like this? 
  ```
  const allOrders = await openbook.account.openOrdersAccount.all([
    { memcmp: { offset: 8, bytes: owner.toBase58() } },
    { memcmp: { offset: 40, bytes: proposal.account.openbookPassMarket.toBase58() } },
    { memcmp: { offset: 40, bytes: proposal.account.openbookFailMarket.toBase58() } },
  ]);
  ```
riordanp commented 8 months ago

afraid not

The resultant account(s) must meet ALL filter criteria to be included in the returned results https://solana.com/docs/rpc/http/getprogramaccounts#parameters