defuse/contract/tokens/nep141/
native.rs

1use defuse_core::intents::tokens::NativeWithdraw;
2use near_sdk::{Gas, Promise, env, near, require};
3
4use crate::contract::{Contract, ContractExt};
5
6#[near]
7impl Contract {
8    pub(crate) const DO_NATIVE_WITHDRAW_GAS: Gas = Gas::from_tgas(12);
9
10    #[private]
11    pub fn do_native_withdraw(withdraw: NativeWithdraw) -> Promise {
12        require!(
13            matches!(env::promise_result_checked(0, 0), Ok(data) if data.is_empty()),
14            "near_withdraw failed",
15        );
16
17        Promise::new(withdraw.receiver_id).transfer(withdraw.amount)
18    }
19}