Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TanLocc opened this issue Sep 2, 2023 · 0 comments

Comments

@TanLocc
Copy link

TanLocc commented Sep 2, 2023

I have the following nft generation code:
`async function createNft(
metaplex: Metaplex,
uri: string,
): Promise {
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant