Skip to content

Commit

Permalink
StorageManagement: retrun0 instead None
Browse files Browse the repository at this point in the history
  • Loading branch information
karim-en committed Oct 17, 2024
1 parent 441f004 commit 1d36f1f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion eth-connector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use near_contract_standards::fungible_token::metadata::{
use near_contract_standards::fungible_token::receiver::ext_ft_receiver;
use near_contract_standards::fungible_token::resolver::{ext_ft_resolver, FungibleTokenResolver};
use near_contract_standards::fungible_token::FungibleToken;
use near_contract_standards::storage_management::{
StorageBalance, StorageBalanceBounds, StorageManagement,
};
use near_plugins::{
access_control, access_control_any, pause, AccessControlRole, AccessControllable, Pausable,
Upgradable,
Expand Down Expand Up @@ -579,7 +582,46 @@ impl FungibleTokenResolver for EthConnectorContract {
}
}

near_contract_standards::impl_fungible_token_storage!(EthConnectorContract, ft);
#[near_bindgen]
impl StorageManagement for EthConnectorContract {
#[payable]
fn storage_deposit(
&mut self,
account_id: Option<AccountId>,
registration_only: Option<bool>,
) -> StorageBalance {
self.ft.storage_deposit(account_id, registration_only)
}

#[payable]
fn storage_withdraw(&mut self, amount: Option<U128>) -> StorageBalance {
self.ft.storage_withdraw(amount)
}

#[payable]
fn storage_unregister(&mut self, force: Option<bool>) -> bool {
if let Some(_) = self.ft.internal_storage_unregister(force) {
true
} else {
false
}
}

fn storage_balance_bounds(&self) -> StorageBalanceBounds {
self.ft.storage_balance_bounds()
}

fn storage_balance_of(&self, account_id: AccountId) -> Option<StorageBalance> {
if self.ft.account_storage_usage == 0 {
Some(StorageBalance {
total: 0.into(),
available: 0.into(),
})
} else {
self.ft.storage_balance_of(account_id)
}
}
}

#[near_bindgen]
impl FungibleTokenMetadataProvider for EthConnectorContract {
Expand Down
Binary file modified res/aurora-eth-connector-mainnet-migration.wasm
Binary file not shown.
Binary file modified res/aurora-eth-connector-mainnet.wasm
Binary file not shown.

0 comments on commit 1d36f1f

Please sign in to comment.