diff --git a/packages/page-assets/src/Balances/Transfer.tsx b/packages/page-assets/src/Balances/Transfer.tsx index e4da47e94a..f5b154fe0d 100644 --- a/packages/page-assets/src/Balances/Transfer.tsx +++ b/packages/page-assets/src/Balances/Transfer.tsx @@ -22,7 +22,7 @@ function Transfer ({ accountId, assetId, className, minBalance, siFormat: [siDec const { t } = useTranslation(); const { api } = useApi(); const [isOpen, toggleOpen] = useToggle(); - const [amount, setAmount] = useState(null); + const [amount, setAmount] = useState(); const [recipientId, setRecipientId] = useState(null); const [isProtected, setIsProtected] = useState(true); diff --git a/packages/page-assets/src/Overview/Create/Info.tsx b/packages/page-assets/src/Overview/Create/Info.tsx index f166dd91a4..a5e6612f16 100644 --- a/packages/page-assets/src/Overview/Create/Info.tsx +++ b/packages/page-assets/src/Overview/Create/Info.tsx @@ -26,11 +26,11 @@ function Info ({ assetIds, className = '', defaultValue, onChange, openId }: Pro const [initial] = useState(() => defaultValue); const [initialId] = useState(() => openId); const [accountId, setAccountId] = useState(null); - const [assetId, setAssetId] = useState(null); - const [assetDecimals, setAssetDecimals] = useState(null); + const [assetId, setAssetId] = useState(); + const [assetDecimals, setAssetDecimals] = useState(); const [assetName, setAssetName] = useState(() => defaultValue?.assetName); const [assetSymbol, setAssetSymbol] = useState(() => defaultValue?.assetSymbol); - const [minBalance, setMinBalance] = useState(null); + const [minBalance, setMinBalance] = useState(); const [siDecimals, siSymbol] = useMemo( () => assetDecimals && assetSymbol diff --git a/packages/page-assets/src/Overview/Mint/Mint.tsx b/packages/page-assets/src/Overview/Mint/Mint.tsx index 22be4ec165..11d0dda934 100644 --- a/packages/page-assets/src/Overview/Mint/Mint.tsx +++ b/packages/page-assets/src/Overview/Mint/Mint.tsx @@ -22,7 +22,7 @@ interface Props { function Mint ({ className, details: { issuer, minBalance }, id, metadata, onClose }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); - const [amount, setAmount] = useState(null); + const [amount, setAmount] = useState(); const [recipientId, setRecipientId] = useState(null); const isAmountValid = useMemo( diff --git a/packages/page-bounties/src/BountyActions/ProposeCuratorAction.tsx b/packages/page-bounties/src/BountyActions/ProposeCuratorAction.tsx index 6329466d84..87faffc458 100644 --- a/packages/page-bounties/src/BountyActions/ProposeCuratorAction.tsx +++ b/packages/page-bounties/src/BountyActions/ProposeCuratorAction.tsx @@ -9,7 +9,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { getTreasuryProposalThreshold } from '@polkadot/apps-config'; import { Button, InputAddress, InputBalance, MarkError, Modal, TxButton } from '@polkadot/react-components'; import { useApi, useCollectiveInstance, useCollectiveMembers, useToggle } from '@polkadot/react-hooks'; -import { BN, BN_ZERO } from '@polkadot/util'; +import { BN } from '@polkadot/util'; import { truncateTitle } from '../helpers'; import { useBounties } from '../hooks'; @@ -34,7 +34,7 @@ function ProposeCuratorAction ({ description, index, proposals, value }: Props): const [accountId, setAccountId] = useState(null); const [curatorId, setCuratorId] = useState(null); const [threshold, setThreshold] = useState(); - const [fee, setFee] = useState(BN_ZERO); + const [fee, setFee] = useState(); const [isFeeValid, setIsFeeValid] = useState(false); useEffect((): void => { @@ -56,7 +56,7 @@ function ProposeCuratorAction ({ description, index, proposals, value }: Props): ); useEffect(() => { - setIsFeeValid(!!value?.gt(fee)); + setIsFeeValid(!!fee && !!value?.gt(fee)); }, [value, fee]); return isMember && !isVotingInitiated && councilMod diff --git a/packages/page-council/src/Overview/SubmitCandidacy.tsx b/packages/page-council/src/Overview/SubmitCandidacy.tsx index e6353f8372..da4c943cc0 100644 --- a/packages/page-council/src/Overview/SubmitCandidacy.tsx +++ b/packages/page-council/src/Overview/SubmitCandidacy.tsx @@ -1,6 +1,7 @@ // Copyright 2017-2023 @polkadot/app-council authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { u128 } from '@polkadot/types'; import type { ComponentProps as Props } from './types'; import React, { useState } from 'react'; @@ -41,7 +42,7 @@ function SubmitCandidacy ({ electionsInfo }: Props): React.ReactElement | {api.consts[modLocation] && ( ('candidacy bond')} /> diff --git a/packages/page-gilt/src/Overview/BidAdd.tsx b/packages/page-gilt/src/Overview/BidAdd.tsx index 032f107a0c..df13d38ded 100644 --- a/packages/page-gilt/src/Overview/BidAdd.tsx +++ b/packages/page-gilt/src/Overview/BidAdd.tsx @@ -80,14 +80,14 @@ function Bid ({ className, isDisabled, proxies }: Props): React.ReactElement('The amount you wish to lock for the duration. It needs to be more than the gilt minimum.')}> ('bid amount')} onChange={setAmount} /> ('minimum freeze amount')} /> diff --git a/packages/page-parachains/src/Parathreads/RegisterId.tsx b/packages/page-parachains/src/Parathreads/RegisterId.tsx index 3a7011f2f9..3b01c30e07 100644 --- a/packages/page-parachains/src/Parathreads/RegisterId.tsx +++ b/packages/page-parachains/src/Parathreads/RegisterId.tsx @@ -1,6 +1,7 @@ // Copyright 2017-2023 @polkadot/app-parachains authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { u128 } from '@polkadot/types'; import type { BN } from '@polkadot/util'; import React, { useState } from 'react'; @@ -46,7 +47,7 @@ function RegisterId ({ className, nextParaId, onClose }: Props): React.ReactElem ('The reservation fee for this Id')}> ('reserved deposit')} /> diff --git a/packages/page-parachains/src/Proposals/Propose.tsx b/packages/page-parachains/src/Proposals/Propose.tsx index ca49067abc..c68b287315 100644 --- a/packages/page-parachains/src/Proposals/Propose.tsx +++ b/packages/page-parachains/src/Proposals/Propose.tsx @@ -49,7 +49,7 @@ function Propose ({ className, onClose }: Props): React.ReactElement { const [accountId, setAccountId] = useState(null); const [name, setName] = useState(''); const [paraId, setParaId] = useState(); - const [balance, setBalance] = useState(() => BN_THOUSAND.mul(BN_TEN.pow(new BN(api.registry.chainDecimals[0])))); + const [balance, setBalance] = useState(() => BN_THOUSAND.mul(BN_TEN.pow(new BN(api.registry.chainDecimals[0])))); const [validators, setValidators] = useState(['']); const [{ isWasmValid, wasm }, setWasm] = useState({ isWasmValid: false, wasm: null }); const [genesisState, setGenesisState] = useState(null); diff --git a/packages/page-staking/src/Actions/Account/Unbond.tsx b/packages/page-staking/src/Actions/Account/Unbond.tsx index 529c7b5c64..80a60c634c 100644 --- a/packages/page-staking/src/Actions/Account/Unbond.tsx +++ b/packages/page-staking/src/Actions/Account/Unbond.tsx @@ -26,7 +26,7 @@ function Unbond ({ controllerId, onClose, stakingLedger, stashId }: Props): Reac const { api } = useApi(); const bondedBlocks = useUnbondDuration(); const [maxBalance] = useState(() => stakingLedger?.active?.unwrap() || null); - const [maxUnbond, setMaxUnbond] = useState(null); + const [maxUnbond, setMaxUnbond] = useState(); const [withMax, setWithMax] = useState(false); return ( diff --git a/packages/page-staking/src/Actions/Pool/BondExtra.tsx b/packages/page-staking/src/Actions/Pool/BondExtra.tsx index aba527ada5..8dfd2e46b9 100644 --- a/packages/page-staking/src/Actions/Pool/BondExtra.tsx +++ b/packages/page-staking/src/Actions/Pool/BondExtra.tsx @@ -27,7 +27,7 @@ function BondExtra ({ className, controllerId, onClose, poolId }: Props): React. const { t } = useTranslation(); const { api } = useApi(); const [type, setType] = useState(DEFAULT_TYPE); - const [amount, setAmount] = useState(BN_ZERO); + const [amount, setAmount] = useState(); const isAmountError = useAmountError(controllerId, amount, BN_ZERO); const typeRef = useRef([ diff --git a/packages/page-staking/src/Actions/Pool/Unbond.tsx b/packages/page-staking/src/Actions/Pool/Unbond.tsx index abfb21d41f..8c147c1c74 100644 --- a/packages/page-staking/src/Actions/Pool/Unbond.tsx +++ b/packages/page-staking/src/Actions/Pool/Unbond.tsx @@ -8,7 +8,6 @@ import React, { useState } from 'react'; import { InputBalance, Modal, Static, Toggle, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import { BlockToTime, FormatBalance } from '@polkadot/react-query'; -import { BN_ZERO } from '@polkadot/util'; import { useTranslation } from '../../translate'; import PoolInfo from '../partials/PoolInfo'; @@ -25,7 +24,7 @@ interface Props { function Unbond ({ className, controllerId, maxUnbond, onClose, poolId }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); - const [amount, setAmount] = useState(BN_ZERO); + const [amount, setAmount] = useState(); const [withMax, setWithMax] = useState(false); const bondedBlocks = useUnbondDuration(); diff --git a/packages/page-staking/src/Pools/Create.tsx b/packages/page-staking/src/Pools/Create.tsx index 548c2efce2..9dc5075880 100644 --- a/packages/page-staking/src/Pools/Create.tsx +++ b/packages/page-staking/src/Pools/Create.tsx @@ -8,7 +8,7 @@ import React, { useMemo, useState } from 'react'; import { Button, Input, InputAddress, InputBalance, InputNumber, Modal, TxButton } from '@polkadot/react-components'; import { useApi, useToggle } from '@polkadot/react-hooks'; -import { BN_ZERO, bnMax } from '@polkadot/util'; +import { bnMax } from '@polkadot/util'; import { useTranslation } from '../translate'; import useAmountError from './useAmountError'; @@ -28,7 +28,7 @@ function Create ({ className, isDisabled, ownAccounts, params: { minCreateBond, const { api } = useApi(); const [isOpen, toggleOpen] = useToggle(); const [accountId, setAccount] = useState(null); - const [amount, setAmount] = useState(BN_ZERO); + const [amount, setAmount] = useState(); const [metadata, setMetadata] = useState(''); const minValue = useMemo( diff --git a/packages/react-components/src/InputBalance.tsx b/packages/react-components/src/InputBalance.tsx index c38a6d0fd6..f80aaa25ba 100644 --- a/packages/react-components/src/InputBalance.tsx +++ b/packages/react-components/src/InputBalance.tsx @@ -4,7 +4,6 @@ import type { SiDef } from '@polkadot/util/types'; import React, { useMemo } from 'react'; -import styled from 'styled-components'; import { BN, formatBalance, isUndefined } from '@polkadot/util'; @@ -14,7 +13,7 @@ interface Props { autoFocus?: boolean; children?: React.ReactNode; className?: string; - defaultValue?: BN | string; + defaultValue?: BN | string | null; isDisabled?: boolean; isError?: boolean; isFull?: boolean; @@ -23,14 +22,14 @@ interface Props { isZeroable?: boolean; label?: React.ReactNode; labelExtra?: React.ReactNode; - maxValue?: BN; + maxValue?: BN | null; onChange?: (value?: BN) => void; onEnter?: () => void; onEscape?: () => void; placeholder?: string; siDecimals?: number; siSymbol?: string; - value?: BN; + value?: BN | null; withEllipsis?: boolean; withLabel?: boolean; withMax?: boolean; @@ -38,7 +37,7 @@ interface Props { const DEFAULT_BITLENGTH = 128; -function reformat (value?: string | BN, isDisabled = false, siDecimals?: number): { defaultValue?: string; siDefault?: SiDef } { +function reformat (value?: string | BN | null, isDisabled = false, siDecimals?: number): { defaultValue?: string; siDefault?: SiDef } { if (!value) { return {}; } @@ -102,28 +101,4 @@ function InputBalance ({ autoFocus, children, className = '', defaultValue: inDe ); } -export default React.memo(styled(InputBalance)` - &&:not(.isSmall) .labelExtra { - right: 6.5rem; - } - - .ui.action.input.ui--Input > .buttons { - align-items: stretch; - - .ui--SiDropdown.ui.button.compact.floating.selection.dropdown { - &.disabled { - border-style: solid; - opacity: 1 !important; - } - - > div.text:first-child { - font-size: var(--font-size-small); - position: absolute; - top: 50%; - transform: translateY(-50%); - left: 0.5rem; - width: 3rem; - } - } - } -`); +export default React.memo(InputBalance); diff --git a/packages/react-components/src/InputNumber.tsx b/packages/react-components/src/InputNumber.tsx index 77930cd25c..85e434b6a3 100644 --- a/packages/react-components/src/InputNumber.tsx +++ b/packages/react-components/src/InputNumber.tsx @@ -277,16 +277,12 @@ function InputNumber ({ autoFocus, bitLength = DEFAULT_BITLENGTH, children, clas export default React.memo(styled(InputNumber)` .siUnit { + bottom: 0.85rem; + color: var(--color-label); font-size: var(--font-size-tiny); + font-weight: var(--font-weight-label); position: absolute; - top: 50%; - transform: translateY(-50%); font-weight: var(--font-weight-bold); right: 1.25rem; } - - .ui.buttons+.ui--Toggle.isOverlay { - bottom: 1.1rem; - right: 6.5rem; - } `); diff --git a/packages/react-components/src/Labelled.tsx b/packages/react-components/src/Labelled.tsx index 5162f2d5ff..24ef173e0d 100644 --- a/packages/react-components/src/Labelled.tsx +++ b/packages/react-components/src/Labelled.tsx @@ -108,7 +108,7 @@ export default React.memo(styled(Labelled)` color: var(--color-label); font-size: var(--font-size-label); font-weight: var(--font-weight-label); - right: 1.75rem; + right: 1.25rem; text-align: right; text-transform: var(--text-transform-label); } diff --git a/packages/react-signer/src/Tip.tsx b/packages/react-signer/src/Tip.tsx index 2c5574405d..4f063d711c 100644 --- a/packages/react-signer/src/Tip.tsx +++ b/packages/react-signer/src/Tip.tsx @@ -12,12 +12,12 @@ import { useTranslation } from './translate'; interface Props { className?: string; - onChange: (tip: BN) => void; + onChange: (tip?: BN) => void; } function Tip ({ className, onChange }: Props): React.ReactElement | null { const { t } = useTranslation(); - const [tip, setTip] = useState(BN_ZERO); + const [tip, setTip] = useState(); const [showTip, setShowTip] = useState(false); useEffect((): void => { diff --git a/packages/react-signer/src/TxSigned.tsx b/packages/react-signer/src/TxSigned.tsx index a5e629d013..050d53a286 100644 --- a/packages/react-signer/src/TxSigned.tsx +++ b/packages/react-signer/src/TxSigned.tsx @@ -8,6 +8,7 @@ import type { KeyringPair } from '@polkadot/keyring/types'; import type { QueueTx, QueueTxMessageSetStatus } from '@polkadot/react-components/Status/types'; import type { Option } from '@polkadot/types'; import type { Multisig, Timepoint } from '@polkadot/types/interfaces'; +import type { BN } from '@polkadot/util'; import type { HexString } from '@polkadot/util/types'; import type { AddressFlags, AddressProxy, QrState } from './types'; @@ -19,7 +20,7 @@ import { web3FromSource } from '@polkadot/extension-dapp'; import { Button, ErrorBoundary, Modal, Output, Toggle } from '@polkadot/react-components'; import { useApi, useLedger, useQueue, useToggle } from '@polkadot/react-hooks'; import { keyring } from '@polkadot/ui-keyring'; -import { assert, BN_ZERO, nextTick } from '@polkadot/util'; +import { assert, nextTick } from '@polkadot/util'; import { addressEq } from '@polkadot/util-crypto'; import Address from './Address'; @@ -204,7 +205,7 @@ function TxSigned ({ className, currentItem, requestAddress }: Props): React.Rea const [signedOptions, setSignedOptions] = useState>({}); const [signedTx, setSignedTx] = useState(null); const [{ innerHash, innerTx }, setCallInfo] = useState(EMPTY_INNER); - const [tip, setTip] = useState(BN_ZERO); + const [tip, setTip] = useState(); useEffect((): void => { setFlags(tryExtract(senderInfo.signAddress));