diff --git a/nym-wallet/src-tauri/src/main.rs b/nym-wallet/src-tauri/src/main.rs index acaaa6d995..6824afbc15 100644 --- a/nym-wallet/src-tauri/src/main.rs +++ b/nym-wallet/src-tauri/src/main.rs @@ -115,7 +115,7 @@ fn main() { utils::owns_mixnode, utils::owns_nym_node, utils::get_env, - utils::try_convert_pubkey_to_mix_id, + utils::try_convert_pubkey_to_node_id, utils::default_mixnode_cost_params, nym_api::status::compute_mixnode_reward_estimation, nym_api::status::gateway_core_node_status, @@ -178,8 +178,8 @@ fn main() { simulate::mixnet::simulate_update_mixnode_config, simulate::mixnet::simulate_update_mixnode_cost_params, simulate::mixnet::simulate_update_gateway_config, - simulate::mixnet::simulate_delegate_to_mixnode, - simulate::mixnet::simulate_undelegate_from_mixnode, + simulate::mixnet::simulate_delegate_to_node, + simulate::mixnet::simulate_undelegate_from_node, simulate::vesting::simulate_vesting_delegate_to_mixnode, simulate::vesting::simulate_vesting_undelegate_from_mixnode, simulate::vesting::simulate_vesting_bond_gateway, diff --git a/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs b/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs index afcb0a512f..733f8cb5f5 100644 --- a/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs +++ b/nym-wallet/src-tauri/src/operations/simulate/mixnet.rs @@ -184,7 +184,7 @@ pub async fn simulate_update_gateway_config( } #[tauri::command] -pub async fn simulate_delegate_to_mixnode( +pub async fn simulate_delegate_to_node( node_id: NodeId, amount: DecCoin, state: tauri::State<'_, WalletState>, @@ -193,7 +193,7 @@ pub async fn simulate_delegate_to_mixnode( } #[tauri::command] -pub async fn simulate_undelegate_from_mixnode( +pub async fn simulate_undelegate_from_node( node_id: NodeId, state: tauri::State<'_, WalletState>, ) -> Result { diff --git a/nym-wallet/src-tauri/src/utils.rs b/nym-wallet/src-tauri/src/utils.rs index 9a90861059..1c18d0206a 100644 --- a/nym-wallet/src-tauri/src/utils.rs +++ b/nym-wallet/src-tauri/src/utils.rs @@ -55,16 +55,34 @@ pub async fn owns_nym_node(state: tauri::State<'_, WalletState>) -> Result, mix_identity: IdentityKey, ) -> Result, BackendError> { - let res = nyxd_client!(state) - .get_mixnode_details_by_identity(mix_identity) - .await?; - Ok(res + let guard = state.read().await; + let client = guard.current_client()?; + + // first try native nym-node + if let Some(node) = client + .nyxd + .get_nymnode_details_by_identity(mix_identity.clone()) + .await? + .details + { + return Ok(Some(node.node_id())); + } + + // fallback to legacy mixnode + if let Some(node) = client + .nyxd + .get_mixnode_details_by_identity(mix_identity.clone()) + .await? .mixnode_details - .map(|mixnode_details| mixnode_details.mix_id())) + { + return Ok(Some(node.mix_id())); + } + + Ok(None) } #[tauri::command] diff --git a/nym-wallet/src/components/Delegation/DelegateModal.tsx b/nym-wallet/src/components/Delegation/DelegateModal.tsx index 211b4ae2b9..88b91627c7 100644 --- a/nym-wallet/src/components/Delegation/DelegateModal.tsx +++ b/nym-wallet/src/components/Delegation/DelegateModal.tsx @@ -5,7 +5,7 @@ import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField' import { CurrencyDenom, FeeDetails, DecCoin, decimalToFloatApproximation } from '@nymproject/types'; import { Console } from 'src/utils/console'; import { useGetFee } from 'src/hooks/useGetFee'; -import { simulateDelegateToMixnode, simulateVestingDelegateToMixnode, tryConvertIdentityToMixId } from 'src/requests'; +import { simulateDelegateToNode, simulateVestingDelegateToMixnode, tryConvertIdentityToNodeId } from 'src/requests'; import { debounce } from 'lodash'; import { AppContext } from 'src/context'; import { SimpleModal } from '../Modals/SimpleModal'; @@ -152,7 +152,7 @@ export const DelegateModal: FCWithChildren<{ } if (tokenPool === 'balance') { - getFee(simulateDelegateToMixnode, { mixId: id, amount: value }); + getFee(simulateDelegateToNode, { nodeId: id, amount: value }); } if (tokenPool === 'locked') { @@ -187,16 +187,16 @@ export const DelegateModal: FCWithChildren<{ } let res; try { - res = await tryConvertIdentityToMixId(idKey); + res = await tryConvertIdentityToNodeId(idKey); } catch (e) { - Console.warn(`failed to resolve mix_id for "${idKey}": ${e}`); + Console.warn(`failed to resolve node_id for "${idKey}": ${e}`); return; } if (res) { setMixId(res); setMixIdError(undefined); } else { - setMixIdError('Mixnode with this identity does not seem to be currently bonded'); + setMixIdError('Node with this identity does not seem to be currently bonded'); } }, 500), [], diff --git a/nym-wallet/src/components/Delegation/UndelegateModal.tsx b/nym-wallet/src/components/Delegation/UndelegateModal.tsx index 65820eb2bb..1038dbe341 100644 --- a/nym-wallet/src/components/Delegation/UndelegateModal.tsx +++ b/nym-wallet/src/components/Delegation/UndelegateModal.tsx @@ -2,7 +2,7 @@ import React, { useContext, useEffect } from 'react'; import { Box, SxProps } from '@mui/material'; import { FeeDetails } from '@nymproject/types'; import { useGetFee } from 'src/hooks/useGetFee'; -import { simulateUndelegateFromMixnode, simulateVestingUndelegateFromMixnode } from 'src/requests'; +import { simulateUndelegateFromNode, simulateVestingUndelegateFromMixnode } from 'src/requests'; import { AppContext } from 'src/context'; import { ModalFee } from '../Modals/ModalFee'; import { ModalListItem } from '../Modals/ModalListItem'; @@ -27,7 +27,7 @@ export const UndelegateModal: FCWithChildren<{ useEffect(() => { if (usesVestingContractTokens) getFee(simulateVestingUndelegateFromMixnode, { mixId }); else { - getFee(simulateUndelegateFromMixnode, mixId); + getFee(simulateUndelegateFromNode, mixId); } }, []); diff --git a/nym-wallet/src/requests/simulate.ts b/nym-wallet/src/requests/simulate.ts index 8f7373bb07..58e704d979 100644 --- a/nym-wallet/src/requests/simulate.ts +++ b/nym-wallet/src/requests/simulate.ts @@ -28,14 +28,14 @@ export const simulateUpdateMixnodeConfig = async (update: MixNodeConfigUpdate) = export const simulateUpdateGatewayConfig = async (update: GatewayConfigUpdate) => invokeWrapper('simulate_update_gateway_config', { update }); -export const simulateDelegateToMixnode = async (args: { mixId: number; amount: DecCoin }) => - invokeWrapper('simulate_delegate_to_mixnode', args); +export const simulateDelegateToNode = async (args: { nodeId: number; amount: DecCoin }) => + invokeWrapper('simulate_delegate_to_node', args); -export const simulateUndelegateFromMixnode = async (mixId: number) => - invokeWrapper('simulate_undelegate_from_mixnode', { mixId }); +export const simulateUndelegateFromNode = async (nodeId: number) => + invokeWrapper('simulate_undelegate_from_node', { nodeId }); -export const simulateClaimDelegatorReward = async (mixId: number) => - invokeWrapper('simulate_claim_delegator_reward', { mixId }); +export const simulateClaimDelegatorReward = async (nodeId: number) => + invokeWrapper('simulate_claim_delegator_reward', { nodeId }); export const simulateVestingClaimDelegatorReward = async (mixId: number) => invokeWrapper('simulate_vesting_claim_delegator_reward', { mixId }); diff --git a/nym-wallet/src/requests/utils.ts b/nym-wallet/src/requests/utils.ts index f16c2d71b1..82ee989aa6 100644 --- a/nym-wallet/src/requests/utils.ts +++ b/nym-wallet/src/requests/utils.ts @@ -4,8 +4,8 @@ import { invokeWrapper } from './wrapper'; export const getEnv = async () => invokeWrapper('get_env'); -export const tryConvertIdentityToMixId = async (mixIdentity: string) => - invokeWrapper('try_convert_pubkey_to_mix_id', { mixIdentity }); +export const tryConvertIdentityToNodeId = async (mixIdentity: string) => + invokeWrapper('try_convert_pubkey_to_node_id', { mixIdentity }); export const getDefaultNodeCostParams = async (profitMarginPercent: string) => invokeWrapper('default_mixnode_cost_params', { profitMarginPercent });