diff --git a/public/locales/en.json b/public/locales/en.json index c4b8d14..d39b2d2 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -561,6 +561,7 @@ "contactLabel": "Contact:", "balance": "Current balance", + "stake": "Stake", "names": "Names", "nameCount": "{{count, number}} name", "nameCount_plural": "{{count, number}} names", diff --git a/src/pages/addresses/AddressPage.tsx b/src/pages/addresses/AddressPage.tsx index 19ea985..c8bf7b0 100644 --- a/src/pages/addresses/AddressPage.tsx +++ b/src/pages/addresses/AddressPage.tsx @@ -15,7 +15,7 @@ import { DateTime } from "@comp/DateTime"; import * as api from "@api"; -import { lookupAddress, TenebraAddressWithNames } from "@api/lookup"; +import { lookupAddress, lookupStakes, TenebraAddressWithNames } from "@api/lookup"; import { useWallets } from "@wallets"; import { useContacts } from "@contacts"; import { useSubscription } from "@global/ws/WebsocketSubscription"; @@ -32,6 +32,7 @@ import { useSendTransactionModal } from "@comp/transactions/SendTransactionModalLink"; import "./AddressPage.less"; +import { TenebraStake } from "@api/types"; const { Text } = Typography; @@ -42,9 +43,10 @@ interface PageContentsProps { address: TenebraAddressWithNames; lastTransactionID: number; + stake: TenebraStake; } -function PageContents({ address, lastTransactionID }: PageContentsProps): JSX.Element { +function PageContents({ address, lastTransactionID, stake }: PageContentsProps): JSX.Element { const { t } = useTranslation(); const { walletAddressMap } = useWallets(); const { contactAddressMap } = useContacts(); @@ -122,6 +124,13 @@ /> + + } + /> + + {/* Names */} (); const [tenebraAddress, setTenebraAddress] = useState(); + const [tenebraStake, setTenebraStake] = useState(); const [error, setError] = useState(); // Used to refresh the address data when a transaction is made to it @@ -200,6 +210,12 @@ .catch(setError); }, [syncNode, address, usedRefreshID]); + useEffect(() => { + lookupStakes([address]) + .then(results => setTenebraStake(results[address] ?? undefined)) + .catch(setError); + }, [syncNode, address, usedRefreshID]); + // Change the page title depending on whether or not the address has loaded const title = tenebraAddress ? { siteTitle: tenebraAddress.address, subTitle: tenebraAddress.address } @@ -223,11 +239,12 @@ notFoundSubTitleKey="address.resultNotFound" /> ) - : (tenebraAddress + : (tenebraAddress && tenebraStake ? ( ) : )}