js icon indicating copy to clipboard operation
js copied to clipboard

Problem with filter on findAllByCreator() ?

Open quentingosset opened this issue 2 years ago • 1 comments

Hello, I am confronted with a problem and I have the impression that the current library has a problem at the level of the filter when one calls findAllByCreator.

Here is an example of code where I use directly the library of solana web3 and this one returns me a correct result:

const a = await connection.getProgramAccounts(
    new PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s'),
    {
      encoding: 'base64',
      filters: [
        {
          "memcmp": {
            "offset": 326,
            "bytes": "8gXiDTQ9J6hN4XvSaRJEf8vdJcfdxuUyM9dTxjLoNiP5"
          }
        }
      ]
    }
  )

the request received by my server is the following:

{"method": "getProgramAccounts", "jsonrpc": "2.0", "params":["metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",{"encoding": "base64", "filters":[{"memcmp":{"offset": 326,"bytes":"8gXiDTQ9J6hN4XvSaRJEf8vdJcfdxuUyM9dTxjLoNiP5"}}]}],"id":"b0dfe5c1-afae-48bc-a53d-bbe49938e17b"} as you can see, in the filter, the "bytes" contains the address of "8gXiDTQ9J6hN4XvSaRJEf8vdJcfdxuUyM9dTxjLoNiP5"

However the same call via :

const connection = new Connection(process.env.RPC_HOST);
  const metaplex = Metaplex.make(connection).use(bundlrStorage());

  var creatorId = new PublicKey("8gXiDTQ9J6hN4XvSaRJEf8vdJcfdxuUyM9dTxjLoNiP5");

  const nfts = await metaplex.nfts().findAllByCreator({ creatorId , position: 1 });

returns the following request:

{"method": "getProgramAccounts", "jsonrpc": "2. 0","params":["metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",{"encoding":"base64","filters":[{"memcmp": {"offset":0,"bytes":"5"}},{"memcmp":{"offset":326,"bytes":"1"}}]}],"id":"45fd429a-78fc-475c-81e9-de9a20a8ac8a"} as you can see the filter is completely different. Am I doing something wrong?

quentingosset avatar Dec 18 '22 12:12 quentingosset