From 23892fec8cbc3943bf6572f109b6151bae2de443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Fri, 8 Dec 2023 11:19:11 +0000 Subject: [PATCH 1/3] Propagating memo field when simulating token transfer --- common/client-libs/validator-client/src/nyxd/mod.rs | 8 ++++++-- nym-wallet/src-tauri/src/operations/simulate/admin.rs | 2 +- nym-wallet/src-tauri/src/operations/simulate/cosmos.rs | 3 ++- nym-wallet/src-tauri/src/operations/simulate/mixnet.rs | 2 +- nym-wallet/src-tauri/src/operations/simulate/vesting.rs | 2 +- nym-wallet/src/components/Send/SendModal.tsx | 2 +- nym-wallet/src/requests/simulate.ts | 4 ++-- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/common/client-libs/validator-client/src/nyxd/mod.rs b/common/client-libs/validator-client/src/nyxd/mod.rs index c9c27370e2..f28df6567f 100644 --- a/common/client-libs/validator-client/src/nyxd/mod.rs +++ b/common/client-libs/validator-client/src/nyxd/mod.rs @@ -376,7 +376,11 @@ where }) } - pub async fn simulate(&self, messages: I) -> Result + pub async fn simulate( + &self, + messages: I, + memo: impl Into + Send + 'static, + ) -> Result where I: IntoIterator + Send, M: Msg, @@ -391,7 +395,7 @@ where .map_err(|_| { NyxdError::SerializationError("custom simulate messages".to_owned()) })?, - "simulating execution of transactions", + memo, ) .await } diff --git a/nym-wallet/src-tauri/src/operations/simulate/admin.rs b/nym-wallet/src-tauri/src/operations/simulate/admin.rs index 1884c7472e..ddb24bb63b 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/admin.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/admin.rs @@ -32,6 +32,6 @@ pub async fn simulate_update_contract_settings( vec![], )?; - let result = client.nyxd.simulate(vec![msg]).await?; + let result = client.nyxd.simulate(vec![msg], "").await?; guard.create_detailed_fee(result) } diff --git a/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs b/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs index 6d538175c4..447e624ae9 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/cosmos.rs @@ -12,6 +12,7 @@ use std::str::FromStr; pub async fn simulate_send( address: &str, amount: DecCoin, + memo: String, state: tauri::State<'_, WalletState>, ) -> Result { let guard = state.read().await; @@ -30,7 +31,7 @@ pub async fn simulate_send( amount, }; - let result = client.nyxd.simulate(vec![msg]).await?; + let result = client.nyxd.simulate(vec![msg], memo).await?; guard.create_detailed_fee(result) } diff --git a/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs b/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs index 11d360ef71..c64fcc53af 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs @@ -38,7 +38,7 @@ async fn simulate_mixnet_operation( .nyxd .wrap_contract_execute_message(mixnet_contract, &msg, funds)?; - let result = client.nyxd.simulate(vec![msg]).await?; + let result = client.nyxd.simulate(vec![msg], "").await?; guard.create_detailed_fee(result) } diff --git a/nym-wallet/src-tauri/src/operations/simulate/vesting.rs b/nym-wallet/src-tauri/src/operations/simulate/vesting.rs index b225aa9ff3..9a33e2a3ed 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/vesting.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/vesting.rs @@ -39,7 +39,7 @@ async fn simulate_vesting_operation( .nyxd .wrap_contract_execute_message(vesting_contract, &msg, funds)?; - let result = client.nyxd.simulate(vec![msg]).await?; + let result = client.nyxd.simulate(vec![msg], "").await?; guard.create_detailed_fee(result) } diff --git a/nym-wallet/src/components/Send/SendModal.tsx b/nym-wallet/src/components/Send/SendModal.tsx index b6d391d0ef..40c97eee3f 100644 --- a/nym-wallet/src/components/Send/SendModal.tsx +++ b/nym-wallet/src/components/Send/SendModal.tsx @@ -52,7 +52,7 @@ export const SendModal = ({ onClose, hasStorybookStyles }: { onClose: () => void if (userFees) { await setFeeManually(userFees); } else { - await getFee(simulateSend, { address: toAddress, amount }); + await getFee(simulateSend, { address: toAddress, amount, memo }); } setModal('send details'); } catch (e) { diff --git a/nym-wallet/src/requests/simulate.ts b/nym-wallet/src/requests/simulate.ts index 158df8e5be..94bbcb9f5e 100644 --- a/nym-wallet/src/requests/simulate.ts +++ b/nym-wallet/src/requests/simulate.ts @@ -69,8 +69,8 @@ export const simulateVestingUpdateGatewayConfig = async (update: GatewayConfigUp export const simulateWithdrawVestedCoins = async (args: any) => invokeWrapper('simulate_withdraw_vested_coins', args); -export const simulateSend = async ({ address, amount }: { address: string; amount: DecCoin }) => - invokeWrapper('simulate_send', { address, amount }); +export const simulateSend = async ({ address, amount }: { address: string; amount: DecCoin; memo: string }) => + invokeWrapper('simulate_send', { address, amount, memo }); export const getCustomFees = async ({ feesAmount }: { feesAmount: DecCoin }) => invokeWrapper('get_custom_fees', { feesAmount }); From 2d57ed49e83858b940aa6f6b076a6e0cd4bc112e Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Fri, 8 Dec 2023 14:08:59 +0100 Subject: [PATCH 2/3] amend a few warnings --- nym-wallet/src-tauri/src/config/mod.rs | 2 +- nym-wallet/src/components/Send/SendModal.tsx | 4 ++-- nym-wallet/src/requests/simulate.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nym-wallet/src-tauri/src/config/mod.rs b/nym-wallet/src-tauri/src/config/mod.rs index bdb369ade6..371a634398 100644 --- a/nym-wallet/src-tauri/src/config/mod.rs +++ b/nym-wallet/src-tauri/src/config/mod.rs @@ -25,7 +25,7 @@ pub const REMOTE_SOURCE_OF_NYXD_URLS: &str = const CURRENT_GLOBAL_CONFIG_VERSION: u32 = 1; const CURRENT_NETWORK_CONFIG_VERSION: u32 = 1; -pub(crate) const CUSTOM_SIMULATED_GAS_MULTIPLIER: f32 = 1.4; +pub(crate) const CUSTOM_SIMULATED_GAS_MULTIPLIER: f32 = 1.5; #[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct Config { diff --git a/nym-wallet/src/components/Send/SendModal.tsx b/nym-wallet/src/components/Send/SendModal.tsx index 40c97eee3f..b8c1ca5eeb 100644 --- a/nym-wallet/src/components/Send/SendModal.tsx +++ b/nym-wallet/src/components/Send/SendModal.tsx @@ -21,7 +21,7 @@ export const SendModal = ({ onClose, hasStorybookStyles }: { onClose: () => void const [gasError, setGasError] = useState(); const [isLoading, setIsLoading] = useState(false); const [userFees, setUserFees] = useState(); - const [memo, setMemo] = useState(); + const [memo, setMemo] = useState(''); const [txDetails, setTxDetails] = useState(); const [showMoreOptions, setShowMoreOptions] = useState(false); @@ -37,7 +37,7 @@ export const SendModal = ({ onClose, hasStorybookStyles }: { onClose: () => void useEffect(() => { if (!showMoreOptions) { setUserFees(undefined); - setMemo(undefined); + setMemo(''); } }, [showMoreOptions]); diff --git a/nym-wallet/src/requests/simulate.ts b/nym-wallet/src/requests/simulate.ts index 94bbcb9f5e..d15d41d5c6 100644 --- a/nym-wallet/src/requests/simulate.ts +++ b/nym-wallet/src/requests/simulate.ts @@ -69,7 +69,7 @@ export const simulateVestingUpdateGatewayConfig = async (update: GatewayConfigUp export const simulateWithdrawVestedCoins = async (args: any) => invokeWrapper('simulate_withdraw_vested_coins', args); -export const simulateSend = async ({ address, amount }: { address: string; amount: DecCoin; memo: string }) => + export const simulateSend = async ({ address, amount, memo }: { address: string; amount: DecCoin; memo: string }) => invokeWrapper('simulate_send', { address, amount, memo }); export const getCustomFees = async ({ feesAmount }: { feesAmount: DecCoin }) => From 866309cedf58db03f1887f113aef55b2f8aa41c9 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Fri, 8 Dec 2023 14:19:58 +0100 Subject: [PATCH 3/3] fix linting --- nym-wallet/src/requests/simulate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-wallet/src/requests/simulate.ts b/nym-wallet/src/requests/simulate.ts index d15d41d5c6..a8f603ed72 100644 --- a/nym-wallet/src/requests/simulate.ts +++ b/nym-wallet/src/requests/simulate.ts @@ -69,7 +69,7 @@ export const simulateVestingUpdateGatewayConfig = async (update: GatewayConfigUp export const simulateWithdrawVestedCoins = async (args: any) => invokeWrapper('simulate_withdraw_vested_coins', args); - export const simulateSend = async ({ address, amount, memo }: { address: string; amount: DecCoin; memo: string }) => +export const simulateSend = async ({ address, amount, memo }: { address: string; amount: DecCoin; memo: string }) => invokeWrapper('simulate_send', { address, amount, memo }); export const getCustomFees = async ({ feesAmount }: { feesAmount: DecCoin }) =>