metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
357 stars 182 forks source link

feePayer not being set in printNewEdition #134

Closed cjohansen11 closed 2 years ago

cjohansen11 commented 2 years ago

I believe there is an issue with the printNewEdition method due to the payer not being set properly for the TransactionBuilder.

Issue

The printNewEdition method accepts a payer as part of the PrintNewEditionSharedInput. When the transaction is build that payer is not converted to the required feePayer that the TransactionBuilder requires so it gets set to undefined and fails.

node_api         | Error: Transaction fee payer required
node_api         |     at Transaction.compileMessage (/node_modules/@solana/web3.js/src/transaction.ts:351:13)
node_api         |     at Transaction._compile (/node_modules/@solana/web3.js/src/transaction.ts:508:26)
node_api         |     at Transaction.partialSign (/node_modules/@solana/web3.js/src/transaction.ts:639:26)
node_api         |     at RpcClient.sendTransaction (/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:69:19)
node_api         |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
node_api         |     at async RpcClient.sendAndConfirmTransaction (/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:114:23)
node_api         |     at async Object.handle (/node_modules/@metaplex-foundation/js/src/plugins/nftModule/printNewEdition.ts:175:29)
node_api         |     at async /node_modules/@metaplex-foundation/js/src/utils/Task.ts:76:23
node_api         |     at async Disposable.run (/node_modules/@metaplex-foundation/js/src/utils/Disposable.ts:34:14)
node_api         |     at async NftClient.printNewEdition (/node_modules/@metaplex-foundation/js/src/plugins/nftModule/NftClient.ts:92:35)

Possible Solution

I haven't messed around with the code base much but a possible solution would be to call the setFeePayer method on line 320 when TransactionBuilder.make() is called similar to how it is called in the createMint method... TransactionBuilder.make().setFeePayer(payer)

lorisleiva commented 2 years ago

Hi there 👋

That's a good point, the payer should be set there as well.

However, I suspect this is happening to you because you don't have an "identity" set up in your Metaplex instance because the SDK will default to making the current identity the fee payer for all transactions.

lorisleiva commented 2 years ago

This should now be fixed for printNewEdition in version 0.11.4. 🚀

cjohansen11 commented 2 years ago

Awesome, thanks so much! 🙌🏼