diff --git a/explorer/src/components/Filters/Filters.tsx b/explorer/src/components/Filters/Filters.tsx index b4e7752bcd..4bf165d52e 100644 --- a/explorer/src/components/Filters/Filters.tsx +++ b/explorer/src/components/Filters/Filters.tsx @@ -142,11 +142,10 @@ export const Filters = () => { diff --git a/explorer/src/components/MixNodes/Economics/Rows.ts b/explorer/src/components/MixNodes/Economics/Rows.ts index e4c674f551..ace2cec61a 100644 --- a/explorer/src/components/MixNodes/Economics/Rows.ts +++ b/explorer/src/components/MixNodes/Economics/Rows.ts @@ -5,10 +5,16 @@ import { EconomicsInfoRowWithIndex } from './types'; const selectionChance = (economicDynamicsStats: ApiState | undefined) => { const inclusionProbability = economicDynamicsStats?.data?.active_set_inclusion_probability; + // TODO: when v2 will be deployed, remove cases: VeryHigh, Moderate and VeryLow switch (inclusionProbability) { + case 'VeryLow': + return 'Very Low'; + case 'VeryHigh': + return 'Very High'; case 'High': case 'Good': case 'Low': + case 'Moderate': return inclusionProbability; default: return '-'; diff --git a/explorer/src/components/MixNodes/Economics/Table.tsx b/explorer/src/components/MixNodes/Economics/Table.tsx index 356a4c32b2..5977847436 100644 --- a/explorer/src/components/MixNodes/Economics/Table.tsx +++ b/explorer/src/components/MixNodes/Economics/Table.tsx @@ -19,12 +19,16 @@ const textColour = (value: EconomicsRowsType, field: string, theme: Theme) => { return theme.palette.warning.main; } if (field === 'selectionChance') { + // TODO: when v2 will be deployed, remove cases: VeryHigh, Moderate and VeryLow switch (fieldValue) { case 'High': + case 'VeryHigh': return theme.palette.nym.networkExplorer.selectionChance.overModerate; case 'Good': + case 'Moderate': return theme.palette.nym.networkExplorer.selectionChance.moderate; case 'Low': + case 'VeryLow': return theme.palette.nym.networkExplorer.selectionChance.underModerate; default: return theme.palette.nym.wallet.fee; diff --git a/explorer/src/components/MixNodes/StatusDropdown.tsx b/explorer/src/components/MixNodes/StatusDropdown.tsx index 1dba2c2f95..18263edf6e 100644 --- a/explorer/src/components/MixNodes/StatusDropdown.tsx +++ b/explorer/src/components/MixNodes/StatusDropdown.tsx @@ -46,7 +46,7 @@ export const MixNodeStatusDropdown: React.FC = ({ st } }} sx={{ - width: isMobile ? 'auto' : 200, + width: isMobile ? '50%' : 200, ...sx, }} > diff --git a/explorer/src/components/TableToolbar.tsx b/explorer/src/components/TableToolbar.tsx index c6a64dd6c5..7452b4707a 100644 --- a/explorer/src/components/TableToolbar.tsx +++ b/explorer/src/components/TableToolbar.tsx @@ -30,39 +30,40 @@ export const TableToolbar: React.FC = ({ width: '100%', marginBottom: 2, display: 'flex', - flexDirection: isMobile ? 'column-reverse' : 'row', + flexDirection: isMobile ? 'column' : 'row', justifyContent: 'space-between', }} > - - {childrenBefore} - - - + + + {childrenBefore} + + = ({ placeholder="search" onChange={(event) => onChangeSearch(event.target.value)} /> + + {withFilters && } {childrenAfter} diff --git a/explorer/src/typeDefs/explorer-api.ts b/explorer/src/typeDefs/explorer-api.ts index 241d656edf..dd342ac149 100644 --- a/explorer/src/typeDefs/explorer-api.ts +++ b/explorer/src/typeDefs/explorer-api.ts @@ -215,7 +215,8 @@ export type UptimeStoryResponse = { export type MixNodeEconomicDynamicsStatsResponse = { stake_saturation: number; - active_set_inclusion_probability: 'High' | 'Good' | 'Low'; + // TODO: when v2 will be deployed, remove cases: VeryHigh, Moderate and VeryLow + active_set_inclusion_probability: 'High' | 'Good' | 'Low' | 'VeryLow' | 'Moderate' | 'VeryHigh'; reserve_set_inclusion_probability: 'High' | 'Good' | 'Low'; estimated_total_node_reward: number; estimated_operator_reward: number; diff --git a/nym-wallet/src/components/Accounts/MultiAccountHowTo.tsx b/nym-wallet/src/components/Accounts/MultiAccountHowTo.tsx index fa7ae1659c..a9da0f1ef3 100644 --- a/nym-wallet/src/components/Accounts/MultiAccountHowTo.tsx +++ b/nym-wallet/src/components/Accounts/MultiAccountHowTo.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Alert, Box, Paper, Dialog, DialogContent, DialogTitle, IconButton, Stack, Typography } from '@mui/material'; import { Close } from '@mui/icons-material'; +import { useTheme } from '@mui/material/styles'; const passwordCreationSteps = [ 'Log out', @@ -10,34 +11,46 @@ const passwordCreationSteps = [ 'Now you can create multiple accounts', ]; -export const MultiAccountHowTo = ({ show, handleClose }: { show: boolean; handleClose: () => void }) => ( - - - - Multi accounts - - - - - theme.palette.nym.text.muted }}> - How to set up multiple accounts - - - - - (t.palette.mode === 'dark' ? { bgcolor: (theme) => theme.palette.background.paper } : {})} - > - In order to create multiple accounts your wallet needs a password. - Follow steps below to create password. - - How to create a password for your account - {passwordCreationSteps.map((step, index) => ( - {`${index + 1}. ${step}`} - ))} - - - -); +export const MultiAccountHowTo = ({ show, handleClose }: { show: boolean; handleClose: () => void }) => { + const theme = useTheme(); + return ( + + + + + Multi accounts + + + + + theme.palette.nym.text.muted }}> + How to set up multiple accounts + + + + + (t.palette.mode === 'dark' ? { bgcolor: (theme) => theme.palette.background.paper } : {})} + > + In order to create multiple accounts your wallet needs a password. + Follow steps below to create password. + + How to create a password for your account + {passwordCreationSteps.map((step, index) => ( + {`${index + 1}. ${step}`} + ))} + + + + + ); +}; diff --git a/nym-wallet/src/components/Accounts/modals/AccountsModal.tsx b/nym-wallet/src/components/Accounts/modals/AccountsModal.tsx index efe5a5428c..91525b8a54 100644 --- a/nym-wallet/src/components/Accounts/modals/AccountsModal.tsx +++ b/nym-wallet/src/components/Accounts/modals/AccountsModal.tsx @@ -12,6 +12,7 @@ import { Divider, } from '@mui/material'; import { Add, ArrowDownwardSharp, Close } from '@mui/icons-material'; +import { useTheme } from '@mui/material/styles'; import { AccountsContext } from 'src/context'; import { AccountItem } from '../AccountItem'; import { ConfirmPasswordModal } from './ConfirmPasswordModal'; @@ -21,6 +22,8 @@ export const AccountsModal = () => { useContext(AccountsContext); const [accountToSwitchTo, setAccountToSwitchTo] = useState(); + const theme = useTheme(); + const handleClose = () => { setDialogToDisplay(undefined); setError(undefined); @@ -47,48 +50,51 @@ export const AccountsModal = () => { open={dialogToDisplay === 'Accounts'} onClose={handleClose} fullWidth - PaperComponent={Paper} - PaperProps={{ elevation: 0 }} + PaperProps={{ + style: { border: `1px solid ${theme.palette.nym.nymWallet.modal.border}` }, + }} > - - - Accounts - - - - - - Switch between accounts - - - - {accounts?.map(({ id, address }) => ( - { - if (selectedAccount?.id !== id) { - setAccountToSwitchTo(id); - } - }} - /> - ))} - - - - - - + + + + Accounts + + + + + + Switch between accounts + + + + {accounts?.map(({ id, address }) => ( + { + if (selectedAccount?.id !== id) { + setAccountToSwitchTo(id); + } + }} + /> + ))} + + + + + + + ); }; diff --git a/nym-wallet/src/components/Accounts/modals/ConfirmPasswordModal.tsx b/nym-wallet/src/components/Accounts/modals/ConfirmPasswordModal.tsx index 29694fcda8..07baa9b8d8 100644 --- a/nym-wallet/src/components/Accounts/modals/ConfirmPasswordModal.tsx +++ b/nym-wallet/src/components/Accounts/modals/ConfirmPasswordModal.tsx @@ -1,6 +1,6 @@ import React, { useContext } from 'react'; -import { Box, Paper, Dialog, DialogTitle, IconButton, Typography } from '@mui/material'; -import { ArrowBack } from '@mui/icons-material'; +import { Paper, Dialog, DialogTitle, Typography } from '@mui/material'; +import { useTheme } from '@mui/material/styles'; import { ConfirmPassword } from 'src/components/ConfirmPassword'; import { AccountsContext } from 'src/context'; @@ -14,28 +14,32 @@ export const ConfirmPasswordModal = ({ onConfirm: (password: string) => Promise; }) => { const { isLoading, error } = useContext(AccountsContext); + const theme = useTheme(); return ( - - Switch account - - Confirm password - - - + + + Switch account + + Confirm password + + + + ); }; diff --git a/nym-wallet/src/components/Accounts/modals/EditAccountModal.tsx b/nym-wallet/src/components/Accounts/modals/EditAccountModal.tsx index 91a0a65e9d..8ddbb207b3 100644 --- a/nym-wallet/src/components/Accounts/modals/EditAccountModal.tsx +++ b/nym-wallet/src/components/Accounts/modals/EditAccountModal.tsx @@ -12,6 +12,7 @@ import { Typography, } from '@mui/material'; import { Close } from '@mui/icons-material'; +import { useTheme } from '@mui/material/styles'; import { AccountsContext } from 'src/context'; export const EditAccountModal = () => { @@ -19,6 +20,8 @@ export const EditAccountModal = () => { const { accountToEdit, dialogToDisplay, setDialogToDisplay, handleEditAccount } = useContext(AccountsContext); + const theme = useTheme(); + useEffect(() => { setAccountName(accountToEdit ? accountToEdit?.id : ''); }, [accountToEdit]); @@ -28,48 +31,51 @@ export const EditAccountModal = () => { open={dialogToDisplay === 'Edit'} onClose={() => setDialogToDisplay('Accounts')} fullWidth - PaperComponent={Paper} - PaperProps={{ elevation: 0 }} + PaperProps={{ + style: { border: `1px solid ${theme.palette.nym.nymWallet.modal.border}` }, + }} > - - - Edit account name - setDialogToDisplay('Accounts')}> - - - - - New wallet address - - - - - + + + Edit account name + setDialogToDisplay('Accounts')}> + + + + + New wallet address + + + + + setAccountName(e.target.value)} + autoFocus + /> + + + + - + disableElevation + variant="contained" + size="large" + onClick={() => { + if (accountToEdit) { + handleEditAccount({ ...accountToEdit, id: accountName }); + setDialogToDisplay('Accounts'); + } + }} + disabled={!accountName?.length} + > + Edit + + + ); }; diff --git a/nym-wallet/src/components/Bonding/Bond.tsx b/nym-wallet/src/components/Bonding/Bond.tsx index 3392cde43f..1f96da875a 100644 --- a/nym-wallet/src/components/Bonding/Bond.tsx +++ b/nym-wallet/src/components/Bonding/Bond.tsx @@ -14,11 +14,11 @@ export const Bond = ({ - Bond a mixnode or a gateway + Bond a mixnode or a gateway - + {hasVestingTokens && setValue('tokenPool', pool)} />} {step === 1 && ( <> - + diff --git a/nym-wallet/src/components/Bonding/modals/BondMixnodeModal.tsx b/nym-wallet/src/components/Bonding/modals/BondMixnodeModal.tsx index c2bf747d83..3151ffad5d 100644 --- a/nym-wallet/src/components/Bonding/modals/BondMixnodeModal.tsx +++ b/nym-wallet/src/components/Bonding/modals/BondMixnodeModal.tsx @@ -152,18 +152,16 @@ export const BondMixnodeModal = ({ subHeader={`Step ${step}/2`} okLabel="Next" > - - - + ); }; diff --git a/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx b/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx index 50921df9e1..4ff55d5dc3 100644 --- a/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx +++ b/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx @@ -53,13 +53,15 @@ export const NodeSettings = ({ return; } - // TODO: this will have to be updated with allowing users to provide their operating cost in the form - const defaultCostParams = await attachDefaultOperatingCost(toPercentFloatString(pm)); + if (pm) { + // TODO: this will have to be updated with allowing users to provide their operating cost in the form + const defaultCostParams = await attachDefaultOperatingCost(toPercentFloatString(pm)); - if (isVesting) { - await getFee(simulateVestingUpdateMixnodeCostParams, defaultCostParams); - } else { - await getFee(simulateUpdateMixnodeCostParams, defaultCostParams); + if (isVesting) { + await getFee(simulateVestingUpdateMixnodeCostParams, defaultCostParams); + } else { + await getFee(simulateUpdateMixnodeCostParams, defaultCostParams); + } } }; @@ -112,7 +114,7 @@ export const NodeSettings = ({ Set profit margin - setPm(e.target.value)} fullWidth /> + setPm(e.target.value)} fullWidth /> {error && ( Profit margin should be a number between 0 and 100 diff --git a/nym-wallet/src/components/ConfirmTX.stories.tsx b/nym-wallet/src/components/ConfirmTX.stories.tsx index 77bbf4fdcf..2eec07b7e3 100644 --- a/nym-wallet/src/components/ConfirmTX.stories.tsx +++ b/nym-wallet/src/components/ConfirmTX.stories.tsx @@ -10,9 +10,9 @@ export default { const Template: ComponentStory = (args) => ( - - - + + + ); diff --git a/nym-wallet/src/components/Delegation/DelegateModal.tsx b/nym-wallet/src/components/Delegation/DelegateModal.tsx index 50873055e4..a6c1bb0dbf 100644 --- a/nym-wallet/src/components/Delegation/DelegateModal.tsx +++ b/nym-wallet/src/components/Delegation/DelegateModal.tsx @@ -213,8 +213,8 @@ export const DelegateModal: React.FC<{ onPrev={resetFeeState} onConfirm={handleOk} > - - + + ); } @@ -267,7 +267,7 @@ export const DelegateModal: React.FC<{ > {errorIdentityKey} - + {hasVestingContract && setTokenPool(pool)} />} - + )} diff --git a/nym-wallet/src/components/NymCard.tsx b/nym-wallet/src/components/NymCard.tsx index 8dcefd415d..b1927efaac 100644 --- a/nym-wallet/src/components/NymCard.tsx +++ b/nym-wallet/src/components/NymCard.tsx @@ -35,7 +35,7 @@ export const NymCard: React.FC<{ {noPadding ? ( {children} ) : ( - {children} + {children} )} ); diff --git a/nym-wallet/src/components/Receive/ReceiveModal.tsx b/nym-wallet/src/components/Receive/ReceiveModal.tsx index 181e93c0c7..951ce8ff25 100644 --- a/nym-wallet/src/components/Receive/ReceiveModal.tsx +++ b/nym-wallet/src/components/Receive/ReceiveModal.tsx @@ -1,35 +1,52 @@ import React, { useContext } from 'react'; import { AppContext } from 'src/context'; -import { Box, Stack, Typography, SxProps, Dialog, DialogTitle, DialogContent, Paper } from '@mui/material'; +import { Box, Stack, SxProps } from '@mui/material'; import QRCode from 'qrcode.react'; import { ClientAddress } from '../ClientAddress'; import { ModalListItem } from '../Modals/ModalListItem'; -import { Close as CloseIcon } from '@mui/icons-material'; +import { SimpleModal } from '../Modals/SimpleModal'; -export const ReceiveModal = ({ onClose }: { onClose: () => void; sx?: SxProps; backdropProps?: object }) => { - const { clientDetails, mode } = useContext(AppContext); +export const ReceiveModal = ({ + onClose, + sx, + backdropProps, +}: { + onClose: () => void; + sx?: SxProps; + backdropProps?: object; +}) => { + const { clientDetails } = useContext(AppContext); return ( - - - - - Receive - - - - - - - } /> - + + + } /> (t.palette.mode === 'dark' ? t.palette.background.default : 'rgba(251, 110, 78, 5%)'), + borderRadius: '0px 0px 16px 16px', + }} > `1px solid ${mode === 'light' ? t.palette.nym.highlight : t.palette.nym.text.grey} `, - bgcolor: mode === 'light' ? 'white' : 'nym.background.main', + border: (t) => + t.palette.mode === 'dark' + ? `1px solid ${t.palette.nym.nymWallet.modal.border}` + : `1px solid ${t.palette.nym.highlight}`, + bgcolor: (t) => (t.palette.mode === 'dark' ? 'transparent' : 'white'), borderRadius: 2, p: 3, }} @@ -37,7 +54,7 @@ export const ReceiveModal = ({ onClose }: { onClose: () => void; sx?: SxProps; b {clientDetails && } - - + + ); }; diff --git a/nym-wallet/src/components/Send/SendDetailsModal.tsx b/nym-wallet/src/components/Send/SendDetailsModal.tsx index eac87cded3..f2b7d13491 100644 --- a/nym-wallet/src/components/Send/SendDetailsModal.tsx +++ b/nym-wallet/src/components/Send/SendDetailsModal.tsx @@ -3,7 +3,7 @@ import { Stack, SxProps } from '@mui/material'; import { FeeDetails, DecCoin, CurrencyDenom } from '@nymproject/types'; import { SimpleModal } from '../Modals/SimpleModal'; import { ModalListItem } from '../Modals/ModalListItem'; -import { ModalFee } from '../Modals/ModalFee'; +import { ModalFee, ModalTotalAmount } from '../Modals/ModalFee'; export const SendDetailsModal = ({ amount, @@ -38,11 +38,12 @@ export const SendDetailsModal = ({ sx={sx} backdropProps={backdropProps} > - - - - + + + + + ); diff --git a/nym-wallet/src/components/Send/SendInputModal.tsx b/nym-wallet/src/components/Send/SendInputModal.tsx index cbd735f57b..c27eb58781 100644 --- a/nym-wallet/src/components/Send/SendInputModal.tsx +++ b/nym-wallet/src/components/Send/SendInputModal.tsx @@ -55,8 +55,8 @@ export const SendInputModal = ({ sx={sx} backdropProps={backdropProps} > - - + + - - + + Est. fee for this transaction will be show on the next page diff --git a/nym-wallet/src/components/StyledBackButton.tsx b/nym-wallet/src/components/StyledBackButton.tsx index c934cc7968..319bb84c02 100644 --- a/nym-wallet/src/components/StyledBackButton.tsx +++ b/nym-wallet/src/components/StyledBackButton.tsx @@ -1,9 +1,9 @@ import React from 'react'; -import { Button } from '@mui/material'; +import { Button, SxProps } from '@mui/material'; import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; -export const StyledBackButton = ({ onBack }: { onBack: () => void }) => ( - ); diff --git a/nym-wallet/src/context/bonding.tsx b/nym-wallet/src/context/bonding.tsx index 5f454a71c1..2064e6abcc 100644 --- a/nym-wallet/src/context/bonding.tsx +++ b/nym-wallet/src/context/bonding.tsx @@ -167,16 +167,15 @@ export const BondingContextProvider = ({ children }: { children?: React.ReactNod Console.warn(`get_operator_rewards request failed: ${e}`); } if (data) { -<<<<<<< HEAD - const { mix_node } = data; - const { status, stakeSaturation, numberOfDelegators } = await getAdditionalMixnodeDetails( - data.mix_node.identity_key, -======= + // const { mix_node } = data; + // const { status, stakeSaturation, numberOfDelegators } = await getAdditionalMixnodeDetails( + // data.mix_node.identity_key, + // ); + console.log('data', data); const { status, stakeSaturation } = await getAdditionalMixnodeDetails(data.bond_information.id); const nodeDescription = await getNodeDescription( data.bond_information.mix_node.host, data.bond_information.mix_node.http_api_port, ->>>>>>> develop ); setBondedNode({ name: nodeDescription?.name, @@ -193,13 +192,20 @@ export const BondingContextProvider = ({ children }: { children?: React.ReactNod operatorRewards, status, stakeSaturation, - host: mix_node.host.replace(/\s/g, ''), - httpApiPort: mix_node.http_api_port, - mixPort: mix_node.mix_port, - profitMarginPercent: mix_node.profit_margin_percent, - verlocPort: mix_node.verloc_port, - version: mix_node.version, + host: '1.2.34.5', + httpApiPort: 8000, + mixPort: 1789, + profitMarginPercent: 10, + verlocPort: 1790, + version: '1.0.2', } as TBondedMixnode); + + // host: mix_node.host.replace(/\s/g, ''), + // httpApiPort: mix_node.http_api_port, + // mixPort: mix_node.mix_port, + // profitMarginPercent: mix_node.profit_margin_percent, + // verlocPort: mix_node.verloc_port, + // version: mix_node.version, } } catch (e: any) { Console.warn(e); diff --git a/nym-wallet/src/pages/balance/components/TransferModal.tsx b/nym-wallet/src/pages/balance/components/TransferModal.tsx index 451a9899e8..02a8318064 100644 --- a/nym-wallet/src/pages/balance/components/TransferModal.tsx +++ b/nym-wallet/src/pages/balance/components/TransferModal.tsx @@ -87,12 +87,12 @@ export const TransferModal = ({ onClose }: { onClose: () => void }) => { ) : ( <> } divider /> diff --git a/nym-wallet/src/pages/bonding/Bonding.tsx b/nym-wallet/src/pages/bonding/Bonding.tsx index 5836bdd20b..84444dfbad 100644 --- a/nym-wallet/src/pages/bonding/Bonding.tsx +++ b/nym-wallet/src/pages/bonding/Bonding.tsx @@ -14,7 +14,7 @@ import { AppContext, urls } from 'src/context/main'; import { isGateway, isMixnode, TBondGatewayArgs, TBondMixNodeArgs } from 'src/types'; import { BondedGateway } from 'src/components/Bonding/BondedGateway'; import { RedeemRewardsModal } from 'src/components/Bonding/modals/RedeemRewardsModal'; -import { CompoundRewardsModal } from 'src/components/Bonding/modals/CompoundRewardsModal'; +// import { CompoundRewardsModal } from 'src/components/Bonding/modals/CompoundRewardsModal'; import { BondingContextProvider, useBondingContext } from '../../context'; import { Box } from '@mui/material'; @@ -37,7 +37,7 @@ const Bonding = () => { unbond, updateMixnode, redeemRewards, - compoundRewards, + // compoundRewards, isLoading, checkOwnership, } = useBondingContext(); @@ -87,15 +87,15 @@ const Bonding = () => { }); }; - const handleUpdateProfitMargin = async (profitMargin: number, fee?: FeeDetails) => { - setShowModal(undefined); - const tx = await updateMixnode(profitMargin, fee); - setConfirmationDetails({ - status: 'success', - title: 'Profit margin update successful', - txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, - }); - }; + // const handleUpdateProfitMargin = async (profitMargin: number, fee?: FeeDetails) => { + // setShowModal(undefined); + // const tx = await updateMixnode(profitMargin, fee); + // setConfirmationDetails({ + // status: 'success', + // title: 'Profit margin update successful', + // txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, + // }); + // }; const handleRedeemReward = async (fee?: FeeDetails) => { setShowModal(undefined); @@ -107,16 +107,16 @@ const Bonding = () => { }); }; - const handleCompoundReward = async (fee?: FeeDetails) => { - setShowModal(undefined); - const tx = await compoundRewards(fee); - setConfirmationDetails({ - status: 'success', - title: 'Rewards compounded successfully', - txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, - }); - return undefined; - }; + // const handleCompoundReward = async (fee?: FeeDetails) => { + // setShowModal(undefined); + // const tx = await compoundRewards(fee); + // setConfirmationDetails({ + // status: 'success', + // title: 'Rewards compounded successfully', + // txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, + // }); + // return undefined; + // }; const handleBondedMixnodeAction = (action: TBondedMixnodeActions) => { switch (action) { @@ -198,14 +198,14 @@ const Bonding = () => { /> )} - {showModal === 'compound' && bondedNode && isMixnode(bondedNode) && ( + {/* {showModal === 'compound' && bondedNode && isMixnode(bondedNode) && ( setShowModal(undefined)} onConfirm={handleCompoundReward} onError={handleError} /> - )} + )} */} {confirmationDetails && confirmationDetails.status === 'success' && ( { - const [showModal, setShowModal] = useState< - 'bond-mixnode' | 'bond-gateway' | 'bond-more' | 'unbond' | 'redeem' | 'compound' | 'node-settings' - >(); - const [confirmationDetails, setConfirmationDetails] = useState(); - - const { - network, - clientDetails, - userBalance: { originalVesting }, - } = useContext(AppContext); - - const { - bondedNode, - bondMixnode, - bondGateway, - unbond, - updateMixnode, - redeemRewards, - isLoading, - checkOwnership, - error, - } = useBondingContext(); - - useEffect(() => { - if (error) { - setShowModal(undefined); - setConfirmationDetails({ - status: 'error', - title: 'An error occurred', - subtitle: error, - }); - } - }, [error]); - - const handleCloseModal = async () => { - setShowModal(undefined); - await checkOwnership(); - }; - - const handleError = (e: string) => { - setShowModal(undefined); - setConfirmationDetails({ - status: 'error', - title: 'An error occurred', - subtitle: e, - }); - }; - - const handleBondMixnode = async (data: TBondMixNodeArgs, tokenPool: TPoolOption) => { - setShowModal(undefined); - const tx = await bondMixnode(data, tokenPool); - setConfirmationDetails({ - status: 'success', - title: 'Bond successful', - txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, - }); - return undefined; - }; - - const handleBondGateway = async (data: TBondGatewayArgs, tokenPool: TPoolOption) => { - setShowModal(undefined); - const tx = await bondGateway(data, tokenPool); - setConfirmationDetails({ - status: 'success', - title: 'Bond successful', - txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, - }); - }; - - const handleUnbond = async (fee?: FeeDetails) => { - setShowModal(undefined); - const tx = await unbond(fee); - setConfirmationDetails({ - status: 'success', - title: 'Unbond successful', - txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, - }); - }; - - const handleUpdateProfitMargin = async (profitMargin: string, fee?: FeeDetails) => { - setShowModal(undefined); - const tx = await updateMixnode(profitMargin, fee); - setConfirmationDetails({ - status: 'success', - title: 'Profit margin update successful', - txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, - }); - }; - - const handleRedeemReward = async (fee?: FeeDetails) => { - setShowModal(undefined); - const tx = await redeemRewards(fee); - setConfirmationDetails({ - status: 'success', - title: 'Rewards redeemed successfully', - txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, - }); - }; - - const handleBondedMixnodeAction = (action: TBondedMixnodeActions) => { - switch (action) { - case 'bondMore': { - setShowModal('bond-more'); - break; - } - case 'unbond': { - setShowModal('unbond'); - break; - } - case 'redeem': { - setShowModal('redeem'); - break; - } - case 'nodeSettings': { - setShowModal('node-settings'); - break; - } - default: { - return undefined; - } - } - return undefined; - }; - - return ( - - {!bondedNode && setShowModal('bond-mixnode')} />} - - {bondedNode && isMixnode(bondedNode) && ( - handleBondedMixnodeAction(action)} - /> - )} - - {bondedNode && isGateway(bondedNode) && ( - - )} - {showModal === 'bond-mixnode' && ( - setShowModal('bond-gateway')} - onClose={() => setShowModal(undefined)} - onError={handleError} - /> - )} - - {showModal === 'bond-gateway' && ( - setShowModal('bond-mixnode')} - onClose={() => setShowModal(undefined)} - onError={handleError} - /> - )} - - {showModal === 'unbond' && bondedNode && ( - setShowModal(undefined)} - onConfirm={handleUnbond} - onError={handleError} - /> - )} - - {showModal === 'redeem' && bondedNode && isMixnode(bondedNode) && ( - setShowModal(undefined)} - onConfirm={handleRedeemReward} - onError={handleError} - /> - )} - - {showModal === 'node-settings' && bondedNode && isMixnode(bondedNode) && ( - setShowModal(undefined)} - onError={handleError} - /> - )} - - {confirmationDetails && confirmationDetails.status === 'success' && ( - { - setConfirmationDetails(undefined); - handleCloseModal(); - }} - /> - )} - - {confirmationDetails && confirmationDetails.status === 'error' && ( - setConfirmationDetails(undefined)} /> - )} - - {isLoading && } - - ); -}; - -export const BondingPage = () => ( - - - -); ->>>>>>> develop diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 6115643c15..92845056b0 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -1,6 +1,6 @@ import React, { FC, useContext, useEffect, useState } from 'react'; -import { Box, Button, Paper, Stack, Typography } from '@mui/material'; -import { Theme, useTheme } from '@mui/material/styles'; +import { Box, Button, Paper, Stack, Typography, CircularProgress } from '@mui/material'; +import { useTheme, Theme } from '@mui/material/styles'; import { DecCoin, decimalToFloatApproximation, DelegationWithEverything, FeeDetails } from '@nymproject/types'; import { Link } from '@nymproject/react/link/Link'; import { AppContext, urls } from 'src/context/main'; @@ -10,7 +10,7 @@ import { Console } from 'src/utils/console'; import { OverSaturatedBlockerModal } from 'src/components/Delegation/DelegateBlocker'; import { getSpendableCoins, userBalance } from 'src/requests'; import { RewardsSummary } from '../../components/Rewards/RewardsSummary'; -import { DelegationContextProvider, useDelegationContext } from '../../context/delegations'; +import { DelegationContextProvider, useDelegationContext, TDelegations } from '../../context/delegations'; import { RewardsContextProvider, useRewardsContext } from '../../context/rewards'; import { DelegateModal } from '../../components/Delegation/DelegateModal'; import { UndelegateModal } from '../../components/Delegation/UndelegateModal'; @@ -268,41 +268,90 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { } }; - return ( - <> - - - - - Delegations - + const delegationsComponent = (delegations: TDelegations | undefined) => { + if (isLoading) { + return ( + + + + ); + } else if (Boolean(delegations?.length)) { + return ( + + ); + } + return ( + + + + Checkout the{' '} + />{' '} + for performance and other parameters to help make delegation decisions. + + + Hint: In Nym explorer use advanced filters to precisely define what node you are looking for. + + + + + ); + }; + + return ( + <> + + + + + Delegations + + {!!delegations?.length && ( + + )} - - - - - + + {!!delegations?.length && ( + + + + + + )} + {delegationsComponent(delegations)} diff --git a/nym-wallet/src/routes/app.tsx b/nym-wallet/src/routes/app.tsx index b6f9874492..0fbc9edc6c 100644 --- a/nym-wallet/src/routes/app.tsx +++ b/nym-wallet/src/routes/app.tsx @@ -4,11 +4,7 @@ import { ApplicationLayout } from 'src/layouts'; import { Terminal } from 'src/pages/terminal'; import { Send } from 'src/components/Send'; import { Receive } from '../components/Receive'; -<<<<<<< HEAD -import { Balance, InternalDocs, Unbond, DelegationPage, Admin, BondingPage, NodeSettingsPage } from '../pages'; -======= -import { Balance, InternalDocs, DelegationPage, Admin, BondingPage } from '../pages'; ->>>>>>> develop +import { Balance, InternalDocs, DelegationPage, Admin, BondingPage, NodeSettingsPage } from '../pages'; export const AppRoutes = () => ( @@ -18,11 +14,7 @@ export const AppRoutes = () => ( } /> } /> -<<<<<<< HEAD } /> - } /> -======= ->>>>>>> develop } /> } /> } /> diff --git a/nym-wallet/src/theme/mui-theme.d.ts b/nym-wallet/src/theme/mui-theme.d.ts index 5bf3fb2712..7074472232 100644 --- a/nym-wallet/src/theme/mui-theme.d.ts +++ b/nym-wallet/src/theme/mui-theme.d.ts @@ -69,6 +69,9 @@ declare module '@mui/material/styles' { hover: { background: string; }; + modal: { + border: string; + }; } /** diff --git a/nym-wallet/src/theme/theme.tsx b/nym-wallet/src/theme/theme.tsx index b2d943d4df..9f49234560 100644 --- a/nym-wallet/src/theme/theme.tsx +++ b/nym-wallet/src/theme/theme.tsx @@ -61,6 +61,9 @@ const darkMode: NymPaletteVariant = { hover: { background: '#36393E', }, + modal: { + border: '#484d53', + }, }; const lightMode: NymPaletteVariant = { @@ -89,6 +92,9 @@ const lightMode: NymPaletteVariant = { hover: { background: '#F9F9F9', }, + modal: { + border: 'transparent', + }, }; /** diff --git a/validator-api/src/epoch_operations/mod.rs b/validator-api/src/epoch_operations/mod.rs index 62270715eb..eb0918f2ab 100644 --- a/validator-api/src/epoch_operations/mod.rs +++ b/validator-api/src/epoch_operations/mod.rs @@ -22,7 +22,6 @@ use mixnet_contract_common::{ use rand::prelude::SliceRandom; use rand::rngs::OsRng; use std::collections::HashSet; -use std::process; use std::time::Duration; use tokio::time::sleep; use validator_client::nymd::SigningNymdClient; @@ -314,20 +313,10 @@ impl RewardedSetUpdater { async fn wait_until_epoch_end(&mut self, shutdown: &mut ShutdownListener) -> Option { const POLL_INTERVAL: Duration = Duration::from_secs(120); - const MAXIMUM_ATTEMPTS: usize = 5; - let mut failed_attempts = 0; loop { let current_interval = match self.current_interval_details().await { Err(err) => { - failed_attempts += 1; - if failed_attempts == MAXIMUM_ATTEMPTS { - error!( - "failed to obtain epoch information {} times in a row. Existing now", - MAXIMUM_ATTEMPTS - ); - process::exit(1); - } error!("failed to obtain information about the current interval - {}. Going to retry in {}s", err, POLL_INTERVAL.as_secs()); tokio::select! { _ = sleep(POLL_INTERVAL) => { @@ -342,8 +331,6 @@ impl RewardedSetUpdater { Ok(interval) => interval, }; - failed_attempts = 0; - if current_interval.is_current_epoch_over { return Some(current_interval.interval); } else { @@ -378,14 +365,7 @@ impl RewardedSetUpdater { ) -> Result<(), RewardingError> { self.validator_cache.wait_for_initial_values().await; - const MAX_FAILURES: usize = 10; - let mut consecutive_failures = 0; while !shutdown.is_shutdown() { - if consecutive_failures == MAX_FAILURES { - error!("We have failed to perform epoch operations {} times in a row. The validator API will shutdown now", MAX_FAILURES); - std::process::exit(1); - } - let interval_details = match self.wait_until_epoch_end(&mut shutdown).await { // received a shutdown None => return Ok(()), @@ -397,10 +377,7 @@ impl RewardedSetUpdater { } if let Err(err) = self.perform_epoch_operations(interval_details).await { error!("failed to perform epoch operations - {}", err); - consecutive_failures += 1; - sleep(Duration::from_secs(5)).await; - } else { - consecutive_failures = 0; + sleep(Duration::from_secs(30)).await; } }