Add NFT API nft_get_metadata_by_owner() #459

Closed
opened 2022-09-30 16:48:10 +00:00 by christophersanborn · 8 comments
christophersanborn commented 2022-09-30 16:48:10 +00:00 (Migrated from gitlab.com)

The database API currently provides a way of retrieving NFTs by owner, but does not provide a way to retrieve NFTs by issuer.

Since NFTs are issued through an issuance contract, which on Peerplays is modeled by the the nft_metadata_object, it seems what is really needed an API call that retrieves not NFT objects (1.31.x), but metadata objects (1.30.x), by owner account. The owner of a metadata object can be considered to be the issuer of NFTs linked to the metadata.

Exists:

 vector<nft_object> nft_get_tokens_by_owner(const account_id_type owner) const;

In code here: (Declaration, Definition)

Desired:

 vector<nft_metadata_object> nft_get_metadata_by_owner(const account_id_type owner) const;

Note: Although existing API call does not have lower-bound and limit parameters, these would probably be a good idea for both API functions. See #458+ for rationale.

Importance:

This will support several projects, including TradeHands Explorer, wherein it will allow inspecting user accounts and seeing NFT collections issued by the account, and PeerShare (currently being worked on by @Hiltos1), in which NFT metadata objects associated with an account are used as a documents database for unique applications including onboarding new users.

The database API currently provides a way of retrieving NFTs by owner, but does _not_ provide a way to retrieve NFTs by issuer. Since NFTs are issued through an issuance contract, which on Peerplays is modeled by the the nft_metadata_object, it seems what is really needed an API call that retrieves not NFT objects (1.31.x), but metadata objects (1.30.x), by owner account. The owner of a metadata object can be considered to be the issuer of NFTs linked to the metadata. ### Exists: ```c++ vector<nft_object> nft_get_tokens_by_owner(const account_id_type owner) const; ``` In code here: ([Declaration](https://gitlab.com/PBSA/peerplays/-/blob/master/libraries/app/include/graphene/app/database_api.hpp#L1020), [Definition](https://gitlab.com/PBSA/peerplays/-/blob/master/libraries/app/database_api.cpp#L3033)) ### Desired: ```c++ vector<nft_metadata_object> nft_get_metadata_by_owner(const account_id_type owner) const; ``` Note: Although existing API call does not have lower-bound and limit parameters, these would probably be a good idea for both API functions. See #458+ for rationale. ### Importance: This will support several projects, including [TradeHands Explorer](https://gitlab.com/PBSA/dapps/trade-hands), wherein it will allow inspecting user accounts and seeing NFT collections issued by the account, and PeerShare (currently being worked on by @Hiltos1), in which NFT metadata objects associated with an account are used as a documents database for unique applications including onboarding new users.
christophersanborn commented 2022-09-30 20:14:40 +00:00 (Migrated from gitlab.com)

mentioned in issue PBSA/dapps/trade-hands#40

mentioned in issue PBSA/dapps/trade-hands#40
serkixenos commented 2022-10-11 00:27:45 +00:00 (Migrated from gitlab.com)

assigned to @timur.5

assigned to @timur.5
timur.5 commented 2022-12-20 19:05:04 +00:00 (Migrated from gitlab.com)
!194
timur.5 commented 2022-12-20 19:10:31 +00:00 (Migrated from gitlab.com)

Testcase:

  1. Use branch
    https://gitlab.com/PBSA/peerplays/-/tree/feature/nft_get_metadata_by_owner

  2. In cli_wallet:

gethelp nft_get_metadata_by_owner

and see that it's described.

  1. Run 'nft_tests' group of unit tests.
    I myself did it by
./chain_test --log_level=message --run_test=nft_tests
Testcase: 0) Use branch https://gitlab.com/PBSA/peerplays/-/tree/feature/nft_get_metadata_by_owner 1) In cli_wallet: ``` gethelp nft_get_metadata_by_owner ``` and see that it's described. 2) Run 'nft_tests' group of unit tests. I myself did it by ``` ./chain_test --log_level=message --run_test=nft_tests ```
timur.5 commented 2022-12-20 19:10:55 +00:00 (Migrated from gitlab.com)

assigned to @wsalloum

assigned to @wsalloum
timur.5 commented 2022-12-20 19:11:02 +00:00 (Migrated from gitlab.com)

assigned to @prandnum

assigned to @prandnum
wsalloum commented 2022-12-21 15:56:45 +00:00 (Migrated from gitlab.com)
unlocked >>> gethelp nft_get_metadata_by_owner
gethelp nft_get_metadata_by_owner

Returns all NFT metadata objects owned by owner.

Command:
    nft_get_metadata_by_owner owner limit lower_id

Parameters:
    owner (account_id_type): NFT owner account ID
    limit (integer): the maximum number of NFT metadata objects to return
	(max: 100)
    lower_id (nft_metadata_id_type): ID of the first NFT metadata object to
	include in the list.

Returns:
    Returns vector of NFT metadata objects, empty vector if none


``` unlocked >>> gethelp nft_get_metadata_by_owner gethelp nft_get_metadata_by_owner Returns all NFT metadata objects owned by owner. Command: nft_get_metadata_by_owner owner limit lower_id Parameters: owner (account_id_type): NFT owner account ID limit (integer): the maximum number of NFT metadata objects to return (max: 100) lower_id (nft_metadata_id_type): ID of the first NFT metadata object to include in the list. Returns: Returns vector of NFT metadata objects, empty vector if none ```
bobinson commented 2022-12-22 07:18:26 +00:00 (Migrated from gitlab.com)

mentioned in issue #498

mentioned in issue #498
wsalloum (Migrated from gitlab.com) closed this issue 2022-12-22 08:35:43 +00:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Peerplays_Blockchain/peerplays_migrated#459
No description provided.