defuse/tokens/
nep171.rs

1use near_contract_standards::non_fungible_token::{TokenId, core::NonFungibleTokenReceiver};
2use near_plugins::AccessControllable;
3use near_sdk::{AccountId, PromiseOrValue, ext_contract};
4
5#[ext_contract(ext_nft_withdraw)]
6pub trait NonFungibleTokenWithdrawer:
7    NonFungibleTokenReceiver + NonFungibleTokenWithdrawResolver
8{
9    /// Returns number of tokens were successfully withdrawn
10    ///
11    /// Optionally can specify `storage_deposit` for `receiver_id` on `token`.
12    /// The amount will be subtracted from user's NEP-141 `wNEAR` balance.
13    ///
14    /// NOTE: MUST attach 1 yⓃ for security purposes.
15    fn nft_withdraw(
16        &mut self,
17        token: AccountId,
18        receiver_id: AccountId,
19        token_id: TokenId,
20        memo: Option<String>,
21        msg: Option<String>,
22    ) -> PromiseOrValue<bool>;
23}
24
25#[ext_contract(ext_nft_withdraw_resolver)]
26pub trait NonFungibleTokenWithdrawResolver {
27    fn nft_resolve_withdraw(
28        &mut self,
29        token: AccountId,
30        sender_id: AccountId,
31        token_id: TokenId,
32        is_call: bool,
33    ) -> bool;
34}
35
36#[ext_contract(ext_nft_force_withdraw)]
37pub trait NonFungibleTokenForceWithdrawer: NonFungibleTokenWithdrawer + AccessControllable {
38    fn nft_force_withdraw(
39        &mut self,
40        owner_id: AccountId,
41        token: AccountId,
42        receiver_id: AccountId,
43        token_id: TokenId,
44        memo: Option<String>,
45        msg: Option<String>,
46    ) -> PromiseOrValue<bool>;
47}