js icon indicating copy to clipboard operation
js copied to clipboard

Error: Invalid public key input when running findAllByCreator

Open cctdaniel opened this issue 2 years ago • 2 comments

getting Error: Invalid public key input when running const nfts = await mx.nfts().findAllByCreator(new PublicKey("3Fht1Ue3xLWEXiTjoFSo71YaRdqNMq5Qk9UbGkTXAZrT"));

this is a legit pubkey as seen from https://explorer.solana.com/address/3Fht1Ue3xLWEXiTjoFSo71YaRdqNMq5Qk9UbGkTXAZrT

upon further debugging, somehow there's a buffer with length 679 being passed to new PublicKey() and hence the error but not sure where this buffer is from

cctdaniel avatar May 23 '22 08:05 cctdaniel

Hi there 👋

Thanks for raising this, I'll debug this as soon as I can and report back here.

lorisleiva avatar May 23 '22 08:05 lorisleiva

Okay, so I've been able to reproduce the error.

The error is not very clear, but the issue is not about the provided PublicKey but about the PublicKeys found by the getProgramAccounts call.

That call fetches all Metadata accounts where the first creator is equal to the public key provided and they slice the data to only take the public key of the mint accounts.

It then take that slice of data and parse them into Public Key so it can fetch the NFTs.

account => new PublicKey(account.data)

And this is the code that throws the error. So there must be something wrong with one of the NFT retrieved.

I'll leave this issue open thought because the SDK should either:

  • Provide a much better error message explaining which NFT is corrupted.
  • Or allow the logic to continue by removing corrupted NFTs from the returned list.

Thanks again for raising this.

lorisleiva avatar May 25 '22 16:05 lorisleiva

I've taken note of this as TODOs so I'll close this for now. Thanks again for raising this.

lorisleiva avatar Sep 30 '22 11:09 lorisleiva