// Copyright 2017-2025 @polkadot/app-treasury authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Option, u128 } from '@polkadot/types'; import type { Permill } from '@polkadot/types/interfaces'; import React, { useMemo, useState } from 'react'; import { Button, InputAddress, InputBalance, MarkWarning, Modal, Static, TxButton } from '@polkadot/react-components'; import { useApi, useToggle } from '@polkadot/react-hooks'; import { BN, BN_HUNDRED, BN_MILLION } from '@polkadot/util'; import { useTranslation } from '../translate.js'; interface Props { className?: string; } function Propose ({ className }: Props): React.ReactElement | null { const { t } = useTranslation(); const { api } = useApi(); const [accountId, setAccountId] = useState(null); const [beneficiary, setBeneficiary] = useState(null); const [isOpen, toggleOpen] = useToggle(); const [value, setValue] = useState(); const hasValue = value?.gtn(0); const [bondMin, bondMax, bondPercentage] = useMemo( () => [ api.consts.treasury.proposalBondMinimum ? (api.consts.treasury.proposalBondMinimum as u128).toString() : null, (api.consts.treasury.proposalBondMaximum as Option)?.isSome ? (api.consts.treasury.proposalBondMaximum as Option).unwrap().toString() : null, api.consts.treasury.proposalBond ? `${(api.consts.treasury.proposalBond as Permill).mul(BN_HUNDRED).div(BN_MILLION).toNumber().toFixed(2)}%` : `${new BN(0).toNumber().toFixed(2)}%` ], [api] ); return ( <> {isOpen && (

{t('The value is the amount that is being asked for and that will be allocated to the beneficiary if the proposal is approved.')}

{bondMax ?

{t('Of the beneficiary amount, no less than the minimum bond amount and no more than maximum on-chain bond would need to be put up as collateral. This is calculated from {{bondPercentage}} of the requested amount.', { replace: { bondPercentage } })}

:

{t('Of the beneficiary amount, no less than the minimum bond amount would need to be put up as collateral. This is calculated from {{bondPercentage}} of the requested amount.', { replace: { bondPercentage } })}

} } > {bondPercentage} {bondMin && ( )} {bondMax && ( )}
)}