diff --git a/packages/page-assets/src/Balances/Balance.tsx b/packages/page-assets/src/Balances/Account.tsx similarity index 66% rename from packages/page-assets/src/Balances/Balance.tsx rename to packages/page-assets/src/Balances/Account.tsx index c4308d2f49..773208a8f5 100644 --- a/packages/page-assets/src/Balances/Balance.tsx +++ b/packages/page-assets/src/Balances/Account.tsx @@ -1,7 +1,7 @@ // Copyright 2017-2021 @polkadot/app-assets authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { AssetBalance } from '@polkadot/types/interfaces'; +import type { AssetBalance, AssetId } from '@polkadot/types/interfaces'; import React from 'react'; @@ -9,15 +9,17 @@ import { AddressSmall } from '@polkadot/react-components'; import { FormatBalance } from '@polkadot/react-query'; import { useTranslation } from '../translate'; +import Transfer from './Transfer'; interface Props { accountId: string; + assetId: AssetId; balance: AssetBalance; className?: string; siFormat: [number, string]; } -function Balance ({ accountId, balance: { balance, isFrozen, isSufficient }, className, siFormat }: Props): React.ReactElement { +function Account ({ accountId, assetId, balance: { balance, isFrozen, isSufficient }, className, siFormat }: Props): React.ReactElement { const { t } = useTranslation(); return ( @@ -37,8 +39,15 @@ function Balance ({ accountId, balance: { balance, isFrozen, isSufficient }, cla value={balance} /> + + + ); } -export default React.memo(Balance); +export default React.memo(Account); diff --git a/packages/page-assets/src/Balances/Transfer.tsx b/packages/page-assets/src/Balances/Transfer.tsx new file mode 100644 index 0000000000..a97f613657 --- /dev/null +++ b/packages/page-assets/src/Balances/Transfer.tsx @@ -0,0 +1,106 @@ +// Copyright 2017-2021 @polkadot/app-assets authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type BN from 'bn.js'; +import type { AssetId } from '@polkadot/types/interfaces'; + +import React, { useMemo, useState } from 'react'; + +import { Button, InputAddress, InputBalance, Modal, Toggle, TxButton } from '@polkadot/react-components'; +import { useApi, useToggle } from '@polkadot/react-hooks'; + +import { useTranslation } from '../translate'; + +interface Props { + accountId: string; + assetId: AssetId; + className?: string; + siFormat: [number, string]; +} + +function Transfer ({ accountId, assetId, className, siFormat: [siDecimals, siSymbol] }: Props): React.ReactElement { + const { t } = useTranslation(); + const { api } = useApi(); + const [isOpen, toggleOpen] = useToggle(); + const [amount, setAmount] = useState(null); + const [recipientId, setRecipientId] = useState(null); + const [isProtected, setIsProtected] = useState(true); + + const isAmountValid = useMemo( + () => !!amount && !amount.isZero(), + [amount] + ); + + return ( + <> +