From 19d2e1ae01947955059680ffc1fb8db1d2a72b20 Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Thu, 4 May 2023 18:14:33 +0900 Subject: [PATCH] multi: Remove staking from hw wallet menus. Staking does not currently work for hardware wallets. Remove the screens and options that have to do with staking for now to avoid confusion. Hardware wallets also cannot currently handle stake inputs when signing. Add a warning to receiving screens not to use addresses for staking or treasury receives. --- app/components/SideBar/MenuLinks/Links.jsx | 4 ++ app/components/SideBar/MenuLinks/hooks.js | 7 +- app/components/views/HomePage/HomePage.jsx | 68 +++++++++++-------- .../ReceiveTab/ReceivePage/ReceivePage.jsx | 19 ++++++ .../ReceivePage/ReceivePage.module.css | 14 ++++ 5 files changed, 83 insertions(+), 29 deletions(-) diff --git a/app/components/SideBar/MenuLinks/Links.jsx b/app/components/SideBar/MenuLinks/Links.jsx index 84c57ed2df..5e88fa800f 100644 --- a/app/components/SideBar/MenuLinks/Links.jsx +++ b/app/components/SideBar/MenuLinks/Links.jsx @@ -2,6 +2,8 @@ import { FormattedMessage as T } from "react-intl"; export const LN_KEY = "ln"; export const DEX_KEY = "dex"; +export const TICKETS_KEY = "tickets"; +export const GOV_KEY = "governance"; export const linkList = [ { @@ -27,6 +29,7 @@ export const linkList = [ path: "/governance", link: , icon: "governance", + key: GOV_KEY, notifProp: [ "newProposalsStartedVoting", "newNotYetVotedAgendasCount", @@ -38,6 +41,7 @@ export const linkList = [ path: "/tickets", link: , icon: "tickets", + key: TICKETS_KEY, ariaLabel: "Staking" }, { diff --git a/app/components/SideBar/MenuLinks/hooks.js b/app/components/SideBar/MenuLinks/hooks.js index 78fe1397d3..c9ec883b8a 100644 --- a/app/components/SideBar/MenuLinks/hooks.js +++ b/app/components/SideBar/MenuLinks/hooks.js @@ -1,7 +1,7 @@ import { useEffect, useState, useMemo } from "react"; import { useSelector } from "react-redux"; import * as sel from "selectors"; -import { linkList, LN_KEY, DEX_KEY } from "./Links"; +import { linkList, LN_KEY, DEX_KEY, TICKETS_KEY, GOV_KEY } from "./Links"; import { useHistory } from "react-router-dom"; import { cloneDeep } from "fp"; @@ -46,8 +46,11 @@ export function useMenuLinks() { if (!lnEnabled) { links = links.filter((l) => l.key !== LN_KEY); } + // TODO: Enable ticket purchacing for Trezor. if (isTrezor) { - links = links.filter((l) => l.key !== DEX_KEY); + links = links.filter( + (l) => l.key !== DEX_KEY && l.key !== TICKETS_KEY && l.key !== GOV_KEY + ); } return links.map((link) => ({ ...link, diff --git a/app/components/views/HomePage/HomePage.jsx b/app/components/views/HomePage/HomePage.jsx index cc105af874..0406db5189 100644 --- a/app/components/views/HomePage/HomePage.jsx +++ b/app/components/views/HomePage/HomePage.jsx @@ -1,5 +1,6 @@ import { useState } from "react"; import { FormattedMessage as T } from "react-intl"; +import { useSelector } from "react-redux"; import { classNames } from "pi-ui"; import ErrorScreen from "ErrorScreen"; import { useService } from "hooks"; @@ -10,6 +11,7 @@ import RecentTransactions from "./RecentTransactions"; import RecentTickets from "./RecentTickets"; import { BalanceTab, TicketsTab, TransactionsTab } from "./Tabs"; import styles from "./HomePage.module.css"; +import * as sel from "selectors"; const ROWS_NUMBER_ON_TABLE = 5; @@ -19,23 +21,23 @@ const tabMessages = { transactions: }; -const tabs = [ - { - label: tabMessages.balance, - component: , - icon: styles.balanceIcon - }, - { - label: tabMessages.tickets, - component: , - icon: styles.ticketsIcon - }, - { - label: tabMessages.transactions, - component: , - icon: styles.txIcon - } -]; +const balanceTab = { + label: tabMessages.balance, + component: , + icon: styles.balanceIcon +}; + +const ticketsTab = { + label: tabMessages.tickets, + component: , + icon: styles.ticketsIcon +}; + +const transactionsTab = { + label: tabMessages.transactions, + component: , + icon: styles.txIcon +}; export default () => { const { walletService } = useService(); @@ -52,6 +54,27 @@ export default () => { tsDate } = useHomePage(); + // TODO: Enable ticket purchacing for Trezor. + const isTrezor = useSelector(sel.isTrezor); + let recentTickets, tabs; + if (isTrezor) { + tabs = [balanceTab, transactionsTab]; + } else { + recentTickets = ( + + ); + tabs = [balanceTab, ticketsTab, transactionsTab]; + } + return walletService ? (
@@ -86,16 +109,7 @@ export default () => { tsDate }} /> - + {recentTickets}
) : ( diff --git a/app/components/views/TransactionsPage/ReceiveTab/ReceivePage/ReceivePage.jsx b/app/components/views/TransactionsPage/ReceiveTab/ReceivePage/ReceivePage.jsx index accb6d1e43..48d28f37d5 100644 --- a/app/components/views/TransactionsPage/ReceiveTab/ReceivePage/ReceivePage.jsx +++ b/app/components/views/TransactionsPage/ReceiveTab/ReceivePage/ReceivePage.jsx @@ -1,4 +1,5 @@ import { useState, useRef } from "react"; +import { useSelector } from "react-redux"; import copy from "clipboard-copy"; import { FormattedMessage as T, injectIntl, defineMessages } from "react-intl"; import { ReceiveAccountsSelect, DcrInput } from "inputs"; @@ -14,6 +15,7 @@ import { TextHighlighted } from "pi-ui"; import styles from "./ReceivePage.module.css"; +import * as sel from "selectors"; const messages = defineMessages({ amountPlaceholder: { @@ -50,6 +52,21 @@ const ReceivePage = ({ const { theme } = useTheme(); const iconColor = getThemeProperty(theme, "accent-blue"); + // TODO: Enable ticket purchacing for Trezor. + const isTrezor = useSelector(sel.isTrezor); + let hardwareWalletWarning; + if (isTrezor) { + const warningStr = + "Caution! Hardware wallets cannot spend from special/staking inputs. " + + "Only use this address for receiving funds from normal transacitons. Do not " + + "use for staking or treasury related receives."; + hardwareWalletWarning = ( + + ); + } + return ( <> {modal && } @@ -94,6 +111,8 @@ const ReceivePage = ({ + {hardwareWalletWarning} +