diff --git a/.vscode/settings.json b/.vscode/settings.json index 579c41e..f900d9e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ + "AGPL", "Algo", "Authed", "Authorise", diff --git a/public/locales/en.json b/public/locales/en.json index 7387b52..ebb2242 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -423,6 +423,8 @@ "buttonEditContact": "Edit in address book", "buttonEditWallet": "Edit wallet", + "tooltipV1Address": "Transactions cannot be sent to v1 addresses, as they have been deprecated.", + "cardRecentTransactionsTitle": "Recent transactions", "cardNamesTitle": "Names", diff --git a/src/pages/addresses/AddressButtonRow.tsx b/src/pages/addresses/AddressButtonRow.tsx index fc6ca0b..b207797 100644 --- a/src/pages/addresses/AddressButtonRow.tsx +++ b/src/pages/addresses/AddressButtonRow.tsx @@ -1,11 +1,13 @@ // Copyright (c) 2020-2021 Drew Lemmy // This file is part of KristWeb 2 under AGPL-3.0. // Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt -import { Button } from "antd"; +import { Button, Tooltip } from "antd"; import { SendOutlined, SwapOutlined, UserAddOutlined, EditOutlined } from "@ant-design/icons"; import { useTranslation } from "react-i18next"; +import { isV1Address } from "@utils/currency"; + import { KristAddressWithNames } from "@api/lookup"; import { Wallet } from "@wallets"; import { WalletEditButton } from "../wallets/WalletEditButton"; @@ -19,23 +21,31 @@ export function AddressButtonRow({ address, myWallet }: Props): JSX.Element { const { t } = useTranslation(); + const isV1 = address && isV1Address(address.address); + + const sendButton = ; + return <> {/* Send/transfer Krist button */} - - - + {isV1 + ? ( // Disable the button and show a tooltip for V1 addresses + + {sendButton} + + ) + : ( // Otherwise, enable the button + + {sendButton} + + )} + {/* Add contact/edit wallet button */} {/* TODO: Change this to edit if they're already a contact */} diff --git a/src/pages/addresses/AddressPage.less b/src/pages/addresses/AddressPage.less index a96abc7..0e53861 100644 --- a/src/pages/addresses/AddressPage.less +++ b/src/pages/addresses/AddressPage.less @@ -29,8 +29,9 @@ .ant-btn { margin-right: @margin-md; - &:last-child { margin-right: 0; } } + + > .ant-btn:last-child { margin-right: 0; } } .address-wallet-row { diff --git a/src/utils/currency.ts b/src/utils/currency.ts index a6bbfff..feaff7c 100644 --- a/src/utils/currency.ts +++ b/src/utils/currency.ts @@ -120,6 +120,9 @@ : getAddressRegexV2(addressPrefix).test(address); } +export const v1AddressRegex = /^[a-f0-9]{10}$/; +export const isV1Address = (address: string): boolean => + v1AddressRegex.test(address); // ----------------------------------------------------------------------------- // MISC