From df4385ab71d07ddf819076a33bda70082a1e5847 Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Mon, 18 Jul 2022 11:35:59 +0100 Subject: [PATCH] update coin types in new bonding page --- nym-wallet/src/components/Nav.tsx | 56 ++----------------- nym-wallet/src/components/index.ts | 1 - nym-wallet/src/context/bonding.tsx | 26 ++++----- nym-wallet/src/context/mocks/bonding.tsx | 23 ++++---- .../src/pages/bonding/bonding/AmountModal.tsx | 2 +- .../bonding/mixnode/bond-more/BondModal.tsx | 10 ++-- .../bonding/mixnode/bond-more/BondMore.tsx | 6 +- .../mixnode/bond-more/SummaryModal.tsx | 6 +- .../bonding/mixnode/compound/SummaryModal.tsx | 6 +- .../mixnode/node-settings/NodeSettings.tsx | 4 +- .../node-settings/ProfitMarginModal.tsx | 4 +- .../mixnode/node-settings/SummaryModal.tsx | 4 +- .../bonding/mixnode/redeem/SummaryModal.tsx | 6 +- nym-wallet/src/pages/bonding/types.ts | 6 +- .../src/pages/bonding/unbond/SummaryModal.tsx | 8 +-- .../src/pages/bonding/unbond/Unbond.tsx | 1 - 16 files changed, 61 insertions(+), 108 deletions(-) diff --git a/nym-wallet/src/components/Nav.tsx b/nym-wallet/src/components/Nav.tsx index 275b32467f..5558b2163c 100644 --- a/nym-wallet/src/components/Nav.tsx +++ b/nym-wallet/src/components/Nav.tsx @@ -5,56 +5,6 @@ import { AccountBalanceWalletOutlined, ArrowBack, ArrowForward, Description, Set import { AppContext } from '../context/main'; import { Bond, Delegate, Unbond, Bonding } from '../svg-icons'; -const routesSchema = [ - { - label: 'Balance', - route: '/balance', - Icon: AccountBalanceWalletOutlined, - }, - { - label: 'Send', - route: '/send', - Icon: ArrowForward, - }, - { - label: 'Receive', - route: '/receive', - Icon: ArrowBack, - }, - { - label: 'Bond', - route: '/bond', - Icon: Bond, - }, - { - label: 'Bonding', - route: '/bonding', - Icon: Bonding, - }, - { - label: 'Unbond', - route: '/unbond', - Icon: Unbond, - }, - { - label: 'Delegation', - route: '/delegation', - Icon: Delegate, - }, - { - label: 'Docs', - route: '/docs', - Icon: Description, - mode: 'dev', - }, - { - label: 'Admin', - route: '/admin', - Icon: Settings, - mode: 'admin', - }, -]; - export const Nav = () => { const location = useLocation(); const navigate = useNavigate(); @@ -79,6 +29,12 @@ export const Nav = () => { Icon: ArrowBack, onClick: () => navigate('/receive'), }, + { + label: 'Bonding', + route: '/bonding', + Icon: Bond, + onClick: () => navigate('/bonding'), + }, { label: 'Bond', route: '/bond', diff --git a/nym-wallet/src/components/index.ts b/nym-wallet/src/components/index.ts index 63f9fccd37..690f9c9c86 100644 --- a/nym-wallet/src/components/index.ts +++ b/nym-wallet/src/components/index.ts @@ -20,4 +20,3 @@ export * from './TokenPoolSelector'; export * from './TransactionDetails'; export * from './Warning'; export * from './Modals/ConfirmationModal'; -export * from './SimpleDialog'; diff --git a/nym-wallet/src/context/bonding.tsx b/nym-wallet/src/context/bonding.tsx index 12ff1615b7..feb2abf0da 100644 --- a/nym-wallet/src/context/bonding.tsx +++ b/nym-wallet/src/context/bonding.tsx @@ -1,4 +1,4 @@ -import { FeeDetails, MajorCurrencyAmount, MixnodeStatus, TransactionExecuteResult } from '@nymproject/types'; +import { FeeDetails, DecCoin, MixnodeStatus, TransactionExecuteResult } from '@nymproject/types'; import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'; import type { Network } from 'src/types'; import { TBondGatewayArgs, TBondMixNodeArgs } from 'src/types'; @@ -35,19 +35,19 @@ import { AppContext } from './main'; const bounded: BondedMixnode = { identityKey: 'B2Xx4haarLWMajX8w259oHjtRZsC7nHwagbWrJNiA3QC', - bond: { denom: 'NYM', amount: '1234' }, + bond: { denom: 'nym', amount: '1234' }, delegators: 123, ip: '1.2.34.5', - nodeRewards: { denom: 'NYM', amount: '123' }, - operatorRewards: { denom: 'NYM', amount: '12' }, + nodeRewards: { denom: 'nym', amount: '123' }, + operatorRewards: { denom: 'nym', amount: '12' }, profitMargin: 10, - stake: { denom: 'NYM', amount: '99' }, + stake: { denom: 'nym', amount: '99' }, stakeSaturation: 99, status: 'active', }; /* const bounded: BondedMixnode | BondedGateway = { - bond: { denom: 'NYM', amount: '1234' }, + bond: { denom: 'nym', amount: '1234' }, identityKey: 'B2Xx4haarLWMajX8w259oHjtRZsC7nHwagbWrJNiA3QC', ip: '1.2.34.5', location: 'France', @@ -57,12 +57,12 @@ const bounded: BondedMixnode = { export interface BondedMixnode { identityKey: string; ip: string; - stake: MajorCurrencyAmount; - bond: MajorCurrencyAmount; + stake: DecCoin; + bond: DecCoin; stakeSaturation: number; profitMargin: number; - nodeRewards: MajorCurrencyAmount; - operatorRewards: MajorCurrencyAmount; + nodeRewards: DecCoin; + operatorRewards: DecCoin; delegators: number; status: MixnodeStatus; } @@ -71,7 +71,7 @@ export interface BondedMixnode { export interface BondedGateway { identityKey: string; ip: string; - bond: MajorCurrencyAmount; + bond: DecCoin; location?: string; // TODO not yet available, only available in Network Explorer API } @@ -103,7 +103,7 @@ export type TBondingContext = { data: Omit, tokenPool: TokenPool, ) => Promise; - bondMore: (signature: string, additionalBond: MajorCurrencyAmount) => Promise; + bondMore: (signature: string, additionalBond: DecCoin) => Promise; unbondMixnode: () => Promise; unbondGateway: () => Promise; redeemRewards: () => Promise; @@ -359,7 +359,7 @@ export const BondingContextProvider = ({ return tx; }; - const bondMore = async (_signature: string, _additionalBond: MajorCurrencyAmount) => + const bondMore = async (_signature: string, _additionalBond: DecCoin) => // TODO to implement undefined; diff --git a/nym-wallet/src/context/mocks/bonding.tsx b/nym-wallet/src/context/mocks/bonding.tsx index 63cfa7c7c9..bb47342c32 100644 --- a/nym-wallet/src/context/mocks/bonding.tsx +++ b/nym-wallet/src/context/mocks/bonding.tsx @@ -1,4 +1,4 @@ -import { FeeDetails, MajorCurrencyAmount, TransactionExecuteResult } from '@nymproject/types'; +import { FeeDetails, DecCoin, TransactionExecuteResult } from '@nymproject/types'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import type { Network } from 'src/types'; import { BondedGateway, BondedMixnode, BondingContext, FeeOperation } from '../bonding'; @@ -9,12 +9,12 @@ const SLEEP_MS = 1000; const bondedMixnodeMock: BondedMixnode = { identityKey: '7mjM2fYbtN6kxMwp1TrmQ4VwPks3URR5pBgWPWhzT98F', ip: '112.43.234.56', - stake: { denom: 'NYM', amount: '1234' }, - bond: { denom: 'NYM', amount: '1234' }, + stake: { denom: 'nym', amount: '1234' }, + bond: { denom: 'nym', amount: '1234' }, stakeSaturation: 95, profitMargin: 15, - nodeRewards: { denom: 'NYM', amount: '1234' }, - operatorRewards: { denom: 'NYM', amount: '1234' }, + nodeRewards: { denom: 'nym', amount: '1234' }, + operatorRewards: { denom: 'nym', amount: '1234' }, delegators: 5423, status: 'active', }; @@ -22,7 +22,7 @@ const bondedMixnodeMock: BondedMixnode = { const bondedGatewayMock: BondedGateway = { identityKey: 'WayM2fYbtN6kxMwp1TrmQ4VwPks3URR5pBgWPWhzT98F', ip: '112.43.234.57', - bond: { denom: 'NYM', amount: '1234' }, + bond: { denom: 'nym', amount: '1234' }, }; const TxResultMock: TransactionExecuteResult = { @@ -30,15 +30,14 @@ const TxResultMock: TransactionExecuteResult = { data_json: '', transaction_hash: '55303CD4B91FAC4C2715E40EBB52BB3B92829D9431B3A279D37B5CC58432E354', gas_info: { - gas_wanted: BigInt(1), - gas_used: BigInt(1), - fee: { amount: '1', denom: 'NYM' }, + gas_wanted: { gas_units: BigInt(1) }, + gas_used: { gas_units: BigInt(1) }, }, - fee: { amount: '1', denom: 'NYM' }, + fee: { amount: '1', denom: 'nym' }, }; const feeMock: FeeDetails = { - amount: { denom: 'NYM', amount: '1' }, + amount: { denom: 'nym', amount: '1' }, fee: { Auto: 1 }, }; @@ -145,7 +144,7 @@ export const MockBondingContextProvider = ({ return TxResultMock; }; - const bondMore = async (_signature: string, _additionalBond: MajorCurrencyAmount) => { + const bondMore = async (_signature: string, _additionalBond: DecCoin) => { setLoading(true); await mockSleep(SLEEP_MS); triggerStateUpdate(); diff --git a/nym-wallet/src/pages/bonding/bonding/AmountModal.tsx b/nym-wallet/src/pages/bonding/bonding/AmountModal.tsx index 4c389b3307..f3c67f4bbf 100644 --- a/nym-wallet/src/pages/bonding/bonding/AmountModal.tsx +++ b/nym-wallet/src/pages/bonding/bonding/AmountModal.tsx @@ -80,7 +80,7 @@ const AmountModal = ({ open, onClose, onSubmit, nodeType }: Props) => { fullWidth label="Amount" name="amount" - currencyDenom={clientDetails?.denom} + currencyDenom={clientDetails?.display_mix_denom} errorMessage={errors.amount?.amount?.message} /> diff --git a/nym-wallet/src/pages/bonding/mixnode/bond-more/BondModal.tsx b/nym-wallet/src/pages/bonding/mixnode/bond-more/BondModal.tsx index 0be35c5077..93b3ad9af3 100644 --- a/nym-wallet/src/pages/bonding/mixnode/bond-more/BondModal.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/bond-more/BondModal.tsx @@ -3,7 +3,7 @@ import { useContext } from 'react'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { Box, Divider, Stack, Typography } from '@mui/material'; -import { MajorCurrencyAmount } from '@nymproject/types'; +import { DecCoin } from '@nymproject/types'; import { CurrencyInput, TextFieldInput } from '../../components'; import schema from './schema'; import { AppContext } from '../../../../context'; @@ -13,12 +13,12 @@ import { SimpleModal } from '../../../../components/Modals/SimpleModal'; export interface Props { open: boolean; onClose: () => void; - onConfirm: (bond: MajorCurrencyAmount, signature: string) => void; - currentBond: MajorCurrencyAmount; + onConfirm: (bond: DecCoin, signature: string) => void; + currentBond: DecCoin; } interface FormData { - amount: MajorCurrencyAmount; + amount: DecCoin; tokenPool: string; signature: string; } @@ -61,7 +61,7 @@ const BondModal = ({ open, onClose, onConfirm, currentBond }: Props) => { fullWidth label="Amount" name="amount" - currencyDenom={clientDetails?.denom} + currencyDenom={clientDetails?.display_mix_denom} errorMessage={errors.amount?.amount?.message} /> diff --git a/nym-wallet/src/pages/bonding/mixnode/bond-more/BondMore.tsx b/nym-wallet/src/pages/bonding/mixnode/bond-more/BondMore.tsx index 513a772f7b..cd3335b187 100644 --- a/nym-wallet/src/pages/bonding/mixnode/bond-more/BondMore.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/bond-more/BondMore.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { useContext, useState } from 'react'; -import { MajorCurrencyAmount, TransactionExecuteResult } from '@nymproject/types'; +import { DecCoin, TransactionExecuteResult } from '@nymproject/types'; import { Link } from '@nymproject/react/link/Link'; import { Typography } from '@mui/material'; import { ErrorOutline } from '@mui/icons-material'; @@ -16,7 +16,7 @@ interface Props { } const BondMore = ({ mixnode, show, onClose }: Props) => { - const [addBond, setAddBond] = useState({ amount: '0', denom: 'NYM' }); + const [addBond, setAddBond] = useState({ amount: '0', denom: 'nym' }); const [signature, setSignature] = useState(); const [step, setStep] = useState<1 | 2 | 3>(1); const [tx, setTx] = useState(); @@ -33,7 +33,7 @@ const BondMore = ({ mixnode, show, onClose }: Props) => { }; const reset = () => { - setAddBond({ amount: '0', denom: 'NYM' }); + setAddBond({ amount: '0', denom: 'nym' }); setSignature(''); setStep(1); onClose(); diff --git a/nym-wallet/src/pages/bonding/mixnode/bond-more/SummaryModal.tsx b/nym-wallet/src/pages/bonding/mixnode/bond-more/SummaryModal.tsx index 29b5b7cfa1..51c50b9ce8 100644 --- a/nym-wallet/src/pages/bonding/mixnode/bond-more/SummaryModal.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/bond-more/SummaryModal.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { Divider, Stack, Typography } from '@mui/material'; -import { MajorCurrencyAmount } from '@nymproject/types'; +import { DecCoin } from '@nymproject/types'; import { useEffect } from 'react'; import { ErrorOutline } from '@mui/icons-material'; import { SimpleModal } from '../../../../components/Modals/SimpleModal'; @@ -12,8 +12,8 @@ export interface Props { onClose: () => void; onConfirm: () => Promise; onCancel: () => void; - currentBond: MajorCurrencyAmount; - addBond: MajorCurrencyAmount; + currentBond: DecCoin; + addBond: DecCoin; } const SummaryModal = ({ open, onClose, onConfirm, onCancel, currentBond, addBond }: Props) => { diff --git a/nym-wallet/src/pages/bonding/mixnode/compound/SummaryModal.tsx b/nym-wallet/src/pages/bonding/mixnode/compound/SummaryModal.tsx index f2629a78a6..092460b2bc 100644 --- a/nym-wallet/src/pages/bonding/mixnode/compound/SummaryModal.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/compound/SummaryModal.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { Divider, Stack, Typography } from '@mui/material'; -import { MajorCurrencyAmount } from '@nymproject/types'; +import { DecCoin } from '@nymproject/types'; import { SimpleModal } from '../../../../components/Modals/SimpleModal'; export interface Props { @@ -8,8 +8,8 @@ export interface Props { onClose: () => void; onConfirm: () => Promise; onCancel: () => void; - rewards: MajorCurrencyAmount; - fee?: MajorCurrencyAmount | null; + rewards: DecCoin; + fee?: DecCoin | null; } const SummaryModal = ({ open, onClose, onConfirm, onCancel, rewards, fee }: Props) => ( diff --git a/nym-wallet/src/pages/bonding/mixnode/node-settings/NodeSettings.tsx b/nym-wallet/src/pages/bonding/mixnode/node-settings/NodeSettings.tsx index 9fc21d77dd..9dd6e74b74 100644 --- a/nym-wallet/src/pages/bonding/mixnode/node-settings/NodeSettings.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/node-settings/NodeSettings.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { useContext, useEffect, useState } from 'react'; -import { MajorCurrencyAmount, TransactionExecuteResult } from '@nymproject/types'; +import { DecCoin, TransactionExecuteResult } from '@nymproject/types'; import { Link } from '@nymproject/react/link/Link'; import { Typography } from '@mui/material'; import { ErrorOutline } from '@mui/icons-material'; @@ -16,7 +16,7 @@ interface Props { } // TODO fetch real estimated operator reward for 10% PM -const MOCK_ESTIMATED_OP_REWARD: MajorCurrencyAmount = { amount: '42', denom: 'NYM' }; +const MOCK_ESTIMATED_OP_REWARD: DecCoin = { amount: '42', denom: 'nym' }; const NodeSettings = ({ mixnode, show, onClose }: Props) => { const [status, setStatus] = useState<'success' | 'error'>(); diff --git a/nym-wallet/src/pages/bonding/mixnode/node-settings/ProfitMarginModal.tsx b/nym-wallet/src/pages/bonding/mixnode/node-settings/ProfitMarginModal.tsx index eb8e2c46ae..68744724d8 100644 --- a/nym-wallet/src/pages/bonding/mixnode/node-settings/ProfitMarginModal.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/node-settings/ProfitMarginModal.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; +import { DecCoin } from '@nymproject/types'; import { Box, Divider, Stack, Tooltip, Typography } from '@mui/material'; -import { MajorCurrencyAmount } from '@nymproject/types'; import { TextFieldInput } from '../../components'; import getSchema from './schema'; import { SimpleModal } from '../../../../components/Modals/SimpleModal'; @@ -11,7 +11,7 @@ export interface Props { open: boolean; onClose: () => void; onConfirm: (pm: number) => void; - estimatedOpReward: MajorCurrencyAmount; + estimatedOpReward: DecCoin; currentPm: number; } diff --git a/nym-wallet/src/pages/bonding/mixnode/node-settings/SummaryModal.tsx b/nym-wallet/src/pages/bonding/mixnode/node-settings/SummaryModal.tsx index a24ae2e05d..e9feeb3c22 100644 --- a/nym-wallet/src/pages/bonding/mixnode/node-settings/SummaryModal.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/node-settings/SummaryModal.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { Divider, Stack, Typography } from '@mui/material'; -import { MajorCurrencyAmount } from '@nymproject/types'; +import { DecCoin } from '@nymproject/types'; import { SimpleModal } from '../../../../components/Modals/SimpleModal'; export interface Props { @@ -10,7 +10,7 @@ export interface Props { onCancel: () => void; currentPm: number; newPm: number; - fee?: MajorCurrencyAmount | null; + fee?: DecCoin | null; } const SummaryModal = ({ open, onClose, onConfirm, onCancel, currentPm, newPm, fee }: Props) => ( diff --git a/nym-wallet/src/pages/bonding/mixnode/redeem/SummaryModal.tsx b/nym-wallet/src/pages/bonding/mixnode/redeem/SummaryModal.tsx index c802ca79d4..b2f1147728 100644 --- a/nym-wallet/src/pages/bonding/mixnode/redeem/SummaryModal.tsx +++ b/nym-wallet/src/pages/bonding/mixnode/redeem/SummaryModal.tsx @@ -1,15 +1,15 @@ import * as React from 'react'; import { Divider, Stack, Typography } from '@mui/material'; -import { MajorCurrencyAmount } from '@nymproject/types'; import { SimpleModal } from '../../../../components/Modals/SimpleModal'; +import { DecCoin } from '@nymproject/types'; export interface Props { open: boolean; onClose: () => void; onConfirm: () => Promise; onCancel: () => void; - rewards: MajorCurrencyAmount; - fee?: MajorCurrencyAmount | null; + rewards: DecCoin; + fee?: DecCoin | null; } const SummaryModal = ({ open, onClose, onConfirm, onCancel, rewards, fee }: Props) => ( diff --git a/nym-wallet/src/pages/bonding/types.ts b/nym-wallet/src/pages/bonding/types.ts index b6d7d450dd..724952e4a0 100644 --- a/nym-wallet/src/pages/bonding/types.ts +++ b/nym-wallet/src/pages/bonding/types.ts @@ -1,4 +1,4 @@ -import { MajorCurrencyAmount, TNodeType, TransactionExecuteResult } from '@nymproject/types'; +import { DecCoin, TNodeType, TransactionExecuteResult } from '@nymproject/types'; export type FormStep = 1 | 2 | 3 | 4; export type NodeType = TNodeType; @@ -34,7 +34,7 @@ export type MixnodeData = NodeIdentity & { }; export type MixnodeAmount = { - amount: MajorCurrencyAmount; + amount: DecCoin; tokenPool: string; profitMargin: number; }; @@ -51,7 +51,7 @@ export type NodeData = { } & N; export interface AmountData { - amount: MajorCurrencyAmount; + amount: DecCoin; tokenPool: string; profitMargin?: number; } diff --git a/nym-wallet/src/pages/bonding/unbond/SummaryModal.tsx b/nym-wallet/src/pages/bonding/unbond/SummaryModal.tsx index 0ec6a4b23b..79620d1e74 100644 --- a/nym-wallet/src/pages/bonding/unbond/SummaryModal.tsx +++ b/nym-wallet/src/pages/bonding/unbond/SummaryModal.tsx @@ -1,16 +1,16 @@ import * as React from 'react'; import { Divider, Stack, Typography } from '@mui/material'; -import { MajorCurrencyAmount } from '@nymproject/types'; import { SimpleModal } from '../../../components/Modals/SimpleModal'; +import { DecCoin } from '@nymproject/types'; export interface Props { open: boolean; onClose: () => void; onConfirm: () => Promise; onCancel: () => void; - bond: MajorCurrencyAmount; - rewards?: MajorCurrencyAmount; - fee?: MajorCurrencyAmount | null; + bond: DecCoin; + rewards?: DecCoin; + fee?: DecCoin | null; } const SummaryModal = ({ open, onClose, onConfirm, onCancel, bond, rewards, fee }: Props) => ( diff --git a/nym-wallet/src/pages/bonding/unbond/Unbond.tsx b/nym-wallet/src/pages/bonding/unbond/Unbond.tsx index 59591865a4..64fe73538a 100644 --- a/nym-wallet/src/pages/bonding/unbond/Unbond.tsx +++ b/nym-wallet/src/pages/bonding/unbond/Unbond.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import { useContext, useEffect, useState } from 'react'; -import { MajorCurrencyAmount } from '@nymproject/types'; import { Link } from '@nymproject/react/link/Link'; import { Typography } from '@mui/material'; import { ErrorOutline } from '@mui/icons-material';