From 6961d503f79b12015cc675b9dfc53d15d1964738 Mon Sep 17 00:00:00 2001 From: laruh Date: Mon, 16 Sep 2024 14:09:05 +0700 Subject: [PATCH] update gas limit fields names --- mm2src/coins/eth.rs | 36 +++++++++---------- .../eth/eth_swap_v2/eth_maker_swap_v2.rs | 4 +-- .../eth/eth_swap_v2/eth_taker_swap_v2.rs | 4 +-- mm2src/coins/eth/nft_swap_v2/mod.rs | 4 +-- .../tests/docker_tests/eth_docker_tests.rs | 14 ++++---- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/mm2src/coins/eth.rs b/mm2src/coins/eth.rs index 133cf76641..8107c90e52 100644 --- a/mm2src/coins/eth.rs +++ b/mm2src/coins/eth.rs @@ -255,8 +255,8 @@ pub mod gas_limit { pub mod gas_limit_v2 { /// Gas limits for maker operations in EtomicSwapMakerV2 contract pub mod maker { - pub const ETH_SEND_PAYMENT: u64 = 65_000; - pub const ERC20_SEND_PAYMENT: u64 = 115_000; + pub const ETH_PAYMENT: u64 = 65_000; + pub const ERC20_PAYMENT: u64 = 115_000; pub const ETH_TAKER_SPEND: u64 = 65_000; pub const ERC20_TAKER_SPEND: u64 = 65_000; pub const ETH_MAKER_REFUND_TIMELOCK: u64 = 65_000; @@ -267,8 +267,8 @@ pub mod gas_limit_v2 { /// Gas limits for taker operations in EtomicSwapTakerV2 contract pub mod taker { - pub const ETH_SEND_PAYMENT: u64 = 65_000; - pub const ERC20_SEND_PAYMENT: u64 = 115_000; + pub const ETH_PAYMENT: u64 = 65_000; + pub const ERC20_PAYMENT: u64 = 115_000; pub const ETH_MAKER_SPEND: u64 = 100_000; pub const ERC20_MAKER_SPEND: u64 = 115_000; pub const ETH_TAKER_REFUND_TIMELOCK: u64 = 65_000; @@ -279,8 +279,8 @@ pub mod gas_limit_v2 { } pub mod nft_maker { - pub const ERC721_SEND_PAYMENT: u64 = 130_000; - pub const ERC1155_SEND_PAYMENT: u64 = 130_000; + pub const ERC721_PAYMENT: u64 = 130_000; + pub const ERC1155_PAYMENT: u64 = 130_000; pub const ERC721_TAKER_SPEND: u64 = 100_000; pub const ERC1155_TAKER_SPEND: u64 = 100_000; pub const ERC721_MAKER_REFUND_TIMELOCK: u64 = 100_000; @@ -341,8 +341,8 @@ pub struct EthGasLimitV2 { #[derive(Deserialize)] #[serde(default)] pub struct MakerGasLimitV2 { - pub eth_send_payment: u64, - pub erc20_send_payment: u64, + pub eth_payment: u64, + pub erc20_payment: u64, pub eth_taker_spend: u64, pub erc20_taker_spend: u64, pub eth_maker_refund_timelock: u64, @@ -354,8 +354,8 @@ pub struct MakerGasLimitV2 { #[derive(Deserialize)] #[serde(default)] pub struct TakerGasLimitV2 { - pub eth_send_payment: u64, - pub erc20_send_payment: u64, + pub eth_payment: u64, + pub erc20_payment: u64, pub eth_maker_spend: u64, pub erc20_maker_spend: u64, pub eth_taker_refund_timelock: u64, @@ -368,8 +368,8 @@ pub struct TakerGasLimitV2 { #[derive(Deserialize)] #[serde(default)] pub struct NftMakerGasLimitV2 { - pub erc721_send_payment: u64, - pub erc1155_send_payment: u64, + pub erc721_payment: u64, + pub erc1155_payment: u64, pub erc721_taker_spend: u64, pub erc1155_taker_spend: u64, pub erc721_maker_refund_timelock: u64, @@ -381,8 +381,8 @@ pub struct NftMakerGasLimitV2 { impl Default for MakerGasLimitV2 { fn default() -> Self { MakerGasLimitV2 { - eth_send_payment: gas_limit_v2::maker::ETH_SEND_PAYMENT, - erc20_send_payment: gas_limit_v2::maker::ERC20_SEND_PAYMENT, + eth_payment: gas_limit_v2::maker::ETH_PAYMENT, + erc20_payment: gas_limit_v2::maker::ERC20_PAYMENT, eth_taker_spend: gas_limit_v2::maker::ETH_TAKER_SPEND, erc20_taker_spend: gas_limit_v2::maker::ERC20_TAKER_SPEND, eth_maker_refund_timelock: gas_limit_v2::maker::ETH_MAKER_REFUND_TIMELOCK, @@ -396,8 +396,8 @@ impl Default for MakerGasLimitV2 { impl Default for TakerGasLimitV2 { fn default() -> Self { TakerGasLimitV2 { - eth_send_payment: gas_limit_v2::taker::ETH_SEND_PAYMENT, - erc20_send_payment: gas_limit_v2::taker::ERC20_SEND_PAYMENT, + eth_payment: gas_limit_v2::taker::ETH_PAYMENT, + erc20_payment: gas_limit_v2::taker::ERC20_PAYMENT, eth_maker_spend: gas_limit_v2::taker::ETH_MAKER_SPEND, erc20_maker_spend: gas_limit_v2::taker::ERC20_MAKER_SPEND, eth_taker_refund_timelock: gas_limit_v2::taker::ETH_TAKER_REFUND_TIMELOCK, @@ -412,8 +412,8 @@ impl Default for TakerGasLimitV2 { impl Default for NftMakerGasLimitV2 { fn default() -> Self { NftMakerGasLimitV2 { - erc721_send_payment: gas_limit_v2::nft_maker::ERC721_SEND_PAYMENT, - erc1155_send_payment: gas_limit_v2::nft_maker::ERC1155_SEND_PAYMENT, + erc721_payment: gas_limit_v2::nft_maker::ERC721_PAYMENT, + erc1155_payment: gas_limit_v2::nft_maker::ERC1155_PAYMENT, erc721_taker_spend: gas_limit_v2::nft_maker::ERC721_TAKER_SPEND, erc1155_taker_spend: gas_limit_v2::nft_maker::ERC1155_TAKER_SPEND, erc721_maker_refund_timelock: gas_limit_v2::nft_maker::ERC721_MAKER_REFUND_TIMELOCK, diff --git a/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs b/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs index 1f010ddafa..0313d1d7fc 100644 --- a/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs +++ b/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs @@ -73,7 +73,7 @@ impl EthCoin { payment_amount, Action::Call(maker_swap_v2_contract), data, - U256::from(self.gas_limit_v2.maker.eth_send_payment), + U256::from(self.gas_limit_v2.maker.eth_payment), ) .compat() .await @@ -92,7 +92,7 @@ impl EthCoin { U256::from(ZERO_VALUE), Action::Call(maker_swap_v2_contract), data, - U256::from(self.gas_limit_v2.maker.erc20_send_payment), + U256::from(self.gas_limit_v2.maker.erc20_payment), ) .compat() .await diff --git a/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs b/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs index ffda7626dc..56eb5dcf4e 100644 --- a/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs +++ b/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs @@ -94,7 +94,7 @@ impl EthCoin { eth_total_payment, Action::Call(taker_swap_v2_contract), data, - U256::from(self.gas_limit_v2.taker.eth_send_payment), + U256::from(self.gas_limit_v2.taker.eth_payment), ) .compat() .await @@ -110,7 +110,7 @@ impl EthCoin { U256::from(ZERO_VALUE), Action::Call(taker_swap_v2_contract), data, - U256::from(self.gas_limit_v2.taker.erc20_send_payment), + U256::from(self.gas_limit_v2.taker.erc20_payment), ) .compat() .await diff --git a/mm2src/coins/eth/nft_swap_v2/mod.rs b/mm2src/coins/eth/nft_swap_v2/mod.rs index 8277cc8bf5..d6eea6cb50 100644 --- a/mm2src/coins/eth/nft_swap_v2/mod.rs +++ b/mm2src/coins/eth/nft_swap_v2/mod.rs @@ -38,8 +38,8 @@ impl EthCoin { let data = try_tx_s!(self.prepare_nft_maker_payment_v2_data(&args, htlc_data).await); let gas_limit = match args.nft_swap_info.contract_type { - ContractType::Erc1155 => self.gas_limit_v2.nft_maker.erc1155_send_payment, - ContractType::Erc721 => self.gas_limit_v2.nft_maker.erc721_send_payment, + ContractType::Erc1155 => self.gas_limit_v2.nft_maker.erc1155_payment, + ContractType::Erc721 => self.gas_limit_v2.nft_maker.erc721_payment, }; self.sign_and_send_transaction( ZERO_VALUE.into(), diff --git a/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs b/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs index f4cd7c31c3..a9e429379e 100644 --- a/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs +++ b/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs @@ -1446,6 +1446,7 @@ fn eth_coin_v2_activation_with_random_privkey( coin } +#[ignore] #[test] fn send_and_refund_taker_funding_by_secret_eth() { // sepolia test @@ -1506,6 +1507,7 @@ fn send_and_refund_taker_funding_by_secret_eth() { wait_for_confirmations(&taker_coin, &funding_tx_refund, 100); } +#[ignore] #[test] fn send_and_refund_taker_funding_by_secret_erc20() { thread::sleep(Duration::from_secs(30)); @@ -1567,6 +1569,7 @@ fn send_and_refund_taker_funding_by_secret_erc20() { wait_for_confirmations(&taker_coin, &funding_tx_refund, 200); } +#[ignore] #[test] fn send_and_refund_taker_funding_exceed_pre_approve_timelock_eth() { // sepolia test @@ -1631,6 +1634,7 @@ fn send_and_refund_taker_funding_exceed_pre_approve_timelock_eth() { wait_for_confirmations(&taker_coin, &funding_tx_refund, 100); } +#[ignore] #[test] fn taker_send_approve_and_spend_eth() { // sepolia test @@ -1740,6 +1744,7 @@ fn taker_send_approve_and_spend_eth() { block_on(taker_coin.wait_for_taker_payment_spend(&spend_tx, 0u64, payment_time_lock)).unwrap(); } +#[ignore] #[test] fn taker_send_approve_and_spend_erc20() { // sepolia test @@ -1849,6 +1854,7 @@ fn taker_send_approve_and_spend_erc20() { block_on(taker_coin.wait_for_taker_payment_spend(&spend_tx, 0u64, payment_time_lock)).unwrap(); } +#[ignore] #[test] fn send_and_refund_taker_funding_exceed_payment_timelock_eth() { // sepolia test @@ -1932,6 +1938,7 @@ fn send_and_refund_taker_funding_exceed_payment_timelock_eth() { wait_for_confirmations(&taker_coin, &funding_tx_refund, 100); } +#[ignore] #[test] fn send_and_refund_taker_funding_exceed_payment_timelock_erc20() { // sepolia test @@ -2017,6 +2024,7 @@ fn send_and_refund_taker_funding_exceed_payment_timelock_erc20() { wait_for_confirmations(&taker_coin, &funding_tx_refund, 100); } +#[ignore] #[test] fn send_and_refund_taker_funding_exceed_pre_approve_timelock_erc20() { // sepolia test @@ -2083,7 +2091,6 @@ fn send_and_refund_taker_funding_exceed_pre_approve_timelock_erc20() { wait_for_confirmations(&taker_coin, &funding_tx_refund, 150); } -#[ignore] #[test] fn send_maker_payment_and_refund_timelock_eth() { thread::sleep(Duration::from_secs(150)); @@ -2136,7 +2143,6 @@ fn send_maker_payment_and_refund_timelock_eth() { wait_for_confirmations(&maker_coin, &payment_tx_refund, 100); } -#[ignore] #[test] fn send_maker_payment_and_refund_timelock_erc20() { thread::sleep(Duration::from_secs(120)); @@ -2190,7 +2196,6 @@ fn send_maker_payment_and_refund_timelock_erc20() { wait_for_confirmations(&maker_coin, &payment_tx_refund, 100); } -#[ignore] #[test] fn send_maker_payment_and_refund_secret_eth() { thread::sleep(Duration::from_secs(90)); @@ -2240,7 +2245,6 @@ fn send_maker_payment_and_refund_secret_eth() { wait_for_confirmations(&maker_coin, &payment_tx_refund, 100); } -#[ignore] #[test] fn send_maker_payment_and_refund_secret_erc20() { thread::sleep(Duration::from_secs(60)); @@ -2291,7 +2295,6 @@ fn send_maker_payment_and_refund_secret_erc20() { wait_for_confirmations(&maker_coin, &payment_tx_refund, 100); } -#[ignore] #[test] fn send_and_spend_maker_payment_eth() { let taker_coin = get_or_create_sepolia_coin(&MM_CTX1, SEPOLIA_TAKER_PRIV, ETH, ð_sepolia_conf(), false); @@ -2353,7 +2356,6 @@ fn send_and_spend_maker_payment_eth() { block_on(maker_coin.wait_for_maker_payment_spend(&spend_tx, 0u64, payment_time_lock)).unwrap(); } -#[ignore] #[test] fn send_and_spend_maker_payment_erc20() { thread::sleep(Duration::from_secs(30));