js icon indicating copy to clipboard operation
js copied to clipboard

Function metaplex.nfts().create(...) returns output of type Nft despite not passing the "tree" argument.

Open TanLocc opened this issue 2 years ago • 0 comments

I have the following nft generation code: `async function createNft( metaplex: Metaplex, uri: string, ): Promise<NftWithToken> { const { nft } = await metaplex .nfts() .create({ uri: uri, name: tokenName, sellerFeeBasisPoints: sellerFeeBasisPoints, tree: undefined, })

console.log( Token Mint: https://explorer.solana.com/address/${nft.address.toString()}?cluster=devnet )

return nft }`

But I get the following error when implementing the function: `The newly created NFT and, potentially, its associated token.

Type 'Nft' is not assignable to type 'NftWithToken'. Property 'token' is missing in type 'Nft' but required in type '{ token: Token; }'.`

And here is the definition of Nft's create(...) function I found in the library: create(input: CreateNftInput, options?: OperationOptions) { if (input?.tree) return this.metaplex .operations() .execute( createCompressedNftOperation(input as CreateCompressedNftInput), options ); return this.metaplex .operations() .execute(createNftOperation(input), options); }

According to the function definition, when not passing the "tree" parameter, the function returns output of type "NftWithToken", and when passing the "tree" parameter, the function returns output of type "Nft"

And the problem here is that when passing "tree" and not passing "tree", the function returns output of type "Nft"

Can any sona expert please help me with this error.

TanLocc avatar Sep 02 '23 10:09 TanLocc