Merge pull request #4235 from nymtech/simulate-with-memo
Propagating memo field when simulating token transfer
This commit is contained in:
@@ -376,7 +376,11 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn simulate<I, M>(&self, messages: I) -> Result<SimulateResponse, NyxdError>
|
||||
pub async fn simulate<I, M>(
|
||||
&self,
|
||||
messages: I,
|
||||
memo: impl Into<String> + Send + 'static,
|
||||
) -> Result<SimulateResponse, NyxdError>
|
||||
where
|
||||
I: IntoIterator<Item = M> + Send,
|
||||
M: Msg,
|
||||
@@ -391,7 +395,7 @@ where
|
||||
.map_err(|_| {
|
||||
NyxdError::SerializationError("custom simulate messages".to_owned())
|
||||
})?,
|
||||
"simulating execution of transactions",
|
||||
memo,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use std::str::FromStr;
|
||||
pub async fn simulate_send(
|
||||
address: &str,
|
||||
amount: DecCoin,
|
||||
memo: String,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<FeeDetails, BackendError> {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const SendModal = ({ onClose, hasStorybookStyles }: { onClose: () => void
|
||||
const [gasError, setGasError] = useState<string>();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [userFees, setUserFees] = useState<DecCoin>();
|
||||
const [memo, setMemo] = useState<string>();
|
||||
const [memo, setMemo] = useState<string>('');
|
||||
const [txDetails, setTxDetails] = useState<TTransactionDetails>();
|
||||
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]);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -69,8 +69,8 @@ export const simulateVestingUpdateGatewayConfig = async (update: GatewayConfigUp
|
||||
export const simulateWithdrawVestedCoins = async (args: any) =>
|
||||
invokeWrapper<FeeDetails>('simulate_withdraw_vested_coins', args);
|
||||
|
||||
export const simulateSend = async ({ address, amount }: { address: string; amount: DecCoin }) =>
|
||||
invokeWrapper<FeeDetails>('simulate_send', { address, amount });
|
||||
export const simulateSend = async ({ address, amount, memo }: { address: string; amount: DecCoin; memo: string }) =>
|
||||
invokeWrapper<FeeDetails>('simulate_send', { address, amount, memo });
|
||||
|
||||
export const getCustomFees = async ({ feesAmount }: { feesAmount: DecCoin }) =>
|
||||
invokeWrapper<FeeDetails>('get_custom_fees', { feesAmount });
|
||||
|
||||
Reference in New Issue
Block a user