diff --git a/nym-wallet/src-tauri/src/operations/simulate/admin.rs b/nym-wallet/src-tauri/src/operations/simulate/admin.rs index e3da08f3cc..ac698f86c3 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/admin.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/admin.rs @@ -28,5 +28,5 @@ pub async fn simulate_update_contract_settings( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } diff --git a/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs b/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs index 4b90e96ac2..413df4e887 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs @@ -33,5 +33,5 @@ pub async fn simulate_send( }; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } diff --git a/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs b/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs index 3ee7d18f75..903819e235 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs @@ -36,7 +36,7 @@ pub async fn simulate_bond_gateway( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -56,7 +56,7 @@ pub async fn simulate_unbond_gateway( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -83,7 +83,7 @@ pub async fn simulate_bond_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -103,7 +103,7 @@ pub async fn simulate_unbond_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -126,7 +126,7 @@ pub async fn simulate_update_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -151,7 +151,7 @@ pub async fn simulate_delegate_to_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -174,7 +174,7 @@ pub async fn simulate_undelegate_from_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -185,7 +185,7 @@ pub async fn simulate_claim_operator_reward( .simulate_claim_operator_reward(None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -196,7 +196,7 @@ pub async fn simulate_compound_operator_reward( .simulate_compound_operator_reward(None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -208,7 +208,7 @@ pub async fn simulate_claim_delegator_reward( .simulate_claim_delegator_reward(mix_identity, None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -220,5 +220,5 @@ pub async fn simulate_compound_delegator_reward( .simulate_compound_delegator_reward(mix_identity, None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } diff --git a/nym-wallet/src-tauri/src/operations/simulate/mod.rs b/nym-wallet/src-tauri/src/operations/simulate/mod.rs index f9fb86abcf..4cbe3c0664 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/mod.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/mod.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 use nym_types::currency::MajorCurrencyAmount; -use nym_types::error::TypesError; use nym_types::fees::FeeDetails; use validator_client::nymd::cosmwasm_client::types::GasInfo; use validator_client::nymd::{tx, CosmosCoin, Fee, GasPrice}; @@ -30,15 +29,12 @@ impl SimulateResult { } } - pub fn detailed_fee(&self) -> Result { - let amount: Option = match self.to_fee_amount() { - Some(a) => Some(a.into()), - None => None, - }; - Ok(FeeDetails { + pub fn detailed_fee(&self) -> FeeDetails { + let amount = self.to_fee_amount().map(MajorCurrencyAmount::from); + FeeDetails { amount, fee: self.to_fee(), - }) + } } fn to_fee_amount(&self) -> Option { diff --git a/nym-wallet/src-tauri/src/operations/simulate/vesting.rs b/nym-wallet/src-tauri/src/operations/simulate/vesting.rs index 2fe52bcba5..b0f3f649d2 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/vesting.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/vesting.rs @@ -37,7 +37,7 @@ pub async fn simulate_vesting_bond_gateway( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -57,7 +57,7 @@ pub async fn simulate_vesting_unbond_gateway( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -85,7 +85,7 @@ pub async fn simulate_vesting_bond_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -105,7 +105,7 @@ pub async fn simulate_vesting_unbond_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -128,7 +128,7 @@ pub async fn simulate_vesting_update_mixnode( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -150,7 +150,7 @@ pub async fn simulate_withdraw_vested_coins( )?; let result = client.nymd.simulate(vec![msg]).await?; - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -161,7 +161,7 @@ pub async fn simulate_vesting_claim_operator_reward( .simulate_vesting_claim_operator_reward(None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -172,7 +172,7 @@ pub async fn simulate_vesting_compound_operator_reward( .simulate_vesting_compound_operator_reward(None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -184,7 +184,7 @@ pub async fn simulate_vesting_claim_delegator_reward( .simulate_vesting_claim_delegator_reward(mix_identity, None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) } #[tauri::command] @@ -196,5 +196,5 @@ pub async fn simulate_vesting_compound_delegator_reward( .simulate_vesting_compound_delegator_reward(mix_identity, None) .await?; let gas_price = nymd_client!(state).gas_price().clone(); - Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()?) + Ok(SimulateResult::new(result.gas_info, gas_price).detailed_fee()) }