Replies: 2 comments 5 replies
-
Rust-translated: /// Ref:
/// https://github.com/near/NEPs/blob/master/specs/Standards/NonFungibleToken/Enumeration.md
pub trait NonFungibleContractEnumeration {
/// Returns the total supply of non-fungible tokens as a String representing an
/// unsigned 128-bit integer to avoid JSON number limit of 2^53.
fn nft_total_supply(&self) -> U64;
/// Get a list of all tokens
///
/// Arguments:
/// * `from_index`: a String representing an unsigned 128-bit integer,
/// representing the starting index of tokens to return
/// * `limit`: the maximum number of tokens to return
///
/// Returns an array of Token objects, as described in Core standard
fn nft_tokens(
&self,
from_index: Option<U64>, // default: "0"
limit: Option<U64>, // default: = self.nft_total_supply()
) -> Vec<Token>;
/// Get number of tokens owned by a given account
///
/// Arguments:
/// * `account_id`: a valid NEAR account
///
/// Returns the number of non-fungible tokens owned by given `account_id` as
/// a String representing the value as an unsigned 128-bit integer to avoid JSON
/// number limit of 2^53.
fn nft_supply_for_owner(&self, account_id: String) -> U64;
// temp
fn nft_tokens_for_owner_set(&self, account_id: String) -> Vec<TokenId>;
/// Get list of all tokens owned by a given account
///
/// Arguments:
/// * `account_id`: a valid NEAR account
/// * `from_index`: a String representing an unsigned 128-bit integer,
/// representing the starting index of tokens to return
/// * `limit`: the maximum number of tokens to return
///
/// Returns a paginated list of all tokens owned by this account
fn nft_tokens_for_owner(
&self,
account_id: String,
from_index: Option<U64>, // default: 0
limit: Option<U64>, // default: nft_supply_for_owner(account_id)
) -> Vec<TokenId>;
} Some of the outstanding comments I have on the spec:
pub tokens_per_owner: LookupMap<AccountId, UnorderedSet<TokenId>>,
//or
pub tokens_per_owner: LookupMap<AccountId, Vector<TokenId>>, If the former is used, it's not possible to index into the UnorderedSet in a reasonable way. Therefore, the spec is implicitly forcing the latter implementation. This should be explicit, or if this is unintended, the API for |
Beta Was this translation helpful? Give feedback.
-
Colleagues, could you please help me to understand what method |
Beta Was this translation helpful? Give feedback.
-
This discussion split from the more general discussion in #171. While that was intended to tackle the entire upcoming NFT standard, this discussion aims to only clarify the Enumeration aspect. Below seems to be the current best-guess at what a v1.0.0 standard might look like, based on current discussion in #171 & the NEAR team's best guesses:
Summary
Standard interfaces for counting & fetching tokens, for an entire NFT contract or for a given owner.
Motivation
Apps such as marketplaces and wallets need a way to show all tokens owned by a given account and to show statistics about all tokens for a given contract. This extension provides a standard way to do so.
While some NFT contracts may forego this extension to save storage costs, this requires apps to have custom off-chain indexing layers. This makes it harder for apps to integrate with such NFTs. Apps which integrate only with NFTs that use the Enumeration extension do not even need a server-side component at all, since they can retrieve all information they need directly from the blockchain.
Prior art:
Interface
The contract must implement the following view methods:
Beta Was this translation helpful? Give feedback.
All reactions