From 87932329be51812b274c0fc41a84d5bb1fb335df Mon Sep 17 00:00:00 2001 From: Septen Date: Thu, 10 Jun 2021 01:00:34 +0300 Subject: [PATCH 1/2] EthConnector: don't burn NEP-141 on deposit. --- src/connector.rs | 2 +- tests/test_connector.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/connector.rs b/src/connector.rs index 6db5a125a..6f38ed83c 100644 --- a/src/connector.rs +++ b/src/connector.rs @@ -388,6 +388,7 @@ impl EthConnectorContract { } /// Burn NEAR tokens + #[allow(dead_code)] fn burn_near(&mut self, owner_id: AccountId, amount: Balance) { #[cfg(feature = "log")] sdk::log(&format!("Burn NEAR {} tokens for: {}", amount, owner_id)); @@ -593,7 +594,6 @@ impl EthConnectorContract { // Special case when predecessor_account_id is current_account_id if current_account_id == predecessor_account_id { let fee = message_data.fee.as_u128(); - self.burn_near(current_account_id, args.amount); // Mint fee to relayer let relayer = engine.get_relayer(&message_data.relayer.as_bytes()); if fee > 0 && relayer.is_some() { diff --git a/tests/test_connector.rs b/tests/test_connector.rs index 9dcb8c255..f880585f9 100644 --- a/tests/test_connector.rs +++ b/tests/test_connector.rs @@ -316,13 +316,13 @@ fn test_eth_deposit_balance_total_supply() { assert_eq!(balance, DEPOSITED_EVM_FEE); let balance = total_supply(&master_account, CONTRACT_ACC); - assert_eq!(balance, DEPOSITED_EVM_AMOUNT); + assert_eq!(balance, DEPOSITED_EVM_AMOUNT * 2); let balance = total_supply_eth(&master_account, CONTRACT_ACC); assert_eq!(balance, DEPOSITED_EVM_AMOUNT); let balance = total_supply_near(&master_account, CONTRACT_ACC); - assert_eq!(balance, 0); + assert_eq!(balance, DEPOSITED_EVM_AMOUNT); } #[test] @@ -457,7 +457,7 @@ fn test_ft_transfer_call_eth() { assert_eq!(balance, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = get_near_balance(&master_account, CONTRACT_ACC, CONTRACT_ACC); - assert_eq!(balance, DEPOSITED_FEE - transfer_amount); + assert_eq!(balance, DEPOSITED_FEE); let balance = get_eth_balance( &master_account, @@ -474,10 +474,10 @@ fn test_ft_transfer_call_eth() { assert_eq!(balance, fee); let balance = total_supply(&master_account, CONTRACT_ACC); - assert_eq!(balance, DEPOSITED_AMOUNT); + assert_eq!(balance, DEPOSITED_AMOUNT + transfer_amount); let balance = total_supply_near(&master_account, CONTRACT_ACC); - assert_eq!(balance, DEPOSITED_AMOUNT - transfer_amount); + assert_eq!(balance, DEPOSITED_AMOUNT); let balance = total_supply_eth(&master_account, CONTRACT_ACC); assert_eq!(balance, transfer_amount); @@ -558,7 +558,7 @@ fn test_ft_transfer_call_without_relayer() { assert_eq!(balance, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = get_near_balance(&master_account, CONTRACT_ACC, CONTRACT_ACC); - assert_eq!(balance, DEPOSITED_FEE - transfer_amount); + assert_eq!(balance, DEPOSITED_FEE); let balance = get_eth_balance( &master_account, @@ -575,10 +575,10 @@ fn test_ft_transfer_call_without_relayer() { assert_eq!(balance, 0); let balance = total_supply(&master_account, CONTRACT_ACC); - assert_eq!(balance, DEPOSITED_AMOUNT); + assert_eq!(balance, DEPOSITED_AMOUNT + transfer_amount); let balance = total_supply_near(&master_account, CONTRACT_ACC); - assert_eq!(balance, DEPOSITED_AMOUNT - transfer_amount); + assert_eq!(balance, DEPOSITED_AMOUNT); let balance = total_supply_eth(&master_account, CONTRACT_ACC); assert_eq!(balance, transfer_amount); @@ -1042,13 +1042,13 @@ fn test_deposit_evm_with_zero_fee() { assert_eq!(balance, 0); let balance = total_supply(&master_account, CONTRACT_ACC); - assert_eq!(balance, deposited_amount); + assert_eq!(balance, deposited_amount * 2); let balance = total_supply_eth(&master_account, CONTRACT_ACC); assert_eq!(balance, deposited_amount); let balance = total_supply_near(&master_account, CONTRACT_ACC); - assert_eq!(balance, 0); + assert_eq!(balance, deposited_amount); } #[test] From fee22ca6733746175c459b8da60e50df2332fb22 Mon Sep 17 00:00:00 2001 From: Septen Date: Thu, 10 Jun 2021 18:19:13 +0300 Subject: [PATCH 2/2] Remove method --- src/connector.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/connector.rs b/src/connector.rs index 6f38ed83c..409201290 100644 --- a/src/connector.rs +++ b/src/connector.rs @@ -387,14 +387,6 @@ impl EthConnectorContract { self.ft.internal_deposit_eth(owner_id, amount); } - /// Burn NEAR tokens - #[allow(dead_code)] - fn burn_near(&mut self, owner_id: AccountId, amount: Balance) { - #[cfg(feature = "log")] - sdk::log(&format!("Burn NEAR {} tokens for: {}", amount, owner_id)); - self.ft.internal_withdraw(&owner_id, amount); - } - /// Burn ETH tokens fn burn_eth(&mut self, address: EthAddress, amount: Balance) { #[cfg(feature = "log")]