From 87fb4daeda69b6a04eeadced48da08eff0f751af Mon Sep 17 00:00:00 2001 From: benedetta davico <46782255+benedettadavico@users.noreply.github.com> Date: Fri, 18 Nov 2022 13:38:16 +0100 Subject: [PATCH] Release/v1.1.1 nym wallet (#1775) * fix undelegating with vesting tokens * update version number * update tauri conf version * fix(wallet): explorer links * refactor(explorer): rename mixnodeidentitykey to mixid * fix(wallet): broken explorer links Co-authored-by: fmtabbara Co-authored-by: pierre --- explorer/src/context/mixnode.tsx | 24 ++++----- explorer/src/pages/MixnodeDetail/index.tsx | 2 +- nym-wallet/Cargo.lock | 2 +- nym-wallet/package.json | 2 +- nym-wallet/src-tauri/Cargo.toml | 2 +- nym-wallet/src-tauri/tauri.conf.json | 2 +- .../src/components/Bonding/BondedGateway.tsx | 2 +- .../src/components/Bonding/BondedMixnode.tsx | 3 +- .../components/Delegation/DelegationItem.tsx | 2 +- .../Delegation/PendingDelegationItem.tsx | 2 +- nym-wallet/src/context/bonding.tsx | 2 + nym-wallet/src/context/delegations.tsx | 25 ++++++---- nym-wallet/src/context/mocks/bonding.tsx | 1 + nym-wallet/src/context/mocks/delegations.tsx | 49 ++++++++++++------- nym-wallet/src/pages/delegation/index.tsx | 24 ++++++--- 15 files changed, 90 insertions(+), 54 deletions(-) diff --git a/explorer/src/context/mixnode.tsx b/explorer/src/context/mixnode.tsx index a17366645c..a710095811 100644 --- a/explorer/src/context/mixnode.tsx +++ b/explorer/src/context/mixnode.tsx @@ -36,16 +36,16 @@ export const useMixnodeContext = (): React.ContextType => React.useContext(MixnodeContext); interface MixnodeContextProviderProps { - mixNodeIdentityKey: string; + mixId: string; } /** * Provides a state context for a mixnode by identity - * @param mixNodeIdentityKey The identity key of the mixnode + * @param mixId The mixID of the mixnode */ -export const MixnodeContextProvider: React.FC = ({ mixNodeIdentityKey, children }) => { +export const MixnodeContextProvider: React.FC = ({ mixId, children }) => { const [mixNode, fetchMixnodeById, clearMixnodeById] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchMixnodeByID, 'Failed to fetch mixnode by id', ); @@ -53,44 +53,44 @@ export const MixnodeContextProvider: React.FC = ({ const [mixNodeRow, setMixnodeRow] = React.useState(); const [delegations, fetchDelegations, clearDelegations] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchDelegationsById, 'Failed to fetch delegations for mixnode', ); const [uniqDelegations, fetchUniqDelegations, clearUniqDelegations] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchUniqDelegationsById, 'Failed to fetch delegations for mixnode', ); const [status, fetchStatus, clearStatus] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchStatusById, 'Failed to fetch mixnode status', ); const [stats, fetchStats, clearStats] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchStatsById, 'Failed to fetch mixnode stats', ); const [description, fetchDescription, clearDescription] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchMixnodeDescriptionById, 'Failed to fetch mixnode description', ); const [economicDynamicsStats, fetchEconomicDynamicsStats, clearEconomicDynamicsStats] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchMixnodeEconomicDynamicsStatsById, 'Failed to fetch mixnode dynamics stats by id', ); const [uptimeStory, fetchUptimeHistory, clearUptimeHistory] = useApiState( - mixNodeIdentityKey, + mixId, Api.fetchUptimeStoryById, 'Failed to fetch mixnode uptime history', ); @@ -123,7 +123,7 @@ export const MixnodeContextProvider: React.FC = ({ fetchUptimeHistory(), ]); }); - }, [mixNodeIdentityKey]); + }, [mixId]); const state = React.useMemo( () => ({ diff --git a/explorer/src/pages/MixnodeDetail/index.tsx b/explorer/src/pages/MixnodeDetail/index.tsx index 266c13be3a..1c38f69a53 100644 --- a/explorer/src/pages/MixnodeDetail/index.tsx +++ b/explorer/src/pages/MixnodeDetail/index.tsx @@ -223,7 +223,7 @@ export const PageMixnodeDetail: React.FC = () => { } return ( - + ); diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index a0086ebb09..1bc9e48663 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -2877,7 +2877,7 @@ dependencies = [ [[package]] name = "nym_wallet" -version = "1.1.0" +version = "1.1.1" dependencies = [ "aes-gcm", "argon2 0.3.4", diff --git a/nym-wallet/package.json b/nym-wallet/package.json index 973fc67ded..a9a55d2d0b 100644 --- a/nym-wallet/package.json +++ b/nym-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/nym-wallet-app", - "version": "1.0.0", + "version": "1.1.1", "main": "index.js", "license": "MIT", "scripts": { diff --git a/nym-wallet/src-tauri/Cargo.toml b/nym-wallet/src-tauri/Cargo.toml index 21dfa19030..835383188e 100644 --- a/nym-wallet/src-tauri/Cargo.toml +++ b/nym-wallet/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym_wallet" -version = "1.1.0" +version = "1.1.1" description = "Nym Native Wallet" authors = ["Nym Technologies SA"] license = "" diff --git a/nym-wallet/src-tauri/tauri.conf.json b/nym-wallet/src-tauri/tauri.conf.json index 11af64d0a0..b7b616b2e8 100644 --- a/nym-wallet/src-tauri/tauri.conf.json +++ b/nym-wallet/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "package": { "productName": "nym-wallet", - "version": "1.1.0" + "version": "1.1.1" }, "build": { "distDir": "../dist", diff --git a/nym-wallet/src/components/Bonding/BondedGateway.tsx b/nym-wallet/src/components/Bonding/BondedGateway.tsx index 8b2776f8a9..51523ef6ca 100644 --- a/nym-wallet/src/components/Bonding/BondedGateway.tsx +++ b/nym-wallet/src/components/Bonding/BondedGateway.tsx @@ -91,7 +91,7 @@ export const BondedGateway = ({ {network && ( Check more stats of your gateway on the{' '} - + explorer diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 00b3ea7196..5d63555ddb 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -66,6 +66,7 @@ export const BondedMixnode = ({ const navigate = useNavigate(); const { name, + mixId, stake, bond, stakeSaturation, @@ -165,7 +166,7 @@ export const BondedMixnode = ({ {network && ( Check more stats of your node on the{' '} - + explorer diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index 2906ed2abd..d800f9f487 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -45,7 +45,7 @@ export const DelegationItem = ({ ) : ( Promise; - undelegate: ( - mix_id: number, - usesVestingContractTokens: boolean, - fee?: FeeDetails, - ) => Promise; + undelegate: (mix_id: number, fee?: Fee) => Promise; + undelegateVesting: (mix_id: number) => Promise; }; export type TDelegationTransaction = { @@ -51,7 +54,10 @@ export const DelegationContext = createContext({ addDelegation: async () => { throw new Error('Not implemented'); }, - undelegate: async () => { + undelegate: () => { + throw new Error('Not implemented'); + }, + undelegateVesting: () => { throw new Error('Not implemented'); }, }); @@ -135,7 +141,8 @@ export const DelegationContextProvider: FC<{ totalRewards, refresh, addDelegation, - undelegate: undelegateAllFromMixnode, + undelegate: undelegateFromMixnode, + undelegateVesting: vestingUndelegateFromMixnode, }), [isLoading, error, delegations, pendingDelegations, totalDelegations], ); diff --git a/nym-wallet/src/context/mocks/bonding.tsx b/nym-wallet/src/context/mocks/bonding.tsx index 5fde300d75..8d97deb090 100644 --- a/nym-wallet/src/context/mocks/bonding.tsx +++ b/nym-wallet/src/context/mocks/bonding.tsx @@ -8,6 +8,7 @@ const SLEEP_MS = 1000; const bondedMixnodeMock: TBondedMixnode = { name: 'Monster node', + mixId: 1, identityKey: '7mjM2fYbtN6kxMwp1TrmQ4VwPks3URR5pBgWPWhzT98F', stake: { denom: 'nym', amount: '1234' }, bond: { denom: 'nym', amount: '1234' }, diff --git a/nym-wallet/src/context/mocks/delegations.tsx b/nym-wallet/src/context/mocks/delegations.tsx index 3674dc1494..bc216fd7bf 100644 --- a/nym-wallet/src/context/mocks/delegations.tsx +++ b/nym-wallet/src/context/mocks/delegations.tsx @@ -1,5 +1,12 @@ import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { DelegationWithEverything, DecCoin, TransactionExecuteResult, FeeDetails } from '@nymproject/types'; +import { + DelegationWithEverything, + DecCoin, + TransactionExecuteResult, + FeeDetails, + Fee, + CurrencyDenom, +} from '@nymproject/types'; import { DelegationContext, TDelegationTransaction } from '../delegations'; import { mockSleep } from './utils'; @@ -154,11 +161,7 @@ export const MockDelegationContextProvider: FC<{}> = ({ children }) => { }; }; - const undelegate = async ( - mix_id: number, - _usesVestingContractTokens: boolean, - _fee?: FeeDetails, - ): Promise => { + const undelegate = async (mix_id: number, _fee?: Fee): Promise => { await mockSleep(SLEEP_MS); mockDelegations = mockDelegations.map((d) => { if (d.mix_id === mix_id) { @@ -175,18 +178,29 @@ export const MockDelegationContextProvider: FC<{}> = ({ children }) => { triggerStateUpdate(); }, 3000); - return [ - { - logs_json: '', - data_json: '', - transaction_hash: '', - gas_info: { - gas_wanted: { gas_units: BigInt(1) }, - gas_used: { gas_units: BigInt(1) }, - }, - fee: { amount: '1', denom: 'nym' }, + return { + logs_json: '', + data_json: '', + transaction_hash: '', + gas_info: { + gas_wanted: { gas_units: BigInt(1) }, + gas_used: { gas_units: BigInt(1) }, }, - ]; + fee: { amount: '1', denom: 'nym' as CurrencyDenom }, + }; + }; + + const undelegateVesting = async (mix_id: number, _fee?: FeeDetails) => { + return { + logs_json: '', + data_json: '', + transaction_hash: '', + gas_info: { + gas_wanted: { gas_units: BigInt(1) }, + gas_used: { gas_units: BigInt(1) }, + }, + fee: { amount: '1', denom: 'nym' as CurrencyDenom }, + }; }; const resetState = () => { @@ -226,6 +240,7 @@ export const MockDelegationContextProvider: FC<{}> = ({ children }) => { addDelegation, updateDelegation, undelegate, + undelegateVesting, }), [isLoading, error, delegations, totalDelegations, trigger], ); diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 62418f0463..a70300388f 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -52,6 +52,7 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { isLoading, addDelegation, undelegate, + undelegateVesting, refresh: refreshDelegations, } = useDelegationContext(); @@ -206,7 +207,8 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { const handleUndelegate = async ( mixId: number, - identityKey: string, + // identityKey is no longer used + _: string, usesVestingContractTokens: boolean, fee?: FeeDetails, ) => { @@ -216,19 +218,27 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { }); setShowUndelegateModal(false); setCurrentDelegationListActionItem(undefined); - + let tx; try { - const txs = await undelegate(mixId, usesVestingContractTokens, fee); + if (usesVestingContractTokens) { + tx = await undelegateVesting(mixId); + } else { + tx = await undelegate(mixId, fee?.fee); + } + + // const txs = await undelegate(mixId, usesVestingContractTokens, fee); const balances = await getAllBalances(); setConfirmationModalProps({ status: 'success', action: 'undelegate', ...balances, - transactions: txs.map((tx) => ({ - url: `${urls(network).blockExplorer}/transaction/${tx.transaction_hash}`, - hash: tx.transaction_hash, - })), + transactions: [ + { + url: `${urls(network).blockExplorer}/transaction/${tx.transaction_hash}`, + hash: tx.transaction_hash, + }, + ], }); } catch (e) { Console.error('Failed to undelegate', e);