Skip to content

Commit

Permalink
feat: connect button on front page
Browse files Browse the repository at this point in the history
  • Loading branch information
dianasavvatina committed Mar 3, 2025
1 parent a745002 commit 6a664d4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
1 change: 1 addition & 0 deletions apps/web/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export { default as PencilIcon } from "./pencil.svg";
export { default as PlusIcon } from "./plus.svg";
export { default as PlusCircleIcon } from "./plus-circle.svg";
export { default as PyramidIcon } from "./pyramid.svg";
export { default as QRCodeIcon } from "./qrcode.svg";
export { default as RefreshIcon } from "./refresh.svg";
export { default as RadioIcon } from "./radio.svg";
export { default as RedditIcon } from "./reddit.svg";
Expand Down
8 changes: 8 additions & 0 deletions apps/web/src/assets/icons/qrcode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion apps/web/src/components/AccountCard/AccountButtons.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ describe("<AccountButtons />", () => {
expect(screen.getByRole("button", { name: "Receive" })).toBeVisible();
});

it("renders a connect button", () => {
render(<AccountButtons />, { store });

expect(screen.getByRole("button", { name: "Connect" })).toBeVisible();
});

describe("renders a send button", () => {
it("if user has enough balance", async () => {
const user = userEvent.setup();
Expand Down Expand Up @@ -121,7 +127,7 @@ describe("<AccountButtons />", () => {
);
});

it.each(["Buy", "Send", "Receive"])("%s button is disabled", buttonName => {
it.each(["Buy", "Connect", "Send", "Receive"])("%s button is disabled", buttonName => {
render(<AccountButtons />, { store });

const button = screen.getByLabelText(buttonName);
Expand Down
20 changes: 18 additions & 2 deletions apps/web/src/components/AccountCard/AccountButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { Box, Flex, Link } from "@chakra-ui/react";
import { useDynamicModalContext } from "@umami/components";
import { useBuyTezUrl, useCurrentAccount } from "@umami/state";
import { useAddPeer, useBuyTezUrl, useCurrentAccount } from "@umami/state";

import { SendTezButton } from "./SendTezButton";
import { ArrowDownLeftIcon, WalletIcon } from "../../assets/icons";
import { ArrowDownLeftIcon, QRCodeIcon, WalletIcon } from "../../assets/icons";
import { AccountInfoModal } from "../AccountSelectorModal";
import { IconButtonWithText } from "../IconButtonWithText";
import { useIsAccountVerified } from "../Onboarding/VerificationFlow";
import { useOnWalletConnect } from "../WalletConnect";

export const AccountButtons = () => {
const { openWith } = useDynamicModalContext();
const currentAccount = useCurrentAccount()!;
const address = currentAccount.address.pkh;
const buyTezUrl = useBuyTezUrl(address);
const isVerified = useIsAccountVerified();
const onBeaconConnect = useAddPeer();
const onWalletConnect = useOnWalletConnect();

return (
<Box data-testid="account-buttons" paddingX="12px">
Expand All @@ -33,6 +36,19 @@ export const AccountButtons = () => {
variant="iconButtonSolid"
/>
<Flex gap="24px">
<IconButtonWithText
icon={QRCodeIcon}
isDisabled={!isVerified}
label="Connect"
onClick={() =>
navigator.clipboard
.readText()
.then(payload =>
payload.startsWith("wc:") ? onWalletConnect(payload) : onBeaconConnect(payload)
)
}
variant="iconButtonSolid"
/>
<IconButtonWithText
icon={ArrowDownLeftIcon}
isDisabled={!isVerified}
Expand Down
8 changes: 3 additions & 5 deletions packages/state/src/hooks/beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ export const useAddPeer = () => {
.then(parsePeerInfo)
.then(peer => WalletClient.addPeer(peer as ExtendedPeerInfo))
.then(() => refresh())
.catch(e => {
.catch(() => {
const description =
"Beacon sync code in the clipboard is invalid. Please copy a beacon sync code from the dApp";
const type = "error";
"To connect, open the dApp’s connect menu and copy the QR code. Look for a Beacon or WalletConnect option.";
const type = "info";

toast.show
? toast.show({
Expand All @@ -124,7 +124,5 @@ export const useAddPeer = () => {
description,
status: type,
});

console.error(e);
});
};

1 comment on commit 6a664d4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title Lines Statements Branches Functions
apps/desktop Coverage: 83%
83.74% (1788/2135) 79.42% (849/1069) 78.27% (454/580)
apps/web Coverage: 83%
83.74% (1788/2135) 79.42% (849/1069) 78.27% (454/580)
packages/components Coverage: 97%
97.48% (194/199) 94.87% (74/78) 89.7% (61/68)
packages/core Coverage: 82%
82.64% (219/265) 72.51% (95/131) 81.66% (49/60)
packages/crypto Coverage: 100%
100% (43/43) 90.9% (10/11) 100% (7/7)
packages/data-polling Coverage: 96%
94.66% (142/150) 87.5% (21/24) 92.85% (39/42)
packages/multisig Coverage: 98%
98.47% (129/131) 85.71% (18/21) 100% (36/36)
packages/social-auth Coverage: 95%
95.45% (21/22) 91.66% (11/12) 100% (3/3)
packages/state Coverage: 81%
81% (874/1079) 74.04% (194/262) 75.77% (316/417)
packages/tezos Coverage: 89%
88.65% (125/141) 93.02% (40/43) 87.5% (35/40)
packages/tzkt Coverage: 89%
87.32% (62/71) 87.5% (14/16) 80.48% (33/41)

Please sign in to comment.