defuse/contract/tokens/nep141/
storage_deposit.rs1use defuse_core::intents::tokens::StorageDeposit;
2use defuse_near_utils::promise_result_checked_void;
3use near_contract_standards::storage_management::ext_storage_management;
4use near_sdk::{Gas, Promise, near, require};
5
6use crate::contract::{Contract, ContractExt, tokens::STORAGE_DEPOSIT_GAS};
7
8#[near]
9impl Contract {
10 pub(crate) const DO_STORAGE_DEPOSIT_GAS: Gas =
11 Gas::from_tgas(5).saturating_add(STORAGE_DEPOSIT_GAS);
12
13 #[private]
14 pub fn do_storage_deposit(storage_deposit: StorageDeposit) -> Promise {
15 require!(
16 promise_result_checked_void(0).is_ok(),
17 "near_withdraw failed",
18 );
19
20 ext_storage_management::ext(storage_deposit.contract_id)
21 .with_attached_deposit(storage_deposit.amount)
22 .with_static_gas(STORAGE_DEPOSIT_GAS)
23 .with_unused_gas_weight(0)
25 .storage_deposit(Some(storage_deposit.deposit_for_account_id), None)
26 }
27}