diff --git a/packages/extension-polkagate/src/components/AccountHolder.tsx b/packages/extension-polkagate/src/components/AccountHolder.tsx index be718efd9..0f52c74cf 100644 --- a/packages/extension-polkagate/src/components/AccountHolder.tsx +++ b/packages/extension-polkagate/src/components/AccountHolder.tsx @@ -11,24 +11,26 @@ import { Identity, ShortAddress } from '.'; interface Props { address: string | undefined; + direction?: 'row' | 'column' ; style?: SxProps | undefined; title?: string; } -function AccountHolder ({ address, style, title }: Props): React.ReactElement { +function AccountHolder ({ address, direction = 'column', style, title }: Props): React.ReactElement { const { t } = useTranslation(); const isExtensionPopup = useIsExtensionPopup(); const { api, formatted } = useInfo(address); return ( - + - {title ?? t('Account holder')} + {title ?? t('Account')} | undefined; selectedProxyAddress?: string; title?: string; - chain: Chain | null | undefined; + chain?: Chain | null | undefined; + direction?: 'row' | 'column' ; } -function AccountHolderWithProxy ({ address, chain, selectedProxyAddress, showDivider = false, style, title }: Props): React.ReactElement { +function AccountHolderWithProxy ({ address, chain, direction = 'column', selectedProxyAddress, showDivider = false, style, title }: Props): React.ReactElement { + const _chain = useChain(address); + return ( {selectedProxyAddress && diff --git a/packages/extension-polkagate/src/components/AccountWithProxyInConfirmation.tsx b/packages/extension-polkagate/src/components/AccountWithProxyInConfirmation.tsx new file mode 100644 index 000000000..e63590c1b --- /dev/null +++ b/packages/extension-polkagate/src/components/AccountWithProxyInConfirmation.tsx @@ -0,0 +1,50 @@ +// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +/* eslint-disable react/jsx-max-props-per-line */ + +import type { TxInfo } from '../util/types'; + +import { Grid, Typography } from '@mui/material'; +import React from 'react'; + +import { useTranslation } from '../hooks'; +import { ThroughProxy } from '../partials'; +import { ShortAddress } from '.'; + +interface Props { + txInfo: TxInfo; + label?: string; +} + +export default function AccountWithProxyInConfirmation ({ label, txInfo }: Props): React.ReactElement { + const { t } = useTranslation(); + + return ( + <> + + + { label || t('Account')}: + + + {txInfo.from.name} + + + + + + {txInfo.throughProxy && + + + + } + + ); +} diff --git a/packages/extension-polkagate/src/components/DisplayInfo.tsx b/packages/extension-polkagate/src/components/DisplayInfo.tsx new file mode 100644 index 000000000..eedc5c7f7 --- /dev/null +++ b/packages/extension-polkagate/src/components/DisplayInfo.tsx @@ -0,0 +1,34 @@ +// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +/* eslint-disable react/jsx-max-props-per-line */ + +import { Divider, Grid, Typography } from '@mui/material'; +import React from 'react'; + +interface Props { + caption: string; + value: any | React.ReactNode | string | undefined; + showDivider?: boolean; + fontSize?: string; + fontWeight?: number; +} + +export default function DisplayInfo ({ caption, fontSize = '16px', fontWeight = 400, showDivider = true, value }: Props) { + return ( + + + + {caption} + + + {value || ''} + + + {showDivider && + + + } + + ); +} diff --git a/packages/extension-polkagate/src/components/Identity.tsx b/packages/extension-polkagate/src/components/Identity.tsx index 4b3e4284f..26d8b7d75 100644 --- a/packages/extension-polkagate/src/components/Identity.tsx +++ b/packages/extension-polkagate/src/components/Identity.tsx @@ -26,6 +26,7 @@ interface Props { direction?: 'row' | 'column'; formatted?: string | AccountId; identiconSize?: number; + inParentheses?: boolean; judgement?: unknown; name?: string; noIdenticon?: boolean; @@ -39,7 +40,7 @@ interface Props { subIdOnly?: boolean; } -function Identity ({ accountInfo, address, api, chain, direction = 'column', formatted, identiconSize = 40, judgement, name, noIdenticon = false, onClick, returnIdentity, showChainLogo = false, showShortAddress, showSocial = true, style, subIdOnly = false, withShortAddress }: Props): React.ReactElement { +function Identity ({ accountInfo, address, api, chain, direction = 'column', formatted, identiconSize = 40, inParentheses = false, judgement, name, noIdenticon = false, onClick, returnIdentity, showChainLogo = false, showShortAddress, showSocial = true, style, subIdOnly = false, withShortAddress }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); @@ -153,13 +154,13 @@ function Identity ({ accountInfo, address, api, chain, direction = 'column', for } {withShortAddress && direction === 'column' && - + } {withShortAddress && direction === 'row' && - + } {_showSocial && diff --git a/packages/extension-polkagate/src/components/index.ts b/packages/extension-polkagate/src/components/index.ts index a85eb9831..0604cf6f0 100644 --- a/packages/extension-polkagate/src/components/index.ts +++ b/packages/extension-polkagate/src/components/index.ts @@ -6,6 +6,7 @@ export { default as AccountHolderWithProxy } from './AccountHolderWithProxy'; export { default as AccountInputWithIdentity } from './AccountInputWithIdentity'; export { default as AccountNamePasswordCreation } from './AccountNamePasswordCreation'; export { default as AccountsTable } from './AccountsTable'; +export { default as AccountWithProxyInConfirmation } from './AccountWithProxyInConfirmation'; export { default as ActionText } from './ActionText'; export { default as Address } from './Address'; export { default as AddressInput } from './AddressInput'; @@ -29,6 +30,7 @@ export { default as ColorContext } from './ColorContext'; export * from './contexts'; export { default as Convictions } from './Convictions'; export { default as CopyAddressButton } from './CopyAddressButton'; +export { default as DisplayInfo } from './DisplayInfo'; export { default as ErrorBoundary } from './ErrorBoundary'; export { default as FormatBalance } from './FormatBalance'; export { default as FormatBalance2 } from './FormatBalance2'; diff --git a/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Confirmation.tsx b/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Confirmation.tsx index ab3477977..874ddd0bf 100644 --- a/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Confirmation.tsx +++ b/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Confirmation.tsx @@ -1,18 +1,18 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { TxInfo } from '../../../util/types'; + import { Container, Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { PButton, ShortAddress } from '../../../components'; -import { useChainName, useToken, useTranslation } from '../../../hooks'; -import { SubTitle, ThroughProxy } from '../../../partials'; +import { AccountWithProxyInConfirmation, DisplayInfo, PButton, ShortAddress } from '../../../components'; +import { useInfo, useTranslation } from '../../../hooks'; +import { SubTitle } from '../../../partials'; import Explorer from '../../../popup/history/Explorer'; import FailSuccessIcon from '../../../popup/history/partials/FailSuccessIcon'; -import type { TxInfo } from '../../../util/types'; interface Props { address: string | undefined; @@ -21,34 +21,18 @@ interface Props { onPrimaryBtnClick: () => void; } -export default function Confirmation({ address, onPrimaryBtnClick, txInfo }: Props): React.ReactElement { +export default function Confirmation ({ address, onPrimaryBtnClick, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); - const token = useToken(address); - const chainName = useChainName(address); + const { chainName, token } = useInfo(address); const fee = txInfo.api.createType('Balance', txInfo.fee); - const DisplayInfo = ({ caption, showDivider = true, value }: { caption: string, value: string, showDivider?: boolean }) => { - return ( - - - {caption} - {value} - - {showDivider && - - - } - - ); - }; - return ( {txInfo?.failureText && @@ -56,22 +40,9 @@ export default function Confirmation({ address, onPrimaryBtnClick, txInfo }: Pro {txInfo.failureText} } - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + @@ -96,7 +67,7 @@ export default function Confirmation({ address, onPrimaryBtnClick, txInfo }: Pro } { - txInfo?.txHash && + txInfo?.txHash && chainName && diff --git a/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Review.tsx b/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Review.tsx index cca2b665a..194771e59 100644 --- a/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/accountDetails/unlock/Review.tsx @@ -138,7 +138,7 @@ export default function Review ({ address, api, classToUnlock, setDisplayPopup, selectedProxyAddress={selectedProxyAddress} showDivider style={{ mt: '-5px' }} - title={t('Account holder')} + title={t('Account')} /> { - return ( - - - {caption} - {value} - - {showDivider && - - - } - - ); - }; - return ( {txInfo?.failureText && @@ -60,22 +45,10 @@ export default function Confirmation ({ address, allCategoriesLength, delegateIn {txInfo.failureText} } - - - {status === 'Remove' ? t('Account holder') : t('Delegation from')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension-polkagate/src/fullscreen/governance/delegate/remove/RemoveDelegate.tsx b/packages/extension-polkagate/src/fullscreen/governance/delegate/remove/RemoveDelegate.tsx index 49a85487e..dc254919a 100644 --- a/packages/extension-polkagate/src/fullscreen/governance/delegate/remove/RemoveDelegate.tsx +++ b/packages/extension-polkagate/src/fullscreen/governance/delegate/remove/RemoveDelegate.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -11,20 +10,20 @@ import type { Balance } from '@polkadot/types/interfaces'; import type { Proxy, TxInfo } from '../../../../util/types'; +import type { AlreadyDelegateInformation, DelegateInformation} from '..'; import { Divider, Grid, Typography } from '@mui/material'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { BN_ONE, BN_ZERO } from '@polkadot/util'; -import { Identity, Motion, ShowValue, SignArea2, WrongPasswordAlert } from '../../../../components'; +import { AccountHolderWithProxy, Identity, Motion, ShowValue, SignArea2, WrongPasswordAlert } from '../../../../components'; import { useIdentity, useInfo, useTracks, useTranslation } from '../../../../hooks'; -import { ThroughProxy } from '../../../../partials'; import { PROXY_TYPE } from '../../../../util/constants'; import DisplayValue from '../../post/castVote/partial/DisplayValue'; import ReferendaTable from '../partial/ReferendaTable'; import TracksList from '../partial/TracksList'; -import { AlreadyDelegateInformation, DelegateInformation, STEPS } from '..'; +import { STEPS } from '..'; interface Props { address: string | undefined; @@ -39,25 +38,27 @@ interface Props { selectedProxy: Proxy | undefined; } -export default function RemoveDelegate({ address, classicDelegateInformation, formatted, mixedDelegateInformation, selectedProxy, setModalHeight, setSelectedTracksLength, setStep, setTxInfo, step }: Props): React.ReactElement { +export default function RemoveDelegate ({ address, classicDelegateInformation, formatted, mixedDelegateInformation, selectedProxy, setModalHeight, setSelectedTracksLength, setStep, setTxInfo, step }: Props): React.ReactElement { const { t } = useTranslation(); + const { api, chain, decimal, genesisHash, token } = useInfo(address); const { tracks } = useTracks(address); + const ref = useRef(null); + const delegateeAddress = classicDelegateInformation ? classicDelegateInformation.delegateeAddress : mixedDelegateInformation ? mixedDelegateInformation.delegatee : undefined; const delegateeName = useIdentity(genesisHash, delegateeAddress)?.identity?.display; - const ref = useRef(null); const [isPasswordError, setIsPasswordError] = useState(false); const [estimatedFee, setEstimatedFee] = useState(); const selectedProxyAddress = selectedProxy?.delegate as unknown as string; - const undelegate = api && api.tx['convictionVoting']['undelegate']; - const batch = api && api.tx['utility']['batchAll']; + const undelegate = api?.tx['convictionVoting']['undelegate']; + const batch = api?.tx['utility']['batchAll']; const delegatedTracks = useMemo(() => { if (classicDelegateInformation) { @@ -80,8 +81,8 @@ export default function RemoveDelegate({ address, classicDelegateInformation, fo }, [delegatedTracks]); useEffect(() => { - if (ref) { - setModalHeight(ref.current?.offsetHeight as number); + if (ref?.current?.offsetHeight) { + setModalHeight(ref.current.offsetHeight); } }, [setModalHeight]); @@ -94,7 +95,7 @@ export default function RemoveDelegate({ address, classicDelegateInformation, fo if (!api?.call?.['transactionPaymentApi']) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return setEstimatedFee(api?.createType('Balance', BN_ONE)); + return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } params.length === 1 @@ -128,27 +129,14 @@ export default function RemoveDelegate({ address, classicDelegateInformation, fo {isPasswordError && } - - - {t('Account Holder')} - - - - {selectedProxyAddress && - - - - } + @@ -156,7 +144,7 @@ export default function RemoveDelegate({ address, classicDelegateInformation, fo { - return ( - - - {caption} - {value} - - {showDivider && - - - } - - ); - }; - return ( {txInfo?.failureText && @@ -74,23 +57,9 @@ export default function Confirmation({ address, alterType, handleClose, txInfo, {txInfo.failureText} } - {/* */} - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension-polkagate/src/fullscreen/governance/post/castVote/Review.tsx b/packages/extension-polkagate/src/fullscreen/governance/post/castVote/Review.tsx index 7c3b1a38c..9727d4811 100644 --- a/packages/extension-polkagate/src/fullscreen/governance/post/castVote/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/governance/post/castVote/Review.tsx @@ -20,9 +20,8 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { BN_ZERO } from '@polkadot/util'; -import { Identity, Motion, ShowBalance, ShowValue, SignArea2, Warning, WrongPasswordAlert } from '../../../../components'; +import { AccountHolderWithProxy, Motion, ShowBalance, ShowValue, SignArea2, Warning, WrongPasswordAlert } from '../../../../components'; import { useInfo, useTranslation } from '../../../../hooks'; -import { ThroughProxy } from '../../../../partials'; import { PROXY_TYPE } from '../../../../util/constants'; import { ENDED_STATUSES, STATUS_COLOR } from '../../utils/consts'; import DisplayValue from './partial/DisplayValue'; @@ -46,7 +45,7 @@ interface Props { export default function Review ({ address, estimatedFee, selectedProxy, setModalHeight, setRefresh, setStep, setTxInfo, status, step, tx, txType, voteInformation }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); - const { api, chain, decimal, token } = useInfo(address); + const { chain, decimal, token } = useInfo(address); const ref = useRef(null); const [isPasswordError, setIsPasswordError] = useState(false); @@ -133,26 +132,13 @@ export default function Review ({ address, estimatedFee, selectedProxy, setModal {t('Think twice before removing your vote. It may affect the outcome.')} } - - - {t('Account holder')} - - - - {selectedProxyAddress && - - - - } + diff --git a/packages/extension-polkagate/src/fullscreen/governance/post/castVote/partial/DisplayValue.tsx b/packages/extension-polkagate/src/fullscreen/governance/post/castVote/partial/DisplayValue.tsx index 937fc4a2d..047a9eb1e 100644 --- a/packages/extension-polkagate/src/fullscreen/governance/post/castVote/partial/DisplayValue.tsx +++ b/packages/extension-polkagate/src/fullscreen/governance/post/castVote/partial/DisplayValue.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -15,7 +14,7 @@ interface Props { childrenFontSize?: string; } -export default function DisplayValue({ children, childrenFontSize = '28px', dividerHeight = '2px', title, topDivider = true }: Props): React.ReactElement { +export default function DisplayValue ({ children, childrenFontSize = '28px', dividerHeight = '2px', title, topDivider = true }: Props): React.ReactElement { return ( diff --git a/packages/extension-polkagate/src/fullscreen/governance/post/decisionDeposit/Confirmation.tsx b/packages/extension-polkagate/src/fullscreen/governance/post/decisionDeposit/Confirmation.tsx index e9dc44d67..b73bb2367 100644 --- a/packages/extension-polkagate/src/fullscreen/governance/post/decisionDeposit/Confirmation.tsx +++ b/packages/extension-polkagate/src/fullscreen/governance/post/decisionDeposit/Confirmation.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -9,9 +8,9 @@ import type { TxInfo } from '../../../../util/types'; import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { Motion, PButton, ShortAddress } from '../../../../components'; +import { AccountWithProxyInConfirmation, DisplayInfo, Motion, PButton, ShortAddress } from '../../../../components'; import { useTranslation } from '../../../../hooks'; -import { SubTitle, ThroughProxy } from '../../../../partials'; +import { SubTitle } from '../../../../partials'; import Explorer from '../../../../popup/history/Explorer'; import FailSuccessIcon from '../../../../popup/history/partials/FailSuccessIcon'; @@ -21,35 +20,20 @@ interface Props { refIndex: number; } -export default function Confirmation({ handleClose, refIndex, txInfo }: Props): React.ReactElement { +export default function Confirmation ({ handleClose, refIndex, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const chainName = txInfo.chain.name.replace(' Relay Chain', ''); const fee = txInfo.api.createType('Balance', txInfo.fee); const amount = txInfo.api.createType('Balance', txInfo.amount); - const DisplayInfo = ({ caption, showDivider = true, value }: { caption: string, value: string, showDivider?: boolean }) => { - return ( - - - {caption} - {value} - - {showDivider && - - - } - - ); - }; - return ( {txInfo?.failureText && @@ -71,23 +55,9 @@ export default function Confirmation({ handleClose, refIndex, txInfo }: Props): {txInfo.failureText} } - {/* */} - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension-polkagate/src/fullscreen/manageIdentity/Review.tsx b/packages/extension-polkagate/src/fullscreen/manageIdentity/Review.tsx index d067828e5..2524202e6 100644 --- a/packages/extension-polkagate/src/fullscreen/manageIdentity/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/manageIdentity/Review.tsx @@ -1,26 +1,24 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ -import type { Balance } from '@polkadot/types/interfaces'; +import type { ApiPromise } from '@polkadot/api'; +import type { DeriveAccountRegistration } from '@polkadot/api-derive/types'; +import type { Chain } from '@polkadot/extension-chains/types'; +//@ts-ignore import type { PalletIdentityLegacyIdentityInfo } from '@polkadot/types/lookup'; +import type { BN } from '@polkadot/util'; import type { BalancesInfo, Proxy, ProxyItem, TxInfo } from '../../util/types'; import { Close as CloseIcon } from '@mui/icons-material'; import { Divider, Grid, Typography, useTheme } from '@mui/material'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { ApiPromise } from '@polkadot/api'; -import type { DeriveAccountRegistration } from '@polkadot/api-derive/types'; -import type { Chain } from '@polkadot/extension-chains/types'; - import { PEOPLE_CHAINS, PROXY_TYPE } from '@polkadot/extension-polkagate/src/util/constants'; -import { BN, BN_ONE } from '@polkadot/util'; import { CanPayErrorAlert, Identity, Motion, ShowBalance, SignArea2, Warning, WrongPasswordAlert } from '../../components'; -import { useCanPayFeeAndDeposit, useInfo, useProxies } from '../../hooks'; +import { useCanPayFeeAndDeposit, useEstimatedFee, useInfo, useProxies } from '../../hooks'; import useTranslation from '../../hooks/useTranslation'; import { ThroughProxy } from '../../partials'; import { pgBoxShadow } from '../../util/utils'; @@ -53,7 +51,7 @@ interface Props { selectedRegistrarName: string | undefined; } -export default function Review({ address, api, chain, depositToPay, depositValue, identityToSet, infoParams, maxFeeAmount, mode, parentDisplay, selectedRegistrar, selectedRegistrarName, setRefresh, setStep, step, subIdsParams }: Props): React.ReactElement { +export default function Review ({ address, api, chain, depositToPay, depositValue, identityToSet, infoParams, maxFeeAmount, mode, parentDisplay, selectedRegistrar, selectedRegistrarName, setRefresh, setStep, step, subIdsParams }: Props): React.ReactElement { const { t } = useTranslation(); const { chainName, formatted } = useInfo(address); const proxies = useProxies(api, formatted); @@ -62,7 +60,6 @@ export default function Review({ address, api, chain, depositToPay, depositValue const isPeopleChainEnabled = PEOPLE_CHAINS.includes(chainName || ''); const isOnPeopleChain = chainName?.toLowerCase()?.includes('people'); - const [estimatedFee, setEstimatedFee] = useState(); const [txInfo, setTxInfo] = useState(); const [isPasswordError, setIsPasswordError] = useState(false); const [selectedProxy, setSelectedProxy] = useState(); @@ -71,17 +68,15 @@ export default function Review({ address, api, chain, depositToPay, depositValue const selectedProxyAddress = selectedProxy?.delegate as unknown as string; - const feeAndDeposit = useCanPayFeeAndDeposit(formatted?.toString(), selectedProxyAddress, estimatedFee, depositToPay, balances); - - const setIdentity = api && api.tx['identity']['setIdentity']; - const clearIdentity = api && api.tx['identity']['clearIdentity']; - const setSubs = api && api.tx['identity']['setSubs']; - const requestJudgement = api && api.tx['identity']['requestJudgement']; - const cancelRequest = api && api.tx['identity']['cancelRequest']; + const setIdentity = api?.tx['identity']['setIdentity']; + const clearIdentity = api?.tx['identity']['clearIdentity']; + const setSubs = api?.tx['identity']['setSubs']; + const requestJudgement = api?.tx['identity']['requestJudgement']; + const cancelRequest = api?.tx['identity']['cancelRequest']; useEffect(() => { - formatted && api && api.derive.balances?.all(formatted).then((b) => { - setBalances(b); + formatted && api?.derive.balances?.all(formatted).then((b) => { + setBalances(b as BalancesInfo); }); }, [api, formatted]); @@ -92,6 +87,7 @@ export default function Review({ address, api, chain, depositToPay, depositValue return subIdsParams.map((subs) => ({ address: subs[0], + //@ts-ignore name: subs[1]?.raw as string })) as SubIdAccountsToSubmit; }, [mode, subIdsParams]); @@ -124,29 +120,15 @@ export default function Review({ address, api, chain, depositToPay, depositValue return undefined; }, [cancelRequest, clearIdentity, infoParams, maxFeeAmount, mode, requestJudgement, selectedRegistrar, setIdentity, setSubs, subIdsParams]); + const estimatedFee = useEstimatedFee(address, tx); + const feeAndDeposit = useCanPayFeeAndDeposit(formatted?.toString(), selectedProxyAddress, estimatedFee, depositToPay, balances); + useEffect((): void => { const fetchedProxyItems = proxies?.map((p: Proxy) => ({ proxy: p, status: 'current' })) as ProxyItem[]; setProxyItems(fetchedProxyItems); }, [proxies]); - useEffect(() => { - if (!formatted || !tx) { - return; - } - - if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); - } - - tx.paymentInfo(formatted) - .then((i) => setEstimatedFee(i?.partialFee)) - .catch((error) => { - console.error(' error while fetching fee:', error); - setEstimatedFee(api?.createType('Balance', BN_ONE)); - }); - }, [api, formatted, tx]); - const extraInfo = useMemo(() => ({ action: 'Manage Identity', fee: String(estimatedFee || 0), @@ -240,7 +222,7 @@ export default function Review({ address, api, chain, depositToPay, depositValue {mode === 'ManageSubId' ? t('Parent account') - : t('Account holder')} + : t('Account')} { - return ( - <>{value && - - - {caption} - {value} - - {showDivider && - - - } - - } - ); - }; - const ManageIdentityDetail = () => ( <> ); @@ -110,7 +84,7 @@ export default function Confirmation({ SubIdentityAccounts, handleClose, identit {txInfo?.failureText && @@ -118,35 +92,15 @@ export default function Confirmation({ SubIdentityAccounts, handleClose, identit {txInfo.failureText} } - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + {(status === 'Modify' || status === 'Set') && } - {/* {status === 'Clear' && - - {txInfo.success - ? t('Identity cleared.') - : t('Identity not cleared.')} - - } */} {status === 'ManageSubId' && SubIdentityAccounts && SubIdentityAccounts.length > 0 && } diff --git a/packages/extension-polkagate/src/fullscreen/manageProxies/Confirmation.tsx b/packages/extension-polkagate/src/fullscreen/manageProxies/Confirmation.tsx index fb09cef33..a24883932 100644 --- a/packages/extension-polkagate/src/fullscreen/manageProxies/Confirmation.tsx +++ b/packages/extension-polkagate/src/fullscreen/manageProxies/Confirmation.tsx @@ -1,19 +1,17 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { BN } from '@polkadot/util'; import type { ProxyItem, TxInfo } from '../../util/types'; import { Divider, Grid, Typography, useTheme } from '@mui/material'; import React, { useCallback, useContext } from 'react'; -import { BN } from '@polkadot/util'; - -import { AccountContext, Motion, PButton, ShortAddress, ShowBalance } from '../../components'; +import { AccountContext, AccountWithProxyInConfirmation, DisplayInfo, Motion, PButton, ShortAddress, ShowBalance } from '../../components'; import { useChainName, useTranslation } from '../../hooks'; -import { SubTitle, ThroughProxy } from '../../partials'; +import { SubTitle } from '../../partials'; import Explorer from '../../popup/history/Explorer'; import FailSuccessIcon from '../../popup/history/partials/FailSuccessIcon'; import { getSubstrateAddress, pgBoxShadow } from '../../util/utils'; @@ -26,7 +24,7 @@ interface Props { proxyItems: ProxyItem[]; } -export default function Confirmation({ address, depositAmount, handleClose, proxyItems, txInfo }: Props): React.ReactElement { +export default function Confirmation ({ address, depositAmount, handleClose, proxyItems, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); const chainName = useChainName(address); @@ -36,28 +34,13 @@ export default function Confirmation({ address, depositAmount, handleClose, prox const fee = txInfo.api.createType('Balance', txInfo.fee); - const DisplayInfo = ({ caption, showDivider = true, value }: { caption: string, value: string, showDivider?: boolean }) => { - return ( - - - {caption} - {value} - - {showDivider && - - - } - - ); - }; - return ( {txInfo?.failureText && @@ -65,22 +48,9 @@ export default function Confirmation({ address, depositAmount, handleClose, prox {txInfo.failureText} } - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + {proxyItems.map(({ proxy, status }, index) => { diff --git a/packages/extension-polkagate/src/fullscreen/sendFund/Confirmation.tsx b/packages/extension-polkagate/src/fullscreen/sendFund/Confirmation.tsx index c1d60b410..99140a1ab 100644 --- a/packages/extension-polkagate/src/fullscreen/sendFund/Confirmation.tsx +++ b/packages/extension-polkagate/src/fullscreen/sendFund/Confirmation.tsx @@ -80,7 +80,7 @@ export default function Confirmation ({ handleDone, txInfo }: Props): React.Reac {txInfo?.failureText && diff --git a/packages/extension-polkagate/src/fullscreen/socialRecovery/Review.tsx b/packages/extension-polkagate/src/fullscreen/socialRecovery/Review.tsx index 34d7e1963..b506ccc73 100644 --- a/packages/extension-polkagate/src/fullscreen/socialRecovery/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/socialRecovery/Review.tsx @@ -1,12 +1,20 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { ApiPromise } from '@polkadot/api'; +import type { SubmittableExtrinsic } from '@polkadot/api/types'; +import type { DeriveAccountInfo } from '@polkadot/api-derive/types'; +import type { Chain } from '@polkadot/extension-chains/types'; import type { Balance } from '@polkadot/types/interfaces'; +//@ts-ignore import type { PalletRecoveryRecoveryConfig } from '@polkadot/types/lookup'; +import type { ISubmittableResult } from '@polkadot/types/types'; +import type { BN } from '@polkadot/util'; +import type { ActiveRecoveryFor } from '../../hooks/useActiveRecoveries'; import type { Proxy, TxInfo } from '../../util/types'; +import type { AddressWithIdentity } from './components/SelectTrustedFriend'; import type { InitiateRecoveryConfig, RecoveryConfigType, SocialRecoveryModes, WithdrawInfo } from './util/types'; import { faShieldHalved } from '@fortawesome/free-solid-svg-icons'; @@ -15,16 +23,10 @@ import { MoreVert as MoreVertIcon } from '@mui/icons-material'; import { Divider, Grid, Skeleton, Typography, useTheme } from '@mui/material'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { ApiPromise } from '@polkadot/api'; -import type { SubmittableExtrinsic } from '@polkadot/api/types'; -import type { Chain } from '@polkadot/extension-chains/types'; - -import type { ISubmittableResult } from '@polkadot/types/types'; -import { BN, BN_ONE, BN_ZERO } from '@polkadot/util'; +import { BN_ONE, BN_ZERO } from '@polkadot/util'; import { CanPayErrorAlert, EndRecoveryIcon, Identity, Infotip2, MakeRecoverableIcon, Motion, RescueRecoveryIcon, ShortAddress, ShowBalance, SignArea2, VouchRecoveryIcon, Warning, WrongPasswordAlert } from '../../components'; import { useCanPayFeeAndDeposit, useCurrentBlockNumber, useInfo } from '../../hooks'; -import type { ActiveRecoveryFor } from '../../hooks/useActiveRecoveries'; import useTranslation from '../../hooks/useTranslation'; import { ThroughProxy } from '../../partials'; import blockToDate from '../../popup/crowdloans/partials/blockToDate'; @@ -33,12 +35,10 @@ import { pgBoxShadow } from '../../util/utils'; import WaitScreen from '../governance/partials/WaitScreen'; import DisplayValue from '../governance/post/castVote/partial/DisplayValue'; import { toTitleCase } from '../governance/utils/util'; -import type { AddressWithIdentity } from './components/SelectTrustedFriend'; import Confirmation from './partial/Confirmation'; import TrustedFriendsDisplay from './partial/TrustedFriendsDisplay'; import recoveryDelayPeriod from './util/recoveryDelayPeriod'; import { STEPS } from '.'; -import type { DeriveAccountInfo } from '@polkadot/api-derive/types'; interface Props { address: string; @@ -62,7 +62,7 @@ interface Props { const dateTimeFormat = { day: 'numeric', hour: '2-digit', hourCycle: 'h23', minute: '2-digit', month: 'short' } as Intl.DateTimeFormatOptions; -export default function Review({ activeLost, address, allActiveRecoveries, api, chain, depositValue, lostAccountAddress, mode, recoveryConfig, recoveryInfo, setMode, setRefresh, setStep, specific, step, vouchRecoveryInfo, withdrawInfo }: Props): React.ReactElement { +export default function Review ({ activeLost, address, allActiveRecoveries, api, chain, depositValue, lostAccountAddress, mode, recoveryConfig, recoveryInfo, setMode, setRefresh, setStep, specific, step, vouchRecoveryInfo, withdrawInfo }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); const { chainName, decimal, formatted } = useInfo(address); @@ -76,22 +76,22 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, const selectedProxyAddress = selectedProxy?.delegate as unknown as string; - const batchAll = api && api.tx['utility']['batchAll']; - const removeRecovery = api && api.tx['recovery']['removeRecovery']; - const createRecovery = api && api.tx['recovery']['createRecovery']; - const initiateRecovery = api && api.tx['recovery']['initiateRecovery']; - const closeRecovery = api && api.tx['recovery']['closeRecovery']; - const vouchRecovery = api && api.tx['recovery']['vouchRecovery']; - const claimRecovery = api && api.tx['recovery']['claimRecovery']; - const asRecovered = api && api.tx['recovery']['asRecovered']; - const chill = api && api.tx['staking']['chill']; - const unbonded = api && api.tx['staking']['unbond']; - const redeem = api && api.tx['staking']['withdrawUnbonded']; - const poolRedeem = api && api.tx['nominationPools']['withdrawUnbonded']; - const transferAll = api && api.tx['balances']['transferAll']; // [rescuer.accountId, false] - const clearIdentity = api && api.tx['identity']['clearIdentity']; - const removeProxies = api && api.tx['proxy']['removeProxies']; - const unbond = api && api.tx['nominationPools']['unbond']; + const batchAll = api?.tx['utility']['batchAll']; + const removeRecovery = api?.tx['recovery']['removeRecovery']; + const createRecovery = api?.tx['recovery']['createRecovery']; + const initiateRecovery = api?.tx['recovery']['initiateRecovery']; + const closeRecovery = api?.tx['recovery']['closeRecovery']; + const vouchRecovery = api?.tx['recovery']['vouchRecovery']; + const claimRecovery = api?.tx['recovery']['claimRecovery']; + const asRecovered = api?.tx['recovery']['asRecovered']; + const chill = api?.tx['staking']['chill']; + const unbonded = api?.tx['staking']['unbond']; + const redeem = api?.tx['staking']['withdrawUnbonded']; + const poolRedeem = api?.tx['nominationPools']['withdrawUnbonded']; + const transferAll = api?.tx['balances']['transferAll']; // [rescuer.accountId, false] + const clearIdentity = api?.tx['identity']['clearIdentity']; + const removeProxies = api?.tx['proxy']['removeProxies']; + const unbond = api?.tx['nominationPools']['unbond']; const depositToPay = useMemo(() => { if (['CloseRecovery', 'RemoveRecovery', 'VouchRecovery', 'Withdraw'].includes(mode ?? '')) { @@ -175,7 +175,7 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, } if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); + return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } // eslint-disable-next-line no-void @@ -236,8 +236,8 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, div:not(:last-child)': { borderBottom: '1px solid', borderBottomColor: 'secondary.light' } }}> {step === STEPS.REVIEW - ? t('Funds available to be withdrawn now') - : t('Withdrawn Funds')} + ? t('Funds available to be withdrawn now') + : t('Withdrawn Funds')} {toBeWithdrawn.map((item, index) => ( @@ -258,8 +258,8 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, div:not(:last-child)': { borderBottom: '1px solid', borderBottomColor: 'secondary.light' } }}> {step === STEPS.REVIEW - ? t('Funds available to withdraw later') - : t('Funds will be withdrawn later')} + ? t('Funds available to withdraw later') + : t('Funds will be withdrawn later')} {toBeWithdrawnLater.map((item, index) => ( @@ -304,7 +304,7 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, <> div:not(:last-child)': { borderBottom: '1px solid', borderBottomColor: 'background.paper' } }}> - {lostAccountAddress?.friends && lostAccountAddress.friends.addresses.map((friend, index) => + {lostAccountAddress?.friends?.addresses.map((friend, index) => {`Trusted friend ${index + 1}`}: @@ -453,8 +453,8 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, {mode === 'InitiateRecovery' || mode === 'VouchRecovery' - ? t('Rescuer account') - : t('Account holder')} + ? t('Rescuer account') + : t('Account')} String(friend))} /> @@ -524,7 +525,7 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, ? vouchRecoveryInfo?.lost.accountIdentity : undefined} api={api} - chain={chain as any} + chain={chain} direction='row' formatted={mode === 'InitiateRecovery' || mode === 'Withdraw' ? lostAccountAddress?.address @@ -552,7 +553,7 @@ export default function Review({ activeLost, address, allActiveRecoveries, api, ('Releasing deposit') + ? t('Releasing deposit') : mode === 'InitiateRecovery' - ? t('Initiation Deposit') + ? t('Initiation Deposit') : mode === 'CloseRecovery' - ? t('Deposit they made') + ? t('Deposit they made') : mode === 'Withdraw' - ? t('Initiation recovery deposit to be released') - : t('Total Deposit')} + ? t('Initiation recovery deposit to be released') + : t('Total Deposit')} > { - return ( - <>{value && - - - {caption} - {value} - - {showDivider && - - - } - - } - ); -}; - -export default function Confirmation({ WithdrawDetails, activeLost, decimal, depositValue, handleClose, lostAccountAddress, mode, recoveryConfig, txInfo, vouchRecoveryInfo }: Props): React.ReactElement { +export default function Confirmation ({ WithdrawDetails, activeLost, decimal, depositValue, handleClose, lostAccountAddress, mode, recoveryConfig, txInfo, vouchRecoveryInfo }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); const token = useToken(txInfo.from.address); @@ -98,16 +72,16 @@ export default function Confirmation({ WithdrawDetails, activeLost, decimal, dep const MakeRecoverableDetail = () => ( <> - {(mode === 'SetRecovery' || mode === 'ModifyRecovery') && recoveryConfig && - recoveryConfig.friends.addresses.map((friend, index) => ( - - - - ))} + {(mode === 'SetRecovery' || mode === 'ModifyRecovery') && + recoveryConfig?.friends.addresses.map((friend, index) => ( + + + + ))} @@ -131,7 +105,7 @@ export default function Confirmation({ WithdrawDetails, activeLost, decimal, dep {txInfo?.failureText && @@ -147,7 +121,7 @@ export default function Confirmation({ WithdrawDetails, activeLost, decimal, dep : vouchRecoveryInfo?.rescuer.address} title={mode === 'VouchRecovery' ? t('Rescuer account') - : t('Account holder')} + : t('Account')} /> {txInfo.throughProxy && diff --git a/packages/extension-polkagate/src/fullscreen/socialRecovery/partial/LostAccountRecoveryInfo.tsx b/packages/extension-polkagate/src/fullscreen/socialRecovery/partial/LostAccountRecoveryInfo.tsx index a0cb20755..b40988c32 100644 --- a/packages/extension-polkagate/src/fullscreen/socialRecovery/partial/LostAccountRecoveryInfo.tsx +++ b/packages/extension-polkagate/src/fullscreen/socialRecovery/partial/LostAccountRecoveryInfo.tsx @@ -1,9 +1,10 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ import type { DeriveAccountInfo } from '@polkadot/api-derive/types'; +import type { AccountId } from '@polkadot/types/interfaces'; +//@ts-ignore import type { PalletRecoveryRecoveryConfig } from '@polkadot/types/lookup'; import { Divider, Grid, type SxProps, type Theme, Typography, useTheme } from '@mui/material'; @@ -11,11 +12,10 @@ import React from 'react'; import { BN } from '@polkadot/util'; -import { Progress, ShortAddress, Warning } from '../../../components'; +import { DisplayInfo, Progress, ShortAddress, Warning } from '../../../components'; import { useTranslation } from '../../../hooks'; import { amountToHuman } from '../../../util/utils'; import recoveryDelayPeriod from '../util/recoveryDelayPeriod'; -import { DisplayInfo } from './Confirmation'; interface Props { accountsInfo: DeriveAccountInfo[] | undefined; @@ -25,7 +25,7 @@ interface Props { token: string | undefined; } -export default function LostAccountRecoveryInfo({ accountsInfo, decimal, lostAccountRecoveryInfo, style, token }: Props): React.ReactElement { +export default function LostAccountRecoveryInfo ({ accountsInfo, decimal, lostAccountRecoveryInfo, style, token }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); @@ -42,22 +42,22 @@ export default function LostAccountRecoveryInfo({ accountsInfo, decimal, lostAcc isBelowInput theme={theme} > - {t('This account is not recoverable, try another address.')} + {t('This account is not recoverable, try another address.')} } {lostAccountRecoveryInfo && - {t('This account is recoverable with the following details.')} + {t('This account is recoverable with the following details.')} - {lostAccountRecoveryInfo.friends.map((friend, index) => { + {lostAccountRecoveryInfo.friends.map((friend: AccountId, index: number) => { const friendID = accountsInfo?.find((info) => String(info.accountId) === String(friend))?.identity.display; return ( - {t(`Trusted friend ${index + 1}`)}: + {t(`Trusted friend ${index + 1}`)}: {friendID && @@ -73,17 +73,17 @@ export default function LostAccountRecoveryInfo({ accountsInfo, decimal, lostAcc ('Threshold:')} + caption={t('Threshold:')} fontSize='20px' value={`${lostAccountRecoveryInfo.threshold.toNumber()} of ${lostAccountRecoveryInfo.friends.length}`} /> ('Delay:')} + caption={t('Delay:')} fontSize='20px' value={recoveryDelayPeriod(lostAccountRecoveryInfo.delayPeriod.toNumber())} /> ('Deposited:')} + caption={t('Deposited:')} fontSize='20px' showDivider={false} value={`${amountToHuman(new BN(lostAccountRecoveryInfo.deposit.toString()), decimal, 4)} ${token ?? ''}`} diff --git a/packages/extension-polkagate/src/fullscreen/stake/easyMode/Confirmation.tsx b/packages/extension-polkagate/src/fullscreen/stake/easyMode/Confirmation.tsx index cf8ce378f..2722d2f3e 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/easyMode/Confirmation.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/easyMode/Confirmation.tsx @@ -83,7 +83,7 @@ export default function Confirmation ({ handleDone, txInfo }: Props): React.Reac {txInfo?.failureText && diff --git a/packages/extension-polkagate/src/fullscreen/stake/easyMode/Review.tsx b/packages/extension-polkagate/src/fullscreen/stake/easyMode/Review.tsx index 63dfcb42e..8e2800fbb 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/easyMode/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/easyMode/Review.tsx @@ -75,7 +75,7 @@ export default function Review ({ address, balances, inputs, setRefresh, setStep } - + void; } +const Div = () => ( + + + +); + export default function Confirmation ({ handleDone, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const { chainName, formatted, token } = useInfo(txInfo.from.address); @@ -39,32 +45,12 @@ export default function Confirmation ({ handleDone, txInfo }: Props): React.Reac const destinationAccountName = useAccountName(maybePayeeAddress); - const Div = () => ( - - - - ); - - const DisplayInfo = ({ caption, showDivider = true, value }: { caption: string, value: string, showDivider?: boolean }) => { - return ( - - - {caption} - {value} - - {showDivider && -
- } - - ); - }; - return ( {txInfo?.failureText && @@ -72,26 +58,9 @@ export default function Confirmation ({ handleDone, txInfo }: Props): React.Reac {txInfo.failureText} } - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - {!txInfo.throughProxy && -
- } - - {txInfo.throughProxy && - - -
- - } + {txInfo?.payee && <> diff --git a/packages/extension-polkagate/src/fullscreen/stake/partials/Review.tsx b/packages/extension-polkagate/src/fullscreen/stake/partials/Review.tsx index b15bc3ccc..010f3a478 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/partials/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/partials/Review.tsx @@ -127,7 +127,7 @@ export default function Review ({ address, inputs, onClose, setRefresh, setStep, chain={chain} selectedProxyAddress={selectedProxyAddress} style={{ mt: 'auto' }} - title={t('Account holder')} + title={t('Account')} /> <> {inputs?.extraInfo?.['payee'] && diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/SetState.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/SetState.tsx index 1a8a6d5a7..8eb1cf2a8 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/SetState.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/SetState.tsx @@ -17,9 +17,8 @@ import { DraggableModal } from '@polkadot/extension-polkagate/src/fullscreen/gov import WaitScreen from '@polkadot/extension-polkagate/src/fullscreen/governance/partials/WaitScreen'; import { BN_ONE } from '@polkadot/util'; -import { ShortAddress } from '../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../components'; import { useTranslation } from '../../../../hooks'; -import { ThroughProxy } from '../../../../partials'; import Review from '../../partials/Review'; import { ModalTitle } from '../../solo/commonTasks/configurePayee'; import Confirmation from '../partials/Confirmation'; @@ -64,9 +63,9 @@ export default function SetState ({ address, api, formatted, onClose, pool, setR return; } - const batchAll = api && api.tx['utility']['batchAll']; - const chilled = api && api.tx['nominationPools']['chill']; - const poolSetState = api && api.tx['nominationPools']['setState']; // (poolId, state) + const batchAll = api?.tx['utility']['batchAll']; + const chilled = api?.tx['nominationPools']['chill']; + const poolSetState = api?.tx['nominationPools']['setState']; // (poolId, state) const poolId = pool.poolId.toString(); @@ -137,30 +136,13 @@ export default function SetState ({ address, api, formatted, onClose, pool, setR txInfo={txInfo} > <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} @@ -169,7 +151,7 @@ export default function SetState ({ address, api, formatted, onClose, pool, setR - {t('New pool state:')} + {t('New pool state')}: {state} diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/Review.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/Review.tsx index bef71750e..0b86b364e 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/Review.tsx @@ -141,7 +141,7 @@ export default function Review ({ address, api, chain, changes, formatted, pool, chain={chain} selectedProxyAddress={selectedProxyAddress} style={{ mt: 'auto' }} - title={t('Account holder')} + title={t('Account')} /> {changes?.newPoolName !== undefined && diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/TxDetail.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/TxDetail.tsx index d0c0befdc..98394da0f 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/TxDetail.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/TxDetail.tsx @@ -1,24 +1,23 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ -import { Divider, Grid, Typography } from '@mui/material'; +import type { TxInfo } from '../../../../../util/types'; +import type { ChangesProps } from '.'; + +import { Divider } from '@mui/material'; import React, { useMemo } from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation, DisplayInfo } from '../../../../../components'; import { useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { TxInfo } from '../../../../../util/types'; -import { ChangesProps } from '.'; interface Props { txInfo: TxInfo; changes: ChangesProps | undefined; } -export default function TxDetail({ changes, txInfo }: Props): React.ReactElement { +export default function TxDetail ({ changes, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const changedRoles = useMemo(() => { @@ -44,43 +43,11 @@ export default function TxDetail({ changes, txInfo }: Props): React.ReactElement return _changes; }, [changes?.commission]); - const DisplayInfo = ({ caption, showDivider = true, value }: { caption: string, value: string | number, showDivider?: boolean }) => { - return ( - - - {caption}: - {value} - - {showDivider && - - - } - - ); - }; - return ( <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + {changes?.newPoolName !== undefined && 10 ? `${String(value).slice(0, 4)} ... ${String(value).slice(-4)}` : value - : value ?? t('Removed') + : value as unknown as string ?? t('Removed') } /> )} diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/index.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/index.tsx index d095eb674..91e03efb6 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/index.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/editPool/index.tsx @@ -1,27 +1,25 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ -import type { MyPoolInfo, Proxy, TxInfo } from '../../../../../util/types'; +import type { ApiPromise } from '@polkadot/api'; +import type { Chain } from '@polkadot/extension-chains/types'; +import type { MyPoolInfo, TxInfo } from '../../../../../util/types'; import { faPenToSquare } from '@fortawesome/free-solid-svg-icons'; import React, { useState } from 'react'; -import { ApiPromise } from '@polkadot/api'; -import type { Chain } from '@polkadot/extension-chains/types'; - import { DraggableModal } from '@polkadot/extension-polkagate/src/fullscreen/governance/components/DraggableModal'; import WaitScreen from '@polkadot/extension-polkagate/src/fullscreen/governance/partials/WaitScreen'; import { useFormatted, useTranslation } from '../../../../../hooks'; import { ModalTitle } from '../../../solo/commonTasks/configurePayee'; import Confirmation from '../../partials/Confirmation'; +import { STEPS } from '../../stake'; import Edit from './Edit'; import Review from './Review'; import TxDetail from './TxDetail'; -import { STEPS } from '../../stake'; interface Props { address: string; @@ -45,7 +43,7 @@ export interface ChangesProps { } | undefined } -export default function ManageEditPool({ address, api, chain, onClose, pool, setRefresh }: Props): React.ReactElement { +export default function ManageEditPool ({ address, api, chain, onClose, pool, setRefresh }: Props): React.ReactElement { const { t } = useTranslation(); const formatted = useFormatted(address); diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/TxDetail.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/TxDetail.tsx index 1dbe03cae..7070b044f 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/TxDetail.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/TxDetail.tsx @@ -1,16 +1,15 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { MyPoolInfo, TxInfo } from '../../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../../components'; import { useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { MyPoolInfo, TxInfo } from '../../../../../util/types'; interface Props { txInfo: TxInfo; @@ -18,35 +17,18 @@ interface Props { token: string | undefined; } -export default function TxDetail({ pool, token, txInfo }: Props): React.ReactElement { +export default function TxDetail ({ pool, token, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); return ( <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} @@ -55,7 +37,7 @@ export default function TxDetail({ pool, token, txInfo }: Props): React.ReactEle - {t('Unstaked')}: + {t('Unstaked')}: {`${txInfo?.amount || ''} ${token || ''}`} diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/index.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/index.tsx index 4abac1445..4c6b5fb58 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/index.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/leavePool/index.tsx @@ -68,7 +68,7 @@ export default function LeavePool ({ address, onClose, pool, setRefresh }: Props }), [decimal, estimatedFee, redeemDate, staked, t, token]); useEffect(() => { - api && api.query['staking']['slashingSpans'](formatted).then((optSpans: any) => { + api?.query['staking']['slashingSpans'](formatted).then((optSpans: any) => { const _spanCount = optSpans.isNone ? 0 : optSpans.unwrap().prior.length + 1; setSpanCount(_spanCount as number); diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/removeAll/Review.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/removeAll/Review.tsx index 48f63baad..4058224c4 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/removeAll/Review.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/commonTasks/removeAll/Review.tsx @@ -151,10 +151,10 @@ export default function Review ({ address, api, chain, mode, pool, poolMembers, } {mode === 'UnbondAll' @@ -172,7 +172,7 @@ export default function Review ({ address, api, chain, mode, pool, poolMembers, } { export type Mode = 'UnbondAll' | 'RemoveAll'; -export default function RemoveAll({ address, api, chain, onClose, pool, setRefresh }: Props): React.ReactElement { +export default function RemoveAll ({ address, api, chain, onClose, pool, setRefresh }: Props): React.ReactElement { const { t } = useTranslation(); const formatted = useFormatted(address); @@ -132,7 +130,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre }, [remainingEraToKick, needsUnboundAll, members, sessionInfo, sessionInfo?.currentEra]); useEffect(() => { - api && api.derive.session?.progress().then((sessionInfo) => { + api?.derive.session?.progress().then((sessionInfo) => { setSessionInfo({ currentEra: Number(sessionInfo.currentEra), eraLength: Number(sessionInfo.eraLength), @@ -166,13 +164,13 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre const RemainingTime = () => ( - {t('Time left to be able to remove all')} + {t('Time left to be able to remove all')} - {remainingTimeCounter?.dayCounter > 0 && + {remainingTimeCounter?.dayCounter && remainingTimeCounter.dayCounter > 0 && - {remainingTimeCounter?.dayCounter > 1 - ? t('days and') - : t('day and')} + {remainingTimeCounter.dayCounter > 1 + ? t('days and') + : t('day and')} } @@ -220,7 +218,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre <> - {t('To remove all members')}: + {t('To remove all members')}: {status > 1 @@ -229,7 +227,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre 1 } - {t('Unstake all members’ tokens')} + {t('Unstake all members’ tokens')} @@ -239,7 +237,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre : } - {t('Wait for unstaking locking period')} + {t('Wait for unstaking locking period')} @@ -249,7 +247,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre : } - {t('Come back here, and remove all')} + {t('Come back here, and remove all')} @@ -259,7 +257,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre - {t('Loading pool members information...')} + {t('Loading pool members information...')} } @@ -274,7 +272,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre _mt='0' _onClick={goUnstakeAll} disabled={!needsUnboundAll} - text={t('Unstake All ({{members}})', { replace: { members: (poolMembers && poolMembers.length - 1) ?? '...' } })} + text={t('Unstake All ({{members}})', { replace: { members: (poolMembers && poolMembers.length - 1) ?? '...' } })} /> } {(status !== 4) && @@ -283,8 +281,8 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre _ml={0} _mt='20px' _onClick={goRemoveAll} - disabled={!members || RemoveAllBtnDisabled} - text={t('Remove All')} + disabled={!members || !!RemoveAllBtnDisabled} + text={t('Remove All')} /> } @@ -293,7 +291,7 @@ export default function RemoveAll({ address, api, chain, onClose, pool, setRefre <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/partials/Confirmation.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/partials/Confirmation.tsx index c2f4de5e8..0da0eb2e3 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/partials/Confirmation.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/partials/Confirmation.tsx @@ -1,17 +1,17 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ -import { Divider, Grid, Typography } from '@mui/material'; +import type { TxInfo } from '../../../../util/types'; + +import { Grid, Typography } from '@mui/material'; import React from 'react'; -import { Motion, PButton, ShortAddress } from '../../../../components'; +import { DisplayInfo, Motion, PButton, ShortAddress } from '../../../../components'; import { useTranslation } from '../../../../hooks'; import Explorer from '../../../../popup/history/Explorer'; import FailSuccessIcon from '../../../../popup/history/partials/FailSuccessIcon'; -import type { TxInfo } from '../../../../util/types'; interface Props { txInfo: TxInfo; @@ -22,32 +22,17 @@ interface Props { const unAvailableSpace = 120; -export default function Confirmation({ children, handleClose, popupHeight, txInfo }: Props): React.ReactElement { +export default function Confirmation ({ children, handleClose, popupHeight, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const chainName = txInfo.chain.name.replace(' Relay Chain', ''); const fee = txInfo.api.createType('Balance', txInfo.fee); - const DisplayInfo = ({ caption, showDivider = true, value }: { caption: string, value: string, showDivider?: boolean }) => { - return ( - - - {caption} - {value} - - {showDivider && - - - } - - ); - }; - return ( {txInfo?.failureText && diff --git a/packages/extension-polkagate/src/hooks/useEstimatedFee.ts b/packages/extension-polkagate/src/hooks/useEstimatedFee.ts index 00ef8ed15..721bf881f 100644 --- a/packages/extension-polkagate/src/hooks/useEstimatedFee.ts +++ b/packages/extension-polkagate/src/hooks/useEstimatedFee.ts @@ -1,9 +1,9 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { SubmittableExtrinsicFunction } from '@polkadot/api/types'; +import type { SubmittableExtrinsic, SubmittableExtrinsicFunction } from '@polkadot/api/types'; import type { Balance } from '@polkadot/types/interfaces'; -import type { AnyTuple } from '@polkadot/types/types'; +import type { AnyTuple, ISubmittableResult } from '@polkadot/types/types'; import { useEffect, useState } from 'react'; @@ -11,13 +11,19 @@ import { BN_ONE } from '@polkadot/util'; import { useInfo } from '.'; -export default function useEstimatedFee (address: string | undefined, call?: SubmittableExtrinsicFunction<'promise', AnyTuple>, params?: unknown[] | (() => unknown)[]): Balance | undefined { +export default function useEstimatedFee (address: string | undefined, call?: SubmittableExtrinsicFunction<'promise', AnyTuple> | SubmittableExtrinsic<'promise', ISubmittableResult>, params?: unknown[] | (() => unknown)[]): Balance | undefined { const { api } = useInfo(address); const [estimatedFee, setEstimatedFee] = useState(); useEffect(() => { - if (!address || !call || !params) { + if (!address || !call) { + return; + } + + const isFunction = typeof call === 'function'; + + if (isFunction && !params) { return; } @@ -25,8 +31,9 @@ export default function useEstimatedFee (address: string | undefined, call?: Sub return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } - call(...params) - .paymentInfo(address) + const _call = isFunction ? call(...params || []) : call; + + _call.paymentInfo(address) .then( (i) => setEstimatedFee(i?.partialFee && api.createType('Balance', i.partialFee) as Balance) ).catch(console.error); diff --git a/packages/extension-polkagate/src/partials/Asset.tsx b/packages/extension-polkagate/src/partials/Asset.tsx index e1e3718dc..69676464a 100644 --- a/packages/extension-polkagate/src/partials/Asset.tsx +++ b/packages/extension-polkagate/src/partials/Asset.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -10,14 +9,13 @@ * */ import type { ApiPromise } from '@polkadot/api'; -import type { DeriveBalancesAll } from '@polkadot/api-derive/types'; import type { Balance } from '@polkadot/types/interfaces'; +import type { BN } from '@polkadot/util'; +import type { BalancesInfo } from '../util/types'; import { Grid, type SxProps, type Theme, useTheme } from '@mui/material'; import React from 'react'; -import { BN } from '@polkadot/util'; - import { ChainLogo } from '../components'; import { useChain, useTranslation } from '../hooks'; import BalanceFee from '../popup/send/partial/BalanceFee'; @@ -26,14 +24,14 @@ interface Props { address?: string; api: ApiPromise | undefined; balance?: BN | null; - balances?: DeriveBalancesAll | null | undefined; + balances?: BalancesInfo | null | undefined; balanceLabel: string; balanceType?: string; fee: Balance | undefined; style?: SxProps | undefined; } -function Asset({ api, balance, address, balanceLabel, balanceType, balances, fee, style = { pt: '10px' } }: Props): React.ReactElement { +function Asset ({ address, api, balance, balanceLabel, balanceType, balances, fee, style = { pt: '10px' } }: Props): React.ReactElement { const theme = useTheme(); const { t } = useTranslation(); const chain = useChain(address); diff --git a/packages/extension-polkagate/src/partials/Confirmation.tsx b/packages/extension-polkagate/src/partials/Confirmation.tsx index 972fdfcf1..0f10d87cf 100644 --- a/packages/extension-polkagate/src/partials/Confirmation.tsx +++ b/packages/extension-polkagate/src/partials/Confirmation.tsx @@ -49,32 +49,18 @@ export default function Confirmation ({ children, headerTitle, onPrimaryBtnClick {txInfo?.failureText && - + {txInfo.failureText} } {children} - {t('Fee:')} + {t('Fee')}: {fee?.toHuman() as string ?? '00.00'} @@ -84,7 +70,7 @@ export default function Confirmation ({ children, headerTitle, onPrimaryBtnClick {!!txInfo?.block && - {t('Block:')} + {t('Block')}: #{txInfo.block} @@ -94,7 +80,7 @@ export default function Confirmation ({ children, headerTitle, onPrimaryBtnClick {txInfo?.txHash && - {t('Hash:')} + {t('Hash')}: void; } -export default function Confirmation({ address, onPrimaryBtnClick, onSecondaryBtnClick, primaryBtnText, secondaryBtnText, showConfirmation, txInfo }: Props): React.ReactElement { +export default function Confirmation ({ address, onPrimaryBtnClick, onSecondaryBtnClick, primaryBtnText, secondaryBtnText, showConfirmation, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = useToken(address); const chainName = txInfo.chain.name.replace(' Relay Chain', ''); const fee = txInfo.api.createType('Balance', txInfo.fee); - const DisplayInfo = ({ caption, showDivider = true, value }: { caption: string, value: string, showDivider?: boolean }) => { - return ( - - - {caption} - {value} - - {showDivider && - - - } - - ); - }; - return ( ('Unlocking')} + text={t('Unlocking')} /> - ('Completed') : t('Failed')} /> + {txInfo?.failureText && - + {txInfo.failureText} } - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + ('Unlock value:')} - value={t(`${txInfo.amount} {{token}}`, { replace: { token } })} + caption={t('Unlock value:')} + value={t(`${txInfo.amount} {{token}}`, { replace: { token } })} /> - ('Fee:')} value={fee?.toHuman() ?? '00.00'} /> + {txInfo?.txHash && - {t('Hash')}: + {t('Hash')}: >; } -export default function Review({ address, api, classToUnlock, setRefresh, setShow, show, totalLocked, unlockableAmount }: Props): React.ReactElement { +export default function Review ({ address, api, classToUnlock, setRefresh, setShow, show, totalLocked, unlockableAmount }: Props): React.ReactElement { const { t } = useTranslation(); - const formatted = useFormatted(address); const theme = useTheme(); + + const { chain, decimal, formatted, token } = useInfo(address); const proxies = useProxies(api, formatted); - const chain = useChain(address); const name = useAccountDisplay(address); - const token = useToken(address); - const decimal = useDecimal(address); const onAction = useContext(ActionContext); + const [password, setPassword] = useState(); const [isPasswordError, setIsPasswordError] = useState(false); const [selectedProxy, setSelectedProxy] = useState(); @@ -92,7 +91,7 @@ export default function Review({ address, api, classToUnlock, setRefresh, setSho setParams(params as any); if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); + return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } batchAll(params).paymentInfo(formatted).then((i) => setEstimatedFee(i?.partialFee)).catch(console.error); @@ -172,7 +171,7 @@ export default function Review({ address, api, classToUnlock, setRefresh, setSho shortBorder showBackArrow showClose - text={t('Unlocking')} + text={t('Unlocking')} /> {isPasswordError && @@ -185,7 +184,7 @@ export default function Review({ address, api, classToUnlock, setRefresh, setSho selectedProxyAddress={selectedProxyAddress} showDivider style={{ mt: '-5px' }} - title={t('Account holder')} + title={t('Account')} /> - {t('The rest will be available when the corresponding locks have expired.')} + {t('The rest will be available when the corresponding locks have expired.')} } @@ -209,7 +208,7 @@ export default function Review({ address, api, classToUnlock, setRefresh, setSho estimatedFee={estimatedFee} genesisHash={chain?.genesisHash} isPasswordError={isPasswordError} - label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} + label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} onChange={setPassword} onConfirmClick={unlockRef} proxiedAddress={formatted} diff --git a/packages/extension-polkagate/src/popup/crowdloans/contribute/Contribute.tsx b/packages/extension-polkagate/src/popup/crowdloans/contribute/Contribute.tsx index 4d1012ffd..c7e9a39dd 100644 --- a/packages/extension-polkagate/src/popup/crowdloans/contribute/Contribute.tsx +++ b/packages/extension-polkagate/src/popup/crowdloans/contribute/Contribute.tsx @@ -1,19 +1,18 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { LinkOption } from '@polkagate/apps-config/endpoints/types'; +import type { ApiPromise } from '@polkadot/api'; +import type { Chain } from '@polkadot/extension-chains/types'; import type { Balance } from '@polkadot/types/interfaces'; +import type { AccountId } from '@polkadot/types/interfaces/runtime'; +import type { Crowdloan } from '../../../util/types'; import { Grid, Typography } from '@mui/material'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { ApiPromise } from '@polkadot/api'; -import type { LinkOption } from '@polkagate/apps-config/endpoints/types'; -import type { Chain } from '@polkadot/extension-chains/types'; - -import type { AccountId } from '@polkadot/types/interfaces/runtime'; import { BN, BN_ONE, BN_ZERO } from '@polkadot/util'; import { AmountWithOptions, From, PButton, Popup, ShowBalance } from '../../../components'; @@ -21,12 +20,11 @@ import { useBalances, useDecimal, useToken, useTranslation } from '../../../hook import { HeaderBrand, SubTitle } from '../../../partials'; import Asset from '../../../partials/Asset'; import { MAX_AMOUNT_LENGTH } from '../../../util/constants'; -import type { Crowdloan } from '../../../util/types'; import { amountToHuman, amountToMachine } from '../../../util/utils'; +import { getValue } from '../../account/util'; import ParachainInfo from '../partials/ParachainInfo'; import ShowParachain from '../partials/ShowParachain'; import Review from './Review'; -import { getValue } from '../../account/util'; interface Props { api?: ApiPromise; @@ -41,13 +39,13 @@ interface Props { myContribution?: string | Balance; } -export default function Contribute({ api, chain, crowdloan, crowdloansId, currentBlockNumber, formatted, minContribution, myContribution, setShowContribute, showContribute = false }: Props): React.ReactElement { +export default function Contribute ({ api, chain, crowdloan, crowdloansId, currentBlockNumber, formatted, minContribution, myContribution, setShowContribute, showContribute = false }: Props): React.ReactElement { const { t } = useTranslation(); const balances = useBalances(String(formatted)); const decimal = useDecimal(formatted); const token = useToken(formatted); - const tx = api && api.tx['crowdloan']['contribute']; + const tx = api?.tx['crowdloan']['contribute']; const [showCrowdloanInfo, setShowCrowdloanInfo] = useState(false); const [showReview, setShowReview] = useState(false); @@ -64,7 +62,7 @@ export default function Contribute({ api, chain, crowdloan, crowdloansId, curren } if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); + return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } const feeDummyParams = ['2000', amountAsBN ?? new BN(minContribution), null]; @@ -128,21 +126,21 @@ export default function Contribute({ api, chain, crowdloan, crowdloansId, curren shortBorder showBackArrow showClose - text={t('Crowdloan')} + text={t('Crowdloan')} /> ('Contribute')} + label={t('Contribute')} withSteps={{ current: 1, total: 2 }} /> ('Account holder')} + title={t('Account')} /> ('Available balance')} + balanceLabel={t('Available balance')} fee={estimatedFee} style={{ m: '15px auto 0', width: '92%' }} /> ('Amount ({{token}})', { replace: { token } })} + label={t('Amount ({{token}})', { replace: { token } })} onChangeAmount={contributionAmountChange} onPrimary={onMinAmount} onSecondary={onMaxAmount} - primaryBtnText={t('Min amount')} - secondaryBtnText={t('Max amount')} + primaryBtnText={t('Min amount')} + secondaryBtnText={t('Max amount')} style={{ m: '15px auto 0', width: '92%' }} value={contributionAmount} /> - {t('Min Contribution')}: + {t('Min Contribution')}: @@ -177,12 +175,12 @@ export default function Contribute({ api, chain, crowdloan, crowdloansId, curren ('Next')} + text={t('Next')} /> {showCrowdloanInfo && chain && (); const [proxyItems, setProxyItems] = useState(); @@ -132,7 +131,7 @@ export default function Review({ api, contributionAmount, crowdloanToContribute, shortBorder showBackArrow showClose - text={t('Contribute')} + text={t('Contribute')} withSteps={{ current: 2, total: 2 }} /> {isPasswordError && @@ -143,22 +142,22 @@ export default function Review({ api, contributionAmount, crowdloanToContribute, isDanger theme={theme} > - {t('You’ve used an incorrect password. Try again.')} + {t('You’ve used an incorrect password. Try again.')} } ('Review')} + label={t('Review')} /> - {t('Amount')} + {t('Amount')} @@ -170,7 +169,7 @@ export default function Review({ api, contributionAmount, crowdloanToContribute, - {t('Fee:')} + {t('Fee:')} @@ -187,7 +186,7 @@ export default function Review({ api, contributionAmount, crowdloanToContribute, api={api} genesisHash={chain?.genesisHash} isPasswordError={isPasswordError} - label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} + label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} onChange={setPassword} onConfirmClick={goContribute} proxiedAddress={formatted} @@ -231,26 +230,13 @@ export default function Review({ api, contributionAmount, crowdloanToContribute, txInfo={txInfo} > <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Parachain')}: + {t('Parachain')}: {getName(crowdloanToContribute.fund.paraId) ?? `Unknown(${crowdloanToContribute.fund.paraId})`} @@ -259,7 +245,7 @@ export default function Review({ api, contributionAmount, crowdloanToContribute, - {t('Amount')}: + {t('Amount')}: {`${txInfo.amount} ${token}`} diff --git a/packages/extension-polkagate/src/popup/history/Detail.tsx b/packages/extension-polkagate/src/popup/history/Detail.tsx index 1be72e6bf..5de3c1536 100644 --- a/packages/extension-polkagate/src/popup/history/Detail.tsx +++ b/packages/extension-polkagate/src/popup/history/Detail.tsx @@ -1,16 +1,16 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { NameAddress, TransactionDetail } from '../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React, { useCallback, useContext, useMemo } from 'react'; import { AccountContext, PButton, Popup } from '../../components'; import { useTranslation } from '../../hooks'; import { HeaderBrand } from '../../partials'; -import type { NameAddress, TransactionDetail } from '../../util/types'; import { accountName, amountToMachine, toShortAddress, upperCaseFirstChar } from '../../util/utils'; import Amount from './partials/Amount'; import FailSuccessIcon from './partials/FailSuccessIcon'; @@ -27,42 +27,41 @@ interface Props { showDetail: boolean; } -export default function Detail({ chainName, decimal, info, setShowDetail, showDetail, token }: Props): React.ReactElement { - const { t } = useTranslation(); +const ShowNameAddress = ({ nameAddress, title }: { title: string, nameAddress: NameAddress }) => { const { accounts } = useContext(AccountContext); - const options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' }; + const name = nameAddress?.name || accountName(accounts, nameAddress?.address); + + return ( + + + + {title}: {name} + + + + {`${name ? ' (' : ''}${toShortAddress(nameAddress.address)}${name ? ')' : ''}`} + + + ); +}; + +export default function Detail ({ chainName, decimal, info, setShowDetail, showDetail, token }: Props): React.ReactElement { + const { t } = useTranslation(); + const options = { day: 'numeric', hour: 'numeric', minute: 'numeric', month: 'short', second: 'numeric', weekday: 'short', year: 'numeric' } as Intl.DateTimeFormatOptions; const _onBack = useCallback(() => { setShowDetail(false); }, [setShowDetail]); const action = useMemo((): string | undefined => upperCaseFirstChar(info?.action), [info?.action]); - const subAction = useMemo((): string | undefined => info?.subAction ? upperCaseFirstChar(info?.subAction) : '', [info]); - const ShowNameAddress = ({ nameAddress, title }: { title: string, nameAddress: NameAddress }) => { - const name = nameAddress?.name || accountName(accounts, nameAddress?.address); - - return ( - - - - {title}: {name} - - - - {`${name ? ' (' : ''}${toShortAddress(nameAddress.address)}${name ? ')' : ''}`} - - - ); - }; - return ( ('Transaction Detail')} + text={t('Transaction Detail')} /> @@ -73,12 +72,12 @@ export default function Detail({ chainName, decimal, info, setShowDetail, showDe - + {info?.from && - } toCopy={info?.from?.address} /> + } toCopy={info?.from?.address} /> } {info?.to && - } toCopy={info?.to?.address} /> + } toCopy={info?.to?.address} /> } {info?.amount && @@ -102,7 +101,7 @@ export default function Detail({ chainName, decimal, info, setShowDetail, showDe ('Back')} + text={t('Back')} /> ); diff --git a/packages/extension-polkagate/src/popup/history/partials/FailSuccessIcon.tsx b/packages/extension-polkagate/src/popup/history/partials/FailSuccessIcon.tsx index ae6184abc..e37b4d7aa 100644 --- a/packages/extension-polkagate/src/popup/history/partials/FailSuccessIcon.tsx +++ b/packages/extension-polkagate/src/popup/history/partials/FailSuccessIcon.tsx @@ -1,9 +1,8 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck import { Check as CheckIcon, Close as CloseIcon } from '@mui/icons-material'; -import { Container, type SxProps, type Theme, Typography } from '@mui/material'; +import { Container, Typography } from '@mui/material'; import React from 'react'; import { useTranslation } from '../../../hooks'; @@ -12,14 +11,18 @@ interface Props { success: boolean; showLabel?: boolean; size?: number; - style?: SxProps; + style?: React.CSSProperties; } -export default function FailSuccessIcon({ showLabel = true, style = { fontSize: '54px', mt: '20px' }, success }: Props) { +//@ts-ignore +export default function FailSuccessIcon ({ showLabel = true, style = { fontSize: '54px', mt: '20px' }, success }: Props) { const { t } = useTranslation(); return ( - + { success ? : } {showLabel && - - {success ? t('Completed') : t('Failed')} + + {success ? t('Completed') : t('Failed')} } diff --git a/packages/extension-polkagate/src/popup/send/index.tsx b/packages/extension-polkagate/src/popup/send/index.tsx deleted file mode 100644 index ede0f0fd3..000000000 --- a/packages/extension-polkagate/src/popup/send/index.tsx +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors -// SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck -/* eslint-disable header/header */ -/* eslint-disable react/jsx-max-props-per-line */ - -/** - * @description - * this component opens - * */ - -import type { DeriveBalancesAll } from '@polkadot/api-derive/types'; -import type { AccountId, Balance } from '@polkadot/types/interfaces'; -import type { FormattedAddressState, TransferType } from '../../util/types'; - -import { Container } from '@mui/material'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { useParams } from 'react-router'; -import { useHistory } from 'react-router-dom'; - -import { AccountsStore } from '@polkadot/extension-base/stores'; -import keyring from '@polkadot/ui-keyring'; -import { BN, BN_ONE, BN_ZERO } from '@polkadot/util'; -import { cryptoWaitReady } from '@polkadot/util-crypto'; - -import { AccountInputWithIdentity, AmountWithOptions, From, Motion, PButton } from '../../components'; -import { useAccountName, useIdentity, useInfo, useTranslation } from '../../hooks'; -import { HeaderBrand } from '../../partials'; -import Asset from '../../partials/Asset'; -import { MAX_AMOUNT_LENGTH } from '../../util/constants'; -import { amountToHuman, amountToMachine, isValidAddress } from '../../util/utils'; -import Review from './Review'; -import { getValue } from '../account/util'; - -export default function Send(): React.ReactElement { - const { t } = useTranslation(); - const history = useHistory(); - const { address } = useParams(); - const { api, chain, decimal, formatted, genesisHash } = useInfo(address); - - const [estimatedFee, setEstimatedFee] = useState(); - const [maxFee, setMaxFee] = useState(); - const [recipientAddress, setRecipientAddress] = useState(); - const recipientNameIfIsInExtension = useAccountName(recipientAddress as string); - const recipientInfo = useIdentity(genesisHash, recipientAddress as string); - const [amount, setAmount] = useState(); - const [balances, setBalances] = useState(); - const [transferType, setTransferType] = useState(); - const [buttonDisabled, setButtonDisabled] = useState(true); - const [recipientName, setRecipientName] = useState(); - const [showReview, setShowReview] = useState(); - - const transfer = api && api.tx?.['balances'] && (['All', 'Max'].includes(transferType as string) ? (api.tx['balances']['transferAll']) : (api.tx['balances']['transferKeepAlive'])); - const amountAsBN = useMemo(() => amountToMachine(amount, decimal), [amount, decimal]); - const transferableBalance = useMemo(() => getValue('transferable', balances), [balances]); - - useEffect(() => { - setRecipientName(recipientInfo?.identity?.display || recipientNameIfIsInExtension || t('Unknown')); - }, [recipientInfo?.identity?.display, recipientNameIfIsInExtension, t]); - - const setWholeAmount = useCallback((type: TransferType) => { - if (!api || !transferableBalance || !maxFee || !decimal) { - return; - } - - setTransferType(type); - const ED = type === 'Max' ? api.consts['balances']['existentialDeposit'] as unknown as BN : BN_ZERO; - const allMaxAmount = transferableBalance.isZero() ? '0' : amountToHuman(transferableBalance.sub(maxFee).sub(ED).toString(), decimal); - - setAmount(allMaxAmount); - }, [api, transferableBalance, decimal, maxFee]); - - useEffect(() => { - if (!decimal) { - return; - } - - const isAmountLessThanAllTransferAble = amountAsBN.gt(transferableBalance?.sub(maxFee ?? BN_ZERO) ?? BN_ZERO); - - setButtonDisabled(!isValidAddress(recipientAddress as string) || !amount || (amount === '0') || isAmountLessThanAllTransferAble); - }, [amount, amountAsBN, api, transferableBalance, decimal, maxFee, recipientAddress]); - - useEffect(() => { - // eslint-disable-next-line no-void - api && void api.derive.balances?.all(formatted as string).then((b) => { - setBalances(b); - }); - }, [api, formatted]); - - useEffect(() => { - if (!api || !transfer || !formatted || !decimal) { - return; - } - - if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); - } - - let params = []; - - if (['All', 'Max'].includes(transferType as string)) { - const keepAlive = transferType === 'Max'; - - params = [formatted, keepAlive]; // just for estimatedFee calculation, sender and receiver are the same - } else { - params = [formatted, amountAsBN]; - } - - // eslint-disable-next-line no-void - void transfer(...params).paymentInfo(formatted) - .then((i) => setEstimatedFee(i?.partialFee)).catch(console.error); - }, [api, formatted, transfer, amount, decimal, transferType, amountAsBN]); - - useEffect(() => { - if (!api) { - return; - } - - if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); - } - - transfer && transferableBalance && formatted && transfer(formatted, transferableBalance).paymentInfo(formatted) - .then((i) => setMaxFee(i?.partialFee)).catch(console.error); - }, [api, formatted, transfer, transferableBalance]); - - useEffect(() => { - cryptoWaitReady() - .then((): void => { - keyring.loadAll({ store: new AccountsStore() }); - }) - .catch(() => null); - }, []); - - const _onBackClick = useCallback(() => { - chain?.genesisHash && history.push({ - pathname: `/account/${chain?.genesisHash}/${address}/` - }); - }, [address, chain?.genesisHash, history]); - - const goToReview = useCallback(() => { - setShowReview(true); - }, []); - - const _onChangeAmount = useCallback((value: string) => { - if (!decimal) { - return; - } - - if (value.length > decimal - 1) { - console.log(`The amount digits is more than decimal:${decimal}`); - - return; - } - - setTransferType('Normal'); - - setAmount(value.slice(0, MAX_AMOUNT_LENGTH)); - }, [decimal]); - - return ( - - ('Send Fund')} - withSteps={{ - current: 1, - total: 2 - }} - /> - - ('From')} - /> - - - ('Amount')} - onChangeAmount={_onChangeAmount} - onPrimary={() => setWholeAmount('Max')} - onSecondary={() => setWholeAmount('All')} - primaryBtnText={t('Max amount')} - secondaryBtnText={t('All amount')} - style={{ pt: '15px' }} - value={amount} - /> - - ('Next')} - /> - {showReview && amount && - - } - - ); -} diff --git a/packages/extension-polkagate/src/popup/send/partial/BalanceFee.tsx b/packages/extension-polkagate/src/popup/send/partial/BalanceFee.tsx index cc6112d10..08fa39668 100644 --- a/packages/extension-polkagate/src/popup/send/partial/BalanceFee.tsx +++ b/packages/extension-polkagate/src/popup/send/partial/BalanceFee.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -10,14 +9,13 @@ * */ import type { ApiPromise } from '@polkadot/api'; -import type { DeriveBalancesAll } from '@polkadot/api-derive/types'; import type { Balance } from '@polkadot/types/interfaces'; +import type { BN } from '@polkadot/util'; +import type { BalancesInfo } from '../../../util/types'; import { Grid } from '@mui/material'; import React from 'react'; -import { BN } from '@polkadot/util'; - import { ShowBalance } from '../../../components'; import { useDecimal, useToken } from '../../../hooks'; import { FLOATING_POINT_DIGIT } from '../../../util/constants'; @@ -25,16 +23,16 @@ import { getValue } from '../../account/util'; interface Props { address?: string; - type: string; - balances: DeriveBalancesAll | null | undefined; + type: string | undefined; + balances: BalancesInfo | null | undefined; fee: Balance | undefined; api: ApiPromise | undefined; - balance?: BN | undefined + balance?: BN | null | undefined } -export default function BalanceFee({ address, api, balance, balances, fee, type }: Props): React.ReactElement { - const value = balance ?? getValue(type, balances); +export default function BalanceFee ({ address, api, balance, balances, fee, type }: Props): React.ReactElement { + const value = balance ?? (type ? getValue(type, balances) : undefined); const token = useToken(address); const decimal = useDecimal(address); diff --git a/packages/extension-polkagate/src/popup/send/partial/SendTxDetail.tsx b/packages/extension-polkagate/src/popup/send/partial/SendTxDetail.tsx index 575d07e26..03a268721 100644 --- a/packages/extension-polkagate/src/popup/send/partial/SendTxDetail.tsx +++ b/packages/extension-polkagate/src/popup/send/partial/SendTxDetail.tsx @@ -1,6 +1,9 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck + +/* eslint-disable react/jsx-max-props-per-line */ + +import type { TxInfo } from '../../../util/types'; import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; @@ -8,13 +11,12 @@ import React from 'react'; import { ShortAddress } from '../../../components'; import { useTranslation } from '../../../hooks'; import ThroughProxy from '../../../partials/ThroughProxy'; -import type { TxInfo } from '../../../util/types'; interface Props { txInfo: TxInfo; } -export default function SendTxDetail({ txInfo }: Props): React.ReactElement { +export default function SendTxDetail ({ txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = txInfo.api.registry.chainTokens[0]; @@ -22,7 +24,7 @@ export default function SendTxDetail({ txInfo }: Props): React.ReactElement { <> - {t('From:')} + {t('From:')} {txInfo.from.name} @@ -30,8 +32,8 @@ export default function SendTxDetail({ txInfo }: Props): React.ReactElement { @@ -49,14 +51,14 @@ export default function SendTxDetail({ txInfo }: Props): React.ReactElement { } - {t('To:')} + {t('To:')} - {txInfo.to.name} + {txInfo?.to?.name} - {t('Amount:')} + {t('Amount:')} {`${txInfo.amount} ${token}`} diff --git a/packages/extension-polkagate/src/popup/staking/partial/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/partial/TxDetail.tsx index 9052232cf..63400339c 100644 --- a/packages/extension-polkagate/src/popup/staking/partial/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/partial/TxDetail.tsx @@ -1,47 +1,33 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { TxInfo } from '../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../components'; +import { AccountWithProxyInConfirmation } from '../../../components'; import { useTranslation } from '../../../hooks'; -import { ThroughProxy } from '../../../partials'; -import type { TxInfo } from '../../../util/types'; interface Props { txInfo: TxInfo; validatorsCount: number; } -export default function TxDetail({ txInfo, validatorsCount }: Props): React.ReactElement { +export default function TxDetail ({ txInfo, validatorsCount }: Props): React.ReactElement { const { t } = useTranslation(); return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Validators')}: {validatorsCount} + {t('Validators')}: {validatorsCount} diff --git a/packages/extension-polkagate/src/popup/staking/pool/claimCommission/index.tsx b/packages/extension-polkagate/src/popup/staking/pool/claimCommission/index.tsx index 7b8b348cd..6fa597936 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/claimCommission/index.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/claimCommission/index.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -9,20 +8,20 @@ * this component opens withdraw rewards review page * */ +import type { MyPoolInfo, Proxy, ProxyItem, TxInfo } from '../../../../util/types'; + import { Container } from '@mui/material'; import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react'; -import type { Balance } from '@polkadot/types/interfaces'; import keyring from '@polkadot/ui-keyring'; -import { BN, BN_ONE } from '@polkadot/util'; +import { BN } from '@polkadot/util'; import { AccountHolderWithProxy, ActionContext, AmountFee, Motion, PasswordUseProxyConfirm, Popup, ShowBalance2, WrongPasswordAlert } from '../../../../components'; -import { useAccountDisplay, useInfo, useProxies, useTranslation } from '../../../../hooks'; +import { useAccountDisplay, useEstimatedFee, useInfo, useProxies, useTranslation } from '../../../../hooks'; import { HeaderBrand, SubTitle, WaitScreen } from '../../../../partials'; import Confirmation from '../../../../partials/Confirmation'; import broadcast from '../../../../util/api/broadcast'; import { PROXY_TYPE } from '../../../../util/constants'; -import type { MyPoolInfo, Proxy, ProxyItem, TxInfo } from '../../../../util/types'; import { amountToHuman, getSubstrateAddress, saveAsHistory } from '../../../../util/utils'; import { To } from '../../../send/Review'; import TxDetail from '../rewards/partials/TxDetail'; @@ -34,7 +33,7 @@ interface Props { setShow: React.Dispatch>; } -export default function ClaimCommission({ address, pool, setShow, show }: Props): React.ReactElement { +export default function ClaimCommission ({ address, pool, setShow, show }: Props): React.ReactElement { const { t } = useTranslation(); const { api, chain, decimal, formatted } = useInfo(address); const proxies = useProxies(api, formatted); @@ -43,6 +42,7 @@ export default function ClaimCommission({ address, pool, setShow, show }: Props) const poolId = pool.poolId; const amount = useMemo(() => new BN(pool.rewardPool?.totalCommissionPending || 0), [pool.rewardPool?.totalCommissionPending]); + //@ts-ignore const payee = pool.bondedPool?.commission?.current?.[1]?.toString() as string | undefined; const [password, setPassword] = useState(); @@ -52,12 +52,12 @@ export default function ClaimCommission({ address, pool, setShow, show }: Props) const [txInfo, setTxInfo] = useState(); const [showWaitScreen, setShowWaitScreen] = useState(false); const [showConfirmation, setShowConfirmation] = useState(false); - const [estimatedFee, setEstimatedFee] = useState(); const selectedProxyAddress = selectedProxy?.delegate as unknown as string; const selectedProxyName = useAccountDisplay(getSubstrateAddress(selectedProxyAddress)); - const tx = api && api.tx['nominationPools']['claimCommission']; + const tx = api?.tx['nominationPools']['claimCommission']; + const estimatedFee = useEstimatedFee(address, tx, [poolId]); const goToStakingHome = useCallback(() => { setShow(false); @@ -71,21 +71,9 @@ export default function ClaimCommission({ address, pool, setShow, show }: Props) setProxyItems(fetchedProxyItems); }, [proxies]); - useEffect((): void => { - if (!api || !formatted) { - return; - } - - if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); - } - - tx(poolId).paymentInfo(formatted).then((i) => setEstimatedFee(i?.partialFee)).catch(console.error); - }, [tx, formatted, api, poolId]); - const submit = useCallback(async () => { try { - if (!formatted) { + if (!formatted || !api || !tx) { return; } @@ -135,7 +123,7 @@ export default function ClaimCommission({ address, pool, setShow, show }: Props) shortBorder showBackArrow showClose - text={t('Withdraw Commission')} + text={t('Withdraw Commission')} /> {isPasswordError && @@ -144,7 +132,7 @@ export default function ClaimCommission({ address, pool, setShow, show }: Props) @@ -172,7 +160,7 @@ export default function ClaimCommission({ address, pool, setShow, show }: Props) estimatedFee={estimatedFee} genesisHash={chain?.genesisHash} isPasswordError={isPasswordError} - label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} + label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} onChange={setPassword} onConfirmClick={submit} proxiedAddress={formatted} @@ -201,7 +189,7 @@ export default function ClaimCommission({ address, pool, setShow, show }: Props) txInfo={txInfo} > ('Withdrawn amount')} + label={t('Withdrawn amount')} txInfo={txInfo} /> ) diff --git a/packages/extension-polkagate/src/popup/staking/pool/myPool/SetState.tsx b/packages/extension-polkagate/src/popup/staking/pool/myPool/SetState.tsx index 8e426e201..5395852ca 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/myPool/SetState.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/myPool/SetState.tsx @@ -1,24 +1,24 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { Balance } from '@polkadot/types/interfaces'; +import type { AccountId } from '@polkadot/types/interfaces/runtime'; +import type { MyPoolInfo, Proxy, ProxyItem, TxInfo } from '../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React, { useCallback, useContext, useEffect, useState } from 'react'; -import type { Balance } from '@polkadot/types/interfaces'; -import type { AccountId } from '@polkadot/types/interfaces/runtime'; import keyring from '@polkadot/ui-keyring'; import { BN_ONE } from '@polkadot/util'; -import { ActionContext, Motion, PasswordUseProxyConfirm, Popup, ShortAddress, ShowBalance, WrongPasswordAlert } from '../../../../components'; -import { useAccountDisplay, useApi, useChain, useProxies, useTranslation } from '../../../../hooks'; -import { HeaderBrand, SubTitle, ThroughProxy, WaitScreen } from '../../../../partials'; +import { AccountWithProxyInConfirmation, ActionContext, Motion, PasswordUseProxyConfirm, Popup, ShowBalance, WrongPasswordAlert } from '../../../../components'; +import { useAccountDisplay, useInfo, useProxies, useTranslation } from '../../../../hooks'; +import { HeaderBrand, SubTitle, WaitScreen } from '../../../../partials'; import Confirmation from '../../../../partials/Confirmation'; import { signAndSend } from '../../../../util/api'; import { PROXY_TYPE } from '../../../../util/constants'; -import type { MyPoolInfo, Proxy, ProxyItem, TxInfo } from '../../../../util/types'; import { getSubstrateAddress, saveAsHistory } from '../../../../util/utils'; import ShowPool from '../../partial/ShowPool'; @@ -34,13 +34,14 @@ interface Props { headerText: string; } -export default function SetState({ address, formatted, headerText, helperText, pool, setRefresh, setShow, show, state }: Props): React.ReactElement { +export default function SetState ({ address, formatted, headerText, helperText, pool, setRefresh, setShow, show, state }: Props): React.ReactElement { const { t } = useTranslation(); - const api = useApi(address); + + const { api, chain } = useInfo(address); const proxies = useProxies(api, formatted); - const chain = useChain(address); const name = useAccountDisplay(address); const onAction = useContext(ActionContext); + const [password, setPassword] = useState(); const [isPasswordError, setIsPasswordError] = useState(false); const [selectedProxy, setSelectedProxy] = useState(); @@ -54,9 +55,9 @@ export default function SetState({ address, formatted, headerText, helperText, p const [estimatedFee, setEstimatedFee] = useState(); - const batchAll = api && api.tx['utility']['batchAll']; - const chilled = api && api.tx['nominationPools']['chill']; - const poolSetState = api && api.tx['nominationPools']['setState'](pool.poolId.toString(), state); // (poolId, state) + const batchAll = api?.tx['utility']['batchAll']; + const chilled = api?.tx['nominationPools']['chill']; + const poolSetState = api?.tx['nominationPools']['setState'](pool.poolId.toString(), state); // (poolId, state) const backToStake = useCallback(() => { setShow(false); @@ -68,7 +69,7 @@ export default function SetState({ address, formatted, headerText, helperText, p } if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); + return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } // eslint-disable-next-line no-void @@ -112,7 +113,7 @@ export default function SetState({ address, formatted, headerText, helperText, p const calls = mayNeedChill ? batchAll([mayNeedChill, poolSetState]) : poolSetState; const tx = selectedProxy ? api.tx['proxy']['proxy'](formatted, selectedProxy.proxyType, calls) : calls; - const { block, failureText, fee, success, txHash } = await signAndSend(api, tx, signer, formatted); + const { block, failureText, fee, success, txHash } = await signAndSend(api, tx, signer, String(formatted)); const subAction = state === 'Destroying' ? 'Destroy Pool' : state === 'Open' ? 'Unblock Pool' : 'Block Pool'; @@ -155,10 +156,10 @@ export default function SetState({ address, formatted, headerText, helperText, p {isPasswordError && } - ('Review')} /> + - {t('Fee:')} + {t('Fee')}: ('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} + label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} onChange={setPassword} onConfirmClick={changeState} proxiedAddress={formatted} @@ -220,30 +221,13 @@ export default function SetState({ address, formatted, headerText, helperText, p txInfo={txInfo} > <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} diff --git a/packages/extension-polkagate/src/popup/staking/pool/myPool/editPool/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/pool/myPool/editPool/TxDetail.tsx index 81e97138a..40db3f9b6 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/myPool/editPool/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/myPool/editPool/TxDetail.tsx @@ -1,51 +1,33 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { MyPoolInfo, TxInfo } from '../../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../../components'; import { useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { MyPoolInfo, TxInfo } from '../../../../../util/types'; interface Props { txInfo: TxInfo pool: MyPoolInfo } -export default function TxDetail({ pool, txInfo }: Props): React.ReactElement { +export default function TxDetail ({ pool, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); return ( <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} diff --git a/packages/extension-polkagate/src/popup/staking/pool/myPool/removeAll/Review.tsx b/packages/extension-polkagate/src/popup/staking/pool/myPool/removeAll/Review.tsx index 9cd9cca3c..4d1e11ad9 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/myPool/removeAll/Review.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/myPool/removeAll/Review.tsx @@ -1,28 +1,26 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ import type { ApiPromise } from '@polkadot/api'; +import type { SubmittableExtrinsic } from '@polkadot/api/types'; +import type { Chain } from '@polkadot/extension-chains/types'; +import type { Balance } from '@polkadot/types/interfaces'; +import type { MemberPoints, MyPoolInfo, Proxy, ProxyItem, TxInfo } from '../../../../../util/types'; import { Divider, Grid, Typography } from '@mui/material'; import React, { useCallback, useContext, useEffect, useState } from 'react'; -import type { SubmittableExtrinsic } from '@polkadot/api/types'; -import type { Chain } from '@polkadot/extension-chains/types'; - -import type { Balance } from '@polkadot/types/interfaces'; import keyring from '@polkadot/ui-keyring'; -import { BN, BN_ONE } from '@polkadot/util'; +import { BN, BN_ONE, BN_ZERO } from '@polkadot/util'; -import { ActionContext, Motion, PasswordUseProxyConfirm, Popup, ShortAddress, ShowBalance, WrongPasswordAlert } from '../../../../../components'; +import { AccountWithProxyInConfirmation, ActionContext, Motion, PasswordUseProxyConfirm, Popup, ShowBalance, WrongPasswordAlert } from '../../../../../components'; import { useAccountDisplay, useProxies, useTranslation } from '../../../../../hooks'; -import { HeaderBrand, SubTitle, ThroughProxy, WaitScreen } from '../../../../../partials'; +import { HeaderBrand, SubTitle, WaitScreen } from '../../../../../partials'; import Confirmation from '../../../../../partials/Confirmation'; import { signAndSend } from '../../../../../util/api'; import { PROXY_TYPE } from '../../../../../util/constants'; -import type { MemberPoints, MyPoolInfo, Proxy, ProxyItem, TxInfo } from '../../../../../util/types'; import { getSubstrateAddress, saveAsHistory } from '../../../../../util/utils'; import ShowPool from '../../../partial/ShowPool'; @@ -40,11 +38,12 @@ interface Props { mode: 'UnbondAll' | 'RemoveAll'; } -export default function Review({ address, api, chain, formatted, mode, pool, poolMembers, setRefresh, setShow, setShowMyPool, show }: Props): React.ReactElement { +export default function Review ({ address, api, chain, formatted, mode, pool, poolMembers, setRefresh, setShow, setShowMyPool, show }: Props): React.ReactElement { const { t } = useTranslation(); const proxies = useProxies(api, formatted); const name = useAccountDisplay(address); const onAction = useContext(ActionContext); + const [password, setPassword] = useState(); const [isPasswordError, setIsPasswordError] = useState(false); const [selectedProxy, setSelectedProxy] = useState(); @@ -85,7 +84,9 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo }, [setShowMyPool]); useEffect(() => { - if (!poolMembers?.length) { return; } + if (!poolMembers?.length) { + return; + } if (mode === 'UnbondAll') { const nonZeroPointMembers = poolMembers.filter((m) => !new BN(m.points).isZero()); @@ -101,7 +102,9 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo }, [poolMembers, mode, poolDepositorAddr]); useEffect(() => { - if (!membersToUnboundAll && !membersToRemoveAll) { return; } + if (!membersToUnboundAll && !membersToRemoveAll) { + return; + } if (mode === 'UnbondAll') { const calls = membersToUnboundAll?.map((m) => unbonded(m.accountId, m.points)); @@ -113,7 +116,7 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo setTxCalls(calls); if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); + return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } // eslint-disable-next-line no-void @@ -125,8 +128,10 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo } else { const dummyParams = [1, 1]; - // eslint-disable-next-line no-void - void poolWithdrawUnbonded(...dummyParams).paymentInfo(formatted).then((j) => setEstimatedFee(api.createType('Balance', fee.add(j?.partialFee)))); + poolWithdrawUnbonded(...dummyParams).paymentInfo(formatted) + // @ts-ignore + .then((j) => setEstimatedFee(api.createType('Balance', fee.add(j?.partialFee || BN_ZERO) as Balance))) + .catch(console.error); } }); } else if (mode === 'RemoveAll') { @@ -139,7 +144,7 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo setTxCalls(calls); if (!api?.call?.['transactionPaymentApi']) { - return setEstimatedFee(api?.createType('Balance', BN_ONE)); + return setEstimatedFee(api?.createType('Balance', BN_ONE) as Balance); } // eslint-disable-next-line no-void @@ -207,28 +212,28 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo shortBorder showBackArrow showClose - text={t(`${mode === 'RemoveAll' ? 'Remove' : 'Unstake'} All`)} + text={t(`${mode === 'RemoveAll' ? 'Remove' : 'Unstake'} All`)} /> {isPasswordError && } - ('Review')} /> + {mode === 'UnbondAll' ? ( - {t('Unstaking all members of the pool except yourself forcefully.')} + {t('Unstaking all members of the pool except yourself forcefully.')} ) : (<> - {t('Removing all members from the pool')} + {t('Removing all members from the pool')} - {t('When you confirm, you will be able to unstake your tokens')} + {t('When you confirm, you will be able to unstake your tokens')} ) } - {t('Fee:')} + {t('Fee')}: ('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} + label={t('Password for {{name}}', { replace: { name: selectedProxyName || name || '' } })} onChange={setPassword} onConfirmClick={unstakeOrRemoveAll} proxiedAddress={formatted} @@ -274,11 +279,11 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo /> (`${mode === 'RemoveAll' ? 'Remove' : 'Unstake'} All`)} + title={t(`${mode === 'RemoveAll' ? 'Remove' : 'Unstake'} All`)} /> {txInfo && ( (`${mode === 'RemoveAll' ? 'Remove' : 'Unstake'} All`)} + headerTitle={t(`${mode === 'RemoveAll' ? 'Remove' : 'Unstake'} All`)} onPrimaryBtnClick={goToStakingHome} onSecondaryBtnClick={goToMyPool} primaryBtnText={t('Staking Home')} @@ -287,30 +292,13 @@ export default function Review({ address, api, chain, formatted, mode, pool, poo txInfo={txInfo} > <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} diff --git a/packages/extension-polkagate/src/popup/staking/pool/rewards/partials/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/pool/rewards/partials/TxDetail.tsx index 904e8f08e..f82ad1b84 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/rewards/partials/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/rewards/partials/TxDetail.tsx @@ -1,44 +1,28 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { TxInfo } from '../../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../components'; -import { useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { TxInfo } from '../../../../../util/types'; +import { AccountWithProxyInConfirmation } from '../../../../../components'; interface Props { txInfo: TxInfo; label: string; } -export default function TxDetail({ label, txInfo }: Props): React.ReactElement { - const { t } = useTranslation(); +export default function TxDetail ({ label, txInfo }: Props): React.ReactElement { const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension-polkagate/src/popup/staking/pool/stake/bondExtra/partial/BondExtraTxDetail.tsx b/packages/extension-polkagate/src/popup/staking/pool/stake/bondExtra/partial/BondExtraTxDetail.tsx index e4fbd6b72..216dcd7a3 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/stake/bondExtra/partial/BondExtraTxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/stake/bondExtra/partial/BondExtraTxDetail.tsx @@ -1,52 +1,34 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { MyPoolInfo, TxInfo } from '../../../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../../../components'; import { useTranslation } from '../../../../../../hooks'; -import { ThroughProxy } from '../../../../../../partials'; -import type { MyPoolInfo, TxInfo } from '../../../../../../util/types'; interface Props { txInfo: TxInfo; pool: MyPoolInfo; } -export default function CreatePoolTxDetail({ pool, txInfo }: Props): React.ReactElement { +export default function CreatePoolTxDetail ({ pool, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy?.address && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} @@ -55,7 +37,7 @@ export default function CreatePoolTxDetail({ pool, txInfo }: Props): React.React - {t('Staked:')} + {t('Staked')}: {`${txInfo.amount} ${token}`} diff --git a/packages/extension-polkagate/src/popup/staking/pool/stake/createPool/partial/CreatePoolTxDetail.tsx b/packages/extension-polkagate/src/popup/staking/pool/stake/createPool/partial/CreatePoolTxDetail.tsx index 03d471175..e8c3f4bec 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/stake/createPool/partial/CreatePoolTxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/stake/createPool/partial/CreatePoolTxDetail.tsx @@ -1,76 +1,34 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck + +/* eslint-disable react/jsx-max-props-per-line */ + +import type { PoolInfo, TxInfo } from '../../../../../../util/types'; import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../../../components'; import { useTranslation } from '../../../../../../hooks'; -import { ThroughProxy } from '../../../../../../partials'; -import type { PoolInfo, TxInfo } from '../../../../../../util/types'; interface Props { txInfo: TxInfo; pool: PoolInfo; } -export default function CreatePoolTxDetail({ pool, txInfo }: Props): React.ReactElement { +export default function CreatePoolTxDetail ({ pool, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy?.address && - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} @@ -78,7 +36,7 @@ export default function CreatePoolTxDetail({ pool, txInfo }: Props): React.React - {t('Index:')} + {t('Index')}: {pool.poolId.toString()} @@ -87,7 +45,7 @@ export default function CreatePoolTxDetail({ pool, txInfo }: Props): React.React - {t('Staked:')} + {t('Staked')}: {`${txInfo.amount} ${token}`} diff --git a/packages/extension-polkagate/src/popup/staking/pool/stake/joinPool/partials/JoinPoolTxDetail.tsx b/packages/extension-polkagate/src/popup/staking/pool/stake/joinPool/partials/JoinPoolTxDetail.tsx index b824cc874..e8f41d4c4 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/stake/joinPool/partials/JoinPoolTxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/stake/joinPool/partials/JoinPoolTxDetail.tsx @@ -1,14 +1,14 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck + +/* eslint-disable react/jsx-max-props-per-line */ +import type { PoolInfo, TxInfo } from '../../../../../../util/types'; import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../../components'; +import AccountWithProxyInConfirmation from '../../../../../../components/AccountWithProxyInConfirmation'; import { useTranslation } from '../../../../../../hooks'; -import { ThroughProxy } from '../../../../../../partials'; -import type { PoolInfo, TxInfo } from '../../../../../../util/types'; interface Props { txInfo: TxInfo; @@ -21,30 +21,13 @@ export default function JoinPoolTxDetail({ pool, txInfo }: Props): React.ReactEl return ( <> - - - {t('Account holder:')} - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + - {t('Pool:')} + {t('Pool')}: {pool.metadata} @@ -53,7 +36,7 @@ export default function JoinPoolTxDetail({ pool, txInfo }: Props): React.ReactEl - {t('Staked:')} + {t('Staked')}: {`${txInfo.amount} ${token}`} diff --git a/packages/extension-polkagate/src/popup/staking/pool/unstake/partials/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/pool/unstake/partials/TxDetail.tsx index 627775d49..a13249425 100644 --- a/packages/extension-polkagate/src/popup/staking/pool/unstake/partials/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/pool/unstake/partials/TxDetail.tsx @@ -1,103 +1,35 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck + +/* eslint-disable react/jsx-max-props-per-line */ + +import type { TxInfo } from '../../../../../util/types'; import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../../components'; import { useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { TxInfo } from '../../../../../util/types'; interface Props { txInfo: TxInfo; } -export default function TxDetail({ txInfo }: Props): React.ReactElement { +export default function TxDetail ({ txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } - - - - {t('Unstaked')}: + + + + {t('Unstaked')}: - + {`${txInfo.amount} ${token}`} diff --git a/packages/extension-polkagate/src/popup/staking/solo/partials/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/solo/partials/TxDetail.tsx index c6105d201..234c4d0c1 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/partials/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/partials/TxDetail.tsx @@ -1,44 +1,28 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { TxInfo } from '../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../components'; -import { useTranslation } from '../../../../hooks'; -import { ThroughProxy } from '../../../../partials'; -import type { TxInfo } from '../../../../util/types'; +import { AccountWithProxyInConfirmation } from '../../../../components'; interface Props { txInfo: TxInfo; label: string; } -export default function TxDetail({ label, txInfo }: Props): React.ReactElement { - const { t } = useTranslation(); +export default function TxDetail ({ label, txInfo }: Props): React.ReactElement { const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension-polkagate/src/popup/staking/solo/restake/partials/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/solo/restake/partials/TxDetail.tsx index 6773a344f..03f3284d2 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/restake/partials/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/restake/partials/TxDetail.tsx @@ -1,43 +1,29 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { TxInfo } from '../../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../../components'; import { useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { TxInfo } from '../../../../../util/types'; interface Props { txInfo: TxInfo; } -export default function TxDetail({ txInfo }: Props): React.ReactElement { +export default function TxDetail ({ txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension-polkagate/src/popup/staking/solo/rewards/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/solo/rewards/TxDetail.tsx index 39da9a6b7..9477df83f 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/rewards/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/rewards/TxDetail.tsx @@ -1,43 +1,29 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { TxInfo } from '../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../components'; import { useTranslation } from '../../../../hooks'; -import { ThroughProxy } from '../../../../partials'; -import type { TxInfo } from '../../../../util/types'; interface Props { txInfo: TxInfo; } -export default function TxDetail({ txInfo }: Props): React.ReactElement { +export default function TxDetail ({ txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension-polkagate/src/popup/staking/solo/settings/partials/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/solo/settings/partials/TxDetail.tsx index 09a2d033b..b0f0e2bfa 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/settings/partials/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/settings/partials/TxDetail.tsx @@ -1,16 +1,15 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { SoloSettings, TxInfo } from '../../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React, { useMemo } from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation, ShortAddress } from '../../../../../components'; import { useAccountName, useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { SoloSettings, TxInfo } from '../../../../../util/types'; import getPayee from '../../stake/partials/util'; interface Props { @@ -18,7 +17,7 @@ interface Props { newSettings: SoloSettings } -export default function TxDetail({ newSettings, txInfo }: Props): React.ReactElement { +export default function TxDetail ({ newSettings, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const controllerName = useAccountName(newSettings?.controllerId); const maybePayeeAddress = useMemo(() => getPayee(newSettings), [newSettings]); @@ -26,26 +25,9 @@ export default function TxDetail({ newSettings, txInfo }: Props): React.ReactEle return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + {newSettings?.controllerId && diff --git a/packages/extension-polkagate/src/popup/staking/solo/stake/Review.tsx b/packages/extension-polkagate/src/popup/staking/solo/stake/Review.tsx index f30ec52ad..ffff75a04 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/stake/Review.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/stake/Review.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -11,26 +10,25 @@ import type { ApiPromise } from '@polkadot/api'; import type { SubmittableExtrinsicFunction } from '@polkadot/api/types'; +import type { Chain } from '@polkadot/extension-chains/types'; +import type { Balance } from '@polkadot/types/interfaces'; +import type { AccountId } from '@polkadot/types/interfaces/runtime'; import type { AnyTuple } from '@polkadot/types/types'; +import type { BN } from '@polkadot/util'; +import type { Proxy, ProxyItem, SoloSettings, TxInfo, ValidatorInfo } from '../../../../util/types'; import MoreVertIcon from '@mui/icons-material/MoreVert'; import { Container, Divider, Grid, Typography } from '@mui/material'; import React, { useCallback, useContext, useEffect, useState } from 'react'; -import type { Chain } from '@polkadot/extension-chains/types'; - -import type { Balance } from '@polkadot/types/interfaces'; -import type { AccountId } from '@polkadot/types/interfaces/runtime'; import keyring from '@polkadot/ui-keyring'; -import { BN } from '@polkadot/util'; import { AccountHolderWithProxy, ActionContext, AmountFee, Identity, Infotip, Motion, PasswordUseProxyConfirm, Popup, ShortAddress, ShowBalance2, WrongPasswordAlert } from '../../../../components'; -import { useAccountDisplay, useFormatted, useProxies, useToken, useTranslation } from '../../../../hooks'; +import { useAccountDisplay, useInfo, useProxies, useTranslation } from '../../../../hooks'; import { HeaderBrand, SubTitle, WaitScreen } from '../../../../partials'; import Confirmation from '../../../../partials/Confirmation'; import { signAndSend } from '../../../../util/api'; import { PROXY_TYPE, SYSTEM_SUGGESTION_TEXT } from '../../../../util/constants'; -import type { Proxy, ProxyItem, SoloSettings, TxInfo, ValidatorInfo } from '../../../../util/types'; import { getSubstrateAddress, saveAsHistory } from '../../../../util/utils'; import RewardsDestination from './partials/RewardDestination'; import ShowValidators from './partials/ShowValidators'; @@ -52,13 +50,13 @@ interface Props { selectedValidators: ValidatorInfo[] | null | undefined; } -export default function Review({ address, amount, api, chain, estimatedFee, isFirstTimeStaking, params, selectedValidators, setShow, settings, show, total, tx }: Props): React.ReactElement { +export default function Review ({ address, amount, api, chain, estimatedFee, isFirstTimeStaking, params, selectedValidators, setShow, settings, show, total, tx }: Props): React.ReactElement { const { t } = useTranslation(); const proxies = useProxies(api, settings.stashId); const name = useAccountDisplay(address); - const token = useToken(address); - const formatted = useFormatted(address); + const { formatted, token } = useInfo(address); const onAction = useContext(ActionContext); + const [password, setPassword] = useState(); const [isPasswordError, setIsPasswordError] = useState(false); const [selectedProxy, setSelectedProxy] = useState(); @@ -119,7 +117,7 @@ export default function Review({ address, amount, api, chain, estimatedFee, isFi const extrinsic = batchCall || tx(...params); const ptx = selectedProxy ? api.tx['proxy']['proxy'](settings.stashId, selectedProxy.proxyType, extrinsic) : extrinsic; - const { block, failureText, fee, success, txHash } = await signAndSend(api, ptx, signer, settings.stashId); + const { block, failureText, fee, success, txHash } = await signAndSend(api, ptx, signer, String(settings.stashId)); const info = { action: 'Solo Staking', @@ -156,7 +154,7 @@ export default function Review({ address, amount, api, chain, estimatedFee, isFi {t('Controller account')} - + @@ -183,11 +181,11 @@ export default function Review({ address, amount, api, chain, estimatedFee, isFi {settings.controllerId !== settings.stashId && @@ -263,7 +261,7 @@ export default function Review({ address, amount, api, chain, estimatedFee, isFi ) } {showSelectedValidators && !!selectedValidators?.length && - + } diff --git a/packages/extension-polkagate/src/popup/staking/solo/stake/partials/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/solo/stake/partials/TxDetail.tsx index 18ad53da2..71474e387 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/stake/partials/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/stake/partials/TxDetail.tsx @@ -1,49 +1,32 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ +import type { SoloSettings, TxInfo } from '../../../../../util/types'; + import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation, ShortAddress } from '../../../../../components'; import { useAccountName, useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; -import type { SoloSettings, TxInfo } from '../../../../../util/types'; interface Props { txInfo: TxInfo; settings?: SoloSettings } -export default function TxDetail({ settings, txInfo }: Props): React.ReactElement { +export default function TxDetail ({ settings, txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const controllerName = useAccountName(settings?.controllerId); const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {settings?.stashId !== settings?.controllerId ? t('Stash account') : t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + {settings?.controllerId && settings?.stashId !== settings?.controllerId && diff --git a/packages/extension-polkagate/src/popup/staking/solo/tuneUp/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/solo/tuneUp/TxDetail.tsx index 3e5dd0a90..f980174cf 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/tuneUp/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/tuneUp/TxDetail.tsx @@ -1,43 +1,22 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ import type { TxInfo } from '../../../../util/types'; -import { Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../components'; -import { useTranslation } from '../../../../hooks'; -import { ThroughProxy } from '../../../../partials'; +import { AccountWithProxyInConfirmation } from '../../../../components'; interface Props { txInfo: TxInfo; } -export default function TxDetail({ txInfo }: Props): React.ReactElement { - const { t } = useTranslation(); - +export default function TxDetail ({ txInfo }: Props): React.ReactElement { return ( - <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } - + ); } diff --git a/packages/extension-polkagate/src/popup/staking/solo/unstake/partials/TxDetail.tsx b/packages/extension-polkagate/src/popup/staking/solo/unstake/partials/TxDetail.tsx index 7e68c0653..a13249425 100644 --- a/packages/extension-polkagate/src/popup/staking/solo/unstake/partials/TxDetail.tsx +++ b/packages/extension-polkagate/src/popup/staking/solo/unstake/partials/TxDetail.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -9,40 +8,22 @@ import type { TxInfo } from '../../../../../util/types'; import { Divider, Grid, Typography } from '@mui/material'; import React from 'react'; -import { ShortAddress } from '../../../../../components'; +import { AccountWithProxyInConfirmation } from '../../../../../components'; import { useTranslation } from '../../../../../hooks'; -import { ThroughProxy } from '../../../../../partials'; interface Props { txInfo: TxInfo; } -export default function TxDetail({ txInfo }: Props): React.ReactElement { +export default function TxDetail ({ txInfo }: Props): React.ReactElement { const { t } = useTranslation(); const token = txInfo.api?.registry.chainTokens[0]; return ( <> - - - {t('Account holder')}: - - - {txInfo.from.name} - - - - - - {txInfo.throughProxy && - - - - } + diff --git a/packages/extension/public/locales/en/translation.json b/packages/extension/public/locales/en/translation.json index e5f92e275..d291b3524 100644 --- a/packages/extension/public/locales/en/translation.json +++ b/packages/extension/public/locales/en/translation.json @@ -1,5 +1,4 @@ { - "Account holder": "", "Is recoverable": "", "Has proxy": "", "Paste the address here": "", @@ -310,7 +309,6 @@ "Already delegated to another account": "", "This category includes expired locks that can be unlocked and made available.": "", "Has already {{trackVotes}} vote(s)/lock": "", - "Account Holder": "", "Delegate to": "", "Member": "", "Rank": "", @@ -868,7 +866,6 @@ "Edited": "", "Commission payee": "", "To be Removed": "", - "Account holder:": "", "Pool:": "", "All My Pools": "", "Select role": "", @@ -1209,7 +1206,7 @@ "Review the newly selected validators": "", "click to view": "", "on-chain staking info": "", - "New pool state:": "", + "New pool state": "", "Change State": "", "You can join existing pools, which will be shown to you in a list,": "", "You can create a pool yourself and should manage pool and nominate validators for the pool yourself.": "", diff --git a/packages/extension/public/locales/fr/translation.json b/packages/extension/public/locales/fr/translation.json index e4450a177..d5f5b5a7c 100644 --- a/packages/extension/public/locales/fr/translation.json +++ b/packages/extension/public/locales/fr/translation.json @@ -1,5 +1,4 @@ { - "Account holder": "Titulaire du compte", "Is recoverable": "Est récupérable", "Has proxy": "A un mandataire", "Paste the address here": "Collez l'adresse ici", @@ -310,7 +309,6 @@ "Already delegated to another account": "Déjà délégué à un autre compte", "This category includes expired locks that can be unlocked and made available.": "Cette catégorie comprend des verrous expirés qui peuvent être déverrouillés et rendus disponibles.", "Has already {{trackVotes}} vote(s)/lock": "A déjà {{trackVotes}} vote(s)/verrou", - "Account Holder": "Titulaire du compte", "Delegate to": "Déléguer à", "Member": "Membre", "Rank": "Classement", @@ -868,7 +866,6 @@ "Edited": "Modifié", "Commission payee": "Bénéficiaire de la commission", "To be Removed": "À supprimer", - "Account holder:": "Titulaire du compte :", "Pool:": "Pool :", "All My Pools": "Tous mes pools", "Select role": "Sélectionner le rôle", @@ -1207,7 +1204,7 @@ "Review the newly selected validators": "Examiner les nouveaux validateurs sélectionnés", "click to view": "cliquez pour afficher", "on-chain staking info": "informations de mise en jeu sur la chaîne", - "New pool state:": "Nouvel état de la piscine :", + "New pool state": "Nouvel état de la piscine", "Change State": "Changer d'état", "You can join existing pools, which will be shown to you in a list,": "Vous pouvez rejoindre des piscines existantes, qui vous seront présentées dans une liste,", "You can create a pool yourself and should manage pool and nominate validators for the pool yourself.": "Vous pouvez créer vous-même une piscine et devez gérer la piscine et nommer les validateurs pour la piscine vous-même.", diff --git a/packages/extension/public/locales/hi/translation.json b/packages/extension/public/locales/hi/translation.json index aa756a210..d86d3a4aa 100644 --- a/packages/extension/public/locales/hi/translation.json +++ b/packages/extension/public/locales/hi/translation.json @@ -1,5 +1,4 @@ { - "Account holder": "खाता धारक", "Is recoverable": "पुनर्प्राप्त हो सकता है", "Has proxy": "प्रॉक्सी है", "Paste the address here": "यहाँ पता पेस्ट करें", @@ -310,7 +309,6 @@ "Already delegated to another account": "पहले से ही दूसरे खाते को प्रतिनिधित किया गया है", "This category includes expired locks that can be unlocked and made available.": "इस श्रेणी में समाप्त हो गए ताले शामिल हैं जो अनलॉक किए जा सकते हैं और उपलब्ध किए जा सकते हैं।", "Has already {{trackVotes}} vote(s)/lock": "{{trackVotes}} मत/ताला पहले से ही है", - "Account Holder": "खाता धारक", "Delegate to": "प्रतिनिधित करें", "Member": "सदस्य", "Rank": "श्रेणी", @@ -869,7 +867,6 @@ "Edited": "संपादित किया गया", "Commission payee": "कमीशन भुगतानकर्ता", "To be Removed": "हटाया जाना है", - "Account holder:": "खाता धारक:", "Pool:": "पूल:", "All My Pools": "सभी मेरे पूल", "Select role": "भूमिका चुनें", @@ -1204,7 +1201,7 @@ "Review the newly selected validators": "नई चयनित मान्यतादाताओं की समीक्षा करें", "click to view": "देखने के लिए क्लिक करें", "on-chain staking info": "ऑन-चेन लगाव सूचना", - "New pool state:": "नया पूल स्थिति:", + "New pool state": "नया पूल स्थिति", "Change State": "स्थिति बदलें", "You can join existing pools, which will be shown to you in a list,": "आप मौजूदा पूलों में शामिल हो सकते हैं, जो आपको एक सूची में दिखाई जाएगा,", "You can create a pool yourself and should manage pool and nominate validators for the pool yourself.": "आप खुद ही एक पूल बना सकते हैं और पूल को प्रबंधित करना चाहिए और पूल के लिए मान्यतादाताओं का चयन भी आपको ही करना चाहिए।", diff --git a/packages/extension/public/locales/ru/translation.json b/packages/extension/public/locales/ru/translation.json index f3432d57c..f02caf478 100644 --- a/packages/extension/public/locales/ru/translation.json +++ b/packages/extension/public/locales/ru/translation.json @@ -1,5 +1,4 @@ { - "Account holder": "Владелец аккаунта", "Is recoverable": "Восстановимый", "Has proxy": "Имеет прокси", "Paste the address here": "Вставьте адрес сюда", @@ -309,7 +308,6 @@ "Already delegated to another account": "Уже делегировано другому аккаунту", "This category includes expired locks that can be unlocked and made available.": "Эта категория включает истекшие блокировки, которые можно разблокировать и сделать доступными.", "Has already {{trackVotes}} vote(s)/lock": "Уже {{trackVotes}} голос(а)/блокировка(и)", - "Account Holder": "Держатель аккаунта", "Delegate to": "Делегировать на", "Member": "Участник", "Rank": "Рейтинг", @@ -867,7 +865,6 @@ "Edited": "Изменено", "Commission payee": "Получатель комиссии", "To be Removed": "Должно быть удалено", - "Account holder:": "Владелец аккаунта:", "Pool:": "Пул:", "All My Pools": "Все мои пулы", "Select role": "Выберите роль", @@ -1202,7 +1199,7 @@ "Review the newly selected validators": "Просмотр новых выбранных майнеров", "click to view": "щелкните, чтобы просмотреть", "on-chain staking info": "Информация о стейкинге на цепочке", - "New pool state:": "Новое состояние пула:", + "New pool state": "Новое состояние пула", "Change State": "Изменить состояние", "You can join existing pools, which will be shown to you in a list,": "Вы можете присоединиться к существующим пулам, которые будут показаны вам в списке,", "You can create a pool yourself and should manage pool and nominate validators for the pool yourself.": "Вы можете создать пул самостоятельно и должны управлять пулом и назначать майнеров для пула самостоятельно.", diff --git a/packages/extension/public/locales/zh/translation.json b/packages/extension/public/locales/zh/translation.json index dcdf1b22f..4fa113e9e 100644 --- a/packages/extension/public/locales/zh/translation.json +++ b/packages/extension/public/locales/zh/translation.json @@ -226,7 +226,6 @@ "We do not utilize any trackers or analytics.": "我们不使用任何跟踪器或分析工具。", "We do not collect keys, addresses, or any personal information. Your data always stays on this device.": "我们不收集密钥、地址或任何个人信息。您的数据始终保留在此设备上。", "We are committed to respecting your privacy and are not engaged in information collection – not even anonymized data.": "我们致力于尊重您的隐私,不参与信息收集,甚至不收集匿名数据。", - "Account holder": "账户持有人", "Total stake after": "总质押后", "Please wait a few seconds and don't close the extension.": "请稍等片刻,不要关闭扩展程序。", "Staking": "质押", @@ -332,7 +331,6 @@ "Pool name": "池名称", "Max": "最大", "Open Pool": "开放池", - "Account holder:": "账户持有者:", "My pool": "我的池", "Pool:": "池:", "Remove All": "移除全部", @@ -511,7 +509,6 @@ "Already delegated to another account": "已经委托给其他帐户", "This category includes expired locks that can be unlocked and made available.": "此类别包括可以解锁并提供的已过期锁定。", "Has already {{trackVotes}} vote(s)/lock": "已经有{{trackVotes}}票/锁定", - "Account Holder": "帐户持有人", "Delegate to": "委托给", "Member": "成员", "Rank": "排名", @@ -1212,7 +1209,7 @@ "Review the newly selected validators": "查看新选择的验证器", "click to view": "点击查看", "on-chain staking info": "链上抵押信息", - "New pool state:": "新池状态:", + "New pool state": "新池状态", "Change State": "更改状态", "You can join existing pools, which will be shown to you in a list,": "您可以加入现有的池,它们将以列表形式显示给您,", "You can create a pool yourself and should manage pool and nominate validators for the pool yourself.": "您可以自己创建一个池,并且应该自己管理池并为池提名验证器。",