solana-labs / solana-web3.js

Solana JavaScript SDK
https://solana-labs.github.io/solana-web3.js
MIT License
1.97k stars 792 forks source link

bug: wrap memcmp filters of getProgramAccounts in required `memcmp` object #2830

Closed wjthieme closed 2 weeks ago

wjthieme commented 2 weeks ago

Not sure if this is the right place to fix or if the intention was to have a transformer somewhere that wraps the filter in a memcmp object.

In current version GPA with a memcmp filter turns into the following params:

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "getProgramAccounts",
  "params": [
    "<program-id>",
    {
      "encoding": "base64",
      "filters": [
        {
          "offset": 0,
          "bytes": "6",
          "encoding": "base58"
        }
      ],
      "commitment": "confirmed"
    }
  ]
}

The filter should however be wrapped in a memcmp object:

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "getProgramAccounts",
  "params": [
    "<program-id>",
    {
      "encoding": "base64",
      "filters": [
        {
          "memcmp": {
             "offset": 0,
            "bytes": "6",
            "encoding": "base58"
          }
        }
      ],
      "commitment": "confirmed"
    }
  ]
}

Reference: https://solana.com/docs/rpc/http/getprogramaccounts

changeset-bot[bot] commented 2 weeks ago

⚠️ No Changeset found

Latest commit: f6eb4518a799ec2cb434ff1a4cc9183a76fa52a9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

steveluscher commented 2 weeks ago

Damnit, I thought I got all of these in #2729. Thanks!

github-actions[bot] commented 4 days ago

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.