From a221c815b66990aa0540039f140b47db5b4e0f96 Mon Sep 17 00:00:00 2001
From: Pavlos Chrysochoidis <10210143+pchrysochoidis@users.noreply.github.com>
Date: Fri, 24 Feb 2023 13:05:11 +0000
Subject: [PATCH] wallet-ext: allow selecting the accounts to connect to dapp
(#8413)
* adds WalletListSelect component that allows selecting between the
accounts of the wallet and creating new ones
* when multiaccounts is enabled while connecting to a dapp user is able
to choose which accounts to connect
When multiaccount is disabled
When multiaccount is enabled and user has more than one account
https://user-images.githubusercontent.com/10210143/219980417-79a944d4-b409-4046-832a-09d8b98b2c40.mov
NOTE: To check the accounts that are connected
* switch between accounts and check the dapp status popup
* or run
```
chrome.storage.local.get('permissions').then(({permissions: p}) => console.log(p['http://localhost:3000'].accounts))
```
in the console of the extension.
Closes APPS-283
---
.../src/ui/app/components/SummaryCard.tsx | 52 +++++++++++
.../ui/app/components/WalletListSelect.tsx | 81 +++++++++++++++++
.../app/components/WalletListSelectItem.tsx | 38 ++++++++
.../menu/content/AccountsSettings.tsx | 18 +---
.../user-approve-container/index.tsx | 89 ++++++++-----------
.../app/hooks/useDeriveNextAccountMutation.ts | 23 +++++
.../ui/app/pages/layout/Layout.module.scss | 1 +
.../site-connect/SiteConnectPage.module.scss | 13 +--
.../src/ui/app/pages/site-connect/index.tsx | 85 +++++++++++++-----
9 files changed, 308 insertions(+), 92 deletions(-)
create mode 100644 apps/wallet/src/ui/app/components/SummaryCard.tsx
create mode 100644 apps/wallet/src/ui/app/components/WalletListSelect.tsx
create mode 100644 apps/wallet/src/ui/app/components/WalletListSelectItem.tsx
create mode 100644 apps/wallet/src/ui/app/hooks/useDeriveNextAccountMutation.ts
diff --git a/apps/wallet/src/ui/app/components/SummaryCard.tsx b/apps/wallet/src/ui/app/components/SummaryCard.tsx
new file mode 100644
index 0000000000000..8599d95aa2b43
--- /dev/null
+++ b/apps/wallet/src/ui/app/components/SummaryCard.tsx
@@ -0,0 +1,52 @@
+// Copyright (c) Mysten Labs, Inc.
+// SPDX-License-Identifier: Apache-2.0
+
+import { cx } from 'class-variance-authority';
+
+import { Text } from '../shared/text';
+
+import type { ReactNode } from 'react';
+
+export type SummaryCardProps = {
+ header?: string;
+ body: ReactNode;
+ footer?: ReactNode;
+ minimalPadding?: boolean;
+};
+
+export function SummaryCard({
+ body,
+ header,
+ footer,
+ minimalPadding,
+}: SummaryCardProps) {
+ return (
+