diff --git a/bridge-token-factory/src/lib.rs b/bridge-token-factory/src/lib.rs index 24670cf5..96c4c512 100644 --- a/bridge-token-factory/src/lib.rs +++ b/bridge-token-factory/src/lib.rs @@ -400,18 +400,8 @@ impl BridgeTokenFactory { let required_deposit = self.record_proof(&proof); - assert!( - env::attached_deposit() - >= required_deposit + self.bridge_token_storage_deposit_required - ); - let Recipient { target, message } = parse_recipient(new_owner_id); - env::log_str(&format!( - "Finish deposit. Target:{} Message:{:?}", - target, message - )); - let token = EthAddressHex(token); let amount_to_transfer: u128; let fee_amount = self.calculate_deposit_fee_amount( @@ -421,10 +411,21 @@ impl BridgeTokenFactory { ); amount_to_transfer = amount - fee_amount; + let multiplier = if fee_amount > 0 { 1 } else { 2 }; + require!( + env::attached_deposit() + >= required_deposit + self.bridge_token_storage_deposit_required * multiplier + ); + + env::log_str(&format!( + "Finish deposit. Target:{} Message:{:?}", + target, message + )); + match message { Some(message) => ext_bridge_token::ext(self.get_bridge_token_account_id(&token)) .with_static_gas(MINT_GAS) - .with_attached_deposit(env::attached_deposit() - required_deposit) + .with_attached_deposit(self.bridge_token_storage_deposit_required) .mint(env::current_account_id(), amount.into()) .then( ext_bridge_token::ext(self.get_bridge_token_account_id(&token)) @@ -436,12 +437,13 @@ impl BridgeTokenFactory { let mint_target_promise = ext_bridge_token::ext(self.get_bridge_token_account_id(&token)) .with_static_gas(MINT_GAS) - .with_attached_deposit(env::attached_deposit() - required_deposit) + .with_attached_deposit(self.bridge_token_storage_deposit_required) .mint(target, amount_to_transfer.into()); if fee_amount > 0 { mint_target_promise.then( ext_bridge_token::ext(self.get_bridge_token_account_id(&token)) + .with_attached_deposit(self.bridge_token_storage_deposit_required) .with_static_gas(MINT_GAS) .mint(env::current_account_id(), fee_amount.into()), ) diff --git a/bridge-token/src/lib.rs b/bridge-token/src/lib.rs index 0b5c6efd..c07ecab6 100644 --- a/bridge-token/src/lib.rs +++ b/bridge-token/src/lib.rs @@ -59,12 +59,9 @@ impl BridgeToken { "Only the factory account can init this contract" ); - let mut token = FungibleToken::new(b"t".to_vec()); - token.internal_register_account(&env::predecessor_account_id()); - Self { controller: env::predecessor_account_id(), - token, + token: FungibleToken::new(b"t".to_vec()), name: String::default(), symbol: String::default(), reference: String::default(), diff --git a/res/bridge_token.wasm b/res/bridge_token.wasm index d88b47a1..0accdfdd 100755 Binary files a/res/bridge_token.wasm and b/res/bridge_token.wasm differ diff --git a/res/bridge_token_factory.wasm b/res/bridge_token_factory.wasm index da474df5..b3ef231a 100755 Binary files a/res/bridge_token_factory.wasm and b/res/bridge_token_factory.wasm differ