defuse_nep245/enumeration.rs
1use crate::Token;
2use near_sdk::{AccountId, ext_contract, json_types::U128};
3
4/// A trait representing the [multi-token enumeration standard](https://nomicon.io/Standards/Tokens/MultiToken/Enumeration#interface).
5#[ext_contract(ext_mt_enumeration)]
6pub trait MultiTokenEnumeration {
7 /// Get a list of all tokens
8 ///
9 /// Arguments:
10 /// * `from_index`: a string representing an unsigned 128-bit integer,
11 /// representing the starting index of tokens to return
12 /// * `limit`: the maximum number of tokens to return
13 ///
14 /// Returns an array of `Token` objects, as described in the Core standard,
15 /// and an empty array if there are no tokens
16 fn mt_tokens(&self, from_index: Option<U128>, limit: Option<u32>) -> Vec<Token>;
17
18 /// Get list of all tokens owned by a given account
19 ///
20 /// Arguments:
21 /// * `account_id`: a valid NEAR account
22 /// * `from_index`: a string representing an unsigned 128-bit integer,
23 /// representing the starting index of tokens to return
24 /// * `limit`: the maximum number of tokens to return
25 ///
26 /// Returns a paginated list of all tokens owned by this account, and an empty array if there are no tokens
27 fn mt_tokens_for_owner(
28 &self,
29 account_id: AccountId,
30 from_index: Option<U128>,
31 limit: Option<u32>,
32 ) -> Vec<Token>;
33}