js icon indicating copy to clipboard operation
js copied to clipboard

Create NFT Operation Handler does more than simply creating

Open saberistic opened this issue 2 years ago • 4 comments
trafficstars

I have been trying to call create function and it's been failing in localnet. Thinking I am calling the function with wrong parameters tried so many things but no luck. Then I dived deeper into nftModule code and I learned the operation which creates the NFT immediately attempts to find that NFT and asserts the existence of MintAccount.

https://github.com/metaplex-foundation/js/blob/278b93334d73ca995abd98517c9082752209fd02/packages/js/src/plugins/nftModule/operations/createNft.ts#L329-L342

In case this function is being ran in mainnet commitment level is set to finalized and function succeeds. However in cases such as localnet and commitment equal to confirmed this operation fails even though all arguments are set properly.

AccountNotFoundError: The account of type [MintAccount] was not found at the provided address [7wkfQt56BrT8a5rpSjjs46iKfM4S5Zgv1DRQPHfSEnXx].

My two cents says from name of the function which is clearly states creating the NFT, this function should not be responsible for:

  • setting commitement level to finalized on mainnet which overwrites provided commitment and creates a side effect not really expect by caller
  • attempt to find the NFT after creating it, which is another operation not really expected by caller

saberistic avatar Jan 31 '23 00:01 saberistic

I am also seeing this error @lorisleiva on devnet, the mint account issue

Shusanta avatar Feb 01 '23 18:02 Shusanta

'finalized' didn't work for me either. 'recent' as commitment did tho on devnet.

Shusanta avatar Feb 01 '23 19:02 Shusanta

REPRO steps (for me) 1. create a nextjs project, 2. add a keypair that you will use to sign with on the back end or /api route. 3. Call create in this backend function that mints the nft. You will see its very inconsistent. (devnet and sometimes mainnet)

Shusanta avatar Feb 01 '23 23:02 Shusanta

Hi, Thanks for the report. It’s the same as #344

you can find a temporary workaround there, too, in one of the last comments

MarkSackerberg avatar Feb 11 '23 13:02 MarkSackerberg