metaplex-foundation / js

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

Add an operation that finds the owner of an NFT #341

Closed haris-aqeel closed 1 year ago

haris-aqeel commented 2 years ago

I am able to get NFT details from the NFT mint address using metaplex.

image

The above part is my code and in response I am getting a long NFT object, which contains

type Nft = Readonly<{ model: 'nft'; address: PublicKey; metadataAddress: Pda; updateAuthorityAddress: PublicKey; json: Option<Json>; jsonLoaded: boolean; name: string; symbol: string; uri: string; isMutable: boolean; primarySaleHappened: boolean; sellerFeeBasisPoints: number; editionNonce: Option<number>; creators: Creator[]; tokenStandard: Option<TokenStandard>; collection: Option<{ address: PublicKey; verified: boolean; }>; collectionDetails: Option<{ version: 'V1'; size: BigNumber; }>; uses: Option<{ useMethod: UseMethod; remaining: BigNumber; total: BigNumber; }>; mint: { model: 'mint'; address: PublicKey; mintAuthorityAddress: Option<PublicKey>; freezeAuthorityAddress: Option<PublicKey>; decimals: number; supply: SplTokenAmount; isWrappedSol: boolean; currency: SplTokenCurrency; }; edition: | { model: 'nftEdition'; isOriginal: true; address: PublicKey; supply: BigNumber; maxSupply: Option<BigNumber>; } | { model: 'nftEdition'; isOriginal: false; address: PublicKey; parent: PublicKey; number: BigNumber; }; }>

The above sample is of NFT response, I am receiving. Everything is fine, but now I want to get all nfts by owner of this particular nft. I understand that metaplex provides us a function like this

image

Here, if I can get the owner address in response, so I can be able to pass in owners address but unable to do so because the nft response does not contains the nft owners info(i.e, address).

USECASE:

I am using next.js so on a dynamic route such as abc.com/nft-detail/. I am able to show nft details from the mint address by using metaplex function. However, along with showing the detail of a selected nft, I also want to show another section on the same page, which shows list of other nfts from the same owner. The issue is that I am using the next SSR and I don't have an access to wallet address and neither I need to be dependent on my wallet to be connected inorder to display other nfts from same owner, therefore, I have a need of a function through metaplex inorder to get owner from the mint address.

lorisleiva commented 2 years ago

Thanks for registering this feature request!

m4thfr34k commented 2 years ago

Second this feature request

Also using nextjs and using a combination of metaplex functions and getTokenLargestAccounts inside of the getServerSideProps to get all of the data needed.

Having the owner of the NFT be returned with the other NFT data in functions such as findbymint would be helpful.

https://solanacookbook.com/references/nfts.html#how-to-get-the-owner-of-an-nft

lorisleiva commented 1 year ago

Hi there, we're moving feature requests to Canny.io so people can upvote and comment on their favourite feature requests. I'll add the "feature request" label to this issue so the label automation triggers the automated message. Thanks for your understanding. 🌸

github-actions[bot] commented 1 year ago

Hi @haris-aqeel,

Thank you for raising this!

We'd like to make sure our GitHub issue tracker remains the best place to manage issues that affect the development of the Metaplex JS SDK itself. It looks like your issue is suggesting an improvement rather than raising a bug.

Unless there exists evidence that this is a bug with the JS SDK itself, please use our Feature Request boards to create new posts or upvote existing ones. You may use the following links to access the JS SDK Feature Request board:

https://metaplex.canny.io/developers?category=js-sdk-tools

If you could please share the link to the relevant Feature Request here afterwards, that would be very helpful for anyone following this thread.


This automated message is a result of having added the "feature request" label.