1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
pub use *;
use crateTokenId;
use AccountId;
use Promise;
/// Trait used when it's desired to have a non-fungible token that has a
/// traditional escrow or approval system. This allows Alice to allow Bob
/// to take only the token with the unique identifier "19" but not others.
/// It should be noted that in the [core non-fungible token standard] there
/// is a method to do "transfer and call" which may be preferred over using
/// an approval management standard in certain use cases.
///
/// [approval management standard]: https://nomicon.io/Standards/NonFungibleToken/ApprovalManagement.html
/// [core non-fungible token standard]: https://nomicon.io/Standards/NonFungibleToken/Core.html
///
/// # Examples
///
/// ```
/// use std::collections::HashMap;
/// use unc_sdk::{PanicOnDefault, AccountId, PromiseOrValue, unc, Promise};
/// use unc_contract_standards::non_fungible_token::{TokenId, NonFungibleToken, NonFungibleTokenApproval};
///
/// #[unc(contract_state)]
/// #[derive(PanicOnDefault)]
/// pub struct Contract {
/// tokens: NonFungibleToken,
///}
///
/// #[unc]
/// impl NonFungibleTokenApproval for Contract {
/// #[payable]
/// fn nft_approve(&mut self, token_id: TokenId, account_id: AccountId, msg: Option<String>) -> Option<Promise> {
/// self.tokens.nft_approve(token_id, account_id, msg)
/// }
///
/// #[payable]
/// fn nft_revoke(&mut self, token_id: TokenId, account_id: AccountId) {
/// self.tokens.nft_revoke(token_id, account_id);
/// }
///
/// #[payable]
/// fn nft_revoke_all(&mut self, token_id: TokenId) {
/// self.tokens.nft_revoke_all(token_id);
///
/// }
///
/// fn nft_is_approved(&self, token_id: TokenId, approved_account_id: AccountId, approval_id: Option<u64>) -> bool {
/// self.tokens.nft_is_approved(token_id, approved_account_id, approval_id)
/// }
/// }
/// ```
///